Querying Device State via ADB Shell Command

Querying Device State via ADB Shell Command

21 May 2024 Stephan Petzl Leave a comment Tech-Help

Understanding your Android device’s current status can be crucial for debugging and development. One common need is to query the battery state directly from the device using ADB (Android Debug Bridge). This guide will walk you through the steps to retrieve various information about your device using ADB shell commands.

Getting Battery Details

To get detailed information about the battery status of your Android device, you can use the following ADB shell command:

adb shell dumpsys battery

This command provides a comprehensive overview of the battery’s current state, including charge level, temperature, and health.

Alternative Methods for Rooted Devices

If your device is rooted, you have more flexibility and can use additional commands to get battery information. For instance:

adb shell cat /sys/class/power_supply/battery/batt_attr_text

Replace batt_attr_text with the specific attribute you are interested in, such as level for the battery level.

Other Useful Dumpsys Options

The dumpsys command is not limited to battery information. You can query various other system services by substituting option with the desired service:

adb shell dumpsys <option>

Some useful options include:

  • diskstats – Disk statistics
  • wifi – WiFi status
  • location – Location services
  • cpuinfo – CPU information
  • meminfo – Memory information

You can also list all available options by running:

adb shell dumpsys | grep "DUMP OF SERVICE"

Example: Customizing Battery Output

For more customized output, you can use shell scripting. Here’s an example to get the battery level and format the output:

adb shell cmd battery get level | sed 's/.*/Battery: &%/'

This command will display the battery level in a more readable format, such as Battery: 85%.


By using the ADB shell commands, you can easily query various aspects of your Android device’s state, which can be invaluable for development and debugging purposes. For more detailed guides on using ADB, check out our related articles:

Enhance Your Testing Workflow with Repeato

For developers looking to streamline their testing processes, Repeato offers a no-code test automation tool for iOS and Android. Repeato utilizes computer vision and AI to create, run, and maintain automated tests efficiently. With built-in ADB support, you can execute ADB commands seamlessly within your test scripts, ensuring precise timing and sequence of operations. Explore how Repeato can enhance your testing workflow by visiting our documentation.

Like this article? there’s more where that came from!