Search code examples
androidadbbattery

Modify battery percentage on real Android device


I have a rooted Galaxy S6 and I want to modify the battery percentage of the device for test purposes. I want that Android 'thinks' it has X percent battery... I have already found that the percentage is stored at:

/sys/class/power_supply/battery/capacity

But when I try to modify the file, it says:

tmp-mksh: can't create capacity: Permission denied

Even if I try as root... Is there some way to modify the percentage of the battery?

EDIT: I tried this too:

Microsoft Windows [versão 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Todos os direitos reservados.

C:\Users\Valentino>adb root
adbd cannot run as root in production builds

C:\Users\Valentino>adb shell
shell@zerolte:/ $ su
su
root@zerolte:/ # setenforce 0
setenforce 0
root@zerolte:/ # echo 45 >> /sys/class/power_supply/battery/capacity
echo 45 >> /sys/class/power_supply/battery/capacity
tmp-mksh: can't create /sys/class/power_supply/battery/capacity: Permission deni
ed
1|root@zerolte:/ #

It doesn't work either...


Solution

  • You can use following command:

    adb shell dumpsys battery set level 30

    to reset the original battery level back, use:

    adb shell dumpsys battery reset