2

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 <packagename> <active|working_set|frequent|rare> 

(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 :

$ > adb shell dumpsys battery unplug
$ > adb shell am get-standby-bucket <package-name>
> 10
$ > adb shell am set-standby-bucket <package-name> rare
$ > adb shell am get-standby-bucket <package-name>
> 10

or

$ > sudo adb shell
$ > su
# > dumpsys battery unplug
# > am get-standby-bucket <package-name>
> 10
# > am set-standby-bucket <package-name> rare
# > am get-standby-bucket <package-name>
> 10

Expected behaviour :

$ > adb shell dumpsys battery unplug
$ > adb shell am get-standby-bucket <package-name>
> 10
$ > adb shell am set-standby-bucket <package-name> rare
$ > adb shell am get-standby-bucket <package-name>
> 40

or

$ > sudo adb shell
$ > su
# > dumpsys battery unplug
# > am get-standby-bucket <package-name>
> 10
# > am set-standby-bucket <package-name> rare
# > am get-standby-bucket <package-name>
> 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 !

1

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 <package-name> 40

Not

adb shell am set-standby-bucket <package-name> rare

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.