Battery Resource Utilization

Android 13 (API level 33) introduces the following battery-preserving measures:

Updates to when an app enters the "restricted" App Standby Bucket

Unless your app qualifies for an exemption, the system places your app in the restricted bucket when your app has any of the following behavior:

  • The user doesn't interact with your app for 8 days. If the user interacts with another app that binds to a service of your app, then the system considers your app to be "used."

  • Your app invokes an excessive number of broadcasts or bindings during a 24-hour period.

  • (Supported devices only) Your app drains a significant amount of device battery in the background during a 24-hour period. This threshold is device-dependent, and in particular might be different for low-RAM devices.

    When measuring your app's impact on a device's battery life, the system takes into account the work that your app does in several different places, including the following:

    • Jobs, including expedited jobs
    • Broadcast receivers
    • Background services
    • Whether the system has cached your app's process

User interaction allows your app to exit "restricted" bucket

When the user interacts with your app, including in the following ways, the system takes your app out of the restricted bucket and into a different App Standby Bucket:

  • The user taps on a notification that your app sends.

  • The user performs an action in a widget that belongs to your app.

  • The user affects a foreground service in your app by pressing a media button.

  • The user connects to your app while interacting with Android Automotive OS, where your app uses either a foreground service or CONNECTION_TYPE_PROJECTION.

  • Your app is visible in picture-in-picture (PiP) mode.

  • Your app is one of the active apps on screen. (Applies mostly to large-screen devices.)

New limitations for restricted background battery usage

Existing versions of Android offer users the ability to adjust the amount of work that apps can do while running in the background. The following options appear in the Battery usage page within system settings:

  • Unrestricted: Allow background work, which might consume more battery.
  • Optimized (default): Optimize an app's ability to perform background work, based on how the user interacts with the app.
  • Restricted: Favor device battery life over app versatility. Places more limitations on what an app can do in the background.

As of Android 9 (API level 28), apps that are placed in the "restricted" state have the following limitations:

  • Can't launch foreground services
  • Existing foreground services are removed from the foreground
  • Alarms aren't triggered
  • Jobs aren't executed

When your app targets Android 13, the system doesn't deliver any of the following broadcasts until the app is started for other reasons:

  • BOOT_COMPLETED
  • LOCKED_BOOT_COMPLETED

System notification for long-running foreground service

If the system detects that your app runs a foreground service for a long period of time—at least 20 hours within a 24-hour window—it sends a notification to the user, inviting them to interact with the Foreground Services (FGS) Task Manager. The notification contains the following text:

APP is running in the background for a long time. Tap to review.

The system doesn't show this notification if any of the following conditions are met:

Furthermore, if your app runs an foreground service whose type is either FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK or FOREGROUND_SERVICE_TYPE_LOCATION for more than 4 hours in a 24-hour period, then the system doesn't send long-running notifications for any foreground services that your app starts.

Exemptions

The following situations exempt apps from all battery-preserving measures introduced in Android 13:

The following situations exempt your app from entering the "restricted" App Standby Bucket, and they allow your app to bypass the 8-day inactivity trigger:

The following situations exempt your app from most battery-preserving measures introduced in Android 13 but don't prevent the system from sending a notification for a long-running foreground service:

Testing

The following sections show a few ways to test how the battery-preserving measures introduced in Android 13 affect your app.

Prevent background use

To prevent your app from being able to run in the background, run the following command in a terminal window:

adb shell cmd appops set PACKAGE_NAME RUN_ANY_IN_BACKGROUND deny

Place app into restricted bucket

To force the system to place your app into the restricted bucket, run the following command in a terminal window:

adb shell am set-standby-bucket PACKAGE_NAME restricted