From 3f313a10cc80fcd3cec9b8eab431a9d8a1756162 Mon Sep 17 00:00:00 2001 From: "Venkatarama NG. Avadhani" Date: Wed, 20 Jan 2021 15:17:53 +0530 Subject: [PATCH] HDMICEC: Add setsystemaudiomode shell command Add command to set the system audio mode ON or OFF. Bug: 177973980 Test: adb shell cmd hdmi_control setsam on Change-Id: I870850724a35315a0057e248182fba5568c79253 --- .../server/hdmi/HdmiControlShellCommand.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java b/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java index ef3c4052971b4..7226cc22f95f0 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java @@ -88,6 +88,8 @@ final class HdmiControlShellCommand extends ShellCommand { pw.println(" Get the current value of a CEC setting"); pw.println(" cec_setting set "); pw.println(" Set the value of a CEC setting"); + pw.println(" setsystemaudiomode, setsam [on|off]"); + pw.println(" Sets the System Audio Mode feature on or off on TV devices"); } private int handleShellCommand(String cmd) throws RemoteException { @@ -101,6 +103,9 @@ final class HdmiControlShellCommand extends ShellCommand { return vendorCommand(pw); case "cec_setting": return cecSetting(pw); + case "setsystemaudiomode": + case "setsam": + return setSystemAudioMode(pw); } getErrPrintWriter().println("Unhandled command: " + cmd); @@ -199,6 +204,31 @@ final class HdmiControlShellCommand extends ShellCommand { } } + private int setSystemAudioMode(PrintWriter pw) throws RemoteException { + if (1 > getRemainingArgsCount()) { + throw new IllegalArgumentException( + "Please indicate if System Audio Mode should be turned \"on\" or \"off\"."); + } + + String arg = getNextArg(); + if (arg.equals("on")) { + pw.println("Setting System Audio Mode on"); + mBinderService.setSystemAudioMode(true, mHdmiControlCallback); + } else if (arg.equals("off")) { + pw.println("Setting System Audio Mode off"); + mBinderService.setSystemAudioMode(false, mHdmiControlCallback); + } else { + throw new IllegalArgumentException( + "Please indicate if System Audio Mode should be turned \"on\" or \"off\"."); + } + + if (!receiveCallback("Set System Audio Mode")) { + return 1; + } + + return mCecResult.get() == HdmiControlManager.RESULT_SUCCESS ? 0 : 1; + } + private boolean receiveCallback(String command) { try { if (!mLatch.await(HdmiConfig.TIMEOUT_MS, TimeUnit.MILLISECONDS)) {