From 062ddc34752b71ecb50b97c027c61e98bfd72029 Mon Sep 17 00:00:00 2001 From: raychi Date: Tue, 6 Oct 2020 00:33:05 +0800 Subject: Add methods for Usb Gadget Hal v1.2 1. Add svc usb getUsbSpeed method 2. Add svc usb getCurrentGadgetHalVersion method Bug: 168282708 Test: build pass and get test result Change-Id: Id3480757fd3545b0cce083aaa3cf906e09ae318c --- .../src/com/android/commands/svc/UsbCommand.java | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'cmds/svc') diff --git a/cmds/svc/src/com/android/commands/svc/UsbCommand.java b/cmds/svc/src/com/android/commands/svc/UsbCommand.java index cd751f4e2d20..227b9e24f173 100644 --- a/cmds/svc/src/com/android/commands/svc/UsbCommand.java +++ b/cmds/svc/src/com/android/commands/svc/UsbCommand.java @@ -42,10 +42,20 @@ public class UsbCommand extends Svc.Command { + " Sets the functions which, if the device was charging, become current on" + "screen unlock. If function is blank, turn off this feature.\n" + " svc usb getFunctions\n" - + " Gets the list of currently enabled functions\n" + + " Gets the list of currently enabled functions\n" + + " possible values of [function] are any of 'mtp', 'ptp', 'rndis',\n" + + " 'midi', 'ncm (if supporting gadget hal v1.2)'\n" + " svc usb resetUsbGadget\n" - + " Reset usb gadget\n\n" - + "possible values of [function] are any of 'mtp', 'ptp', 'rndis', 'midi'\n"; + + " Reset usb gadget\n" + + " svc usb getUsbSpeed\n" + + " Gets current USB speed\n" + + " possible values of USB speed are any of 'low speed', 'full speed',\n" + + " 'high speed', 'super speed', 'super speed (10G)',\n" + + " 'super speed (20G)', or higher (future extension)\n" + + " 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"; } @Override @@ -84,6 +94,23 @@ public class UsbCommand extends Svc.Command { System.err.println("Error communicating with UsbManager: " + e); } return; + } else if ("getUsbSpeed".equals(args[1])) { + try { + System.err.println( + UsbManager.usbSpeedToBandwidth(usbMgr.getCurrentUsbSpeed())); + } catch (RemoteException e) { + System.err.println("Error communicating with UsbManager: " + e); + } + return; + } else if ("getGadgetHalVersion".equals(args[1])) { + try { + System.err.println( + UsbManager.usbGadgetHalVersionToString( + usbMgr.getGadgetHalVersion())); + } catch (RemoteException e) { + System.err.println("Error communicating with UsbManager: " + e); + } + return; } } System.err.println(longHelp()); -- cgit v1.2.3-59-g8ed1b