From 022652f76d641bc44bc45cace890aed348865f01 Mon Sep 17 00:00:00 2001 From: Avichal Rakesh Date: Thu, 19 Jan 2023 19:15:33 -0800 Subject: [PATCH] Migrate UsbManager to reference AIDL USBGadget interface UsbManager referenced the HIDL Gadget HAL interfaces for populating and documenting its fields. As the HIDL interfaces are now deprecated, this CL changes UsbManager to reference AIDL Gadget HAL interfaces instead. The fields cannot be initialized as `GadgetFunction.XYZ` because of b/243718774. So a javadoc reference has been added instead. Also does some formatting fixes for the lint gods. Test: Manually tested that USB gadgets are configured properly after the change Bug: 218791946 Change-Id: I524bb44768f3ec947487bfe266bc79713e544004 --- Android.bp | 1 + .../java/android/hardware/usb/UsbManager.java | 48 +++++++++++-------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/Android.bp b/Android.bp index ea7ced99e4fde..effd7ce2a63a6 100644 --- a/Android.bp +++ b/Android.bp @@ -235,6 +235,7 @@ java_library { "android.hardware.usb-V1.0-java-constants", "android.hardware.usb-V1.1-java-constants", "android.hardware.usb-V1.2-java-constants", + "android.hardware.usb.gadget-V1-java", "android.hardware.usb.gadget-V1.0-java", "android.hardware.usb.gadget-V1.1-java", "android.hardware.usb.gadget-V1.2-java", diff --git a/core/java/android/hardware/usb/UsbManager.java b/core/java/android/hardware/usb/UsbManager.java index 909d147412cf9..0483b71d55878 100644 --- a/core/java/android/hardware/usb/UsbManager.java +++ b/core/java/android/hardware/usb/UsbManager.java @@ -37,8 +37,8 @@ import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; -import android.hardware.usb.gadget.V1_0.GadgetFunction; -import android.hardware.usb.gadget.V1_2.UsbSpeed; +import android.hardware.usb.gadget.GadgetFunction; +import android.hardware.usb.gadget.UsbSpeed; import android.os.Binder; import android.os.Build; import android.os.Bundle; @@ -54,15 +54,12 @@ import com.android.internal.annotations.GuardedBy; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.StringJoiner; -import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.Executor; -import java.util.function.BiConsumer; -import java.util.function.Consumer; +import java.util.concurrent.atomic.AtomicInteger; /** * This class allows you to access the state of USB and communicate with USB devices. @@ -78,7 +75,7 @@ import java.util.function.Consumer; public class UsbManager { private static final String TAG = "UsbManager"; - /** + /** * Broadcast Action: A sticky broadcast for USB state change events when in device mode. * * This is a sticky broadcast for clients that includes USB connected/disconnected state, @@ -104,7 +101,7 @@ public class UsbManager { * MIDI function is enabled * * If the sticky intent has not been found, that indicates USB is disconnected, - * USB is not configued, MTP function is enabled, and all the other functions are disabled. + * USB is not configured, MTP function is enabled, and all the other functions are disabled. * * @hide */ @@ -124,7 +121,7 @@ public class UsbManager { public static final String ACTION_USB_PORT_CHANGED = "android.hardware.usb.action.USB_PORT_CHANGED"; - /** + /** * Broadcast Action: A broadcast for USB compliance warning changes. * * This intent is sent when a port partner's @@ -137,7 +134,7 @@ public class UsbManager { public static final String ACTION_USB_PORT_COMPLIANCE_CHANGED = "android.hardware.usb.action.USB_PORT_COMPLIANCE_CHANGED"; - /** + /** * Activity intent sent when user attaches a USB device. * * This intent is sent when a USB device is attached to the USB bus when in host mode. @@ -150,7 +147,7 @@ public class UsbManager { public static final String ACTION_USB_DEVICE_ATTACHED = "android.hardware.usb.action.USB_DEVICE_ATTACHED"; - /** + /** * Broadcast Action: A broadcast for USB device detached event. * * This intent is sent when a USB device is detached from the USB bus when in host mode. @@ -163,7 +160,7 @@ public class UsbManager { public static final String ACTION_USB_DEVICE_DETACHED = "android.hardware.usb.action.USB_DEVICE_DETACHED"; - /** + /** * Activity intent sent when user attaches a USB accessory. * *