12981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos/* 22981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * Copyright (C) 2017 The Android Open Source Project 32981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * 42981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * Licensed under the Apache License, Version 2.0 (the "License"); 52981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * you may not use this file except in compliance with the License. 62981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * You may obtain a copy of the License at 72981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * 82981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * http://www.apache.org/licenses/LICENSE-2.0 92981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * 102981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * Unless required by applicable law or agreed to in writing, software 112981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * distributed under the License is distributed on an "AS IS" BASIS, 122981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * See the License for the specific language governing permissions and 142981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos * limitations under the License. 152981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos */ 162981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 172981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roospackage com.android.systemui.doze; 182981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 192981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static com.android.systemui.doze.DozeMachine.State.DOZE; 202981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static com.android.systemui.doze.DozeMachine.State.DOZE_AOD; 212981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static com.android.systemui.doze.DozeMachine.State.DOZE_AOD_PAUSED; 22a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roosimport static com.android.systemui.doze.DozeMachine.State.DOZE_AOD_PAUSING; 232981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static com.android.systemui.doze.DozeMachine.State.DOZE_PULSE_DONE; 242981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static com.android.systemui.doze.DozeMachine.State.DOZE_PULSING; 252981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static com.android.systemui.doze.DozeMachine.State.DOZE_REQUEST_PULSE; 262981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static com.android.systemui.doze.DozeMachine.State.FINISH; 272981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static com.android.systemui.doze.DozeMachine.State.INITIALIZED; 282981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static com.android.systemui.doze.DozeMachine.State.UNINITIALIZED; 292981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 302981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static org.junit.Assert.assertEquals; 31a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roosimport static org.junit.Assert.assertFalse; 322981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static org.junit.Assert.assertNotEquals; 33c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roosimport static org.junit.Assert.assertThat; 342981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport static org.junit.Assert.assertTrue; 352981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 362981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport android.os.PowerManager; 372981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport android.support.test.filters.SmallTest; 382981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport android.support.test.runner.AndroidJUnit4; 392981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 402981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport com.android.systemui.SysuiTestCase; 412981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport com.android.systemui.utils.hardware.FakeSensorManager; 422981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 432981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport org.junit.Before; 442981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport org.junit.Test; 452981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roosimport org.junit.runner.RunWith; 462981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 472981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos@RunWith(AndroidJUnit4.class) 482981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos@SmallTest 492981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roospublic class DozeScreenBrightnessTest extends SysuiTestCase { 502981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 51a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos static final int DEFAULT_BRIGHTNESS = 10; 52a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos static final int[] SENSOR_TO_BRIGHTNESS = new int[]{-1, 1, 2, 3, 4}; 53a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos static final int[] SENSOR_TO_OPACITY = new int[]{-1, 10, 0, 0, 0}; 54a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 552981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos DozeServiceFake mServiceFake; 562981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos DozeScreenBrightness mScreen; 572981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos FakeSensorManager.FakeGenericSensor mSensor; 582981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos FakeSensorManager mSensorManager; 59c8e29e78863784037670f56e48464924b7f960eaAdrian Roos DozeHostFake mHostFake; 602981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 612981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos @Before 622981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos public void setUp() throws Exception { 632981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mServiceFake = new DozeServiceFake(); 64c8e29e78863784037670f56e48464924b7f960eaAdrian Roos mHostFake = new DozeHostFake(); 652981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mSensorManager = new FakeSensorManager(mContext); 662981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mSensor = mSensorManager.getFakeLightSensor(); 672981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen = new DozeScreenBrightness(mContext, mServiceFake, mSensorManager, 688443dd0e7680e489509e8a9bf0bb5fcefd7a8c3ejackqdyulei mSensor.getSensor(), mHostFake, null /* handler */, 69a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos DEFAULT_BRIGHTNESS, SENSOR_TO_BRIGHTNESS, SENSOR_TO_OPACITY); 702981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos } 712981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 722981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos @Test 732981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos public void testInitialize_setsScreenBrightnessToValidValue() throws Exception { 742981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 752981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 76a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos assertEquals(DEFAULT_BRIGHTNESS, mServiceFake.screenBrightness); 772981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos assertTrue(mServiceFake.screenBrightness <= PowerManager.BRIGHTNESS_ON); 782981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos } 792981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 802981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos @Test 812981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos public void testAod_usesLightSensor() throws Exception { 822981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 832981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE_AOD); 842981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 85a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mSensor.sendSensorEvent(3); 862981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 87a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos assertEquals(3, mServiceFake.screenBrightness); 882981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos } 892981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 902981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos @Test 91a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos public void testPausingAod_doesntPauseLightSensor() throws Exception { 922981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 932981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE_AOD); 942981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 95a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mSensor.sendSensorEvent(1); 962981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 97a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(DOZE_AOD, DOZE_AOD_PAUSING); 98a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(DOZE_AOD_PAUSING, DOZE_AOD_PAUSED); 992981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 100a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mSensor.sendSensorEvent(2); 1012981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 102a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos assertEquals(2, mServiceFake.screenBrightness); 1032981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos } 1042981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 1052981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos @Test 106a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos public void testPausingAod_doesNotResetBrightness() throws Exception { 1072981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 1082981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE_AOD); 1092981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 110a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mSensor.sendSensorEvent(1); 1112981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 112a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(DOZE_AOD, DOZE_AOD_PAUSING); 113a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(DOZE_AOD_PAUSING, DOZE_AOD_PAUSED); 1142981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 115a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos assertEquals(1, mServiceFake.screenBrightness); 1162981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos } 1172981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 1182981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos @Test 1192981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos public void testPulsing_usesLightSensor() throws Exception { 1202981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 1212981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE); 1222981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(DOZE, DOZE_REQUEST_PULSE); 1232981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 124a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mSensor.sendSensorEvent(1); 1252981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 126a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos assertEquals(1, mServiceFake.screenBrightness); 1272981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos } 1282981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 1292981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos @Test 1302981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos public void testDozingAfterPulsing_pausesLightSensor() throws Exception { 1312981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 1322981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE); 1332981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(DOZE, DOZE_REQUEST_PULSE); 1342981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(DOZE_REQUEST_PULSE, DOZE_PULSING); 1352981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(DOZE_PULSING, DOZE_PULSE_DONE); 1362981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(DOZE_PULSE_DONE, DOZE); 1372981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 138a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mSensor.sendSensorEvent(1); 1392981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 140a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos assertEquals(DEFAULT_BRIGHTNESS, mServiceFake.screenBrightness); 1412981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos } 1422981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 1432981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos @Test 1442981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos public void testNullSensor() throws Exception { 1452981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen = new DozeScreenBrightness(mContext, mServiceFake, mSensorManager, 1468443dd0e7680e489509e8a9bf0bb5fcefd7a8c3ejackqdyulei null /* sensor */, mHostFake, null /* handler */, 147a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos DEFAULT_BRIGHTNESS, SENSOR_TO_BRIGHTNESS, SENSOR_TO_OPACITY); 1482981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 1492981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 1502981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE_AOD); 151a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(DOZE_AOD, DOZE_AOD_PAUSING); 152a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(DOZE_AOD_PAUSING, DOZE_AOD_PAUSED); 1532981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos } 1542981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 1552981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos @Test 1562981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos public void testNoBrightnessDeliveredAfterFinish() throws Exception { 1572981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 1582981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE_AOD); 1592981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(DOZE_AOD, FINISH); 1602981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 161a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mSensor.sendSensorEvent(1); 162a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 163a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos assertNotEquals(1, mServiceFake.screenBrightness); 164a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos } 165a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 166a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos @Test 167c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos public void testNonPositiveBrightness_keepsPreviousBrightnessAndScrim() throws Exception { 168a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 169a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE_AOD); 170a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 171c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mSensor.sendSensorEvent(1); 172a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mSensor.sendSensorEvent(0); 173a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 174c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos assertEquals(1, mServiceFake.screenBrightness); 175c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos assertEquals(10/255f, mHostFake.aodDimmingScrimOpacity, 0.001f /* delta */); 176a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos } 177a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 178a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos @Test 179c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos public void pausingAod_softBlanks() throws Exception { 180a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 181a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE_AOD); 182a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 183c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mSensor.sendSensorEvent(2); 184a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 185c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mScreen.transitionTo(DOZE_AOD, DOZE_AOD_PAUSING); 186c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mScreen.transitionTo(DOZE_AOD_PAUSING, DOZE_AOD_PAUSED); 187c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos 188c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos assertEquals(1f, mHostFake.aodDimmingScrimOpacity, 0.001f /* delta */); 189a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 190a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mSensor.sendSensorEvent(0); 191c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos assertEquals(1f, mHostFake.aodDimmingScrimOpacity, 0.001f /* delta */); 192a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 193c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mScreen.transitionTo(DOZE_AOD_PAUSED, DOZE_AOD); 194c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos assertEquals(1f, mHostFake.aodDimmingScrimOpacity, 0.001f /* delta */); 195a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos } 196a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 197a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos @Test 198c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos public void pausingAod_softBlanks_withSpuriousSensorDuringPause() throws Exception { 199a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 200a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE_AOD); 201c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mScreen.transitionTo(DOZE_AOD, DOZE_AOD_PAUSING); 202c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mScreen.transitionTo(DOZE_AOD_PAUSING, DOZE_AOD_PAUSED); 2032981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 204a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mSensor.sendSensorEvent(1); 205c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos assertEquals(1f, mHostFake.aodDimmingScrimOpacity, 0.001f /* delta */); 2062981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos } 2072981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 2082981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos @Test 209c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos public void pausingAod_unblanksAfterSensor() throws Exception { 2102981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 2112981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE_AOD); 2122981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 213c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mSensor.sendSensorEvent(2); 2142981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos 215c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mScreen.transitionTo(DOZE_AOD, DOZE_AOD_PAUSING); 216c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mScreen.transitionTo(DOZE_AOD_PAUSING, DOZE_AOD_PAUSED); 217a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 218c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mSensor.sendSensorEvent(0); 219c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos 220c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mScreen.transitionTo(DOZE_AOD_PAUSED, DOZE_AOD); 221a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 222c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mSensor.sendSensorEvent(2); 223a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 224c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos assertEquals(0f, mHostFake.aodDimmingScrimOpacity, 0.001f /* delta */); 225a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos } 226a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 227a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos @Test 228c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos public void pausingAod_unblanksIfSensorWasAlwaysReady() throws Exception { 229a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(UNINITIALIZED, INITIALIZED); 230a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos mScreen.transitionTo(INITIALIZED, DOZE_AOD); 231a79ad59d49cdb3ef6f4cf864094063e3e9111586Adrian Roos 232c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mSensor.sendSensorEvent(2); 233c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos 234c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mScreen.transitionTo(DOZE_AOD, DOZE_AOD_PAUSING); 235c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mScreen.transitionTo(DOZE_AOD_PAUSING, DOZE_AOD_PAUSED); 236c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos mScreen.transitionTo(DOZE_AOD_PAUSED, DOZE_AOD); 237c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos 238c7fd69699058e9b7f0601aca9275b597e8f62736Adrian Roos assertEquals(0f, mHostFake.aodDimmingScrimOpacity, 0.001f /* delta */); 2392981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos } 2402981eb0d59f3568bfe84ce905c82fc17d62d21c5Adrian Roos}