diff options
| -rw-r--r-- | services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java | 17 | ||||
| -rw-r--r-- | services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java | 22 |
2 files changed, 32 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java index c0950bf13a1c..d249d578cf67 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java @@ -654,14 +654,17 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { protected int handleTextViewOn(HdmiCecMessage message) { assertRunOnServiceThread(); - // Note that <Text View On> (and <Image View On>) command won't be handled here in - // most cases. A dedicated microcontroller should be in charge while Android system - // is in sleep mode, and the command need not be passed up to this service. - // The only situation where the command reaches this handler is that sleep mode is - // implemented in such a way that Android system is not really put to standby mode - // but only the display is set to blank. Then the command leads to the effect of + // Note that if the device is in sleep mode, the <Text View On> (and <Image View On>) + // command won't be handled here in most cases. A dedicated microcontroller should be in + // charge while the Android system is in sleep mode, and the command doesn't need to be + // passed up to this service. + // The only situations where the command reaches this handler are + // 1. if sleep mode is implemented in such a way that Android system is not really put to + // standby mode but only the display is set to blank. Then the command leads to // turning on the display by the invocation of PowerManager.wakeUp(). - if (mService.isPowerStandbyOrTransient() && getAutoWakeup()) { + // 2. if the device is in dream mode, not sleep mode. Then this command leads to + // waking up the device from dream mode by the invocation of PowerManager.wakeUp(). + if (getAutoWakeup()) { mService.wakeUp(); } return Constants.HANDLED; diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java index a9812ab9bb03..d104871f488a 100644 --- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java +++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java @@ -89,6 +89,7 @@ public class HdmiCecLocalDeviceTvTest { private ArrayList<HdmiCecLocalDevice> mLocalDevices = new ArrayList<>(); private int mTvPhysicalAddress; private int mTvLogicalAddress; + private boolean mWokenUp; @Mock private AudioManager mAudioManager; @@ -104,6 +105,11 @@ public class HdmiCecLocalDeviceTvTest { new HdmiControlService(InstrumentationRegistry.getTargetContext(), Collections.emptyList()) { @Override + void wakeUp() { + mWokenUp = true; + super.wakeUp(); + } + @Override boolean isControlEnabled() { return true; } @@ -308,6 +314,22 @@ public class HdmiCecLocalDeviceTvTest { } @Test + public void handleTextViewOn_Dreaming() { + mHdmiCecLocalDeviceTv.mService.getHdmiCecConfig().setIntValue( + HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY, + HdmiControlManager.TV_WAKE_ON_ONE_TOUCH_PLAY_ENABLED); + mTestLooper.dispatchAll(); + mPowerManager.setInteractive(true); + mWokenUp = false; + HdmiCecMessage textViewOn = HdmiCecMessageBuilder.buildTextViewOn(ADDR_PLAYBACK_1, + mTvLogicalAddress); + assertThat(mHdmiCecLocalDeviceTv.dispatchMessage(textViewOn)).isEqualTo(Constants.HANDLED); + mTestLooper.dispatchAll(); + assertThat(mPowerManager.isInteractive()).isTrue(); + assertThat(mWokenUp).isTrue(); + } + + @Test public void tvSendStandbyOnSleep_Enabled() { mHdmiCecLocalDeviceTv.mService.getHdmiCecConfig().setIntValue( HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP, |