Merge "Exit dream mode when receiving <Text View On>" into tm-dev

This commit is contained in:
Nathalie Le Clair
2022-03-07 17:10:47 +00:00
committed by Android (Google) Code Review
2 changed files with 32 additions and 7 deletions

View File

@@ -654,14 +654,17 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
protected int handleTextViewOn(HdmiCecMessage message) { protected int handleTextViewOn(HdmiCecMessage message) {
assertRunOnServiceThread(); assertRunOnServiceThread();
// Note that <Text View On> (and <Image View On>) command won't be handled here in // Note that if the device is in sleep mode, the <Text View On> (and <Image View On>)
// most cases. A dedicated microcontroller should be in charge while Android system // command won't be handled here in most cases. A dedicated microcontroller should be in
// is in sleep mode, and the command need not be passed up to this service. // charge while the Android system is in sleep mode, and the command doesn't need to be
// The only situation where the command reaches this handler is that sleep mode is // passed up to this service.
// implemented in such a way that Android system is not really put to standby mode // The only situations where the command reaches this handler are
// but only the display is set to blank. Then the command leads to the effect of // 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(). // 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(); mService.wakeUp();
} }
return Constants.HANDLED; return Constants.HANDLED;

View File

@@ -89,6 +89,7 @@ public class HdmiCecLocalDeviceTvTest {
private ArrayList<HdmiCecLocalDevice> mLocalDevices = new ArrayList<>(); private ArrayList<HdmiCecLocalDevice> mLocalDevices = new ArrayList<>();
private int mTvPhysicalAddress; private int mTvPhysicalAddress;
private int mTvLogicalAddress; private int mTvLogicalAddress;
private boolean mWokenUp;
@Mock @Mock
private AudioManager mAudioManager; private AudioManager mAudioManager;
@@ -104,6 +105,11 @@ public class HdmiCecLocalDeviceTvTest {
new HdmiControlService(InstrumentationRegistry.getTargetContext(), new HdmiControlService(InstrumentationRegistry.getTargetContext(),
Collections.emptyList()) { Collections.emptyList()) {
@Override @Override
void wakeUp() {
mWokenUp = true;
super.wakeUp();
}
@Override
boolean isControlEnabled() { boolean isControlEnabled() {
return true; return true;
} }
@@ -307,6 +313,22 @@ public class HdmiCecLocalDeviceTvTest {
assertThat(mPowerManager.isInteractive()).isFalse(); assertThat(mPowerManager.isInteractive()).isFalse();
} }
@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 @Test
public void tvSendStandbyOnSleep_Enabled() { public void tvSendStandbyOnSleep_Enabled() {
mHdmiCecLocalDeviceTv.mService.getHdmiCecConfig().setIntValue( mHdmiCecLocalDeviceTv.mService.getHdmiCecConfig().setIntValue(