Loading services/core/java/com/android/server/display/AutomaticBrightnessController.java +2 −8 Original line number Diff line number Diff line Loading @@ -463,12 +463,6 @@ public class AutomaticBrightnessController { boolean userChangedAutoBrightnessAdjustment, int displayPolicy, boolean shouldResetShortTermModel) { mState = state; // While dozing, the application processor may be suspended which will prevent us from // receiving new information from the light sensor. On some devices, we may be able to // switch to a wake-up light sensor instead but for now we will simply disable the sensor // and hold onto the last computed screen auto brightness. We save the dozing flag for // debugging purposes. boolean dozing = (displayPolicy == DisplayPowerRequest.POLICY_DOZE); boolean changed = setBrightnessConfiguration(configuration, shouldResetShortTermModel); changed |= setDisplayPolicy(displayPolicy); if (userChangedAutoBrightnessAdjustment) { Loading @@ -482,10 +476,10 @@ public class AutomaticBrightnessController { } final boolean userInitiatedChange = userChangedBrightness || userChangedAutoBrightnessAdjustment; if (userInitiatedChange && enable && !dozing) { if (userInitiatedChange && enable) { prepareBrightnessAdjustmentSample(); } changed |= setLightSensorEnabled(enable && !dozing); changed |= setLightSensorEnabled(enable); if (mIsBrightnessThrottled != mBrightnessThrottler.isThrottled()) { // Maximum brightness has changed, so recalculate display brightness. Loading services/core/java/com/android/server/display/DisplayPowerController.java +1 −2 Original line number Diff line number Diff line Loading @@ -1485,8 +1485,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } // Use default brightness when dozing unless overridden. if ((Float.isNaN(brightnessState)) && Display.isDozeState(state)) { if (Float.isNaN(brightnessState) && mPowerRequest.policy == POLICY_DOZE) { rawBrightnessState = mScreenBrightnessDozeConfig; brightnessState = clampScreenBrightness(rawBrightnessState); mBrightnessReasonTemp.setReason(BrightnessReason.REASON_DOZE_DEFAULT); Loading services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java +3 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.server.display.brightness.strategy; import static android.hardware.display.DisplayManagerInternal.DisplayPowerRequest.POLICY_DOZE; import android.annotation.Nullable; import android.content.Context; import android.hardware.display.BrightnessConfiguration; Loading Loading @@ -102,8 +104,7 @@ public class AutomaticBrightnessStrategy { boolean allowAutoBrightnessWhileDozingConfig, int brightnessReason, int policy, float lastUserSetScreenBrightness, boolean userSetBrightnessChanged) { final boolean autoBrightnessEnabledInDoze = allowAutoBrightnessWhileDozingConfig && Display.isDozeState(targetDisplayState); allowAutoBrightnessWhileDozingConfig && policy == POLICY_DOZE; mIsAutoBrightnessEnabled = shouldUseAutoBrightness() && (targetDisplayState == Display.STATE_ON || autoBrightnessEnabledInDoze) && brightnessReason != BrightnessReason.REASON_OVERRIDE Loading services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -1727,6 +1727,27 @@ public final class DisplayPowerControllerTest { /* ignoreAnimationLimits= */ anyBoolean()); } @Test public void testDefaultDozeBrightness() { float brightness = 0.121f; when(mPowerManagerMock.getBrightnessConstraint( PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DOZE)).thenReturn(brightness); mHolder = createDisplayPowerController(DISPLAY_ID, UNIQUE_ID); when(mHolder.displayPowerState.getColorFadeLevel()).thenReturn(1.0f); when(mHolder.automaticBrightnessController.getAutomaticScreenBrightness( any(BrightnessEvent.class))).thenReturn(PowerManager.BRIGHTNESS_INVALID_FLOAT); when(mHolder.hbmController.getCurrentBrightnessMax()) .thenReturn(PowerManager.BRIGHTNESS_MAX); DisplayPowerRequest dpr = new DisplayPowerRequest(); dpr.policy = DisplayPowerRequest.POLICY_DOZE; mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false); advanceTime(1); // Run updatePowerState verify(mHolder.animator).animateTo(eq(brightness), /* linearSecondTarget= */ anyFloat(), eq(BRIGHTNESS_RAMP_RATE_FAST_INCREASE), eq(false)); } /** * Creates a mock and registers it to {@link LocalServices}. */ Loading services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -215,7 +215,7 @@ public class AutomaticBrightnessStrategyTest { mAutomaticBrightnessStrategy.setUseAutoBrightness(true); int targetDisplayState = Display.STATE_DOZE; boolean allowAutoBrightnessWhileDozing = true; int brightnessReason = BrightnessReason.REASON_DOZE; int brightnessReason = BrightnessReason.REASON_UNKNOWN; int policy = DisplayManagerInternal.DisplayPowerRequest.POLICY_DOZE; float lastUserSetBrightness = 0.2f; boolean userSetBrightnessChanged = true; Loading Loading
services/core/java/com/android/server/display/AutomaticBrightnessController.java +2 −8 Original line number Diff line number Diff line Loading @@ -463,12 +463,6 @@ public class AutomaticBrightnessController { boolean userChangedAutoBrightnessAdjustment, int displayPolicy, boolean shouldResetShortTermModel) { mState = state; // While dozing, the application processor may be suspended which will prevent us from // receiving new information from the light sensor. On some devices, we may be able to // switch to a wake-up light sensor instead but for now we will simply disable the sensor // and hold onto the last computed screen auto brightness. We save the dozing flag for // debugging purposes. boolean dozing = (displayPolicy == DisplayPowerRequest.POLICY_DOZE); boolean changed = setBrightnessConfiguration(configuration, shouldResetShortTermModel); changed |= setDisplayPolicy(displayPolicy); if (userChangedAutoBrightnessAdjustment) { Loading @@ -482,10 +476,10 @@ public class AutomaticBrightnessController { } final boolean userInitiatedChange = userChangedBrightness || userChangedAutoBrightnessAdjustment; if (userInitiatedChange && enable && !dozing) { if (userInitiatedChange && enable) { prepareBrightnessAdjustmentSample(); } changed |= setLightSensorEnabled(enable && !dozing); changed |= setLightSensorEnabled(enable); if (mIsBrightnessThrottled != mBrightnessThrottler.isThrottled()) { // Maximum brightness has changed, so recalculate display brightness. Loading
services/core/java/com/android/server/display/DisplayPowerController.java +1 −2 Original line number Diff line number Diff line Loading @@ -1485,8 +1485,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } // Use default brightness when dozing unless overridden. if ((Float.isNaN(brightnessState)) && Display.isDozeState(state)) { if (Float.isNaN(brightnessState) && mPowerRequest.policy == POLICY_DOZE) { rawBrightnessState = mScreenBrightnessDozeConfig; brightnessState = clampScreenBrightness(rawBrightnessState); mBrightnessReasonTemp.setReason(BrightnessReason.REASON_DOZE_DEFAULT); Loading
services/core/java/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategy.java +3 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.server.display.brightness.strategy; import static android.hardware.display.DisplayManagerInternal.DisplayPowerRequest.POLICY_DOZE; import android.annotation.Nullable; import android.content.Context; import android.hardware.display.BrightnessConfiguration; Loading Loading @@ -102,8 +104,7 @@ public class AutomaticBrightnessStrategy { boolean allowAutoBrightnessWhileDozingConfig, int brightnessReason, int policy, float lastUserSetScreenBrightness, boolean userSetBrightnessChanged) { final boolean autoBrightnessEnabledInDoze = allowAutoBrightnessWhileDozingConfig && Display.isDozeState(targetDisplayState); allowAutoBrightnessWhileDozingConfig && policy == POLICY_DOZE; mIsAutoBrightnessEnabled = shouldUseAutoBrightness() && (targetDisplayState == Display.STATE_ON || autoBrightnessEnabledInDoze) && brightnessReason != BrightnessReason.REASON_OVERRIDE Loading
services/tests/displayservicetests/src/com/android/server/display/DisplayPowerControllerTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -1727,6 +1727,27 @@ public final class DisplayPowerControllerTest { /* ignoreAnimationLimits= */ anyBoolean()); } @Test public void testDefaultDozeBrightness() { float brightness = 0.121f; when(mPowerManagerMock.getBrightnessConstraint( PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DOZE)).thenReturn(brightness); mHolder = createDisplayPowerController(DISPLAY_ID, UNIQUE_ID); when(mHolder.displayPowerState.getColorFadeLevel()).thenReturn(1.0f); when(mHolder.automaticBrightnessController.getAutomaticScreenBrightness( any(BrightnessEvent.class))).thenReturn(PowerManager.BRIGHTNESS_INVALID_FLOAT); when(mHolder.hbmController.getCurrentBrightnessMax()) .thenReturn(PowerManager.BRIGHTNESS_MAX); DisplayPowerRequest dpr = new DisplayPowerRequest(); dpr.policy = DisplayPowerRequest.POLICY_DOZE; mHolder.dpc.requestPowerState(dpr, /* waitForNegativeProximity= */ false); advanceTime(1); // Run updatePowerState verify(mHolder.animator).animateTo(eq(brightness), /* linearSecondTarget= */ anyFloat(), eq(BRIGHTNESS_RAMP_RATE_FAST_INCREASE), eq(false)); } /** * Creates a mock and registers it to {@link LocalServices}. */ Loading
services/tests/displayservicetests/src/com/android/server/display/brightness/strategy/AutomaticBrightnessStrategyTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -215,7 +215,7 @@ public class AutomaticBrightnessStrategyTest { mAutomaticBrightnessStrategy.setUseAutoBrightness(true); int targetDisplayState = Display.STATE_DOZE; boolean allowAutoBrightnessWhileDozing = true; int brightnessReason = BrightnessReason.REASON_DOZE; int brightnessReason = BrightnessReason.REASON_UNKNOWN; int policy = DisplayManagerInternal.DisplayPowerRequest.POLICY_DOZE; float lastUserSetBrightness = 0.2f; boolean userSetBrightnessChanged = true; Loading