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
相关推荐
提子拌饭1331 天前
番茄时间管理:鸿蒙Flutter 实现的高效时间管理工具
android·flutter·华为·架构·开源·harmonyos·鸿蒙
4311媒体网1 天前
帝国CMS二次开发实战:精准实现“最新资讯”标识与高亮判断
android
BLUcoding1 天前
Android 轻量级本地存储 SharedPreferences
android
冬奇Lab1 天前
Camera HAL3 接口:Android 相机的真正底牌
android·音视频开发·源码阅读
sensen_kiss1 天前
CAN302 Technologies for E-Commerce 电子商务技术 Pt.6 市场营销与SEO(搜索引擎优化)
android·学习·搜索引擎
菜鸟国国1 天前
Compose + Koin ViewModel 实战完全手册
android
小羊子说1 天前
Android 音频系统深度解析:从 App 到内核的完整链路
android·人工智能·性能优化·车载系统
fengci.1 天前
php反序列化(复习)(第三章)
android·开发语言·学习·php
D4c-lovetrain1 天前
linux个人心得24 (mysql③,AI排版尝试)
android·adb
黑牛儿1 天前
MySQL负载均衡配置详细步骤(新手易操作版)
mysql·adb·负载均衡