linux. fbdump命令,bugreport命令、dumpstate服务

android 5.0 源码

1、/system/core/rootdir/Init.rc

service dumpstate /system/bin/dumpstate -s     =》linux服务进程

class main

socket dumpstatestream 0660 shell log

disabled

oneshot

2、对应/framework/native/cmds/dumpstate/Dumpstate.c

int main(int argc, char *argv[]) {

......

if (getuid() != 0) {

// Old versions of the adb client would call the dumpstate command directly. Newer clients call /system/bin/bugreport instead.

// If we detect we're being called incorrectly, then exec the correct program.

return execl("/system/bin/bugreport", "/system/bin/bugreport", NULL);

}

......

dumpstate();

/* tell activity manager we're done */      =》广播通知AM,已经结束?

if (do_broadcast && use_outfile && do_fb) {

run_command(NULL, 5, "/system/bin/am", "broadcast", "--user", "0",

"-a", "android.intent.action.BUGREPORT_FINISHED",

"--es", "android.intent.extra.BUGREPORT", path,

"--es", "android.intent.extra.SCREENSHOT", screenshot_path,

"--receiver-permission", "android.permission.DUMP", NULL);

}

......

}

/* dumps the current system state to stdout */

static void dumpstate() {  ......  }

3、对应/framework/native/cmds/bugreport/Bugreport.c

说明,bugreport命令,是在dumpstate服务外面包装了一层,通过socket连接dumpstate服务。

int main(int argc, char *argv[]) {

......

/* start the dumpstate service */

property_set("ctl.start", "dumpstate");

/* socket will not be available until service starts */

for (i = 0; i < 20; i++) {

s = socket_local_client("dumpstate",

ANDROID_SOCKET_NAMESPACE_RESERVED,

SOCK_STREAM);

if (s >= 0)

break;

/* try again in 1 second */

sleep(1);

}

......

}

参考:

http://blog.youkuaiyun.com/kevinx_xu/article/details/26253969

http://blog.youkuaiyun.com/chenzhiqin20/article/details/12506227

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值