Reputation: 1374
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...
Upvotes: 1
Views: 12813
Reputation: 24917
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
Upvotes: 10
Reputation: 31
Try the below commands which might help you.
adb root
adb shell
su
setenforce 0
echo 45 >> /sys/class/power_supply/battery/capacity
This will change the battery level to 45% and it worked fine for me. :)
Upvotes: 3