Android 13 introduces the concept of a power consumption tracker, which is a process that monitors foreground or background battery usage by apps to determine if apps violate some policy. Android 13 contains two power consumption trackers: the foreground service tracker and background battery usage tracker. As opposed to using your own mechanisms to determine battery abuse by apps, we recommend using these trackers to monitor and alert users of excessive battery usage.
Foreground service tracker
Foreground services can execute and use battery for an extended period of time. The foreground service tracker displays a notification to users when a foreground service has been running for a long period of time but is invisible, such as when a user has dismissed the service's notification. If the user clicks the notification, the task manager is displayed and lets the user stop the foreground service. This tracker is enabled by default.
Background battery usage tracker
Apps can drain battery in the background without the user being aware. The background battery tracker watches battery usage for each app. Battery usage in this context is defined by three dimensions: foreground app on top, foreground service running something that isn't visible, and background part of app. If the background portion of the app's battery usage crosses some threshold, the app is moved into a restricted bucket limiting it to one job per day. This tracker is disabled by default. To enable this tracker, run the following commands:
adb shell device_config put activity_manager bg_auto_restrict_abusive_apps 1
adb shell device_config put activity_manager bg_current_drain_auto_restrict_abusive_apps_enabled 1