6

I have an application where I create a process and call the dumpsys telephony.registry command to get information about the mobile network status.

String[] cmds={"dumpsys telephony.registry"};
Process p = Runtime.getRuntime().exec(cmds [0]+"\n");

and then after that I parse the result of the command. For "ls" or other commands it works fine. For dupmsys I get Permission Denial: can't dump telephony.registry from pid-953, uid=10090. I get the same error results for dumpsys power or other dumpsys commands.

I have set DUMP permissions android.permission.DUMP in the android Manifest like suggested here

I think that I am doing this right since Android offers this feature here

I have also done the step described here to force eclipse to allow me to give my application DUMP permission in the manifest.

When I execute the dumpsys command I always get the same result

Permission Denial: can't dump telephony.registry from pid-953, uid=10090

Am I doing something wrong? Why does android OS still deny me access to the dump service ?

PS I have set min API 8 and I am testing the application on device running (ICS) API 15

Community
  • 1
  • 1
malcolm the4
  • 347
  • 2
  • 5
  • 15

5 Answers5

8

Why does android OS still deny me access to the dump service ?

Because that permission is flagged as android:protectionLevel="signature|system|development" (or signatureOrSystem using the old syntax) on Android 2.3+, and therefore cannot be held by ordinary Android SDK applications.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I thought that the permission in the android manifest was there to give developers this option.Is there a way for me to do it ? Or Android will not allow me to dumpsys no matter what ? – malcolm the4 Jul 05 '13 at 16:49
  • @malcolmthe4: "Is there a way for me to do it ?" -- root your device and install your app on the system partition. – CommonsWare Jul 05 '13 at 16:51
  • I have tried to run su before the dumpsys commnad. I know that it works, but this restricts me only on rooted devices.... Is there not another way? I read this https://gist.github.com/vnu/3258553 How can I sign my application with a platform key ? – malcolm the4 Jul 05 '13 at 16:56
  • @malcolmthe4: "How can I sign my application with a platform key ?" -- compile your own ROM mod and install that ROM mod on your own device. The signing key you used for compiling the firmware in that ROM mod would be the signing key you would need to use to sign your app, for it to qualify for `signature`-level permissions. – CommonsWare Jul 05 '13 at 17:01
  • OK! so dumpsys is only possible for su and for custom roms. I will try to implement the functionality I want without dumpsys. Thanks anyway!!! :) – malcolm the4 Jul 05 '13 at 19:52
6

There's another (hacky) way to access dumpsys without rooting your device - through adb shell.

This will require allowing USB debugging, and finding the port of the adb service.

  1. Enable USB debugging on your device. This option is found under Settings -> Developer Options.

  2. Connect your device to a PC, and run the following command from the PC's shell/command line: adb tcpip 12345. Then, from your devices shell, issue the command adb connect localhost:12345 from your application. You can now disconnect the device from USB. Alternatively, you can scan the ports on your device one by one without USB connection, using adb connect localhost:<portnum> and find the port adb service is listening to.

  3. Authorize USB debugging from the pop up confirmation dialog, if prompted. Check the "always" checkbox to do not require this step again.

  4. Now, when you have access to the adb service, use adb shell dumpsys ... from your application code to get whatever service dump you need.

NOTE: You don't need the DUMP permission for that to work.

Elist
  • 5,313
  • 3
  • 35
  • 73
1

The android dev team decided to stop granting these permissions to third-party apps. Only system apps can now get them.

more details:https://code.google.com/p/acra/issues/detail?id=100

1

It reports private values of core Android services that you would never be able to typically obtain. Official document says "Not for use by third-party applications".

candy
  • 190
  • 1
  • 5
-2

Add permission on your manifest "android.permission.DUMP". I have not tried it yet but it shows on adb shell that it is missing that permission

Daniel
  • 2,744
  • 1
  • 31
  • 41