Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b5ee823 authored by Jim Kaye's avatar Jim Kaye
Browse files

Do not declare USB support in the Emulator

Some Framework code assumes USB, but the Emulator does not
support USB connections. To work around this, the Emulator
includes a trivial UsbManager and indicates
'android.hardware.usb.accessory' support.

This situation is inconsistent and causes problems, including
CTS and CTS-Verifier failures.

This change removes the indication of
'android.hardware.usb.accessory' and corrects a Framework
NPE if USB support is queried relative to a null device.

BUG: 28088069
     b.android.com/234319

Change-Id: I9d35b6bb7788db08f8121755300384db9eb8baf9
(cherry picked from commit 0f7ca97a57200eb1e2f3fb0081722f5775a6a14b)
parent ae43e073
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -314,10 +314,13 @@ public class UsbManager {
     * @return HashMap containing all connected USB devices.
     */
    public HashMap<String,UsbDevice> getDeviceList() {
        HashMap<String,UsbDevice> result = new HashMap<String,UsbDevice>();
        if (mService == null) {
            return result;
        }
        Bundle bundle = new Bundle();
        try {
            mService.getDeviceList(bundle);
            HashMap<String,UsbDevice> result = new HashMap<String,UsbDevice>();
            for (String name : bundle.keySet()) {
                result.put(name, (UsbDevice)bundle.get(name));
            }
@@ -359,6 +362,9 @@ public class UsbManager {
     * @return list of USB accessories, or null if none are attached.
     */
    public UsbAccessory[] getAccessoryList() {
        if (mService == null) {
            return null;
        }
        try {
            UsbAccessory accessory = mService.getCurrentAccessory();
            if (accessory == null) {
@@ -395,6 +401,9 @@ public class UsbManager {
     * @return true if caller has permission
     */
    public boolean hasPermission(UsbDevice device) {
        if (mService == null) {
            return false;
        }
        try {
            return mService.hasDevicePermission(device);
        } catch (RemoteException e) {
@@ -412,6 +421,9 @@ public class UsbManager {
     * @return true if caller has permission
     */
    public boolean hasPermission(UsbAccessory accessory) {
        if (mService == null) {
            return false;
        }
        try {
            return mService.hasAccessoryPermission(accessory);
        } catch (RemoteException e) {
@@ -529,6 +541,9 @@ public class UsbManager {
     * {@hide}
     */
    public boolean isFunctionEnabled(String function) {
        if (mService == null) {
            return false;
        }
        try {
            return mService.isFunctionEnabled(function);
        } catch (RemoteException e) {
@@ -586,6 +601,9 @@ public class UsbManager {
     * @hide
     */
    public UsbPort[] getPorts() {
        if (mService == null) {
            return null;
        }
        try {
            return mService.getPorts();
        } catch (RemoteException e) {