diff options
8 files changed, 22 insertions, 22 deletions
diff --git a/services/core/java/com/android/server/display/AutomaticBrightnessController.java b/services/core/java/com/android/server/display/AutomaticBrightnessController.java index 9c020a7d4fda..d9c3ab806888 100644 --- a/services/core/java/com/android/server/display/AutomaticBrightnessController.java +++ b/services/core/java/com/android/server/display/AutomaticBrightnessController.java @@ -181,7 +181,7 @@ public class AutomaticBrightnessController { private long mLightSensorEnableTime; // The currently accepted nominal ambient light level. - private float mAmbientLux; + private float mAmbientLux = INVALID_LUX; // The last calculated ambient light level (long time window). private float mSlowAmbientLux; @@ -434,23 +434,23 @@ public class AutomaticBrightnessController { * entering doze - we disable the light sensor, invalidate the lux, but we still need to set * the initial brightness in doze mode. */ - public float getAutomaticScreenBrightnessBasedOnLastObservedLux( + public float getAutomaticScreenBrightnessBasedOnLastUsedLux( BrightnessEvent brightnessEvent) { - if (mLastObservedLux == INVALID_LUX) { + float lastUsedLux = mAmbientLux; + if (lastUsedLux == INVALID_LUX) { return PowerManager.BRIGHTNESS_INVALID_FLOAT; } - float brightness = mCurrentBrightnessMapper.getBrightness(mLastObservedLux, + float brightness = mCurrentBrightnessMapper.getBrightness(lastUsedLux, mForegroundAppPackageName, mForegroundAppCategory); if (shouldApplyDozeScaleFactor()) { brightness *= mDozeScaleFactor; } if (brightnessEvent != null) { - brightnessEvent.setLux(mLastObservedLux); + brightnessEvent.setLux(lastUsedLux); brightnessEvent.setRecommendedBrightness(brightness); brightnessEvent.setFlags(brightnessEvent.getFlags() - | (mLastObservedLux == INVALID_LUX ? BrightnessEvent.FLAG_INVALID_LUX : 0) | (shouldApplyDozeScaleFactor() ? BrightnessEvent.FLAG_DOZE_SCALE : 0)); brightnessEvent.setAutoBrightnessMode(getMode()); } diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java index 5b9d39791a9a..d7a7dd493903 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController.java +++ b/services/core/java/com/android/server/display/DisplayPowerController.java @@ -1448,7 +1448,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call && mAutomaticBrightnessStrategy.shouldUseAutoBrightness()) { // Use the auto-brightness curve and the last observed lux rawBrightnessState = mAutomaticBrightnessController - .getAutomaticScreenBrightnessBasedOnLastObservedLux( + .getAutomaticScreenBrightnessBasedOnLastUsedLux( mTempBrightnessEvent); } else { rawBrightnessState = getDozeBrightnessForOffload(); diff --git a/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java b/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java index 5c4fa842c383..23052286d9ec 100644 --- a/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java +++ b/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java @@ -360,11 +360,11 @@ public class AutomaticBrightnessStrategy extends AutomaticBrightnessStrategy2 * @param brightnessEvent Event object to populate with details about why the specific * brightness was chosen. */ - public float getAutomaticScreenBrightnessBasedOnLastObservedLux( + public float getAutomaticScreenBrightnessBasedOnLastUsedLux( BrightnessEvent brightnessEvent) { float brightness = (mAutomaticBrightnessController != null) ? mAutomaticBrightnessController - .getAutomaticScreenBrightnessBasedOnLastObservedLux(brightnessEvent) + .getAutomaticScreenBrightnessBasedOnLastUsedLux(brightnessEvent) : PowerManager.BRIGHTNESS_INVALID_FLOAT; adjustAutomaticBrightnessStateIfValid(brightness); return brightness; diff --git a/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy2.java b/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy2.java index 25e8b2392665..58670c97e944 100644 --- a/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy2.java +++ b/services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy2.java @@ -279,11 +279,11 @@ public class AutomaticBrightnessStrategy2 { * @param brightnessEvent Event object to populate with details about why the specific * brightness was chosen. */ - public float getAutomaticScreenBrightnessBasedOnLastObservedLux( + public float getAutomaticScreenBrightnessBasedOnLastUsedLux( BrightnessEvent brightnessEvent) { float brightness = (mAutomaticBrightnessController != null) ? mAutomaticBrightnessController - .getAutomaticScreenBrightnessBasedOnLastObservedLux(brightnessEvent) + .getAutomaticScreenBrightnessBasedOnLastUsedLux(brightnessEvent) : PowerManager.BRIGHTNESS_INVALID_FLOAT; adjustAutomaticBrightnessStateIfValid(brightness); return brightness; diff --git a/services/tests/displayservicetests/src/com/android/server/display/AutomaticBrightnessControllerTest.java b/services/tests/displayservicetests/src/com/android/server/display/AutomaticBrightnessControllerTest.java index 64253e10bd21..3628a57f2375 100644 --- a/services/tests/displayservicetests/src/com/android/server/display/AutomaticBrightnessControllerTest.java +++ b/services/tests/displayservicetests/src/com/android/server/display/AutomaticBrightnessControllerTest.java @@ -1030,7 +1030,7 @@ public class AutomaticBrightnessControllerTest { } @Test - public void testBrightnessBasedOnLastObservedLux() throws Exception { + public void testBrightnessBasedOnLastUsedLux() throws Exception { ArgumentCaptor<SensorEventListener> listenerCaptor = ArgumentCaptor.forClass(SensorEventListener.class); verify(mSensorManager).registerListener(listenerCaptor.capture(), eq(mLightSensor), @@ -1054,7 +1054,7 @@ public class AutomaticBrightnessControllerTest { /* userChanged= */ false, DisplayPowerRequest.POLICY_BRIGHT, Display.STATE_ON, /* shouldResetShortTermModel= */ true); assertEquals(normalizedBrightness, - mController.getAutomaticScreenBrightnessBasedOnLastObservedLux( + mController.getAutomaticScreenBrightnessBasedOnLastUsedLux( /* brightnessEvent= */ null), EPSILON); } @@ -1090,7 +1090,7 @@ public class AutomaticBrightnessControllerTest { mController.getAutomaticScreenBrightness( /* brightnessEvent= */ null), EPSILON); assertEquals(normalizedBrightness * DOZE_SCALE_FACTOR, - mController.getAutomaticScreenBrightnessBasedOnLastObservedLux( + mController.getAutomaticScreenBrightnessBasedOnLastUsedLux( /* brightnessEvent= */ null), EPSILON); } @@ -1128,7 +1128,7 @@ public class AutomaticBrightnessControllerTest { assertEquals(normalizedBrightness, mController.getAutomaticScreenBrightness(/* brightnessEvent= */ null), EPSILON); assertEquals(normalizedBrightness, - mController.getAutomaticScreenBrightnessBasedOnLastObservedLux( + mController.getAutomaticScreenBrightnessBasedOnLastUsedLux( /* brightnessEvent= */ null), EPSILON); } @@ -1163,7 +1163,7 @@ public class AutomaticBrightnessControllerTest { assertEquals(normalizedBrightness, mController.getAutomaticScreenBrightness(/* brightnessEvent= */ null), EPSILON); assertEquals(normalizedBrightness, - mController.getAutomaticScreenBrightnessBasedOnLastObservedLux( + mController.getAutomaticScreenBrightnessBasedOnLastUsedLux( /* brightnessEvent= */ null), EPSILON); } } diff --git a/services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java b/services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java index 78ebdb14f8d1..80f38eb52d97 100644 --- a/services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java +++ b/services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java @@ -1776,7 +1776,7 @@ public final class DisplayPowerControllerTest { float brightness = 0.277f; when(mHolder.displayPowerState.getColorFadeLevel()).thenReturn(1.0f); when(mHolder.automaticBrightnessController - .getAutomaticScreenBrightnessBasedOnLastObservedLux(any(BrightnessEvent.class))) + .getAutomaticScreenBrightnessBasedOnLastUsedLux(any(BrightnessEvent.class))) .thenReturn(brightness); when(mHolder.hbmController.getCurrentBrightnessMax()) .thenReturn(PowerManager.BRIGHTNESS_MAX); @@ -1840,7 +1840,7 @@ public final class DisplayPowerControllerTest { float brightness = 0.277f; when(mHolder.displayPowerState.getColorFadeLevel()).thenReturn(1.0f); when(mHolder.automaticBrightnessController - .getAutomaticScreenBrightnessBasedOnLastObservedLux(any(BrightnessEvent.class))) + .getAutomaticScreenBrightnessBasedOnLastUsedLux(any(BrightnessEvent.class))) .thenReturn(brightness); when(mHolder.hbmController.getCurrentBrightnessMax()) .thenReturn(PowerManager.BRIGHTNESS_MAX); diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy2Test.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy2Test.java index fd43720b1c03..09f5bb60a6ad 100644 --- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy2Test.java +++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy2Test.java @@ -343,7 +343,7 @@ public class AutomaticBrightnessStrategy2Test { AutomaticBrightnessController.class); when(automaticBrightnessController.getAutomaticScreenBrightness(any(BrightnessEvent.class))) .thenReturn(automaticScreenBrightness); - when(automaticBrightnessController.getAutomaticScreenBrightnessBasedOnLastObservedLux( + when(automaticBrightnessController.getAutomaticScreenBrightnessBasedOnLastUsedLux( any(BrightnessEvent.class))) .thenReturn(automaticScreenBrightness); mAutomaticBrightnessStrategy.setAutomaticBrightnessController( @@ -352,7 +352,7 @@ public class AutomaticBrightnessStrategy2Test { mAutomaticBrightnessStrategy.getAutomaticScreenBrightness( new BrightnessEvent(DISPLAY_ID)), 0.0f); assertEquals(automaticScreenBrightness, - mAutomaticBrightnessStrategy.getAutomaticScreenBrightnessBasedOnLastObservedLux( + mAutomaticBrightnessStrategy.getAutomaticScreenBrightnessBasedOnLastUsedLux( new BrightnessEvent(DISPLAY_ID)), 0.0f); } diff --git a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java index 54f22687bc75..3e78118cd5df 100644 --- a/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java +++ b/services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java @@ -341,7 +341,7 @@ public class AutomaticBrightnessStrategyTest { AutomaticBrightnessController.class); when(automaticBrightnessController.getAutomaticScreenBrightness(any(BrightnessEvent.class))) .thenReturn(automaticScreenBrightness); - when(automaticBrightnessController.getAutomaticScreenBrightnessBasedOnLastObservedLux( + when(automaticBrightnessController.getAutomaticScreenBrightnessBasedOnLastUsedLux( any(BrightnessEvent.class))) .thenReturn(automaticScreenBrightness); mAutomaticBrightnessStrategy.setAutomaticBrightnessController( @@ -350,7 +350,7 @@ public class AutomaticBrightnessStrategyTest { mAutomaticBrightnessStrategy.getAutomaticScreenBrightness( new BrightnessEvent(DISPLAY_ID)), 0.0f); assertEquals(automaticScreenBrightness, - mAutomaticBrightnessStrategy.getAutomaticScreenBrightnessBasedOnLastObservedLux( + mAutomaticBrightnessStrategy.getAutomaticScreenBrightnessBasedOnLastUsedLux( new BrightnessEvent(DISPLAY_ID)), 0.0f); } |