Cannot set my Android app to restricted bucket

Viewed 332
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;
Related