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
相关推荐
居然是阿宋34 分钟前
Kotlin高阶函数 vs Lambda表达式:关键区别与协作关系
android·开发语言·kotlin
凉、介1 小时前
PCI 总线学习笔记(五)
android·linux·笔记·学习·pcie·pci
cypking1 小时前
mysql 安装
数据库·mysql·adb
小贾要学习2 小时前
【C++】继承----下篇
android·java·c++
投笔丶从戎3 小时前
Kotlin Multiplatform--01:项目结构基础
android·开发语言·kotlin
Lary_Rock5 小时前
Android 编译问题 prebuilts/clang/host/linux-x86
android·linux·运维
王江奎5 小时前
Android FFmpeg 交叉编译全指南:NDK编译 + CMake 集成
android·ffmpeg
limingade5 小时前
手机打电话通话时如何向对方播放录制的IVR引导词声音
android·智能手机·蓝牙电话·手机提取通话声音
hepherd6 小时前
Flutter 环境搭建 (Android)
android·flutter·visual studio code