【Android系统源码修改】 默认开启adb模式

修改如下

build/core/main.mk

 tags_to_install :=
 ifneq (,$(user_variant))
   # Target is secure in user builds.
-  ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
+  ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0

在这里插入图片描述

 ifeq (true,$(strip $(enable_target_debugging)))
   # Target is more debuggable and adbd is on by default
-  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
+  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
   # Include the debugging/testing OTA keys in this build.
   INCLUDE_TEST_OTA_KEYS := true
 else # !enable_target_debugging
   # Target is less debuggable and adbd is off by default
-  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
+  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1 persist.service.adb.enable=1
 endif # !enable_target_debugging

【Android系统源码修改】 默认开启adb模式_第1张图片
external/sepolicy/Android.mk

@@ -112,7 +112,7 @@ $(sepolicy_policy.conf): PRIVATE_MLS_CATS := $(MLS_CATS)
 $(sepolicy_policy.conf) : $(call build_policy, $(sepolicy_build_files))
     @mkdir -p $(dir $@)
     $(hide) m4 -D mls_num_sens=$(PRIVATE_MLS_SENS) -D mls_num_cats=$(PRIVATE_MLS_CATS) \
-        -D target_build_variant=$(TARGET_BUILD_VARIANT) \
+        -D target_build_variant=eng \
         -D force_permissive_to_unconfined=$(FORCE_PERMISSIVE_TO_UNCONFINED) \

【Android系统源码修改】 默认开启adb模式_第2张图片

/system/core/adb/adb.c
@@ -1286,38 +1286,38 @@ static void drop_capabilities_bounding_set_if_needed() {
 }
 static int should_drop_privileges() {
-#ifdef MTK_ALLOW_ADBD_ROOT
+// #ifdef MTK_ALLOW_ADBD_ROOT
+// #endif
+// #ifndef ALLOW_ADBD_ROOT
+    // return 1;
+// #else /* ALLOW_ADBD_ROOT */
+    // int secure = 0;
+    // char value[PROPERTY_VALUE_MAX];
+
+   // /* run adbd in secure mode if ro.secure is set and
+    // ** we are not in the emulator
+    // */
+    // property_get("ro.kernel.qemu", value, "");
+    // if (strcmp(value, "1") != 0) {
+        // property_get("ro.secure", value, "1");
+        // if (strcmp(value, "1") == 0) {
+         ////   don't run as root if ro.secure is set...
+            // secure = 1;
+
+        ////    ... except we allow running as root in userdebug builds if the
+       ////     service.adb.root property has been set by the "adb root" command
+            // property_get("ro.debuggable", value, "");
+            // if (strcmp(value, "1") == 0) {
+                // property_get("service.adb.root", value, "");
+                // if (strcmp(value, "1") == 0) {
+                    // secure = 0;
+                // }
+            // }
+        // }
+    // }
+    // return secure;
+// #endif /* ALLOW_ADBD_ROOT */
 }
 #endif /* !ADB_HOST */

【Android系统源码修改】 默认开启adb模式_第3张图片

你可能感兴趣的:(Android系统源码修改)