Android R user root + remount 修改方案
众所周知,Android在大版本更新上对权限要求越来越严格,AndroidR上user版本包含remount权限也需要进行比较大的修改,如果只需要有root 权限,只需要如下修改即可:
修改源码
system/core/adb/daemon/main.cpp
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;
++ return false;
}
system/core/init/selinux.cpp
bool IsEnforcing() {++ return false;{int fd(open("/mboot/selinux", O_RDONLY | O_CLOEXEC | O_BINARY));
如果需要remount权限,则需要新增如下修改:
diff --git a/adb/Android.bp b/adb/Android.bp
index dee48bf..604d1dd 100644
--- a/adb/Android.bp
+++ b/adb/Android.bp
@@ -594,6 +594,11 @@],}},
+ required: [
+ "libadbd_auth",
+ "libadbd_fs",
+ "remount",
+ ],}phony {diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp
index 658e244..28c4f92 100644
--- a/adb/daemon/main.cpp
+++ b/adb/daemon/main.cpp
@@ -91,7 +91,7 @@drop = true;}- return drop;
+ return false;}static void drop_privileges(int server_port) {@@ -210,9 +210,9 @@#if defined(__ANDROID__)// If we're on userdebug/eng or the device is unlocked, permit no-authentication.
- bool device_unlocked = "orange" == android::base::GetProperty("ro.boot.verifiedbootstate", "");
+ bool device_unlocked = true;if (__android_log_is_debuggable() || device_unlocked) {- auth_required = android::base::GetBoolProperty("ro.adb.secure", false);
+ auth_required = false;}#endifdiff --git a/fs_mgr/Android.bp b/fs_mgr/Android.bp
index ac784b2..5abcecd 100644
--- a/fs_mgr/Android.bp
+++ b/fs_mgr/Android.bp
@@ -79,16 +79,9 @@"libfstab",],cppflags: [
- "-DALLOW_ADBD_DISABLE_VERITY=0",
+ "-UALLOW_ADBD_DISABLE_VERITY",
+ "-DALLOW_ADBD_DISABLE_VERITY=1",],
- product_variables: {- debuggable: {- cppflags: [
- "-UALLOW_ADBD_DISABLE_VERITY",
- "-DALLOW_ADBD_DISABLE_VERITY=1",
- ],
- },
- },header_libs: ["libfiemap_headers","libstorage_literals_headers",
@@ -193,16 +186,9 @@"fs_mgr_remount.cpp",],cppflags: [
- "-DALLOW_ADBD_DISABLE_VERITY=0",
+ "-UALLOW_ADBD_DISABLE_VERITY",
+ "-DALLOW_ADBD_DISABLE_VERITY=1",],
- product_variables: {- debuggable: {- cppflags: [
- "-UALLOW_ADBD_DISABLE_VERITY",
- "-DALLOW_ADBD_DISABLE_VERITY=1",
- ],
- },
- },required: ["clean_scratch_files",],
diff --git a/fs_mgr/fs_mgr_remount.cpp b/fs_mgr/fs_mgr_remount.cpp
index def1c21..4e4113d 100644
--- a/fs_mgr/fs_mgr_remount.cpp
+++ b/fs_mgr/fs_mgr_remount.cpp
@@ -144,7 +144,7 @@// If somehow this executable is delivered on a "user" build, it can// not function, so providing a clear message to the caller rather than// letting if fall through and provide a lot of confusing failure messages.
- if (!ALLOW_ADBD_DISABLE_VERITY || (android::base::GetProperty("ro.debuggable", "0") != "1")) {+ if (!ALLOW_ADBD_DISABLE_VERITY) {LOG(ERROR) << "only functions on userdebug or eng builds";return NOT_USERDEBUG;}
diff --git a/init/property_service.cpp b/init/property_service.cpp
index a89504e..8191db7 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -743,7 +743,7 @@// So we need to apply the same rule of build/make/tools/post_process_props.py// on runtime.static void update_sys_usb_config() {- bool is_debuggable = android::base::GetBoolProperty("ro.debuggable", false);
+ bool is_debuggable = true;std::string config = android::base::GetProperty("persist.sys.usb.config", "");// b/150130503, add (config == "none") condition here to prevent appending// ",adb" if "none" is explicitly defined in default prop.
diff --git a/init/selinux.cpp b/init/selinux.cpp
index 6baada4..4b79ddb 100644
--- a/init/selinux.cpp
+++ b/init/selinux.cpp
@@ -104,7 +104,8 @@}bool IsEnforcing() {- {+ return false;
+ {int fd(open("/mboot/selinux", O_RDONLY | O_CLOEXEC | O_BINARY));if (fd != -1) {char v = 0xff;
diff --git a/set-verity-state/set-verity-state.cpp b/set-verity-state/set-verity-state.cpp
index 0a26aba..478e2bb 100644
--- a/set-verity-state/set-verity-state.cpp
+++ b/set-verity-state/set-verity-state.cpp
@@ -130,16 +130,17 @@static bool overlayfs_setup(bool enable) {auto change = false;
- errno = 0;
- if (enable ? fs_mgr_overlayfs_teardown(nullptr, &change)
- : fs_mgr_overlayfs_setup(nullptr, nullptr, &change)) {- if (change) {- printf("%s overlayfs\n", enable ? "disabling" : "using");
- }
- } else if (errno) {- printf("Overlayfs %s failed with error %s\n", enable ? "teardown" : "setup", strerror(errno));
- suggest_run_adb_root();
- }
+// errno = 0;
+// if (enable ? fs_mgr_overlayfs_teardown(nullptr, &change)
+// : fs_mgr_overlayfs_setup(nullptr, nullptr, &change)) {+// if (change) {+// printf("%s overlayfs\n", enable ? "disabling" : "using");
+// }
+// } else if (errno) {+// printf("Overlayfs %s failed with error %s\n", enable ? "teardown" : "setup", strerror(errno));
+// suggest_run_adb_root();
+// }
+ printf("overlayfs_setup %d\n", enable);return change;}
对于非Go版本,即使用Google mainline的adb,需要删掉mainline的adb,并关闭编译期ssi检查:
禁用ssi:
vendor/sprd/feature_configs/vendorsetup.sh
# lunch if needed, if --unisoc_fc_device xx , will lunch xx otherwise, do nothingif [ -n "$feature_device" ] ; then_wrap_dry_run $dry_run lunch $feature_devicefiexport PRODUCT_SET_CARRIERS=$revision_keys
++ export SKIP_SSI_AUDIT=true
删除mainline adb:
diff --git a/AdbdPrebuilt/Android.bp b/AdbdPrebuilt/Android.bp
deleted file mode 100644
index d3cb4f5..0000000
--- a/AdbdPrebuilt/Android.bp
+++ /dev/null
@@ -1,21 +0,0 @@
-//
-// Copyright (C) 2020 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-apex_set {- name: "com.google.android.adbd",
- owner: "google",
- overrides: ["com.android.adbd"],
- set: "com.google.android.adbd.apks",
-}
diff --git a/build/mainline_modules_r.mk b/build/mainline_modules_r.mk
index 77c132f..89f4f6f 100644
--- a/build/mainline_modules_r.mk
+++ b/build/mainline_modules_r.mk
@@ -47,7 +47,6 @@# Mainline modules - APEX typePRODUCT_PACKAGES += \
- com.google.android.adbd \com.google.android.conscrypt \com.google.android.permission \com.google.android.ipsec \
Android R user root + remount 修改方案相关推荐
- [SPRD]展锐Android R关机充电动画修改
关机充电是用minui开发的,代码路径如下 vendor/sprd/proprietories-source/charge 代码中的图片资源路径 vendor/sprd/proprietories-s ...
- 【Android 逆向】修改 Android 系统文件 ( Android 逆向中需要经常修改的文件和目录 | 在 root 后的设备中获取 / 目录的 rw 权限后注意事项 )
文章目录 一.Android 逆向中需要经常修改的文件和目录 二.在 root 后的设备中获取 / 目录的 rw 权限后注意事项 1.不要随意执行 wipe 命令 2.不要随意执行 rm 命令 一.A ...
- android 平板root,【Android】免root即能修改Android ID,實現手機平板共用一個Line不互踢...
為何網路上會有人有修改「Android ID」的需求呢? 假設你有A手機與B手機,若把B手機的Android ID改成與A手機一樣,會有許多妙用的地方,例如: 多手機(平板)同時登同一個Line而不會 ...
- android 虚拟按键root,(免root)虚拟按键手动修改方法
荣耀6采用了虚拟按键,但原来的虚拟按键对于喜欢个性定制的朋友来说,有点不爽.前几日在贴吧看到有更改的方法,但还是不能自己定制.捣鼓了一下,现在放出最简教程. [修改教程] 1.楼主不提供的透明底图,用 ...
- Android App罕见错误和优化方案
本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 1.App如果被定义一个有参数构造函数,那么需要再定义一个无参数的,如果不则会在某些情况下初始化失败 ...
- user root remount
有些问题需要在user root remount下调试. Android R上,user版本没有remount文件,因此做了一些修改,参考如下: 1.先拿到userdebug版本的remount二进制 ...
- Android官方模拟器root,在Android模拟器上如何获得root权限?
我需要在Android模拟器中获得root权限,从而使用'iptables'和'busybox'功能. 尝试安装了z4root应用程序, 但需要很长时间,且没有完成获取root就卡住了.有人说如果我们 ...
- Android判断是否Root方法
为了照顾那些着急的同学,先直接给出结论: private static final String[] rootRelatedDirs = new String[]{"/su", & ...
- Android 系统(67)---android apk 的root 权限和USB adb 权限的区别
android apk 的root 权限和USB adb 权限的区别 USB adb 权限是指,当adb 连接手机时,手机中的守护进程adbd 的权限为root 权限,从而它的子进程也具有root 权 ...
最新文章
- java后台post请求调用接口
- VS2010 断点无效肿么办?
- C语言实现通用链表初步(四)----双向链表
- 二叉树的前序遍历Python解法
- 北京科技大学计算机专业评估,北京科技大学王牌专业有哪些
- the job was canceled什么意思_什么第三人称单数形式?怎么用?
- gcc的警告提示信息
- Vim快速移动光标至行首和行尾
- pytorch张量操作基础
- SQL必知必会-排序检索数据
- Spark SQL将rdd转换为数据集-反射来推断Inferring the Schema Using Reflection
- java做手机短信验证码平台_java实现短信验证码功能
- ubuntu系统镜像文件下载
- [Python]自学笔记36:论一只爬虫的自我修养3:隐藏
- spring-cloud-context源码解读
- easyefi添加引导盘重启消失引导解决办法
- 怎么设计出来的网站才更好看
- java 字节码操作图和JAVAssist库图
- 替换空格(C++和Python 实现)
- C语言宿舍管理查询软件