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

Commit 9d86af25 authored by Ricky Niu's avatar Ricky Niu Committed by Chien Kun Niu
Browse files

Modified the resetUsbPort command to Asynchronous



Because the resetUsbPort API modified to Asynchronous,
related function need to be modified.

Bug: 217369748
Signed-off-by: default avatarRicky Niu <rickyniu@google.com>
Change-Id: Ieef549736532688ff356b4bb8fa790fb10403300
parent 66c77dfd
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;

import java.util.function.Consumer;
import java.util.concurrent.Executor;
import java.util.List;

public class UsbCommand extends Svc.Command {
@@ -81,6 +83,13 @@ public class UsbCommand extends Svc.Command {
            IUsbManager usbMgr = IUsbManager.Stub.asInterface(ServiceManager.getService(
                    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])) {
                try {
                    usbMgr.setCurrentFunctions(UsbManager.usbFunctionsFromString(
@@ -179,7 +188,7 @@ public class UsbCommand extends Svc.Command {
                        if (port != null && portStatus.isConnected()) {
                            System.err.println(
                                    "Reset the USB port: port" + portNum);
                            port.resetUsbPort();
                            port.resetUsbPort(executor, consumer);
                        } else {
                            System.err.println(
                                    "There is no available reset USB port");