ADB Commands — Part II

In ADB Commands — Part I i made a small intro to the adb commands. In this part i will show some more commands available, some off them very useful for debugging situations .

  • List all the installed packages in the device
adb shell pm list packages
e.g. output showing all the installed packages

  • Granting and revoking permissions of an application is a normal task during debugging and testing, it might be useful to have a script or that grants/revokes all the permissions in order to speedup the testing process.

To grant a permission we can do the following command:

adb shell pm grant com.myapp.mypackagename android.permission.INTERNET

Revoking a permission is similar, just change from grant to revoke.

adb shell pm revoke com.myapp.mypackagename android.permission.INTERNET

Android has set of system properties and settings that can be very useful if you want to know some hardware capabilities of your device, which Android API level the device has or even the ip address. You can get the list of available properties by typing the command:

adb shell getprop
e.g. output example of all the device properties available

If can also retrieve just a single property, e.g. to retrieve which Android api level the devices has:

adb shell getprop ro.build.version.sdk

Just replace the last part of the command with the property name that you want.

To modify those system properties you need root access, however there are other kind of properties that that can be modified. For example there is a set of properties related to UI debugging that can be changed- hwui/Properties.h (see full list in here).

For example each time you want to enable the GPU overdraw debugging you have to go to Settings -> Developer options and then enable it… Instead of this, just type:

adb shell setprop debug.hwui.overdraw show

To disable just type:

adb shell setprop debug.hwui.overdraw false

On old versions, the overdraw key had a different name:

debug.hwui.show_overdraw

The Android Debug Bridge is an extremely powerful command line tool for debugging Android apps.

In part III will continue with more those useful commands. Stay tuned :)

Like what you read? Give Filipe Batista a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.