Merge "Remove "Blacklist" nomenclature from USB services classes." into rvc-dev-plus-aosp am: 2764ffc44d

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

Change-Id: I54bd912d55e02d4c1affba9cdd3d6bc91d6583f5
This commit is contained in:
TreeHugger Robot
2020-08-04 16:16:01 +00:00
committed by Automerger Merge Worker
5 changed files with 52 additions and 52 deletions

View File

@@ -976,7 +976,7 @@
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.
-->
<string-array name="config_usbHostBlacklist" translatable="false">
<string-array name="config_usbHostDenylist" translatable="false">
</string-array>
<!-- List of paths to serial ports that are available to the serial manager.

View File

@@ -1854,7 +1854,7 @@
<java-symbol type="array" name="config_tether_upstream_types" />
<java-symbol type="array" name="config_tether_usb_regexs" />
<java-symbol type="array" name="config_tether_wifi_regexs" />
<java-symbol type="array" name="config_usbHostBlacklist" />
<java-symbol type="array" name="config_usbHostDenylist" />
<java-symbol type="array" name="config_serialPorts" />
<java-symbol type="array" name="radioAttributes" />
<java-symbol type="array" name="config_oemUsbModeOverride" />

View File

@@ -64,7 +64,7 @@ public final class UsbAlsaManager {
private UsbAlsaDevice mSelectedDevice;
//
// Device Blacklist
// Device Denylist
//
// 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.
@@ -73,31 +73,31 @@ public final class UsbAlsaManager {
private static final int USB_PRODUCTID_PS4CONTROLLER_ZCT1 = 0x05C4;
private static final int USB_PRODUCTID_PS4CONTROLLER_ZCT2 = 0x09CC;
private static final int USB_BLACKLIST_OUTPUT = 0x0001;
private static final int USB_BLACKLIST_INPUT = 0x0002;
private static final int USB_DENYLIST_OUTPUT = 0x0001;
private static final int USB_DENYLIST_INPUT = 0x0002;
private static class BlackListEntry {
private static class DenyListEntry {
final int mVendorId;
final int mProductId;
final int mFlags;
BlackListEntry(int vendorId, int productId, int flags) {
DenyListEntry(int vendorId, int productId, int flags) {
mVendorId = vendorId;
mProductId = productId;
mFlags = flags;
}
}
static final List<BlackListEntry> sDeviceBlacklist = Arrays.asList(
new BlackListEntry(USB_VENDORID_SONY,
static final List<DenyListEntry> sDeviceDenylist = Arrays.asList(
new DenyListEntry(USB_VENDORID_SONY,
USB_PRODUCTID_PS4CONTROLLER_ZCT1,
USB_BLACKLIST_OUTPUT),
new BlackListEntry(USB_VENDORID_SONY,
USB_DENYLIST_OUTPUT),
new DenyListEntry(USB_VENDORID_SONY,
USB_PRODUCTID_PS4CONTROLLER_ZCT2,
USB_BLACKLIST_OUTPUT));
USB_DENYLIST_OUTPUT));
private static boolean isDeviceBlacklisted(int vendorId, int productId, int flags) {
for (BlackListEntry entry : sDeviceBlacklist) {
private static boolean isDeviceDenylisted(int vendorId, int productId, int flags) {
for (DenyListEntry entry : sDeviceDenylist) {
if (entry.mVendorId == vendorId && entry.mProductId == productId) {
// see if the type flag is set
return (entry.mFlags & flags) != 0;
@@ -226,11 +226,11 @@ public final class UsbAlsaManager {
// Add it to the devices list
boolean hasInput = parser.hasInput()
&& !isDeviceBlacklisted(usbDevice.getVendorId(), usbDevice.getProductId(),
USB_BLACKLIST_INPUT);
&& !isDeviceDenylisted(usbDevice.getVendorId(), usbDevice.getProductId(),
USB_DENYLIST_INPUT);
boolean hasOutput = parser.hasOutput()
&& !isDeviceBlacklisted(usbDevice.getVendorId(), usbDevice.getProductId(),
USB_BLACKLIST_OUTPUT);
&& !isDeviceDenylisted(usbDevice.getVendorId(), usbDevice.getProductId(),
USB_DENYLIST_OUTPUT);
if (DEBUG) {
Slog.d(TAG, "hasInput: " + hasInput + " hasOutput:" + hasOutput);
}

View File

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

View File

@@ -62,7 +62,7 @@ public class UsbHostManager {
private final Context mContext;
// USB busses to exclude from USB host support
private final String[] mHostBlacklist;
private final String[] mHostDenyList;
private final UsbAlsaManager mUsbAlsaManager;
private final UsbPermissionManager mPermissionManager;
@@ -235,8 +235,8 @@ public class UsbHostManager {
UsbPermissionManager permissionManager) {
mContext = context;
mHostBlacklist = context.getResources().getStringArray(
com.android.internal.R.array.config_usbHostBlacklist);
mHostDenyList = context.getResources().getStringArray(
com.android.internal.R.array.config_usbHostDenylist);
mUsbAlsaManager = alsaManager;
mPermissionManager = permissionManager;
String deviceConnectionHandler = context.getResources().getString(
@@ -271,10 +271,10 @@ public class UsbHostManager {
}
}
private boolean isBlackListed(String deviceAddress) {
int count = mHostBlacklist.length;
private boolean isDenyListed(String deviceAddress) {
int count = mHostDenyList.length;
for (int i = 0; i < count; i++) {
if (deviceAddress.startsWith(mHostBlacklist[i])) {
if (deviceAddress.startsWith(mHostDenyList[i])) {
return true;
}
}
@@ -282,11 +282,11 @@ public class UsbHostManager {
}
/* returns true if the USB device should not be accessible by applications */
private boolean isBlackListed(int clazz, int subClass) {
// blacklist hubs
private boolean isDenyListed(int clazz, int subClass) {
// deny hubs
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
&& subClass == UsbConstants.USB_INTERFACE_SUBCLASS_BOOT;
@@ -355,23 +355,23 @@ public class UsbHostManager {
Slog.d(TAG, "usbDeviceAdded(" + deviceAddress + ") - start");
}
if (isBlackListed(deviceAddress)) {
if (isDenyListed(deviceAddress)) {
if (DEBUG) {
Slog.d(TAG, "device address is black listed");
Slog.d(TAG, "device address is Deny listed");
}
return false;
}
if (isBlackListed(deviceClass, deviceSubclass)) {
if (isDenyListed(deviceClass, deviceSubclass)) {
if (DEBUG) {
Slog.d(TAG, "device class is black listed");
Slog.d(TAG, "device class is deny listed");
}
return false;
}
UsbDescriptorParser parser = new UsbDescriptorParser(deviceAddress, descriptors);
if (deviceClass == UsbConstants.USB_CLASS_PER_INTERFACE
&& !checkUsbInterfacesBlackListed(parser)) {
&& !checkUsbInterfacesDenyListed(parser)) {
return false;
}
@@ -491,12 +491,12 @@ public class UsbHostManager {
public ParcelFileDescriptor openDevice(String deviceAddress,
UsbUserPermissionManager permissions, String packageName, int pid, int uid) {
synchronized (mLock) {
if (isBlackListed(deviceAddress)) {
if (isDenyListed(deviceAddress)) {
throw new SecurityException("USB device is on a restricted bus");
}
UsbDevice device = mDevices.get(deviceAddress);
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(
"device " + deviceAddress + " does not exist or is restricted");
}
@@ -554,23 +554,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
// if ALL interfaces are black-listed.
// if ALL interfaces are deny-listed.
boolean shouldIgnoreDevice = false;
for (UsbDescriptor descriptor: parser.getDescriptors()) {
if (!(descriptor instanceof UsbInterfaceDescriptor)) {
continue;
}
UsbInterfaceDescriptor iface = (UsbInterfaceDescriptor) descriptor;
shouldIgnoreDevice = isBlackListed(iface.getUsbClass(), iface.getUsbSubclass());
shouldIgnoreDevice = isDenyListed(iface.getUsbClass(), iface.getUsbSubclass());
if (!shouldIgnoreDevice) {
break;
}
}
if (shouldIgnoreDevice) {
if (DEBUG) {
Slog.d(TAG, "usb interface class is black listed");
Slog.d(TAG, "usb interface class is deny listed");
}
return false;
}