summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJungshik Jang <jayjang@google.com>2014-08-07 05:23:48 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-04 23:56:40 +0000
commit7bbf9e720d12c06c46c468f18848b37d61bcaf28 (patch)
treedcb158b2e06c5388179fb041442cba9ef06031f1
parent985e566ceca9c11d2f740499053f37dfaeb9033d (diff)
parent5f75cbd8593e83eaf17cfac07186a3b6a7b7b1f1 (diff)
downloadframeworks_base-7bbf9e720d12c06c46c468f18848b37d61bcaf28.zip
frameworks_base-7bbf9e720d12c06c46c468f18848b37d61bcaf28.tar.gz
frameworks_base-7bbf9e720d12c06c46c468f18848b37d61bcaf28.tar.bz2
Merge "Use message validator for sending message." into lmp-dev
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiCecMessage.java8
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiControlService.java11
2 files changed, 9 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecMessage.java b/services/core/java/com/android/server/hdmi/HdmiCecMessage.java
index 26071e6..433e93f 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecMessage.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecMessage.java
@@ -28,8 +28,6 @@ import java.util.Arrays;
public final class HdmiCecMessage {
public static final byte[] EMPTY_PARAM = EmptyArray.BYTE;
- private static final int MAX_MESSAGE_PARAM_LENGTH = 14;
-
private final int mSource;
private final int mDestination;
@@ -43,12 +41,6 @@ public final class HdmiCecMessage {
mSource = source;
mDestination = destination;
mOpcode = opcode & 0xFF;
-
- if (params.length > MAX_MESSAGE_PARAM_LENGTH) {
- throw new IllegalArgumentException(
- "Param length should be at most 13 but current param length is "
- + params.length);
- }
mParams = Arrays.copyOf(params, params.length);
}
diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java
index 3017d2d..e8d8192 100644
--- a/services/core/java/com/android/server/hdmi/HdmiControlService.java
+++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java
@@ -517,13 +517,20 @@ public final class HdmiControlService extends SystemService {
@ServiceThreadOnly
void sendCecCommand(HdmiCecMessage command, @Nullable SendMessageCallback callback) {
assertRunOnServiceThread();
- mCecController.sendCommand(command, callback);
+ if (mMessageValidator.isValid(command)) {
+ mCecController.sendCommand(command, callback);
+ } else {
+ Slog.e(TAG, "Invalid message type:" + command);
+ if (callback != null) {
+ callback.onSendCompleted(Constants.SEND_RESULT_FAILURE);
+ }
+ }
}
@ServiceThreadOnly
void sendCecCommand(HdmiCecMessage command) {
assertRunOnServiceThread();
- mCecController.sendCommand(command, null);
+ sendCecCommand(command, null);
}
/**