[RK3399][Android7.1] 调试笔记 --- user版本默认使能usb调试不弹框

Platform: RK3399
OS: Android 7.1
Kernel: v4.4.83

现象:

编译为user版本连上adb之后会弹出是否允许usb调试的对话框:

[RK3399][Android7.1] 调试笔记 --- user版本默认使能usb调试不弹框_第1张图片


分析:

点击允许->确定之后会有如下流程:

onClick -> UsbDebuggingActivity.java
  service.allowUsbDebugging ->
    allowUsbDebugging -> UsbService.java
      mDeviceManager.allowUsbDebugging ->
        allowUsbDebugging -> UsbDeviceManager.java  
          mDebuggingManager.allowUsbDebugging ->
			allowUsbDebugging ->  UsbDebuggingManager.java

allowUsbDebugging():

public void allowUsbDebugging(boolean alwaysAllow, String publicKey) {
	Message msg = mHandler.obtainMessage(UsbDebuggingHandler.MESSAGE_ADB_ALLOW);
	msg.arg1 = alwaysAllow ? 1 : 0;
	msg.obj = publicKey;
	mHandler.sendMessage(msg);
}

因此,想要不弹出此对话框默认允许usb调试的话可以仿照上面的方法实现。


解决方法:

kris@eco:~/rk3399/frameworks/base$ g df services/usb/java/com/android/server/usb/UsbDebuggingManager.java
diff --git a/services/usb/java/com/android/server/usb/UsbDebuggingManager.java b/services/usb/java/com/android/server/usb/UsbDebuggingManager.java
index f6d9e9a..b6a3ba2 100644
--- a/services/usb/java/com/android/server/usb/UsbDebuggingManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDebuggingManager.java
@@ -137,7 +137,9 @@ public class UsbDebuggingManager {
                     if (buffer[0] == 'P' && buffer[1] == 'K') {
                         String key = new String(Arrays.copyOfRange(buffer, 2, count));
                         Slog.d(TAG, "Received public key: " + key);
-                        Message msg = mHandler.obtainMessage(UsbDebuggingHandler.MESSAGE_ADB_CONFIRM);
+                        Message msg = mHandler.obtainMessage(UsbDebuggingHandler.MESSAGE_ADB_ALLOW);
+                        mFingerprints = getFingerprints(key);
+                        msg.arg1 = 1;
                         msg.obj = key;
                         mHandler.sendMessage(msg);
                     } else {


参考:

[RK3399][Android7.1] 调试笔记 去掉ADB打开时的确认框

你可能感兴趣的:(RK3399,子类__Android)