标签:android style blog http 使用 os io for
dumpsys用来dump某系统组件的信息:
*./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); } } ```
从上面实现代码得知,dumpsys特指dump注册在ServiceManager里的`Service`, 每个`Service`都可以通过实现`dump`接口来说明自己的信息
以media.player为例:
*./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()); } ```
mediaserver进程在ServiceManager里注册了`Service`,名字叫做"media.player",最终dump实现:
``` 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); } ```
当有视频播放的时候,敲入`dumpsys media.player`命令,可以输出:
``` ? ~ 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: ```
扩展阅读:
标签:android style blog http 使用 os io for
原文地址:http://my.oschina.net/caohong/blog/294633