Merge "Parent: cc2d51fc (Merge "Update language to comply with Android's inclusive language guidance") Author: Paul McLean <pmclean@google.com> AuthorDate: 2020-07-28 15:07:26 +0000 Commit: Glenn Kasten <gkasten@android.com> CommitDate: 2020-08-04 00:06:51 +0000" am: 830c70ad25

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1374724

Change-Id: I32f6e92956fc98e60691483f9a6905bbce25c74e
This commit is contained in:
Treehugger Robot
2020-08-05 16:47:03 +00:00
committed by Automerger Merge Worker
5 changed files with 52 additions and 53 deletions

View File

@@ -1230,7 +1230,7 @@
with the modem or some other restricted hardware, add "/dev/bus/usb/001/" with the modem or some other restricted hardware, add "/dev/bus/usb/001/"
to this list. If this is empty, no parts of the host USB bus will be excluded. to this list. If this is empty, no parts of the host USB bus will be excluded.
--> -->
<string-array name="config_usbHostBlacklist" translatable="false"> <string-array name="config_usbHostDenylist" translatable="false">
</string-array> </string-array>
<!-- List of paths to serial ports that are available to the serial manager. <!-- List of paths to serial ports that are available to the serial manager.

View File

@@ -1919,8 +1919,7 @@
<java-symbol type="bool" name="config_tether_upstream_automatic" /> <java-symbol type="bool" name="config_tether_upstream_automatic" />
<java-symbol type="array" name="config_tether_usb_regexs" /> <java-symbol type="array" name="config_tether_usb_regexs" />
<java-symbol type="array" name="config_tether_wifi_regexs" /> <java-symbol type="array" name="config_tether_wifi_regexs" />
<java-symbol type="array" name="config_tether_wifi_p2p_regexs" /> <java-symbol type="array" name="config_usbHostDenylist" />
<java-symbol type="array" name="config_usbHostBlacklist" />
<java-symbol type="array" name="config_serialPorts" /> <java-symbol type="array" name="config_serialPorts" />
<java-symbol type="array" name="radioAttributes" /> <java-symbol type="array" name="radioAttributes" />
<java-symbol type="array" name="config_oemUsbModeOverride" /> <java-symbol type="array" name="config_oemUsbModeOverride" />

View File

@@ -64,7 +64,7 @@ public final class UsbAlsaManager {
private UsbAlsaDevice mSelectedDevice; private UsbAlsaDevice mSelectedDevice;
// //
// Device Blacklist // Device Denylist
// //
// This exists due to problems with Sony game controllers which present as an audio device // This exists due to problems with Sony game controllers which present as an audio device
// even if no headset is connected and have no way to set the volume on the unit. // even if no headset is connected and have no way to set the volume on the unit.
@@ -73,31 +73,31 @@ public final class UsbAlsaManager {
private static final int USB_PRODUCTID_PS4CONTROLLER_ZCT1 = 0x05C4; private static final int USB_PRODUCTID_PS4CONTROLLER_ZCT1 = 0x05C4;
private static final int USB_PRODUCTID_PS4CONTROLLER_ZCT2 = 0x09CC; private static final int USB_PRODUCTID_PS4CONTROLLER_ZCT2 = 0x09CC;
private static final int USB_BLACKLIST_OUTPUT = 0x0001; private static final int USB_DENYLIST_OUTPUT = 0x0001;
private static final int USB_BLACKLIST_INPUT = 0x0002; private static final int USB_DENYLIST_INPUT = 0x0002;
private static class BlackListEntry { private static class DenyListEntry {
final int mVendorId; final int mVendorId;
final int mProductId; final int mProductId;
final int mFlags; final int mFlags;
BlackListEntry(int vendorId, int productId, int flags) { DenyListEntry(int vendorId, int productId, int flags) {
mVendorId = vendorId; mVendorId = vendorId;
mProductId = productId; mProductId = productId;
mFlags = flags; mFlags = flags;
} }
} }
static final List<BlackListEntry> sDeviceBlacklist = Arrays.asList( static final List<DenyListEntry> sDeviceDenylist = Arrays.asList(
new BlackListEntry(USB_VENDORID_SONY, new DenyListEntry(USB_VENDORID_SONY,
USB_PRODUCTID_PS4CONTROLLER_ZCT1, USB_PRODUCTID_PS4CONTROLLER_ZCT1,
USB_BLACKLIST_OUTPUT), USB_DENYLIST_OUTPUT),
new BlackListEntry(USB_VENDORID_SONY, new DenyListEntry(USB_VENDORID_SONY,
USB_PRODUCTID_PS4CONTROLLER_ZCT2, USB_PRODUCTID_PS4CONTROLLER_ZCT2,
USB_BLACKLIST_OUTPUT)); USB_DENYLIST_OUTPUT));
private static boolean isDeviceBlacklisted(int vendorId, int productId, int flags) { private static boolean isDeviceDenylisted(int vendorId, int productId, int flags) {
for (BlackListEntry entry : sDeviceBlacklist) { for (DenyListEntry entry : sDeviceDenylist) {
if (entry.mVendorId == vendorId && entry.mProductId == productId) { if (entry.mVendorId == vendorId && entry.mProductId == productId) {
// see if the type flag is set // see if the type flag is set
return (entry.mFlags & flags) != 0; return (entry.mFlags & flags) != 0;
@@ -226,11 +226,11 @@ public final class UsbAlsaManager {
// Add it to the devices list // Add it to the devices list
boolean hasInput = parser.hasInput() boolean hasInput = parser.hasInput()
&& !isDeviceBlacklisted(usbDevice.getVendorId(), usbDevice.getProductId(), && !isDeviceDenylisted(usbDevice.getVendorId(), usbDevice.getProductId(),
USB_BLACKLIST_INPUT); USB_DENYLIST_INPUT);
boolean hasOutput = parser.hasOutput() boolean hasOutput = parser.hasOutput()
&& !isDeviceBlacklisted(usbDevice.getVendorId(), usbDevice.getProductId(), && !isDeviceDenylisted(usbDevice.getVendorId(), usbDevice.getProductId(),
USB_BLACKLIST_OUTPUT); USB_DENYLIST_OUTPUT);
if (DEBUG) { if (DEBUG) {
Slog.d(TAG, "hasInput: " + hasInput + " hasOutput:" + hasOutput); Slog.d(TAG, "hasInput: " + hasInput + " hasOutput:" + hasOutput);
} }

View File

@@ -190,22 +190,22 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
private String[] mAccessoryStrings; private String[] mAccessoryStrings;
private final UEventObserver mUEventObserver; private final UEventObserver mUEventObserver;
private static Set<Integer> sBlackListedInterfaces; private static Set<Integer> sDenyInterfaces;
private HashMap<Long, FileDescriptor> mControlFds; private HashMap<Long, FileDescriptor> mControlFds;
static { static {
sBlackListedInterfaces = new HashSet<>(); sDenyInterfaces = new HashSet<>();
sBlackListedInterfaces.add(UsbConstants.USB_CLASS_AUDIO); sDenyInterfaces.add(UsbConstants.USB_CLASS_AUDIO);
sBlackListedInterfaces.add(UsbConstants.USB_CLASS_COMM); sDenyInterfaces.add(UsbConstants.USB_CLASS_COMM);
sBlackListedInterfaces.add(UsbConstants.USB_CLASS_HID); sDenyInterfaces.add(UsbConstants.USB_CLASS_HID);
sBlackListedInterfaces.add(UsbConstants.USB_CLASS_PRINTER); sDenyInterfaces.add(UsbConstants.USB_CLASS_PRINTER);
sBlackListedInterfaces.add(UsbConstants.USB_CLASS_MASS_STORAGE); sDenyInterfaces.add(UsbConstants.USB_CLASS_MASS_STORAGE);
sBlackListedInterfaces.add(UsbConstants.USB_CLASS_HUB); sDenyInterfaces.add(UsbConstants.USB_CLASS_HUB);
sBlackListedInterfaces.add(UsbConstants.USB_CLASS_CDC_DATA); sDenyInterfaces.add(UsbConstants.USB_CLASS_CDC_DATA);
sBlackListedInterfaces.add(UsbConstants.USB_CLASS_CSCID); sDenyInterfaces.add(UsbConstants.USB_CLASS_CSCID);
sBlackListedInterfaces.add(UsbConstants.USB_CLASS_CONTENT_SEC); sDenyInterfaces.add(UsbConstants.USB_CLASS_CONTENT_SEC);
sBlackListedInterfaces.add(UsbConstants.USB_CLASS_VIDEO); sDenyInterfaces.add(UsbConstants.USB_CLASS_VIDEO);
sBlackListedInterfaces.add(UsbConstants.USB_CLASS_WIRELESS_CONTROLLER); sDenyInterfaces.add(UsbConstants.USB_CLASS_WIRELESS_CONTROLLER);
} }
/* /*
@@ -884,7 +884,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
while (interfaceCount >= 0) { while (interfaceCount >= 0) {
UsbInterface intrface = config.getInterface(interfaceCount); UsbInterface intrface = config.getInterface(interfaceCount);
interfaceCount--; interfaceCount--;
if (sBlackListedInterfaces.contains(intrface.getInterfaceClass())) { if (sDenyInterfaces.contains(intrface.getInterfaceClass())) {
mHideUsbNotification = true; mHideUsbNotification = true;
break; break;
} }

View File

@@ -62,7 +62,7 @@ public class UsbHostManager {
private final Context mContext; private final Context mContext;
// USB busses to exclude from USB host support // USB busses to exclude from USB host support
private final String[] mHostBlacklist; private final String[] mHostDenyList;
private final UsbAlsaManager mUsbAlsaManager; private final UsbAlsaManager mUsbAlsaManager;
private final UsbSettingsManager mSettingsManager; private final UsbSettingsManager mSettingsManager;
@@ -235,8 +235,8 @@ public class UsbHostManager {
UsbSettingsManager settingsManager) { UsbSettingsManager settingsManager) {
mContext = context; mContext = context;
mHostBlacklist = context.getResources().getStringArray( mHostDenyList = context.getResources().getStringArray(
com.android.internal.R.array.config_usbHostBlacklist); com.android.internal.R.array.config_usbHostDenylist);
mUsbAlsaManager = alsaManager; mUsbAlsaManager = alsaManager;
mSettingsManager = settingsManager; mSettingsManager = settingsManager;
String deviceConnectionHandler = context.getResources().getString( String deviceConnectionHandler = context.getResources().getString(
@@ -271,10 +271,10 @@ public class UsbHostManager {
} }
} }
private boolean isBlackListed(String deviceAddress) { private boolean isDenyListed(String deviceAddress) {
int count = mHostBlacklist.length; int count = mHostDenyList.length;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
if (deviceAddress.startsWith(mHostBlacklist[i])) { if (deviceAddress.startsWith(mHostDenyList[i])) {
return true; return true;
} }
} }
@@ -282,11 +282,11 @@ public class UsbHostManager {
} }
/* returns true if the USB device should not be accessible by applications */ /* returns true if the USB device should not be accessible by applications */
private boolean isBlackListed(int clazz, int subClass) { private boolean isDenyListed(int clazz, int subClass) {
// blacklist hubs // deny hubs
if (clazz == UsbConstants.USB_CLASS_HUB) return true; if (clazz == UsbConstants.USB_CLASS_HUB) return true;
// blacklist HID boot devices (mouse and keyboard) // deny HID boot devices (mouse and keyboard)
return clazz == UsbConstants.USB_CLASS_HID return clazz == UsbConstants.USB_CLASS_HID
&& subClass == UsbConstants.USB_INTERFACE_SUBCLASS_BOOT; && subClass == UsbConstants.USB_INTERFACE_SUBCLASS_BOOT;
@@ -355,23 +355,23 @@ public class UsbHostManager {
Slog.d(TAG, "usbDeviceAdded(" + deviceAddress + ") - start"); Slog.d(TAG, "usbDeviceAdded(" + deviceAddress + ") - start");
} }
if (isBlackListed(deviceAddress)) { if (isDenyListed(deviceAddress)) {
if (DEBUG) { if (DEBUG) {
Slog.d(TAG, "device address is black listed"); Slog.d(TAG, "device address is Deny listed");
} }
return false; return false;
} }
if (isBlackListed(deviceClass, deviceSubclass)) { if (isDenyListed(deviceClass, deviceSubclass)) {
if (DEBUG) { if (DEBUG) {
Slog.d(TAG, "device class is black listed"); Slog.d(TAG, "device class is deny listed");
} }
return false; return false;
} }
UsbDescriptorParser parser = new UsbDescriptorParser(deviceAddress, descriptors); UsbDescriptorParser parser = new UsbDescriptorParser(deviceAddress, descriptors);
if (deviceClass == UsbConstants.USB_CLASS_PER_INTERFACE if (deviceClass == UsbConstants.USB_CLASS_PER_INTERFACE
&& !checkUsbInterfacesBlackListed(parser)) { && !checkUsbInterfacesDenyListed(parser)) {
return false; return false;
} }
@@ -488,12 +488,12 @@ public class UsbHostManager {
public ParcelFileDescriptor openDevice(String deviceAddress, UsbUserSettingsManager settings, public ParcelFileDescriptor openDevice(String deviceAddress, UsbUserSettingsManager settings,
String packageName, int pid, int uid) { String packageName, int pid, int uid) {
synchronized (mLock) { synchronized (mLock) {
if (isBlackListed(deviceAddress)) { if (isDenyListed(deviceAddress)) {
throw new SecurityException("USB device is on a restricted bus"); throw new SecurityException("USB device is on a restricted bus");
} }
UsbDevice device = mDevices.get(deviceAddress); UsbDevice device = mDevices.get(deviceAddress);
if (device == null) { if (device == null) {
// if it is not in mDevices, it either does not exist or is blacklisted // if it is not in mDevices, it either does not exist or is denylisted
throw new IllegalArgumentException( throw new IllegalArgumentException(
"device " + deviceAddress + " does not exist or is restricted"); "device " + deviceAddress + " does not exist or is restricted");
} }
@@ -551,23 +551,23 @@ public class UsbHostManager {
} }
} }
private boolean checkUsbInterfacesBlackListed(UsbDescriptorParser parser) { private boolean checkUsbInterfacesDenyListed(UsbDescriptorParser parser) {
// Device class needs to be obtained through the device interface. Ignore device only // Device class needs to be obtained through the device interface. Ignore device only
// if ALL interfaces are black-listed. // if ALL interfaces are deny-listed.
boolean shouldIgnoreDevice = false; boolean shouldIgnoreDevice = false;
for (UsbDescriptor descriptor: parser.getDescriptors()) { for (UsbDescriptor descriptor: parser.getDescriptors()) {
if (!(descriptor instanceof UsbInterfaceDescriptor)) { if (!(descriptor instanceof UsbInterfaceDescriptor)) {
continue; continue;
} }
UsbInterfaceDescriptor iface = (UsbInterfaceDescriptor) descriptor; UsbInterfaceDescriptor iface = (UsbInterfaceDescriptor) descriptor;
shouldIgnoreDevice = isBlackListed(iface.getUsbClass(), iface.getUsbSubclass()); shouldIgnoreDevice = isDenyListed(iface.getUsbClass(), iface.getUsbSubclass());
if (!shouldIgnoreDevice) { if (!shouldIgnoreDevice) {
break; break;
} }
} }
if (shouldIgnoreDevice) { if (shouldIgnoreDevice) {
if (DEBUG) { if (DEBUG) {
Slog.d(TAG, "usb interface class is black listed"); Slog.d(TAG, "usb interface class is deny listed");
} }
return false; return false;
} }