From 02920a08e129eb58b6c2e35ccda6183ab6503a98 Mon Sep 17 00:00:00 2001 From: Donghyun Cho Date: Tue, 11 Oct 2016 17:17:34 +0900 Subject: [PATCH] CEC: Check standby action availability before request for sleep mode When the playback device is asked to go to Standby state with message, it needs to check whether it can accept the request or not. This check should be done before asking the system for sleep mode. Additionally, this change will fix the behavior after screen timeout. After the timeout, playback device may go into sleep mode, but canGoToStandby() check will prevent the device from tracking the right current power status value. So need to set the status properly, and keep HdmiCecLocalDevices enabled for accepting future CEC commands. Bug: 30182748 Test: Check fugu screen after turning off/on Samsung TV and Archer. Also tested the case of screen timeout. Change-Id: Idbcd7abd5d4e22942845760f77f7f7e622b987c0 --- .../java/com/android/server/hdmi/HdmiControlService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java index 5dc9d02a71c5d..72ee218fba2c8 100644 --- a/services/core/java/com/android/server/hdmi/HdmiControlService.java +++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java @@ -2011,6 +2011,9 @@ public final class HdmiControlService extends SystemService { @ServiceThreadOnly void standby() { assertRunOnServiceThread(); + if (!canGoToStandby()) { + return; + } mStandbyMessageReceived = true; mPowerManager.goToSleep(SystemClock.uptimeMillis(), PowerManager.GO_TO_SLEEP_REASON_HDMI, 0); // PowerManger will send the broadcast Intent.ACTION_SCREEN_OFF and after this gets @@ -2038,10 +2041,13 @@ public final class HdmiControlService extends SystemService { @ServiceThreadOnly private void onStandby(final int standbyAction) { assertRunOnServiceThread(); - if (!canGoToStandby()) return; mPowerStatus = HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY; invokeVendorCommandListenersOnControlStateChanged(false, HdmiControlManager.CONTROL_STATE_CHANGED_REASON_STANDBY); + if (!canGoToStandby()) { + mPowerStatus = HdmiControlManager.POWER_STATUS_STANDBY; + return; + } final List devices = getAllLocalDevices(); disableDevices(new PendingActionClearedCallback() {