Modified the resetUsbPort command to Asynchronous
Because the resetUsbPort API modified to Asynchronous, related function need to be modified. Bug: 217369748 Signed-off-by: Ricky Niu <rickyniu@google.com> Change-Id: Ieef549736532688ff356b4bb8fa790fb10403300
This commit is contained in:
parent
66c77dfdf9
commit
9d86af2555
@ -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");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user