Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

adb

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?

like image 657
HomerPlata Avatar asked Feb 16 '17 13:02

HomerPlata


People also ask

How do I check my battery remaining power?

Show battery percentage in status barOpen your phone's Settings app. Tap Battery. Turn on Battery percentage.

How do I check battery health using adb?

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 .

How do I check battery status on Android?

Go to settings > Battery and device care > Diagnostics. You can now tap on battery status to check its health status. There are other features as well (Camera, speaker and more) of the phone that you can test to see if they are working fine or you should get them fixed.

How can I check my adb status?

You can verify that your device is connected by executing adb devices from the android_sdk /platform-tools/ directory. If connected, you'll see the device name listed as a "device."


2 Answers

Try this: adb shell dumpsys battery

It gives all the battery details.

like image 195
Vineeth Holla Avatar answered Oct 10 '22 20:10

Vineeth Holla


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

like image 38
antoninkriz Avatar answered Oct 10 '22 19:10

antoninkriz