From 7543497f8a8a8ba15edd622061f5d30dfbf6655a Mon Sep 17 00:00:00 2001 From: Jinsuk Kim Date: Thu, 25 Sep 2014 13:52:50 +0900 Subject: [PATCH] CEC: Send keys to active routing path 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 --- .../server/hdmi/DeviceSelectAction.java | 4 ++++ .../server/hdmi/HdmiCecLocalDeviceTv.java | 23 +++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/hdmi/DeviceSelectAction.java b/services/core/java/com/android/server/hdmi/DeviceSelectAction.java index 4d92686e71c64..5a1d896c74a68 100644 --- a/services/core/java/com/android/server/hdmi/DeviceSelectAction.java +++ b/services/core/java/com/android/server/hdmi/DeviceSelectAction.java @@ -168,6 +168,10 @@ final class DeviceSelectAction extends HdmiCecFeatureAction { } private void sendSetStreamPath() { + // Turn the active source invalidated, which remains so till comes from + // the selected device. + tv().getActiveSource().invalidate(); + tv().setActivePath(mTarget.getPhysicalAddress()); sendCommand(HdmiCecMessageBuilder.buildSetStreamPath( getSourceAddress(), mTarget.getPhysicalAddress())); invokeCallback(HdmiControlManager.RESULT_SUCCESS); diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java index bd9f04bf5834e..f6069bb7654b3 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java @@ -350,15 +350,28 @@ 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) { if (callback == null) { return;