Is it possible to query device state (ie. battery charge remaining) via ADB shell command?

蓝咒 提交于 2019-12-30 02:47:15

问题


I'd like to find out various bits of information on an Android device's current status via ADB. Can it be done, and - if so - how?


回答1:


Try this: adb shell dumpsys battery

It gives all the battery details.




回答2:


IF YOUR DEVICE IS ROOTED

You can use ADB almost like a remote shell, so you can get devices battery info using adb shell cat /sys/class/power_supply/battery/batt_attr_text where "level" is battery level or adb shell dumpsys battery.

adb shell <your command> will let you execute almost any linux command. Some commands are not available and must be installed (e.g. busybox).

Source




回答3:


Pretty simple and you don't need rooted device for this. adb shell dumpsys <option>

Subsitute options with any of these: battery diskstats wifi location usagestats cpuinfo iphonesubinfo telephony.registry meminfo netstat package

You may also try adb shell dumpsys | grep "DUMP OF SERVICE" This will list many other options available with dumpsys.



来源:https://stackoverflow.com/questions/42274720/is-it-possible-to-query-device-state-ie-battery-charge-remaining-via-adb-shel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!