[Android]service list与dumpsys -l的结果差异分析


在adb shell中,
service list
Found 137 services:
0       sip: [android.net.sip.ISipService]
1       nfc: [android.nfc.INfcAdapter]
...

对结果安装字母顺序进行排序(可使用sort命令),编辑后,和dumpsys -l 的结果进行比较
多了2个
android.service.gatekeeper.IGateKeeperService
netd


查看code,service.cpp里获取服务列表是
114         else if (strcmp(argv[optind], "list") == 0) {
115             Vector<String16> services = sm->listServices();
116             aout << "Found " << services.size() << " services:" << endl;
117             for (unsigned i = 0; i < services.size(); i++) {
118                 String16 name = services[i];
119                 sp<IBinder> service = sm->checkService(name);
120                 aout << i
121                      << "\t" << good_old_string(name)
122                      << ": [" << good_old_string(get_interface_name(service)) << "]"
123                      << endl;
124             }
125

dumpsys.cpp里

    if ((argc == 1) || showListOnly) {

        services = sm->listServices();

        services.sort(sort_func);

        args.add(String16("-a"));

    } else {

        services.add(String16(argv[1]));

        for (int i=2; i<argc; i++) {

            args.add(String16(argv[i]));

        }

    }

 

    const size_t N = services.size();

 

    if (N > 1) {

        // first print a list of the current services

        aout << "Currently running services:" << endl;

 

        for (size_t i=0; i<N; i++) {

            sp<IBinder> service = sm->checkService(services[i]);

            if (service != NULL) {

                aout << "  " << services[i] << endl;

            }

        }

    }

在打印的时候,进行了检查

            sp<IBinder> service = sm->checkService(services[i]);

            if (service != NULL) {

                aout << "  " << services[i] << endl;

            }


service不为NULL才进行打印



$ service check netd
service check netd
Service netd: not found


$ service check android.service.gatekeeper.IGateKeeperService
service check android.service.gatekeeper.IGateKeeperService
Service android.service.gatekeeper.IGateKeeperService: not found


正常的check
$ service check battery
service check battery
Service battery: found

service list
对结果进行sort,编辑后,和dumpsys -l 的结果进行比较
多了2个
android.service.gatekeeper.IGateKeeperService
netd


查看code,service.cpp里获取服务列表是
114         else if (strcmp(argv[optind], "list") == 0) {
115             Vector<String16> services = sm->listServices();
116             aout << "Found " << services.size() << " services:" << endl;
117             for (unsigned i = 0; i < services.size(); i++) {
118                 String16 name = services[i];
119                 sp<IBinder> service = sm->checkService(name);
120                 aout << i
121                      << "\t" << good_old_string(name)
122                      << ": [" << good_old_string(get_interface_name(service)) << "]"
123                      << endl;
124             }
125

dumpsys.cpp里

    if ((argc == 1) || showListOnly) {

        services = sm->listServices();

        services.sort(sort_func);

        args.add(String16("-a"));

    } else {

        services.add(String16(argv[1]));

        for (int i=2; i<argc; i++) {

            args.add(String16(argv[i]));

        }

    }

 

    const size_t N = services.size();

 

    if (N > 1) {

        // first print a list of the current services

        aout << "Currently running services:" << endl;

 

        for (size_t i=0; i<N; i++) {

            sp<IBinder> service = sm->checkService(services[i]);

            if (service != NULL) {

                aout << "  " << services[i] << endl;

            }

        }

    }

在打印的时候,进行了检查

            sp<IBinder> service = sm->checkService(services[i]);

            if (service != NULL) {

                aout << "  " << services[i] << endl;

            }


service不为NULL才进行打印



$ service check netd
service check netd
Service netd: not found


$ service check android.service.gatekeeper.IGateKeeperService
service check android.service.gatekeeper.IGateKeeperService
Service android.service.gatekeeper.IGateKeeperService: not found


正常的check
$ service check battery
service check battery
Service battery: found

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值