修改真实Android设备上的电池百分比

时间:2015-10-06 02:15:52

标签: android adb battery

我有一个扎根的Galaxy S6,我想修改设备的电池百分比以进行测试。我希望Android'认为'它有X%电池...... 我已经发现百分比存储在:

/sys/class/power_supply/battery/capacity

但是当我尝试修改文件时,它说:

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

即使我以root身份尝试...... 有没有办法修改电池的百分比?

编辑:我也试过了:

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:/ #

它也不起作用......

2 个答案:

答案 0 :(得分:3)

您可以使用以下命令:

adb shell dumpsys battery set level 30

重新恢复原始电池电量,请使用:

adb shell dumpsys battery reset

答案 1 :(得分:2)

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. :)