Dumpsys is a very interesting android shell command that dumps the state of various running services and also other system information on std output.
Benefits :
Retrieve various system information in a simple string representation Analyse the various stats like cpuinfo, batteryinfo, meminfo, wifi, location etc., to analyze the overall performance of the device and also the individual performance of various application and services. Syntax : $ adb shell dumpsys
It takes either no arguments, to list all the dumpsys information or one argument of the specific to list. However, based on the service you can have multiple arguments to the dumpsys command followed by the <servicename>
To List all the services : $ adb shell dumpsys | grep DUMP
Android application needs, android.permission.DUMP
permission added to android manifest to access dumpsys programmatically.
Although dumpsys is a very useful tool that can be used to view the system information on an adb shell, these information cannot be retrieved programmatically by a normal application. Executing this shell command, through android Runtime.getRuntime().exec()
sometimes causes error or unexpected stopping of your application.
If you try to write the output to DataOutputStream
, it shows Permission Denial : cannot dump <servicename>
This is because dumpsys has android:protectionLevel="signatureOrSystem"
. Unless your application is signed with a platform key or built as a system application, dumpsys information cannot be retrieved programmatically.
Solution : One has to either root the phone or install the application as a system application or change the protection level of DUMP permission and create a new build.
If you are root user you can achieve it easily,
My this https://stackoverflow.com/a/48885488/2553431 might help you