Android系统默认开启adb root模式

需求描述

将adb root模式默认开启

解决方案

system/core/adb/daemon/main.cpp

复制代码
static bool should_drop_privileges() {
#if defined(ALLOW_ADBD_ROOT)
    char value[PROPERTY_VALUE_MAX];

    // The properties that affect `adb root` and `adb unroot` are ro.secure and
    // ro.debuggable. In this context the names don't make the expected behavior
    // particularly obvious.
    //
    // ro.debuggable:
    //   Allowed to become root, but not necessarily the default. Set to 1 on
    //   eng and userdebug builds.
    //
    // ro.secure:
    //   Drop privileges by default. Set to 1 on userdebug and user builds.
    property_get("ro.secure", value, "1");
    bool ro_secure = (strcmp(value, "1") == 0);

    property_get("ro.debuggable", value, "");
    bool ro_debuggable = (strcmp(value, "1") == 0);

    // Drop privileges if ro.secure is set...
    bool drop = ro_secure;

    property_get("service.adb.root", value, "");
    bool adb_root = (strcmp(value, "1") == 0);
    bool adb_unroot = (strcmp(value, "0") == 0);

    // ... except "adb root" lets you keep privileges in a debuggable build.
    if (ro_debuggable && adb_root) {
        drop = false;
    }

    // ... and "adb unroot" lets you explicitly drop privileges.
    if (adb_unroot) {
        drop = true;
    }

    return drop;
#else
    return true; // "adb root" not allowed, always drop privileges.
#endif // ALLOW_ADBD_ROOT
}

修改system/core/adb/daemon/main.cpp的should_drop_privileges()方法返回为false

修改build/core/main.mk,使ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0

添加属性device/qcom/msm8953_64/system.prop,该属性会编译到root/default.prop

复制代码
ro.secure=0
ro.adb.secure=0
ro.duebuggbale=1
相关推荐
蜡笔小炘10 小时前
Mysql 结课项目报告
数据库·adb
YF021111 小时前
Frida如何稳定连接PC端跟Android手机端
android·mac·xposed
翔云12345612 小时前
MySQL中,binlog文件开头的Previous_gtids_log_event是如何计算的
数据库·mysql·adb
O***P57112 小时前
【MySQL】MySQL内置函数--日期函数字符串函数数学函数其他相关函数
android·mysql·adb
z***438412 小时前
MySQL-mysql zip安装包配置教程
android·mysql·adb
无心水13 小时前
【Python实战进阶】7、Python条件与循环实战详解:从基础语法到高级技巧
android·java·python·python列表推导式·python条件语句·python循环语句·python实战案例
0***v77714 小时前
MySQL四种备份表的方式
mysql·adb·oracle
g***789114 小时前
鸿蒙NEXT(五):鸿蒙版React Native架构浅析
android·前端·后端
Bervin1213820 小时前
Flutter Android环境的搭建
android·flutter