OSDN Git Service

CEC: Send keys to active routing path
authorJinsuk Kim <jinsukkim@google.com>
Thu, 25 Sep 2014 04:52:50 +0000 (13:52 +0900)
committerJinsuk Kim <jinsukkim@google.com>
Thu, 25 Sep 2014 05:42:29 +0000 (14:42 +0900)
Previously keys were sent out only when active source was set. They should
be sent when only the active routing path is set in order to be able to
turn the device on using the remote.

Bug: 17647133
Change-Id: I6dc3eaf3a2115430d40c3dd73cb2ba226ba8164b

services/core/java/com/android/server/hdmi/DeviceSelectAction.java
services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java

index 4d92686..5a1d896 100644 (file)
@@ -168,6 +168,10 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
     }
 
     private void sendSetStreamPath() {
+        // Turn the active source invalidated, which remains so till <Active Source> comes from
+        // the selected device.
+        tv().getActiveSource().invalidate();
+        tv().setActivePath(mTarget.getPhysicalAddress());
         sendCommand(HdmiCecMessageBuilder.buildSetStreamPath(
                 getSourceAddress(), mTarget.getPhysicalAddress()));
         invokeCallback(HdmiControlManager.RESULT_SUCCESS);
index bd9f04b..f6069bb 100644 (file)
@@ -350,13 +350,26 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
         if (!action.isEmpty()) {
             action.get(0).processKeyEvent(keyCode, isPressed);
         } else {
-            if (isPressed && getActiveSource().isValid()) {
-                int logicalAddress = getActiveSource().logicalAddress;
-                addAndStartAction(new SendKeyAction(this, logicalAddress, keyCode));
-            } else {
-                Slog.w(TAG, "Discard key event: " + keyCode + " pressed:" + isPressed);
+            if (isPressed) {
+                int logicalAddress = findKeyReceiverAddress();
+                if (logicalAddress != Constants.ADDR_INVALID) {
+                    addAndStartAction(new SendKeyAction(this, logicalAddress, keyCode));
+                    return;
+                }
             }
+            Slog.w(TAG, "Discard key event: " + keyCode + " pressed:" + isPressed);
+        }
+    }
+
+    private int findKeyReceiverAddress() {
+        if (getActiveSource().isValid()) {
+            return getActiveSource().logicalAddress;
+        }
+        HdmiDeviceInfo info = getDeviceInfoByPath(getActivePath());
+        if (info != null) {
+            return info.getLogicalAddress();
         }
+        return Constants.ADDR_INVALID;
     }
 
     private static void invokeCallback(IHdmiControlCallback callback, int result) {