Can't change battery configuration in Android

2019-07-03 19:44发布

问题:

I'm trying to change in my emulator the battery status as capacity and ac status but isn't working.

I made the whole steps:

1) Connected to the emulator via telnet;
2) Tried to use the commands such power ac off and power capacity 70
3) Every time I checked the power display, the same configuration appears and no change I input is save, and the emulator always show the battery with a "!".

FR I saw this link Change emulator battery level in Windows, tried it and nothing resolved.

Follow my data about the battery:

power display
AC: online
status: Not charging
health: Dead
present: false
capacity: 0

Thank you!

回答1:

It seems like your emulator device has battery option turned off.

You can change AVD battery configuration through:

  1. Open AVD configuration file:

    Default location for Linux/MAC

    ~/.android/avd/<AVD name>.avd/config.ini
    

    Default location for Windows XP

    C:\Documents and Settings\<user>\.android\avd\<AVD name>.avd\config.ini
    

    Default location for Windows Vista and later

    C:\Users\<user>\.android\avd\<AVD name>.avd\config.ini
    
  2. Change the line:

    hw.battery=no
    

    to

    hw.battery=yes
    


回答2:

You made right. I did it on my computer and sometimes it did not worked too, I just had to set battery status to discharging before setting its capacity.

power status discharging

Additionally there is a nice tutorial that could help you with additional commands:

http://www.stealthcopter.com/blog/2010/07/changing-the-battery-percentage-in-an-avd-android-virtual-device-emulator/