Loading cmds/svc/src/com/android/commands/svc/UsbCommand.java +24 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,11 @@ public class UsbCommand extends Svc.Command { + " svc usb getGadgetHalVersion\n" + " Gets current Gadget Hal Version\n" + " possible values of Hal version are any of 'unknown', 'V1_0', 'V1_1',\n" + " 'V1_2'\n"; + " 'V1_2'\n" + " svc usb getUsbHalVersion\n" + " Gets current USB Hal Version\n" + " possible values of Hal version are any of 'unknown', 'V1_0', 'V1_1',\n" + " 'V1_2', 'V1_3'\n"; } @Override Loading Loading @@ -111,6 +115,25 @@ public class UsbCommand extends Svc.Command { System.err.println("Error communicating with UsbManager: " + e); } return; } else if ("getUsbHalVersion".equals(args[1])) { try { int version = usbMgr.getUsbHalVersion(); if (version == 13) { System.err.println("V1_3"); } else if (version == 12) { System.err.println("V1_2"); } else if (version == 11) { System.err.println("V1_1"); } else if (version == 10) { System.err.println("V1_0"); } else { System.err.println("unknown"); } } catch (RemoteException e) { System.err.println("Error communicating with UsbManager: " + e); } return; } } System.err.println(longHelp()); Loading core/api/module-lib-current.txt +6 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ package android.hardware.usb { public class UsbManager { method @RequiresPermission(android.Manifest.permission.MANAGE_USB) public int getGadgetHalVersion(); method public int getUsbBandwidth(); method @RequiresPermission(android.Manifest.permission.MANAGE_USB) public int getUsbHalVersion(); field public static final int GADGET_HAL_NOT_SUPPORTED = -1; // 0xffffffff field public static final int GADGET_HAL_V1_0 = 10; // 0xa field public static final int GADGET_HAL_V1_1 = 11; // 0xb Loading @@ -85,6 +86,11 @@ package android.hardware.usb { field public static final int USB_DATA_TRANSFER_RATE_HIGH_SPEED = 480; // 0x1e0 field public static final int USB_DATA_TRANSFER_RATE_LOW_SPEED = 2; // 0x2 field public static final int USB_DATA_TRANSFER_RATE_UNKNOWN = -1; // 0xffffffff field public static final int USB_HAL_NOT_SUPPORTED = -1; // 0xffffffff field public static final int USB_HAL_V1_0 = 10; // 0xa field public static final int USB_HAL_V1_1 = 11; // 0xb field public static final int USB_HAL_V1_2 = 12; // 0xc field public static final int USB_HAL_V1_3 = 13; // 0xd } } Loading core/java/android/hardware/usb/IUsbManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,12 @@ interface IUsbManager /* Resets the USB gadget. */ void resetUsbGadget(); /* Set USB data on or off */ boolean enableUsbDataSignal(boolean enable); /* Gets the USB Hal Version. */ int getUsbHalVersion(); /* Get the functionfs control handle for the given function. Usb * descriptors will already be written, and the handle will be * ready to use. Loading core/java/android/hardware/usb/UsbManager.java +92 −0 Original line number Diff line number Diff line Loading @@ -515,6 +515,46 @@ public class UsbManager { @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_DATA_TRANSFER_RATE_40G = 40 * 1024; /** * The Value for USB hal is not presented. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_HAL_NOT_SUPPORTED = -1; /** * Value for USB Hal Version v1.0. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_HAL_V1_0 = 10; /** * Value for USB Hal Version v1.1. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_HAL_V1_1 = 11; /** * Value for USB Hal Version v1.2. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_HAL_V1_2 = 12; /** * Value for USB Hal Version v1.3. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_HAL_V1_3 = 13; /** * Code for the charging usb function. Passed into {@link #setCurrentFunctions(long)} * {@hide} Loading Loading @@ -617,6 +657,16 @@ public class UsbManager { }) public @interface UsbGadgetHalVersion {} /** @hide */ @IntDef(prefix = { "USB_HAL_" }, value = { USB_HAL_NOT_SUPPORTED, USB_HAL_V1_0, USB_HAL_V1_1, USB_HAL_V1_2, USB_HAL_V1_3, }) public @interface UsbHalVersion {} private final Context mContext; private final IUsbManager mService; Loading Loading @@ -1075,6 +1125,26 @@ public class UsbManager { } } /** * Get the Current USB Hal Version. * <p> * This function returns the current USB Hal Version. * </p> * * @return a integer {@code USB_HAL_*} represent hal version. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) @RequiresPermission(Manifest.permission.MANAGE_USB) public @UsbHalVersion int getUsbHalVersion() { try { return mService.getUsbHalVersion(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Resets the USB Gadget. * <p> Loading @@ -1094,6 +1164,28 @@ public class UsbManager { } } /** * Enable/Disable the USB data signaling. * <p> * Enables/Disables USB data path in all the USB ports. * It will force to stop or restore USB data signaling. * </p> * * @param enable enable or disable USB data signaling * @return true enable or disable USB data successfully * false if something wrong * * @hide */ @RequiresPermission(Manifest.permission.MANAGE_USB) public boolean enableUsbDataSignal(boolean enable) { try { return mService.enableUsbDataSignal(enable); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns a list of physical USB ports on the device. * <p> Loading services/usb/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ java_library_static { "android.hardware.usb-V1.0-java", "android.hardware.usb-V1.1-java", "android.hardware.usb-V1.2-java", "android.hardware.usb-V1.3-java", "android.hardware.usb.gadget-V1.0-java", "android.hardware.usb.gadget-V1.1-java", "android.hardware.usb.gadget-V1.2-java", Loading Loading
cmds/svc/src/com/android/commands/svc/UsbCommand.java +24 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,11 @@ public class UsbCommand extends Svc.Command { + " svc usb getGadgetHalVersion\n" + " Gets current Gadget Hal Version\n" + " possible values of Hal version are any of 'unknown', 'V1_0', 'V1_1',\n" + " 'V1_2'\n"; + " 'V1_2'\n" + " svc usb getUsbHalVersion\n" + " Gets current USB Hal Version\n" + " possible values of Hal version are any of 'unknown', 'V1_0', 'V1_1',\n" + " 'V1_2', 'V1_3'\n"; } @Override Loading Loading @@ -111,6 +115,25 @@ public class UsbCommand extends Svc.Command { System.err.println("Error communicating with UsbManager: " + e); } return; } else if ("getUsbHalVersion".equals(args[1])) { try { int version = usbMgr.getUsbHalVersion(); if (version == 13) { System.err.println("V1_3"); } else if (version == 12) { System.err.println("V1_2"); } else if (version == 11) { System.err.println("V1_1"); } else if (version == 10) { System.err.println("V1_0"); } else { System.err.println("unknown"); } } catch (RemoteException e) { System.err.println("Error communicating with UsbManager: " + e); } return; } } System.err.println(longHelp()); Loading
core/api/module-lib-current.txt +6 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ package android.hardware.usb { public class UsbManager { method @RequiresPermission(android.Manifest.permission.MANAGE_USB) public int getGadgetHalVersion(); method public int getUsbBandwidth(); method @RequiresPermission(android.Manifest.permission.MANAGE_USB) public int getUsbHalVersion(); field public static final int GADGET_HAL_NOT_SUPPORTED = -1; // 0xffffffff field public static final int GADGET_HAL_V1_0 = 10; // 0xa field public static final int GADGET_HAL_V1_1 = 11; // 0xb Loading @@ -85,6 +86,11 @@ package android.hardware.usb { field public static final int USB_DATA_TRANSFER_RATE_HIGH_SPEED = 480; // 0x1e0 field public static final int USB_DATA_TRANSFER_RATE_LOW_SPEED = 2; // 0x2 field public static final int USB_DATA_TRANSFER_RATE_UNKNOWN = -1; // 0xffffffff field public static final int USB_HAL_NOT_SUPPORTED = -1; // 0xffffffff field public static final int USB_HAL_V1_0 = 10; // 0xa field public static final int USB_HAL_V1_1 = 11; // 0xb field public static final int USB_HAL_V1_2 = 12; // 0xc field public static final int USB_HAL_V1_3 = 13; // 0xd } } Loading
core/java/android/hardware/usb/IUsbManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,12 @@ interface IUsbManager /* Resets the USB gadget. */ void resetUsbGadget(); /* Set USB data on or off */ boolean enableUsbDataSignal(boolean enable); /* Gets the USB Hal Version. */ int getUsbHalVersion(); /* Get the functionfs control handle for the given function. Usb * descriptors will already be written, and the handle will be * ready to use. Loading
core/java/android/hardware/usb/UsbManager.java +92 −0 Original line number Diff line number Diff line Loading @@ -515,6 +515,46 @@ public class UsbManager { @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_DATA_TRANSFER_RATE_40G = 40 * 1024; /** * The Value for USB hal is not presented. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_HAL_NOT_SUPPORTED = -1; /** * Value for USB Hal Version v1.0. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_HAL_V1_0 = 10; /** * Value for USB Hal Version v1.1. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_HAL_V1_1 = 11; /** * Value for USB Hal Version v1.2. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_HAL_V1_2 = 12; /** * Value for USB Hal Version v1.3. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) public static final int USB_HAL_V1_3 = 13; /** * Code for the charging usb function. Passed into {@link #setCurrentFunctions(long)} * {@hide} Loading Loading @@ -617,6 +657,16 @@ public class UsbManager { }) public @interface UsbGadgetHalVersion {} /** @hide */ @IntDef(prefix = { "USB_HAL_" }, value = { USB_HAL_NOT_SUPPORTED, USB_HAL_V1_0, USB_HAL_V1_1, USB_HAL_V1_2, USB_HAL_V1_3, }) public @interface UsbHalVersion {} private final Context mContext; private final IUsbManager mService; Loading Loading @@ -1075,6 +1125,26 @@ public class UsbManager { } } /** * Get the Current USB Hal Version. * <p> * This function returns the current USB Hal Version. * </p> * * @return a integer {@code USB_HAL_*} represent hal version. * * {@hide} */ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) @RequiresPermission(Manifest.permission.MANAGE_USB) public @UsbHalVersion int getUsbHalVersion() { try { return mService.getUsbHalVersion(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Resets the USB Gadget. * <p> Loading @@ -1094,6 +1164,28 @@ public class UsbManager { } } /** * Enable/Disable the USB data signaling. * <p> * Enables/Disables USB data path in all the USB ports. * It will force to stop or restore USB data signaling. * </p> * * @param enable enable or disable USB data signaling * @return true enable or disable USB data successfully * false if something wrong * * @hide */ @RequiresPermission(Manifest.permission.MANAGE_USB) public boolean enableUsbDataSignal(boolean enable) { try { return mService.enableUsbDataSignal(enable); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns a list of physical USB ports on the device. * <p> Loading
services/usb/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ java_library_static { "android.hardware.usb-V1.0-java", "android.hardware.usb-V1.1-java", "android.hardware.usb-V1.2-java", "android.hardware.usb-V1.3-java", "android.hardware.usb.gadget-V1.0-java", "android.hardware.usb.gadget-V1.1-java", "android.hardware.usb.gadget-V1.2-java", Loading