本文主要是介绍user版本如何打开root权限之android8.1,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.修改ro.adb.secure和ro.secure属性
/code/1-android8.1/build/core$ git diff
diff --git a/core/main.mk b/core/main.mk
index 44ad271..947d7a3 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -239,11 +239,11 @@ enable_target_debugging := truetags_to_install :=ifneq (,$(user_variant))# Target is secure in user builds.
- ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0ADDITIONAL_DEFAULT_PROPERTIES += security.perf_harden=1ifeq ($(user_variant),user)
- ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=1
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=0endififeq ($(user_variant),userdebug)
@@ -251,7 +251,7 @@ ifneq (,$(user_variant))tags_to_install += debugelse# Disable debugging in plain user builds.
- enable_target_debugging :=
+ # enable_target_debugging :=endif# Disallow mock locations by default for user builds
2.修改selinux
/code/1-android8.1/system/core/
diff --git a/init/init.cpp b/init/init.cpp
index 6ecd88c..cfeef46 100755
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -588,6 +588,7 @@ static selinux_enforcing_status selinux_status_from_cmdline() {static bool selinux_is_enforcing(void){
+return false;if (ALLOW_PERMISSIVE_SELINUX) {return selinux_status_from_cmdline() == SELINUX_ENFORCING;}
3.修改adb模块的android.mk文件
/code/1-android8.1/system/core$ git diff
diff --git a/adb/Android.mk b/adb/Android.mk
index ece0645..4057e37 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -350,9 +350,9 @@ LOCAL_CFLAGS := \-D_GNU_SOURCE \-Wno-deprecated-declarations \-LOCAL_CFLAGS += -DALLOW_ADBD_NO_AUTH=$(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),1,0)
+LOCAL_CFLAGS += -DALLOW_ADBD_NO_AUTH=$(if $(filter user userdebug eng,$(TARGET_BUILD_VARIANT)),1,0-ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+ifneq (,$(filter user userdebug eng,$(TARGET_BUILD_VARIANT)))LOCAL_CFLAGS += -DALLOW_ADBD_DISABLE_VERITY=1LOCAL_CFLAGS += -DALLOW_ADBD_ROOT=1endif
4.设置默认打开adb端口
/code/1-android8.1/device/sprd/sharkl2$ git diff .
diff --git a/common/DeviceCommon.mk b/common/DeviceCommon.mk
index c94b914..7aee7f8 100755
--- a/common/DeviceCommon.mk
+++ b/common/DeviceCommon.mk
@@ -153,7 +153,7 @@ PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \# Set default USB interfacePRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
- persist.sys.usb.config=ptp
+ persist.sys.usb.config=ptp,adbPRODUCT_PROPERTY_OVERRIDES += \persist.sys.modem.diag=,gser \
说明:
1.步骤4可以设置默认打开adb端口。因为有些非手机项目并没有屏幕,无法通过菜单项去打开usb debug菜单。
2.步骤1中的
# Disable debugging in plain user builds.
- enable_target_debugging :=
+ # enable_target_debugging :=
如果不修改,开机第一遍adb是拥有root权限。但是如果执行完adb unroot,再执行adb root,无法再次获取到root权限。
只能重新启动机器才可以拥有root权限。
这篇关于user版本如何打开root权限之android8.1的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!