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

Commit ba5a5356 authored by Howard Yen's avatar Howard Yen Committed by Android (Google) Code Review
Browse files

Merge changes from topic "usb_gadget_reset"

* changes:
  Add svc usb resetUsbGadget method
  Support USB Gadget V1.1 HAL
parents bfbad6d3 5665bacc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3686,6 +3686,7 @@ package android.hardware.usb {
    method @RequiresPermission(android.Manifest.permission.MANAGE_USB) public long getCurrentFunctions();
    method @NonNull @RequiresPermission(android.Manifest.permission.MANAGE_USB) public java.util.List<android.hardware.usb.UsbPort> getPorts();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USB) public void grantPermission(android.hardware.usb.UsbDevice, String);
    method @RequiresPermission(android.Manifest.permission.MANAGE_USB) public void resetUsbGadget();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USB) public void setCurrentFunctions(long);
    field @RequiresPermission(android.Manifest.permission.MANAGE_USB) public static final String ACTION_USB_PORT_CHANGED = "android.hardware.usb.action.USB_PORT_CHANGED";
    field public static final String ACTION_USB_STATE = "android.hardware.usb.action.USB_STATE";
+10 −1
Original line number Diff line number Diff line
@@ -42,7 +42,9 @@ 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\n"
                + "          Gets the list of currently enabled functions\n"
                + "       svc usb resetUsbGadget\n"
                + "          Reset usb gadget\n\n"
                + "possible values of [function] are any of 'mtp', 'ptp', 'rndis', 'midi'\n";
    }

@@ -75,6 +77,13 @@ public class UsbCommand extends Svc.Command {
                    System.err.println("Error communicating with UsbManager: " + e);
                }
                return;
            } else if ("resetUsbGadget".equals(args[1])) {
                try {
                    usbMgr.resetUsbGadget();
                } catch (RemoteException e) {
                    System.err.println("Error communicating with UsbManager: " + e);
                }
                return;
            }
        }
        System.err.println(longHelp());
+3 −0
Original line number Diff line number Diff line
@@ -126,6 +126,9 @@ interface IUsbManager
    /* Gets the current screen unlocked functions. */
    long getScreenUnlockedFunctions();

    /* Resets the USB gadget. */
    void resetUsbGadget();

    /* Get the functionfs control handle for the given function. Usb
     * descriptors will already be written, and the handle will be
     * ready to use.
+19 −0
Original line number Diff line number Diff line
@@ -793,6 +793,25 @@ public class UsbManager {
        }
    }

    /**
     * Resets the USB Gadget.
     * <p>
     * Performs USB data stack reset through USB Gadget HAL.
     * It will force USB data connection reset. The connection will disconnect and reconnect.
     * </p>
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(Manifest.permission.MANAGE_USB)
    public void resetUsbGadget() {
        try {
            mService.resetUsbGadget();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Returns a list of physical USB ports on the device.
     * <p>
+1 −0
Original line number Diff line number Diff line
@@ -19,5 +19,6 @@ java_library_static {
        "android.hardware.usb-V1.1-java",
        "android.hardware.usb-V1.2-java",
        "android.hardware.usb.gadget-V1.0-java",
        "android.hardware.usb.gadget-V1.1-java",
    ],
}
Loading