-
-
[原创]修改adbd实现root权限运行adb命令
-
2022-3-29 17:46
10063
-
[原创]修改adbd实现root权限运行adb命令
在adbd中,把降权限的代码去掉,从而让adb shell永远有root的权限。去掉的代码为:
找到system/core/adb/daemon/main.cpp 修改如下代码:
static bool should_drop_privileges() {
return false;
// #if defined(ALLOW_ADBD_ROOT)
// // 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.
// bool ro_secure = android::base::GetBoolProperty("ro.secure", true);
// //netease
// // bool ro_debuggable = __android_log_is_debuggable();
// bool ro_debuggable=true;
// // Drop privileges if ro.secure is set...
// bool drop = ro_secure;
// // ... except "adb root" lets you keep privileges in a debuggable build.
// std::string prop = android::base::GetProperty("service.adb.root", "");
// bool adb_root = (prop == "1");
// bool adb_unroot = (prop == "0");
// 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
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课