Android7.1去掉USB权限弹窗

1.权限弹窗

2.弹窗流程

Android USB通信弹出权限确认框

https://blog.csdn.net/zhongshujunqia/article/details/53212548?locationNum=5&fps=1

3.解决方法

3.1 修改源代码

android 7.0 禁止系统弹出USB 设备权限提示框

https://blog.csdn.net/hefuyou/article/details/81393845

Android绕过usb主机permision确认对话框framework修改方案

https://blog.csdn.net/xzx208/article/details/79670442

3.2 修改xml文件

frameworks\base\services\usb\java\com\android\server\usb\UsbSettingsManager.java

mDisablePermissionDialogs = context.getResources().getBoolean(

                com.android.internal.R.bool.config_disableUsbPermissionDialogs);

 

frameworks/base/core/res/res/values/config.xml

    <!-- If true, then we do not ask user for permission for apps to connect to USB devices.

         Do not set this to true for production devices. Doing so will cause you to fail CTS. -->

<bool name="config_disableUsbPermissionDialogs">false</bool>

这里我把false改为true,这里可以看到如果改为true,就通不过CTS测试

3.3 在AndroidManifest.xml里加上android:sharedUserId="android.uid.system",但是apk需打系统签名

猜你喜欢

转载自blog.csdn.net/LoongEmbedded/article/details/82384239