A Preliminary Study on the working principle of dumpsys

Source: Internet
Author: User

Dumpsys is used to dump the information of a system component:

*./frameworks/av/native/cmds/dumpsys/dumpsys.cpp*```    sp<IServiceManager> sm = defaultServiceManager();//...    for (size_t i=0; i<N; i++) {        sp<IBinder> service = sm->checkService(services[i]);        if (service != NULL) {//...            int err = service->dump(STDOUT_FILENO, args);        }    } ```

The above implementation code shows that dumpsys refers to the 'service' registered by dump in servicemanager. Each 'service' can describe its own information through the 'dump 'interface.

Take media. player as an example:

*./frameworks/av/media/mediaserver/main_mediaserver.cpp*```int main(int argc, char** argv) {MediaPlayerService::instatiate();}```*./frameworks/av/media/libmediaplayerservice/MediaPlayerService.cpp*```void MediaPlayerService::instantiate() {    defaultServiceManager()->addService(            String16("media.player"), new MediaPlayerService());}```


The mediaserver process registers a 'service' in servicemanager and the name is "media. player". Finally, dump is implemented:

```status_t MediaPlayerService::Client::dump(...) const {    String8 result;    result.append(" Client\n");    snprintf(buffer, 255, "  pid(%d), connId(%d), status(%d), looping(%s)\n",            mPid, mConnId, mStatus, mLoop?"true": "false");    result.append(buffer);    write(fd, result.string(), result.size());    if (mPlayer != NULL) {        mPlayer->dump(fd, args);    }    if (mAudioOutput != 0) {        mAudioOutput->dump(fd, args);    }    write(fd, "\n", 1);}```


When a video is played, run the 'dumpsys media. play' command to output the following information:

```?  ~  adb shell dumpsys media.player Client  pid(17882), connId(5), status(0), looping(false) AwesomePlayer  URI(suppressed), flags(0x00000008)  Track 1   MIME(video/avc)   videoDimensions(-1 x -1), numVideoFramesDecoded(0), numVideoFramesDropped(0)  Track 2   MIME(audio/mp4a-latm) AudioOutput  stream type(3), left - right volume(1.000000, 1.000000)  msec per frame(0.000000), latency (-1)  aux effect id(0), send level (0.000000) No media recorder client Files opened and/or mapped:```


Additional reading:

  • Use 'dumpsys statusbar' to find the package name of statusbar

  • Introduction and use of dumpsys functions in Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.