From 64bafd9108b532102bc13c47966444b073c33faf Mon Sep 17 00:00:00 2001 From: Yuncheol Heo Date: Mon, 11 Aug 2014 11:17:54 +0900 Subject: [PATCH] Make it not to go to sleep when changing TV's input to the others. - Previously, we decided to make it go to sleep when changing TV's input to the others. But, we found that the current molly couldn't wake up by CEC commands actively. So, we'll revert the decision. - In addition, during investigating this issue, we found that currently molly couldn't work with Samsung (SS) TV harmoniously. SS TV will send and when it wakes up. If there is no response, then it will change the input to the internal. This CL handles this issue also. Bug: 16803105 Change-Id: I5179561775b186b486fc3f2a042e759fcb07451b --- .../server/hdmi/HdmiCecLocalDevice.java | 6 ++ .../hdmi/HdmiCecLocalDevicePlayback.java | 69 +++++++++++++++---- 2 files changed, 63 insertions(+), 12 deletions(-) diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java index be4c83434d401..b0c1a8aaf3b60 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java @@ -210,6 +210,8 @@ abstract class HdmiCecLocalDevice { return handleReportPhysicalAddress(message); case Constants.MESSAGE_ROUTING_CHANGE: return handleRoutingChange(message); + case Constants.MESSAGE_ROUTING_INFORMATION: + return handleRoutingInformation(message); case Constants.MESSAGE_INITIATE_ARC: return handleInitiateArc(message); case Constants.MESSAGE_TERMINATE_ARC: @@ -331,6 +333,10 @@ abstract class HdmiCecLocalDevice { return false; } + protected boolean handleRoutingInformation(HdmiCecMessage message) { + return false; + } + protected boolean handleReportPhysicalAddress(HdmiCecMessage message) { return false; } diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java index ae7fd82434185..5a2fa9c7882b6 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java @@ -16,8 +16,8 @@ package com.android.server.hdmi; -import android.hardware.hdmi.HdmiDeviceInfo; import android.hardware.hdmi.HdmiControlManager; +import android.hardware.hdmi.HdmiDeviceInfo; import android.hardware.hdmi.IHdmiControlCallback; import android.os.RemoteException; import android.os.SystemProperties; @@ -137,14 +137,14 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { protected boolean handleActiveSource(HdmiCecMessage message) { assertRunOnServiceThread(); int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams()); + mayResetActiveSource(physicalAddress); + return true; // Broadcast message. + } + + private void mayResetActiveSource(int physicalAddress) { if (physicalAddress != mService.getPhysicalAddress()) { mIsActiveSource = false; - if (mService.isPowerOnOrTransient()) { - mService.nap(); - } - return true; } - return false; } @Override @@ -152,13 +152,58 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { protected boolean handleSetStreamPath(HdmiCecMessage message) { assertRunOnServiceThread(); int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams()); + maySetActiveSource(physicalAddress); + maySendActiveSource(); + wakeUpIfActiveSource(); + return true; // Broadcast message. + } + + // Samsung model, we tested, sends and consecutively, + // Then if there is no response, it will change the input to + // the internal source. To handle this, we'll set ActiveSource aggressively. + @Override + @ServiceThreadOnly + protected boolean handleRoutingChange(HdmiCecMessage message) { + assertRunOnServiceThread(); + int newPath = HdmiUtils.twoBytesToInt(message.getParams(), 2); + maySetActiveSource(newPath); + return true; // Broadcast message. + } + + @Override + @ServiceThreadOnly + protected boolean handleRoutingInformation(HdmiCecMessage message) { + assertRunOnServiceThread(); + int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams()); + maySetActiveSource(physicalAddress); + return true; // Broadcast message. + } + + private void maySetActiveSource(int physicalAddress) { if (physicalAddress == mService.getPhysicalAddress()) { - if (mService.isPowerStandbyOrTransient()) { - mService.wakeUp(); - } - return true; + mIsActiveSource = true; } - return false; + } + + private void wakeUpIfActiveSource() { + if (mIsActiveSource && mService.isPowerStandbyOrTransient()) { + mService.wakeUp(); + } + } + + private void maySendActiveSource() { + if (mIsActiveSource) { + mService.sendCecCommand(HdmiCecMessageBuilder.buildActiveSource( + mAddress, mService.getPhysicalAddress())); + } + } + + @Override + @ServiceThreadOnly + protected boolean handleRequestActiveSource(HdmiCecMessage message) { + assertRunOnServiceThread(); + maySendActiveSource(); + return true; // Broadcast message. } @Override @@ -174,4 +219,4 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice { mIsActiveSource = false; checkIfPendingActionsCleared(); } -} +} \ No newline at end of file