给上层添加SuperSu来获取root权限

该文档在 RK3399 7.1 系统上做说明

1.下载较新版本的 SuperSU_Pro 包,目录包含如下:

给上层添加SuperSu来获取root权限
提取一个 su 文件,一个 Superuser.apkcommon 目录下)
文件
su 根据运行的环境选择
拷贝
su 放置到 RKTools/patch/root/system/xbin/daemonsu
RKTools/patch/root/system/xbin/su 

2. init*.rc 里添加 daemon 服务
注意不能声明在 xbin 目录下
service daemonsu /system/bin/daemonsu --auto-daemon
class main
oneshot
device.mk 完成拷贝
PRODUCT_COPY_FILES += \
RKTools/patch/root/system/xbin/daemonsu:system/bin/daemonsu \
RKTools/patch/root/system/xbin/su:system/xbin/su

3. 添加权限

diff --git a/sepolicy/daemonsu.te b/sepolicy/daemonsu.te
new file mode 100644
index 0000000..0289188
--- /dev/null
+++ b/sepolicy/daemonsu.te
@@ -0,0 +1,11 @@
+type daemonsu, domain;
+type daemonsu_exec, exec_type, file_type;
+ +
init_daemon_domain(daemonsu)
+ +
allow daemonsu rootfs:lnk_file getattr;
+allow daemonsu self:capability dac_override;
+allow daemonsu toolbox_exec:file { execute execute_no_trans getattr open read };
+allow daemonsu shell_exec:file { getattr read };
+allow daemonsu sysfs:file { getattr open write };
+allow daemonsu cache_file:dir { add_name getattr search write };
\ No newline at end of file
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index a33152e..9a46873 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -29,6 +29,7 @@
/system/bin/myscr.sh u:object_r:myscr_exec:s0
/system/bin/daemonssh.sh u:object_r:daemonssh_exec:s0
/system/bin/busybox_ln.sh u:object_r:busybox_ln_exec:s0
+/system/bin/daemonsu u:object_r:daemonsu_exec:s0


4. 预装 APK system/app 目录下
这个步骤可以选择跳过, 因为安装该 APK 后会多出一个操作, 就是当调用 su 申请权限的时候, 该 APK 会自动弹窗用于授权获取 root 权限, 缺省该 APK 则自动给予 root
diff --git a/apps/apps.mk b/apps/apps.mk
index ae40205..4bd3a00 100755
--- a/apps/apps.mk
+++ b/apps/apps.mk
@@ -1,7 +1,8 @@
PRODUCT_PACKAGES += \
- RKUpdateService
+ RKUpdateService \
+ Supersu


5.编译系统后验证( 装 APK 的情况)
adb shell
su

如果机器有如下弹窗则证明成功

给上层添加SuperSu来获取root权限