ADB Shell command not applied - "am set-standby-bucket" - Android 9 Currently trying to observe the behaviour of my app in different adaptive battery buckets on Android Pie. I was testing it with the command : 

adb shell am set-standby-bucket &lt;packagename&gt; &lt;active|working_set|frequent|rare&gt; 


(documented here : https://developer.android.com/about/versions/pie/power)

The problem is that the command appear to be ignored by the device as you will see in the actual behavior snippet. 

Notice that only one device is plugged during the process.

Actual behaviour :

$ &gt; adb shell dumpsys battery unplug
$ &gt; adb shell am get-standby-bucket &lt;package-name&gt;
&gt; 10
$ &gt; adb shell am set-standby-bucket &lt;package-name&gt; rare
$ &gt; adb shell am get-standby-bucket &lt;package-name&gt;
&gt; 10


or

$ &gt; sudo adb shell
$ &gt; su
# &gt; dumpsys battery unplug
# &gt; am get-standby-bucket &lt;package-name&gt;
&gt; 10
# &gt; am set-standby-bucket &lt;package-name&gt; rare
# &gt; am get-standby-bucket &lt;package-name&gt;
&gt; 10


Expected behaviour :

$ &gt; adb shell dumpsys battery unplug
$ &gt; adb shell am get-standby-bucket &lt;package-name&gt;
&gt; 10
$ &gt; adb shell am set-standby-bucket &lt;package-name&gt; rare
$ &gt; adb shell am get-standby-bucket &lt;package-name&gt;
&gt; 40


or

$ &gt; sudo adb shell
$ &gt; su
# &gt; dumpsys battery unplug
# &gt; am get-standby-bucket &lt;package-name&gt;
&gt; 10
# &gt; am set-standby-bucket &lt;package-name&gt; rare
# &gt; am get-standby-bucket &lt;package-name&gt;
&gt; 40


Here is my configuration :
Android Studio 3.3.1
Build #AI-182.5107.16.33.5264788, built on January 29, 2019
JRE: 1.8.0_152-release-1248-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
MacBook Pro - MacOS Mojave 10.14.3

Here is the device configuration I am using :


Type : Emulator 
Name: Pixel_API_28 
CPU/ABI: Google APIs Intel Atom    (x86_64)
Path: ..../.android/avd/Pixel_API_28_1.avd
Target:    google_apis [Google APIs] (API level 28)
image.androidVersion.api: 28
tag.id: google_apis


Thank you in advance !
I see the same thing with the Android P emulator.
However, this works for me on a Pixel 2 device with P.

Btw I think you need to use the integer representation when setting:

adb shell am set-standby-bucket &lt;package-name&gt; 40


Not

adb shell am set-standby-bucket &lt;package-name&gt; rare