OSDN Git Service

Check the validity of the port id of HdmiCecMessage only in TV.
authorYuncheol Heo <ycheo@google.com>
Fri, 25 Jul 2014 05:05:19 +0000 (14:05 +0900)
committerYuncheol Heo <ycheo@google.com>
Fri, 25 Jul 2014 06:08:43 +0000 (15:08 +0900)
In playback device, we don't track the port info, so we can't verify
the validity of the port id part of the physical address parameter of
HdmiCecMessages.

Bug: 16274232
Change-Id: I41f95dba0505d45688e2c9031b78863dc93248ce

services/core/java/com/android/server/hdmi/HdmiCecMessageValidator.java
services/core/java/com/android/server/hdmi/HdmiControlService.java

index c9330c5..d491ac2 100644 (file)
@@ -243,12 +243,17 @@ public final class HdmiCecMessageValidator {
     }
 
     private boolean isValidPhysicalAddress(byte[] params, int offset) {
+        // TODO: Add more logic like validating 1.0.1.0.
+
+        if (!mService.isTvDevice()) {
+            // If the device is not TV, we can't convert path to port-id, so stop here.
+            return true;
+        }
         int path = HdmiUtils.twoBytesToInt(params, offset);
         int portId = mService.pathToPortId(path);
         if (portId == Constants.INVALID_PORT_ID) {
             return false;
         }
-        // TODO: Add more logic like validating 1.0.1.0.
         return true;
     }
 
index 7672232..eafcd7c 100644 (file)
@@ -980,10 +980,6 @@ public final class HdmiControlService extends SystemService {
             }
         }
 
-        private boolean isTvDevice() {
-            return tv() != null;
-        }
-
         @Override
         public void setProhibitMode(final boolean enabled) {
             enforceAccessPermission();
@@ -1304,6 +1300,10 @@ public final class HdmiControlService extends SystemService {
         return (HdmiCecLocalDeviceTv) mCecController.getLocalDevice(HdmiCecDeviceInfo.DEVICE_TV);
     }
 
+    boolean isTvDevice() {
+        return tv() != null;
+    }
+
     private HdmiCecLocalDevicePlayback playback() {
         return (HdmiCecLocalDevicePlayback)
                 mCecController.getLocalDevice(HdmiCecDeviceInfo.DEVICE_PLAYBACK);