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

Commit 062ddc34 authored by raychi's avatar raychi
Browse files

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
parent 88254a2b
Loading
Loading
Loading
Loading
+30 −3
Original line number Diff line number Diff line
@@ -43,9 +43,19 @@ public class UsbCommand extends Svc.Command {
                    + "screen unlock. If function is blank, turn off this feature.\n"
                + "       svc usb getFunctions\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());