4

Can anyone tell me how does the adb shell dumpsys work internally? I suppose this command reads the /proc fs somehow, but this is just my understanding.

It seems that android sdk 19 onwards, following command is not supported-

adb shell dumpsys batteryinfo

It has been replaced by

adb shell dumpsys batterystats

I would like to know if any documentation (link) is available, where detailed information about this can be found.

guntbert
  • 536
  • 6
  • 19
darthvading
  • 909
  • 2
  • 11
  • 25
  • After answering below, I searched for the change in service name and found this previous SO answer: http://stackoverflow.com/questions/11201659/whats-android-adb-shell-dumpsys-tool-and-its-benefits?rq=1. The one from Joe has additional detail and I would recommend reviewing it. – GeekyDeaks Jul 03 '14 at 07:51
  • I assume that only "adb shell dumpsys batterystats" is available since Kitkat, right? – android developer Aug 29 '14 at 15:26
  • 1
    @androiddeveloper yes, in Kitkat it is "adb shell dumpsys batterystats" while in JB and earlier versions it was "adb shell dumpsys batteryinfo" – darthvading Sep 01 '14 at 10:40
  • @darthvading Thanks. Do you know perhaps how to read from its output, to get the battery consumption of a specific app? I've tried doing so, but my calculation doesn't match the one on the official battery-info screen. If you know the answer to it, please write it down here: http://stackoverflow.com/questions/23312038/ – android developer Sep 01 '14 at 16:15

1 Answers1

2

If you take a look at the source code for dumpsys, you can see that it simply requests a instance of the service from the default service manager and then calls the service dump() method (which is an interface of IBinder) passing STDOUT and the command line args:

sp<IServiceManager> sm = defaultServiceManager();
...
sp<IBinder> service = sm->checkService(services[i]);
...
int err = service->dump(STDOUT_FILENO, args); 

In your example above, the service in question would appear to have been renamed from batteryinfo to batterystats

GeekyDeaks
  • 650
  • 6
  • 12