Search code examples
androidlinuxadb

android dumpsys batteryinfo vs android dumpsys batterystats


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.


Solution

  • 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