diff options
| author | 2021-02-10 14:43:30 +0100 | |
|---|---|---|
| committer | 2021-02-16 13:30:09 +0100 | |
| commit | cd2a2b6d0f1c5d0adc6d5c3497c51f41faf78278 (patch) | |
| tree | f00394a963adf9bff0deab8b89179d91bc3b3f55 | |
| parent | ce7bd34723e9d44cddd85d801e02e93710a24540 (diff) | |
[CEC Configuration] Add adb shell command to get/set setting value
(cherry-pick from master)
Usage:
adb shell cmd hdmi_control cec_setting get <setting name>
adb shell cmd hdmi_control cec_setting set <setting name> <new value>
Test: manually
Bug: 179780870
Change-Id: I5fab223bd16672056cdbe60825ff5ca7fd0c882e
| -rw-r--r-- | services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java b/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java index ee3427f0a383..a1e613635116 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java @@ -70,6 +70,10 @@ final class HdmiControlShellCommand extends ShellCommand { pw.println(" --args <vendor specific arguments>"); pw.println(" [--id <true if vendor command should be sent with vendor id>]"); pw.println(" Send a Vendor Command to the given target device"); + pw.println(" cec_setting get <setting name>"); + pw.println(" Get the current value of a CEC setting"); + pw.println(" cec_setting set <setting name> <value>"); + pw.println(" Set the value of a CEC setting"); } private int handleShellCommand(String cmd) throws RemoteException { @@ -81,6 +85,8 @@ final class HdmiControlShellCommand extends ShellCommand { return oneTouchPlay(pw); case "vendorcommand": return vendorCommand(pw); + case "cec_setting": + return cecSetting(pw); } getErrPrintWriter().println("Unhandled command: " + cmd); @@ -157,4 +163,39 @@ final class HdmiControlShellCommand extends ShellCommand { mBinderService.sendVendorCommand(deviceType, destination, params, hasVendorId); return 0; } + + private int cecSetting(PrintWriter pw) throws RemoteException { + if (getRemainingArgsCount() < 1) { + throw new IllegalArgumentException("Expected at least 1 argument (operation)."); + } + String operation = getNextArgRequired(); + switch (operation) { + case "get": { + String setting = getNextArgRequired(); + try { + String value = mBinderService.getCecSettingStringValue(setting); + pw.println(setting + " = " + value); + } catch (IllegalArgumentException e) { + int intValue = mBinderService.getCecSettingIntValue(setting); + pw.println(setting + " = " + intValue); + } + return 0; + } + case "set": { + String setting = getNextArgRequired(); + String value = getNextArgRequired(); + try { + mBinderService.setCecSettingStringValue(setting, value); + pw.println(setting + " = " + value); + } catch (IllegalArgumentException e) { + int intValue = Integer.parseInt(value); + mBinderService.setCecSettingIntValue(setting, intValue); + pw.println(setting + " = " + intValue); + } + return 0; + } + default: + throw new IllegalArgumentException("Unknown operation: " + operation); + } + } } |