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 := true
 tags_to_install :=
 ifneq (,$(user_variant))
   # Target is secure in user builds.
-  ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
+  ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
   ADDITIONAL_DEFAULT_PROPERTIES += security.perf_harden=1

   ifeq ($(user_variant),user)
-    ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=1
+    ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=0
   endif

   ifeq ($(user_variant),userdebug)
@@ -251,7 +251,7 @@ ifneq (,$(user_variant))
     tags_to_install += debug
   else
     # 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=1
 LOCAL_CFLAGS += -DALLOW_ADBD_ROOT=1
 endif

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 interface
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
-    persist.sys.usb.config=ptp
+    persist.sys.usb.config=ptp,adb

 PRODUCT_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权限。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐