— ADB, App Standby, Android — 3 min read
App Standby is a power-saving feature introduced in Android 6.0 (Marshmallow) that helps conserve battery life by limiting the resources and activities of apps that the user hasn't interacted with for a while. App Standby introduces the concept of "standby buckets" that categorize apps based on their usage patterns and determine the restrictions imposed on them.
In this article, we'll explore how to use the ADB (Android Debug Bridge) commands set-standby-bucket
and get-standby-bucket
to manage app standby buckets and understand the different values associated with them.
To follow along with the examples in this article, you'll need the following:
To retrieve the standby bucket of an app, we can use the get-standby-bucket
ADB command. This command allows us to check the current standby bucket of a specific app. Here's how you can use it:
1adb shell am get-standby-bucket <package-name>
Replace <package-name>
with the actual package name of the app you want to check. For example, to get the standby bucket of the "com.example.myapp" package, you would run:
1adb shell am get-standby-bucket com.example.myapp
The command will return the standby bucket value for the specified app, which can be one of the following:
active
(or 10
): The app is not subject to any standby restrictions and can run normally.working_set
(or 20
): The app is allowed to run normally, but it may have its background activities limited if not used frequently.frequent
(or 30
): The app's background activities are restricted, and it can't run jobs, syncs, or high-priority GCM/FCM messages.rare
(or 40
): The app is placed in an "app standby" state, limiting most background activities.To change the standby bucket of an app, we can use the set-standby-bucket
ADB command. This command allows us to assign a specific standby bucket to an app. Here's how you can use it:
1adb shell am set-standby-bucket <package-name> <bucket>
Replace <package-name>
with the package name of the app you want to set the standby bucket for, and <bucket>
with the desired bucket value. For example, to set the standby bucket of the "com.example.myapp" package to "rare," you would run:
1adb shell am set-standby-bucket com.example.myapp rare
The command will assign the specified standby bucket to the app, allowing the system to apply the appropriate restrictions and power-saving measures.
Each standby bucket has different restrictions and effects on an app's behavior. Here's a breakdown of the different bucket values and their implications:
active
(or 10
): The app is not subject to any standby restrictions and can run normally. It has full access to system resources and can perform background activities without limitations. This bucket is typically assigned to apps that are actively used by the user and require continuous background processing, such as messaging or navigation apps.
working_set
(or 20
): Apps assigned to the working_set
bucket are allowed to run normally, but their background activities may be limited if they are not frequently used. The system may prioritize resources for higher-priority apps, and background tasks of apps in this bucket might be deferred or executed less frequently. This bucket is suitable for apps that don't require immediate background processing but should still be available for the user when needed.
frequent
(or 30
): Apps in the frequent
bucket have more restrictions on their background activities. They cannot run jobs, syncs, or receive high-priority GCM/FCM (Google Cloud Messaging/Firebase Cloud Messaging) messages. Background processing is limited to conserve battery life. This bucket is suitable for apps that are used occasionally but don't require immediate updates or real-time notifications.
rare
(or 40
): The rare
bucket is the most restricted standby bucket. Apps in this bucket are placed in an "app standby" state, limiting most background activities. They have minimal access to system resources and are subject to aggressive power-saving measures. This bucket is suitable for apps that are rarely used and can tolerate significant delays in background processing or syncing.
By assigning apps to different standby buckets, the Android system optimizes power consumption by allocating resources based on usage patterns. This helps improve battery life while still allowing important apps to function optimally when needed.
It's important to note that the numeric values (10
, 20
, 30
, 40
) are equivalent to the named buckets (active
, working_set
, frequent
, rare
). While the numeric values provide a programmatic representation of the standby buckets, it's recommended to use the named buckets for clarity and ease of understanding.
Remember that not all devices or Android versions support the standby bucket feature. Make sure your device is running a compatible Android version (6.0 Marshmallow or later) and has the necessary system support for this feature to work.
In this article, we explored how to use the ADB commands set-standby-bucket
and get-standby-bucket
to manage app standby buckets in Android. We learned how to retrieve the standby bucket of an app and how to assign a specific standby bucket to an app using these commands. Additionally, we discussed the different standby bucket values and their effects on app behavior and power consumption.
App standby buckets provide a mechanism for developers and users to optimize battery usage and resource allocation on Android devices. By understanding how standby buckets work, you can make informed decisions about managing app behavior and power consumption.
Now you're ready to dive into the world of app standby buckets and leverage the power of ADB commands to manage them effectively. Happy optimizing!