Loading services/core/java/com/android/server/display/DisplayPowerController.java +27 −15 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.display; import android.app.ActivityManager; import com.android.internal.app.IBatteryStats; import com.android.server.LocalServices; import com.android.server.am.BatteryStatsService; Loading Loading @@ -161,6 +162,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // True if should use light sensor to automatically determine doze screen brightness. private final boolean mAllowAutoBrightnessWhileDozingConfig; // Whether or not the color fade on screen on / off is enabled. private final boolean mColorFadeEnabled; // True if we should fade the screen while turning it off, false if we should play // a stylish color fade animation instead. private boolean mColorFadeFadesConfig; Loading Loading @@ -407,6 +411,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mScreenBrightnessRangeMinimum = screenBrightnessRangeMinimum; mColorFadeEnabled = !ActivityManager.isLowRamDeviceStatic(); mColorFadeFadesConfig = resources.getBoolean( com.android.internal.R.bool.config_animateScreenLights); Loading Loading @@ -497,8 +503,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // Initialize the power state object for the default display. // In the future, we might manage multiple displays independently. mPowerState = new DisplayPowerState(mBlanker, new ColorFade(Display.DEFAULT_DISPLAY)); mColorFadeEnabled ? new ColorFade(Display.DEFAULT_DISPLAY) : null); if (mColorFadeEnabled) { mColorFadeOnAnimator = ObjectAnimator.ofFloat( mPowerState, DisplayPowerState.COLOR_FADE_LEVEL, 0.0f, 1.0f); mColorFadeOnAnimator.setDuration(COLOR_FADE_ON_ANIMATION_DURATION_MILLIS); Loading @@ -508,6 +515,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mPowerState, DisplayPowerState.COLOR_FADE_LEVEL, 1.0f, 0.0f); mColorFadeOffAnimator.setDuration(COLOR_FADE_OFF_ANIMATION_DURATION_MILLIS); mColorFadeOffAnimator.addListener(mAnimatorListener); } mScreenBrightnessRampAnimator = new RampAnimator<DisplayPowerState>( mPowerState, DisplayPowerState.SCREEN_BRIGHTNESS); Loading Loading @@ -784,9 +792,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // Note that we do not wait for the brightness ramp animation to complete before // reporting the display is ready because we only need to ensure the screen is in the // right power state even as it continues to converge on the desired brightness. final boolean ready = mPendingScreenOnUnblocker == null && !mColorFadeOnAnimator.isStarted() && !mColorFadeOffAnimator.isStarted() final boolean ready = mPendingScreenOnUnblocker == null && (!mColorFadeEnabled || (!mColorFadeOnAnimator.isStarted() && !mColorFadeOffAnimator.isStarted())) && mPowerState.waitUntilClean(mCleanListener); final boolean finished = ready && !mScreenBrightnessRampAnimator.isAnimating(); Loading Loading @@ -959,8 +967,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private void animateScreenStateChange(int target, boolean performScreenOffTransition) { // If there is already an animation in progress, don't interfere with it. if (mColorFadeOnAnimator.isStarted() || mColorFadeOffAnimator.isStarted()) { if (mColorFadeEnabled && (mColorFadeOnAnimator.isStarted() || mColorFadeOffAnimator.isStarted())) { if (target != Display.STATE_ON) { return; } Loading @@ -984,7 +992,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call if (!setScreenState(Display.STATE_ON)) { return; // screen on blocked } if (USE_COLOR_FADE_ON_ANIMATION && mPowerRequest.isBrightOrDim()) { if (USE_COLOR_FADE_ON_ANIMATION && mColorFadeEnabled && mPowerRequest.isBrightOrDim()) { // Perform screen on animation. if (mPowerState.getColorFadeLevel() == 1.0f) { mPowerState.dismissColorFade(); Loading Loading @@ -1060,6 +1068,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } else { // Want screen off. mPendingScreenOff = true; if (!mColorFadeEnabled) { mPowerState.setColorFadeLevel(0.0f); } if (mPowerState.getColorFadeLevel() == 0.0f) { // Turn the screen off. // A black surface is already hiding the contents of the screen. Loading services/core/java/com/android/server/display/DisplayPowerState.java +4 −4 Original line number Diff line number Diff line Loading @@ -174,7 +174,7 @@ final class DisplayPowerState { * @return True if the electron beam was prepared. */ public boolean prepareColorFade(Context context, int mode) { if (!mColorFade.prepare(context, mode)) { if (mColorFade == null || !mColorFade.prepare(context, mode)) { mColorFadePrepared = false; mColorFadeReady = true; return false; Loading @@ -190,7 +190,7 @@ final class DisplayPowerState { * Dismisses the color fade surface. */ public void dismissColorFade() { mColorFade.dismiss(); if (mColorFade != null) mColorFade.dismiss(); mColorFadePrepared = false; mColorFadeReady = true; } Loading @@ -199,7 +199,7 @@ final class DisplayPowerState { * Dismisses the color fade resources. */ public void dismissColorFadeResources() { mColorFade.dismissResources(); if (mColorFade != null) mColorFade.dismissResources(); } /** Loading Loading @@ -269,7 +269,7 @@ final class DisplayPowerState { pw.println(" mColorFadeDrawPending=" + mColorFadeDrawPending); mPhotonicModulator.dump(pw); mColorFade.dump(pw); if (mColorFade != null) mColorFade.dump(pw); } private void scheduleScreenUpdate() { Loading Loading
services/core/java/com/android/server/display/DisplayPowerController.java +27 −15 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.display; import android.app.ActivityManager; import com.android.internal.app.IBatteryStats; import com.android.server.LocalServices; import com.android.server.am.BatteryStatsService; Loading Loading @@ -161,6 +162,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // True if should use light sensor to automatically determine doze screen brightness. private final boolean mAllowAutoBrightnessWhileDozingConfig; // Whether or not the color fade on screen on / off is enabled. private final boolean mColorFadeEnabled; // True if we should fade the screen while turning it off, false if we should play // a stylish color fade animation instead. private boolean mColorFadeFadesConfig; Loading Loading @@ -407,6 +411,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mScreenBrightnessRangeMinimum = screenBrightnessRangeMinimum; mColorFadeEnabled = !ActivityManager.isLowRamDeviceStatic(); mColorFadeFadesConfig = resources.getBoolean( com.android.internal.R.bool.config_animateScreenLights); Loading Loading @@ -497,8 +503,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // Initialize the power state object for the default display. // In the future, we might manage multiple displays independently. mPowerState = new DisplayPowerState(mBlanker, new ColorFade(Display.DEFAULT_DISPLAY)); mColorFadeEnabled ? new ColorFade(Display.DEFAULT_DISPLAY) : null); if (mColorFadeEnabled) { mColorFadeOnAnimator = ObjectAnimator.ofFloat( mPowerState, DisplayPowerState.COLOR_FADE_LEVEL, 0.0f, 1.0f); mColorFadeOnAnimator.setDuration(COLOR_FADE_ON_ANIMATION_DURATION_MILLIS); Loading @@ -508,6 +515,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mPowerState, DisplayPowerState.COLOR_FADE_LEVEL, 1.0f, 0.0f); mColorFadeOffAnimator.setDuration(COLOR_FADE_OFF_ANIMATION_DURATION_MILLIS); mColorFadeOffAnimator.addListener(mAnimatorListener); } mScreenBrightnessRampAnimator = new RampAnimator<DisplayPowerState>( mPowerState, DisplayPowerState.SCREEN_BRIGHTNESS); Loading Loading @@ -784,9 +792,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // Note that we do not wait for the brightness ramp animation to complete before // reporting the display is ready because we only need to ensure the screen is in the // right power state even as it continues to converge on the desired brightness. final boolean ready = mPendingScreenOnUnblocker == null && !mColorFadeOnAnimator.isStarted() && !mColorFadeOffAnimator.isStarted() final boolean ready = mPendingScreenOnUnblocker == null && (!mColorFadeEnabled || (!mColorFadeOnAnimator.isStarted() && !mColorFadeOffAnimator.isStarted())) && mPowerState.waitUntilClean(mCleanListener); final boolean finished = ready && !mScreenBrightnessRampAnimator.isAnimating(); Loading Loading @@ -959,8 +967,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private void animateScreenStateChange(int target, boolean performScreenOffTransition) { // If there is already an animation in progress, don't interfere with it. if (mColorFadeOnAnimator.isStarted() || mColorFadeOffAnimator.isStarted()) { if (mColorFadeEnabled && (mColorFadeOnAnimator.isStarted() || mColorFadeOffAnimator.isStarted())) { if (target != Display.STATE_ON) { return; } Loading @@ -984,7 +992,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call if (!setScreenState(Display.STATE_ON)) { return; // screen on blocked } if (USE_COLOR_FADE_ON_ANIMATION && mPowerRequest.isBrightOrDim()) { if (USE_COLOR_FADE_ON_ANIMATION && mColorFadeEnabled && mPowerRequest.isBrightOrDim()) { // Perform screen on animation. if (mPowerState.getColorFadeLevel() == 1.0f) { mPowerState.dismissColorFade(); Loading Loading @@ -1060,6 +1068,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } else { // Want screen off. mPendingScreenOff = true; if (!mColorFadeEnabled) { mPowerState.setColorFadeLevel(0.0f); } if (mPowerState.getColorFadeLevel() == 0.0f) { // Turn the screen off. // A black surface is already hiding the contents of the screen. Loading
services/core/java/com/android/server/display/DisplayPowerState.java +4 −4 Original line number Diff line number Diff line Loading @@ -174,7 +174,7 @@ final class DisplayPowerState { * @return True if the electron beam was prepared. */ public boolean prepareColorFade(Context context, int mode) { if (!mColorFade.prepare(context, mode)) { if (mColorFade == null || !mColorFade.prepare(context, mode)) { mColorFadePrepared = false; mColorFadeReady = true; return false; Loading @@ -190,7 +190,7 @@ final class DisplayPowerState { * Dismisses the color fade surface. */ public void dismissColorFade() { mColorFade.dismiss(); if (mColorFade != null) mColorFade.dismiss(); mColorFadePrepared = false; mColorFadeReady = true; } Loading @@ -199,7 +199,7 @@ final class DisplayPowerState { * Dismisses the color fade resources. */ public void dismissColorFadeResources() { mColorFade.dismissResources(); if (mColorFade != null) mColorFade.dismissResources(); } /** Loading Loading @@ -269,7 +269,7 @@ final class DisplayPowerState { pw.println(" mColorFadeDrawPending=" + mColorFadeDrawPending); mPhotonicModulator.dump(pw); mColorFade.dump(pw); if (mColorFade != null) mColorFade.dump(pw); } private void scheduleScreenUpdate() { Loading