[RK3399][Android7.1] 调试笔记 --- 默认禁止弹出USB权限对话框

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

现象:
问题一:
每次插上USB打印机会弹出以下权限框
[RK3399][Android7.1] 调试笔记 --- 默认禁止弹出USB权限对话框_第1张图片
问题二:
开机后主动打开打印机demo,默认没有权限操作USB打印机


解决方法:
问题一对应方法:

diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java
index 3eccccd..18130ab 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java
@@ -99,6 +99,11 @@ public class UsbConfirmActivity extends AlertActivity
 
         setupAlert();
 
+        //Kris, 190506, Release usb permission to app.
+        if (mResolveInfo.activityInfo.packageName.substring(0,11).equals("com.xxx")) {
+            onClick(this, AlertDialog.BUTTON_POSITIVE);
+        } 
     }
 

问题二对应方法:

     @Override
diff --git a/services/usb/java/com/android/server/usb/UsbSettingsManager.java b/services/usb/java/com/android/server/usb/UsbSettingsManager.java
index de9ede3..337ffcf 100644
--- a/services/usb/java/com/android/server/usb/UsbSettingsManager.java
+++ b/services/usb/java/com/android/server/usb/UsbSettingsManager.java
@@ -999,6 +999,10 @@ class UsbSettingsManager {
     }
 
     public boolean hasPermission(UsbDevice device) {
+
+//Kris, 190506, Release usb permission to benebot app.
+       return true;
+/*
         synchronized (mLock) {
             int uid = Binder.getCallingUid();
             if (uid == Process.SYSTEM_UID || mDisablePermissionDialogs) {
@@ -1010,6 +1014,7 @@ class UsbSettingsManager {
             }
             return uidList.get(uid);
         }
+*/
     }
 
     public boolean hasPermission(UsbAccessory accessory) {

相关原理可参考 [RK3399][Android7.1] USB设备权限申请控制流程小结


参考:
Android7.1去掉USB权限弹窗
Android绕过usb主机permision确认对话框framework修改方案

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