android L adb获取root原理

下面的方法就是判断要不要打开root,先上代码

static int should_drop_privileges() {
#ifndef ALLOW_ADBD_ROOT
    return 1;                     //如果没定义AllOW_ADVD_ROOT,则return1,不能root
#else /* ALLOW_ADBD_ROOT */    
    int secure = 0;
    char value[PROPERTY_VALUE_MAX];

   /* run adbd in secure mode if ro.secure is set and
    ** we are not in the emulator
    */
    property_get("ro.kernel.qemu", value, "");          //这个属性不知道是什么,一般不存在
    if (strcmp(value, "1") != 0) {
        property_get("ro.secure", value, "1");            //如果ro.secure是1,不打开root,但如果ro.debuggable是1,且service.adb.root是1,则可以打开root
        if (strcmp(value, "1") == 0) {
            // don't run as root if ro.secure is set...
            secure = 1;

            // ... except we allow running as root in userdebug builds if the
            // service.adb.root property has been set by the "adb root" command
            property_get("ro.debuggable", value, "");
            if (strcmp(value, "1") == 0) {
                property_get("service.adb.root", value, "");
                if (strcmp(value, "1") == 0) {
                    secure = 0;
                }
            }
        }
    }
    return secure;
#endif /* ALLOW_ADBD_ROOT */
}

所以根据上面的代码,可以设置属性ro.secure为0,则打开了root!!!!
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值