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 !