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 分钟前
如何实现安卓端与苹果端互通的多种方案
android
wu_android1 小时前
Android 线性布局中常见的冲突属性总结
android
恋猫de小郭1 小时前
为什么跨平台框架可以适配鸿蒙,它们的技术原理是什么?
android·前端·flutter
张风捷特烈2 小时前
每日一题 Flutter#5,6 | 两道 Widget 选择题
android·flutter
移动开发者1号2 小时前
App主界面点击与跳转启动方式区别
android·kotlin
移动开发者1号2 小时前
我用Intent传大图片时竟然崩了,怎么回事啊
android·kotlin
limingade7 小时前
ADB识别手机系统弹授权框-如何处理多重弹框叠加和重叠问题
adb·智能手机·android自动授权确认·安卓弹框授权·自动化点击android授权框
FREEDOM_X7 小时前
系统调试——ADB 工具
adb
androidwork14 小时前
Android LinearLayout、FrameLayout、RelativeLayout、ConstraintLayout大混战
android·java·kotlin·androidx
每次的天空14 小时前
Android第十三次面试总结基础
android·面试·职场和发展