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關閉
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章