Android12 user版本默认开启adb调试

做无屏幕设备时,需要设备投屏做调试,这个时候在user版本情况下,插入电脑能够默认开启adb调试模式,不然手动无法操作,不能看,也没有方向按键之类。这个问题怎样解决呢

一问题描述:

user版本下,默认开启adb调试模式,方便客户直接投屏

二方案:

python 复制代码
Author: admin 
Date:   Wed Aug 27 09:56:31 2025 +0800

    user版本,默认开启adb调试
    
    Change-Id: I11a11e75c919ff1ea4f57a36497492b3992264f8

diff --git a/core/main.mk b/core/main.mk
index 839dc93bf..83869e7a6 100755
--- a/core/main.mk
+++ b/core/main.mk
@@ -377,11 +377,11 @@ enable_target_debugging := true
 tags_to_install :=
 ifneq (,$(user_variant))
   # Target is secure in user builds.
-  ADDITIONAL_SYSTEM_PROPERTIES += ro.secure=1
+  ADDITIONAL_SYSTEM_PROPERTIES += ro.secure=0
   ADDITIONAL_SYSTEM_PROPERTIES += security.perf_harden=1
 
   ifeq ($(user_variant),user)
-    ADDITIONAL_SYSTEM_PROPERTIES += ro.adb.secure=1
+    ADDITIONAL_SYSTEM_PROPERTIES += ro.adb.secure=0
   endif
 
   ifeq ($(user_variant),userdebug)
diff --git a/tools/post_process_props.py b/tools/post_process_props.py
index efbf614fd..470c7d919 100755
--- a/tools/post_process_props.py
+++ b/tools/post_process_props.py
@@ -30,14 +30,14 @@ PROP_VALUE_MAX = 91
diff --git a/tools/post_process_props.py b/tools/post_process_props.py
index efbf614fd..470c7d919 100755
--- a/tools/post_process_props.py
+++ b/tools/post_process_props.py
@@ -30,14 +30,14 @@ PROP_VALUE_MAX = 91
 def mangle_build_prop(prop_list):
   # If ro.debuggable is 1, then enable adb on USB by default
   # (this is for userdebug builds)
-  if prop_list.get_value("ro.debuggable") == "1":
-    val = prop_list.get_value("persist.sys.usb.config")
-    if "adb" not in val:
-      if val == "":
-        val = "adb"
-      else:
-        val = val + ",adb"
-      prop_list.put("persist.sys.usb.config", val)
+  #if prop_list.get_value("ro.debuggable") == "1":
+  val = prop_list.get_value("persist.sys.usb.config")
+  if "adb" not in val:
+    if val == "":
+      val = "adb"
+    else:
+      val = val + ",adb"
+    prop_list.put("persist.sys.usb.config", val)
   # UsbDeviceManager expects a value here.  If it doesn't get it, it will
   # default to "adb". That might not the right policy there, but it's better
   # to be explicit.

测试在A10 A12测试通过~