From 4657dccc789d5117b8d108beab04c0d506837d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Col=C8=9Ba?= Date: Fri, 27 Aug 2021 13:03:33 +0000 Subject: [PATCH] HDMICEC: Create deviceselect shell command Create deviceSelect method in HdmiControlShellCommand. The command's argument is representing the id of the device to be selected. Bug: 196934198 Test: make Change-Id: Ic3a92f15897898f3af30a452fc922a21a5cc3337 --- .../server/hdmi/HdmiControlShellCommand.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java b/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java index e52e32a7b745c..a9b52140a6db2 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java @@ -92,6 +92,9 @@ final class HdmiControlShellCommand extends ShellCommand { pw.println(" Sets the System Audio Mode feature on or off on TV devices"); pw.println(" setarc [on|off]"); pw.println(" Sets the ARC feature on or off on TV devices"); + pw.println(" deviceselect "); + pw.println(" Switch to device with given id"); + pw.println(" The device's id is represented by its logical address."); } private int handleShellCommand(String cmd) throws RemoteException { @@ -110,12 +113,30 @@ final class HdmiControlShellCommand extends ShellCommand { return setSystemAudioMode(pw); case "setarc": return setArcMode(pw); + case "deviceselect": + return deviceSelect(pw); } getErrPrintWriter().println("Unhandled command: " + cmd); return 1; } + private int deviceSelect(PrintWriter pw) throws RemoteException { + if (getRemainingArgsCount() != 1) { + throw new IllegalArgumentException("Expected exactly 1 argument."); + } + int deviceId = Integer.parseInt(getNextArg()); + + pw.print("Sending Device Select..."); + mBinderService.deviceSelect(deviceId, mHdmiControlCallback); + + if (!receiveCallback("Device Select")) { + return 1; + } + + return mCecResult.get() == HdmiControlManager.RESULT_SUCCESS ? 0 : 1; + } + private int oneTouchPlay(PrintWriter pw) throws RemoteException { pw.print("Sending One Touch Play..."); mBinderService.oneTouchPlay(mHdmiControlCallback);