summaryrefslogtreecommitdiff
path: root/cmds/svc
diff options
context:
space:
mode:
authorJerry Zhang <zhangjerry@google.com>2017-11-30 19:10:55 -0800
committerJerry Zhang <zhangjerry@google.com>2018-01-09 15:36:35 -0800
commit30b9adfad1c5055044f0b585782b10f764e0ddf9 (patch)
tree2501d4b4057bb311aede24739f1f5fdf95107cfa /cmds/svc
parent03033385afd531807c5f96a577f76f12a9a08431 (diff)
Add setScreenUnlockedFunctions method to UsbManager
The screen unlocked functions save effort on setting the usb config during each connection. These functions persist between connections and between boots. When the screen is unlocked and these functions are set, the current functions will be automatically set to the screen unlocked functions. Also added svc command for this so it can be used and tested while the UI is worked on. Bug: 62876645 Test: svc usb setScreenUnlockedFunctions mtp Test: Test functions with locking, unlocking, and disconnecting, with no lockscreen, swipe, and pattern Change-Id: Ia05e095917166d25398c4d310b02971e3a1bb12a
Diffstat (limited to 'cmds/svc')
-rw-r--r--cmds/svc/src/com/android/commands/svc/UsbCommand.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/cmds/svc/src/com/android/commands/svc/UsbCommand.java b/cmds/svc/src/com/android/commands/svc/UsbCommand.java
index adbe9d015626..34f6d7de0cc9 100644
--- a/cmds/svc/src/com/android/commands/svc/UsbCommand.java
+++ b/cmds/svc/src/com/android/commands/svc/UsbCommand.java
@@ -18,6 +18,7 @@ package com.android.commands.svc;
import android.content.Context;
import android.hardware.usb.IUsbManager;
+import android.hardware.usb.UsbManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
@@ -38,6 +39,9 @@ public class UsbCommand extends Svc.Command {
+ "\n"
+ "usage: svc usb setFunction [function] [usbDataUnlocked=false]\n"
+ " Set the current usb function and optionally the data lock state.\n\n"
+ + " svc usb setScreenUnlockedFunctions [function]\n"
+ + " Sets the functions which, if the device was charging,"
+ + " become current on screen unlock.\n"
+ " svc usb getFunction\n"
+ " Gets the list of currently enabled functions\n";
}
@@ -62,6 +66,16 @@ public class UsbCommand extends Svc.Command {
} else if ("getFunction".equals(args[1])) {
System.err.println(SystemProperties.get("sys.usb.config"));
return;
+ } else if ("setScreenUnlockedFunctions".equals(args[1])) {
+ IUsbManager usbMgr = IUsbManager.Stub.asInterface(ServiceManager.getService(
+ Context.USB_SERVICE));
+ try {
+ usbMgr.setScreenUnlockedFunctions((args.length >= 3 ? args[2] :
+ UsbManager.USB_FUNCTION_NONE));
+ } catch (RemoteException e) {
+ System.err.println("Error communicating with UsbManager: " + e);
+ }
+ return;
}
}
System.err.println(longHelp());