android user版本默认开启adb调试,不弹出对话框

  • 需求:user版本默认开启adb调试,不弹出提示框

1.开启adb debug调试

  • 源码位置:buil/core/main.mk
 ifeq (true,$(strip $(enable_target_debugging))) 
	...
 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
 endif # !enable_target_debugging

2.关闭弹窗提示

  • 源码位置:frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java
   boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);
+        //    boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);
+        boolean connected = false;
         if (!connected) {
             mActivity.finish();
         }
+        try {
+             IBinder b = ServiceManager.getService(USB_SERVICE);
+             IUsbManager service = IUsbManager.Stub.asInterface(b);
+             service.allowUsbDebugging(true, mKey);                 
+             //    service.clearUsbDebuggingKeys();
+        } catch (Exception e) {
+             Log.e(TAG, "Unable to notify Usb service", e);
+        }       
           

3.adb相关属性

ro.secure = 0 开启root权限
ro.adb.secure = 1 1开启adb RSA 指纹认证 ,0关闭
ro.debuggable = 1 1开启adb debug,0关闭

你可能感兴趣的:(adb)