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

Commit 5099c5b9 authored by Michal Olech's avatar Michal Olech Committed by Automerger Merge Worker
Browse files

Merge "[CEC Configuration] Add adb shell command to get/set setting value"...

Merge "[CEC Configuration] Add adb shell command to get/set setting value" into sc-dev am: c8ba0b1a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13582008

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I22206185b5f6e91643f9e5d76c0037d82a60b570
parents 940223d9 c8ba0b1a
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -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);
        }
    }
}