Is it possible to query device state (ie. battery

2019-02-06 19:56发布

问题:

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.



标签: android adb