diff options
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/hardware/usb/IUsbManager.aidl | 5 | ||||
| -rw-r--r-- | core/java/android/hardware/usb/UsbManager.java | 26 |
2 files changed, 31 insertions, 0 deletions
diff --git a/core/java/android/hardware/usb/IUsbManager.aidl b/core/java/android/hardware/usb/IUsbManager.aidl index 025d46d12567..4e8c45dc2c46 100644 --- a/core/java/android/hardware/usb/IUsbManager.aidl +++ b/core/java/android/hardware/usb/IUsbManager.aidl @@ -96,6 +96,11 @@ interface IUsbManager */ void setCurrentFunction(String function, boolean usbDataUnlocked); + /* Sets the screen unlocked USB function(s), which will be set automatically + * when the screen is unlocked. + */ + void setScreenUnlockedFunctions(String function); + /* Allow USB debugging from the attached host. If alwaysAllow is true, add the * the public key to list of host keys that the user has approved. */ diff --git a/core/java/android/hardware/usb/UsbManager.java b/core/java/android/hardware/usb/UsbManager.java index d73d3d8b04cf..48e8d342db65 100644 --- a/core/java/android/hardware/usb/UsbManager.java +++ b/core/java/android/hardware/usb/UsbManager.java @@ -590,6 +590,32 @@ public class UsbManager { } /** + * Sets the screen unlocked functions, which are persisted and set as the current functions + * whenever the screen is unlocked. + * <p> + * The allowed values are: {@link #USB_FUNCTION_NONE}, + * {@link #USB_FUNCTION_MIDI}, {@link #USB_FUNCTION_MTP}, {@link #USB_FUNCTION_PTP}, + * or {@link #USB_FUNCTION_RNDIS}. + * {@link #USB_FUNCTION_NONE} has the effect of switching off this feature, so functions + * no longer change on screen unlock. + * </p><p> + * Note: When the screen is on, this method will apply given functions as current functions, + * which is asynchronous and may fail silently without applying the requested changes. + * </p> + * + * @param function function to set as default + * + * {@hide} + */ + public void setScreenUnlockedFunctions(String function) { + try { + mService.setScreenUnlockedFunctions(function); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Returns a list of physical USB ports on the device. * <p> * This list is guaranteed to contain all dual-role USB Type C ports but it might |
