diff --git a/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java b/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java index bccb158d8e95c..ee3427f0a383b 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java @@ -65,6 +65,11 @@ final class HdmiControlShellCommand extends ShellCommand { pw.println(" Print this help text."); pw.println(" onetouchplay, otp"); pw.println(" Send the \"One Touch Play\" feature from a source to the TV"); + pw.println(" vendorcommand --device_type "); + pw.println(" --destination "); + pw.println(" --args "); + pw.println(" [--id ]"); + pw.println(" Send a Vendor Command to the given target device"); } private int handleShellCommand(String cmd) throws RemoteException { @@ -74,6 +79,8 @@ final class HdmiControlShellCommand extends ShellCommand { case "otp": case "onetouchplay": return oneTouchPlay(pw); + case "vendorcommand": + return vendorCommand(pw); } getErrPrintWriter().println("Unhandled command: " + cmd); @@ -104,4 +111,50 @@ final class HdmiControlShellCommand extends ShellCommand { } return cecResult.get() == HdmiControlManager.RESULT_SUCCESS ? 0 : 1; } + + private int vendorCommand(PrintWriter pw) throws RemoteException { + if (6 > getRemainingArgsCount()) { + throw new IllegalArgumentException("Expected 3 arguments."); + } + + int deviceType = -1; + int destination = -1; + String parameters = ""; + boolean hasVendorId = false; + + String arg = getNextOption(); + while (arg != null) { + switch (arg) { + case "-t": + case "--device_type": + deviceType = Integer.parseInt(getNextArgRequired()); + break; + case "-d": + case "--destination": + destination = Integer.parseInt(getNextArgRequired()); + break; + case "-a": + case "--args": + parameters = getNextArgRequired(); + break; + case "-i": + case "--id": + hasVendorId = Boolean.parseBoolean(getNextArgRequired()); + break; + default: + throw new IllegalArgumentException("Unknown argument: " + arg); + } + arg = getNextArg(); + } + + String[] parts = parameters.split(":"); + byte[] params = new byte[parts.length]; + for (int i = 0; i < params.length; i++) { + params[i] = (byte) Integer.parseInt(parts[i], 16); + } + + pw.println("Sending "); + mBinderService.sendVendorCommand(deviceType, destination, params, hasVendorId); + return 0; + } }