Merge changes from topic "asynchronous_resetUsbPort" into tm-dev am: 901ab79568
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17526306 Change-Id: I9c840ba9f01aada4650f4eec33b5cc93793598a0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -26,6 +26,8 @@ import android.os.Looper;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class UsbCommand extends Svc.Command {
|
public class UsbCommand extends Svc.Command {
|
||||||
@@ -81,6 +83,13 @@ public class UsbCommand extends Svc.Command {
|
|||||||
IUsbManager usbMgr = IUsbManager.Stub.asInterface(ServiceManager.getService(
|
IUsbManager usbMgr = IUsbManager.Stub.asInterface(ServiceManager.getService(
|
||||||
Context.USB_SERVICE));
|
Context.USB_SERVICE));
|
||||||
|
|
||||||
|
Executor executor = context.getMainExecutor();
|
||||||
|
Consumer<Integer> consumer = new Consumer<Integer>(){
|
||||||
|
public void accept(Integer status){
|
||||||
|
System.out.println("Consumer status: " + status);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
if ("setFunctions".equals(args[1])) {
|
if ("setFunctions".equals(args[1])) {
|
||||||
try {
|
try {
|
||||||
usbMgr.setCurrentFunctions(UsbManager.usbFunctionsFromString(
|
usbMgr.setCurrentFunctions(UsbManager.usbFunctionsFromString(
|
||||||
@@ -179,7 +188,7 @@ public class UsbCommand extends Svc.Command {
|
|||||||
if (port != null && portStatus.isConnected()) {
|
if (port != null && portStatus.isConnected()) {
|
||||||
System.err.println(
|
System.err.println(
|
||||||
"Reset the USB port: port" + portNum);
|
"Reset the USB port: port" + portNum);
|
||||||
port.resetUsbPort();
|
port.resetUsbPort(executor, consumer);
|
||||||
} else {
|
} else {
|
||||||
System.err.println(
|
System.err.println(
|
||||||
"There is no available reset USB port");
|
"There is no available reset USB port");
|
||||||
|
|||||||
Reference in New Issue
Block a user