USB: Add support for disabling USB permission dialogs.
Setting scom.android.internal.R.bool.config_disableUsbPermissionDialogs to true will disable all USB permission dialogs, allowing apps access to USB devices and accessories by default. For prototyping purposes only. This should not be used in real devices. Bug: 13437578 Change-Id: Ie7bf83882943930b15e5f1edb3044a4a52034273
This commit is contained in:
@@ -1212,6 +1212,10 @@
|
||||
<!-- Whether UI for multi user should be shown -->
|
||||
<bool name="config_enableMultiUserUI">false</bool>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
<!-- Minimum span needed to begin a touch scaling gesture.
|
||||
If the span is equal to or greater than this size, a scaling gesture
|
||||
will begin, where supported. (See android.view.ScaleGestureDetector)
|
||||
|
||||
@@ -290,6 +290,7 @@
|
||||
<java-symbol type="bool" name="config_forceDefaultOrientation" />
|
||||
<java-symbol type="bool" name="config_wifi_batched_scan_supported" />
|
||||
<java-symbol type="bool" name="config_enableMultiUserUI"/>
|
||||
<java-symbol type="bool" name="config_disableUsbPermissionDialogs"/>
|
||||
|
||||
<java-symbol type="integer" name="config_cursorWindowSize" />
|
||||
<java-symbol type="integer" name="config_extraFreeKbytesAdjust" />
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.hardware.usb.UsbAccessory;
|
||||
import android.hardware.usb.UsbDevice;
|
||||
@@ -73,6 +74,7 @@ class UsbSettingsManager {
|
||||
|
||||
private final UserHandle mUser;
|
||||
private final AtomicFile mSettingsFile;
|
||||
private final boolean mDisablePermissionDialogs;
|
||||
|
||||
private final Context mContext;
|
||||
private final Context mUserContext;
|
||||
@@ -510,6 +512,9 @@ class UsbSettingsManager {
|
||||
Environment.getUserSystemDirectory(user.getIdentifier()),
|
||||
"usb_device_manager.xml"));
|
||||
|
||||
mDisablePermissionDialogs = context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_disableUsbPermissionDialogs);
|
||||
|
||||
synchronized (mLock) {
|
||||
if (UserHandle.OWNER.equals(user)) {
|
||||
upgradeSingleUserLocked();
|
||||
@@ -815,6 +820,14 @@ class UsbSettingsManager {
|
||||
(rInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||
defaultRI = rInfo;
|
||||
}
|
||||
|
||||
if (mDisablePermissionDialogs) {
|
||||
// bypass dialog and launch the only matching activity
|
||||
rInfo = matches.get(0);
|
||||
if (rInfo.activityInfo != null) {
|
||||
defaultPackage = rInfo.activityInfo.packageName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultRI == null && defaultPackage != null) {
|
||||
@@ -970,7 +983,7 @@ class UsbSettingsManager {
|
||||
public boolean hasPermission(UsbDevice device) {
|
||||
synchronized (mLock) {
|
||||
int uid = Binder.getCallingUid();
|
||||
if (uid == Process.SYSTEM_UID) {
|
||||
if (uid == Process.SYSTEM_UID || mDisablePermissionDialogs) {
|
||||
return true;
|
||||
}
|
||||
SparseBooleanArray uidList = mDevicePermissionMap.get(device.getDeviceName());
|
||||
@@ -984,7 +997,7 @@ class UsbSettingsManager {
|
||||
public boolean hasPermission(UsbAccessory accessory) {
|
||||
synchronized (mLock) {
|
||||
int uid = Binder.getCallingUid();
|
||||
if (uid == Process.SYSTEM_UID) {
|
||||
if (uid == Process.SYSTEM_UID || mDisablePermissionDialogs) {
|
||||
return true;
|
||||
}
|
||||
SparseBooleanArray uidList = mAccessoryPermissionMap.get(accessory);
|
||||
|
||||
Reference in New Issue
Block a user