Search code examples
androidadb

android adb - how to set emulator to ac power


In an effort to test doze and standby mode im trying to change the battery level and also the set to ac etc using adb and a api 23 emulator.

But when i run the following bash command:

adb shell dumpsys battery set level [95]

i get the following error:

Bad value: [95]

also when i run :

adb shell dumpsys battery set [ac]

i get the following error:

Dump current battery state, or:
  set [ac|usb|wireless|status|level|invalid] <value>
  unplug
  reset

i am assuming meaning it could not find the ac command. How can i change the emulator to ac and also update the battery level ?

update: there is a command adb shell dumpsys battery unplug to unplug the emulator so should there not be a command to plug it in for AC power ?


Solution

  • there is a command adb shell dumpsys battery unplug to unplug the emulator so should there not be a command to plug it in for AC power ?

    Yes, the command is:

    adb shell dumpsys battery set ac 1
    

    To change the level of the battery you can use this command:

    adb shell dumpsys battery set level 42