Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot set my Android app to restricted bucket

Tags:

android

I am trying to set my app to "restricted" bucket, based on this document https://developer.android.com/about/versions/12/behavior-changes-all#restrictive-app-standby-bucket.

adb shell am set-standby-bucket <Package> restricted

However, I always get 20 from this call

adb shell am get-standby-bucket <Package>

I tried this one too, but get the same 20.

adb shell am set-standby-bucket <Package> 45

The app is built target to 31. The device is Pixel 3a with Android OS 12 beta 4.

like image 229
user1443721 Avatar asked Oct 15 '25 04:10

user1443721


1 Answers

  1. You have to exit the app

  2. Run this command, it will set the app in restricted mode.

    adb shell am set-standby-bucket <Package> 45
    
  3. Run this command to get the current App Standby mode

    adb shell am get-standby-bucket <Package>
    
  • Any interaction with the app will/can change the App Standby value

Here is a description from Android Open Source Project regarding the values you get from get-standby-bucket

/**
 * The app has never been used.
 */
STANDBY_BUCKET_NEVER = 50;

/**
 * Exempted battery optimizations and the Doze and 
 * App Standy does not apply to the app
 */
STANDBY_BUCKET_EXEMPTED = 5;

/**
 * The app was used very recently, currently in use or likely to be used very soon. Standby
 * bucket values that are &le; {@link #STANDBY_BUCKET_ACTIVE} will not be throttled by the
 * system while they are in this bucket. Buckets &gt; {@link #STANDBY_BUCKET_ACTIVE} will most
 * likely be restricted in some way. For instance, jobs and alarms may be deferred.
 * @see #getAppStandbyBucket()
 */
STANDBY_BUCKET_ACTIVE = 10;

/**
 * The app was used recently and/or likely to be used in the next few hours. Restrictions will
 * apply to these apps, such as deferral of jobs and alarms.
 * @see #getAppStandbyBucket()
 */
STANDBY_BUCKET_WORKING_SET = 20;

/**
 * The app was used in the last few days and/or likely to be used in the next few days.
 * Restrictions will apply to these apps, such as deferral of jobs and alarms. The delays may be
 * greater than for apps in higher buckets (lower bucket value). Bucket values &gt;
 * {@link #STANDBY_BUCKET_FREQUENT} may additionally have network access limited.
 * @see #getAppStandbyBucket()
 */
STANDBY_BUCKET_FREQUENT = 30;

/**
 * The app has not be used for several days and/or is unlikely to be used for several days.
 * Apps in this bucket will have more restrictions, including network restrictions, except
 * during certain short periods (at a minimum, once a day) when they are allowed to execute
 * jobs, access the network, etc.
 * @see #getAppStandbyBucket()
 */
STANDBY_BUCKET_RARE = 40;

/**
 * The app has not be used for several days, is unlikely to be used for several days, and has
 * been misbehaving in some manner.
 * Apps in this bucket will have the most restrictions, including network restrictions and
 * additional restrictions on jobs.
 * <p> Note: this bucket is not enabled in {@link Build.VERSION_CODES#R}.
 * @see #getAppStandbyBucket()
 */
STANDBY_BUCKET_RESTRICTED = 45;
like image 123
Haroun Hajem Avatar answered Oct 16 '25 18:10

Haroun Hajem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!