Loading services/core/java/com/android/server/display/DisplayPowerController.java +11 −6 Original line number Diff line number Diff line Loading @@ -140,6 +140,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private static final int RAMP_STATE_SKIP_INITIAL = 1; private static final int RAMP_STATE_SKIP_AUTOBRIGHT = 2; private static final int REPORTED_TO_POLICY_UNREPORTED = -1; private static final int REPORTED_TO_POLICY_SCREEN_OFF = 0; private static final int REPORTED_TO_POLICY_SCREEN_TURNING_ON = 1; private static final int REPORTED_TO_POLICY_SCREEN_ON = 2; Loading Loading @@ -311,8 +312,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private long mScreenOnBlockStartRealTime; private long mScreenOffBlockStartRealTime; // Screen state we reported to policy. Must be one of REPORTED_TO_POLICY_SCREEN_* fields. private int mReportedScreenStateToPolicy; // Screen state we reported to policy. Must be one of REPORTED_TO_POLICY_* fields. private int mReportedScreenStateToPolicy = REPORTED_TO_POLICY_UNREPORTED; // If the last recorded screen state was dozing or not. private boolean mDozing; Loading Loading @@ -1440,12 +1441,14 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private boolean setScreenState(int state, boolean reportOnly) { final boolean isOff = (state == Display.STATE_OFF); if (mPowerState.getScreenState() != state) { if (mPowerState.getScreenState() != state || mReportedScreenStateToPolicy == REPORTED_TO_POLICY_UNREPORTED) { // If we are trying to turn screen off, give policy a chance to do something before we // actually turn the screen off. if (isOff && !mScreenOffBecauseOfProximity) { if (mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_ON) { if (mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_ON || mReportedScreenStateToPolicy == REPORTED_TO_POLICY_UNREPORTED) { setReportedScreenState(REPORTED_TO_POLICY_SCREEN_TURNING_OFF); blockScreenOff(); mWindowManagerPolicy.screenTurningOff(mDisplayId, mPendingScreenOffUnblocker); Loading @@ -1456,7 +1459,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } } if (!reportOnly) { if (!reportOnly && mPowerState.getScreenState() != state) { Trace.traceCounter(Trace.TRACE_TAG_POWER, "ScreenState", state); // TODO(b/153319140) remove when we can get this from the above trace invocation SystemProperties.set("debug.tracing.screen_state", String.valueOf(state)); Loading Loading @@ -1486,7 +1489,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mWindowManagerPolicy.screenTurnedOff(mDisplayId); setReportedScreenState(REPORTED_TO_POLICY_SCREEN_OFF); } if (!isOff && mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_OFF) { if (!isOff && (mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_OFF || mReportedScreenStateToPolicy == REPORTED_TO_POLICY_UNREPORTED)) { setReportedScreenState(REPORTED_TO_POLICY_SCREEN_TURNING_ON); if (mPowerState.getColorFadeLevel() == 0.0f) { blockScreenOn(); Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +34 −11 Original line number Diff line number Diff line Loading @@ -405,6 +405,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { private boolean mEnableCarDockHomeCapture = true; boolean mBootMessageNeedsHiding; volatile boolean mBootAnimationDismissable; private KeyguardServiceDelegate mKeyguardDelegate; private boolean mKeyguardBound; final Runnable mWindowManagerDrawCallback = new Runnable() { Loading Loading @@ -4305,6 +4306,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { 0 /* cookie */); updateScreenOffSleepToken(false); mDefaultDisplayPolicy.screenTurnedOn(screenOnListener); mBootAnimationDismissable = false; synchronized (mLock) { if (mKeyguardDelegate != null && mKeyguardDelegate.hasKeyguard()) { Loading Loading @@ -4379,6 +4381,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurningOn", 0 /* cookie */); enableScreen(listener, true /* report */); } private void enableScreen(ScreenOnListener listener, boolean report) { final boolean enableScreen; final boolean awake = mDefaultDisplayPolicy.isAwake(); synchronized (mLock) { Loading @@ -4396,6 +4402,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } if (report) { if (listener != null) { listener.onScreenOn(); } Loading @@ -4407,6 +4414,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } mScreenOnListeners.clear(); } if (enableScreen) { try { Loading Loading @@ -4614,13 +4622,28 @@ public class PhoneWindowManager implements WindowManagerPolicy { } startedWakingUp(PowerManager.WAKE_REASON_UNKNOWN); finishedWakingUp(PowerManager.WAKE_REASON_UNKNOWN); int defaultDisplayState = mDisplayManager.getDisplay(DEFAULT_DISPLAY).getState(); boolean defaultDisplayOn = defaultDisplayState == Display.STATE_ON; boolean defaultScreenTurningOn = mDefaultDisplayPolicy.getScreenOnListener() != null; if (defaultDisplayOn || defaultScreenTurningOn) { // Now that system is booted, wait for keyguard and windows to be drawn before // updating the orientation listener, stopping the boot animation and enabling screen. screenTurningOn(DEFAULT_DISPLAY, mDefaultDisplayPolicy.getScreenOnListener()); screenTurnedOn(DEFAULT_DISPLAY); } else { // We're not turning the screen on, so don't wait for keyguard to be drawn // to dismiss the boot animation and finish booting mBootAnimationDismissable = true; enableScreen(null, false /* report */); } } @Override public boolean canDismissBootAnimation() { return mDefaultDisplayPolicy.isKeyguardDrawComplete(); // Allow to dismiss the boot animation if the keyguard has finished drawing, // or mBootAnimationDismissable has been set return mDefaultDisplayPolicy.isKeyguardDrawComplete() || mBootAnimationDismissable; } ProgressDialog mBootMsgDialog = null; Loading Loading
services/core/java/com/android/server/display/DisplayPowerController.java +11 −6 Original line number Diff line number Diff line Loading @@ -140,6 +140,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private static final int RAMP_STATE_SKIP_INITIAL = 1; private static final int RAMP_STATE_SKIP_AUTOBRIGHT = 2; private static final int REPORTED_TO_POLICY_UNREPORTED = -1; private static final int REPORTED_TO_POLICY_SCREEN_OFF = 0; private static final int REPORTED_TO_POLICY_SCREEN_TURNING_ON = 1; private static final int REPORTED_TO_POLICY_SCREEN_ON = 2; Loading Loading @@ -311,8 +312,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private long mScreenOnBlockStartRealTime; private long mScreenOffBlockStartRealTime; // Screen state we reported to policy. Must be one of REPORTED_TO_POLICY_SCREEN_* fields. private int mReportedScreenStateToPolicy; // Screen state we reported to policy. Must be one of REPORTED_TO_POLICY_* fields. private int mReportedScreenStateToPolicy = REPORTED_TO_POLICY_UNREPORTED; // If the last recorded screen state was dozing or not. private boolean mDozing; Loading Loading @@ -1440,12 +1441,14 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private boolean setScreenState(int state, boolean reportOnly) { final boolean isOff = (state == Display.STATE_OFF); if (mPowerState.getScreenState() != state) { if (mPowerState.getScreenState() != state || mReportedScreenStateToPolicy == REPORTED_TO_POLICY_UNREPORTED) { // If we are trying to turn screen off, give policy a chance to do something before we // actually turn the screen off. if (isOff && !mScreenOffBecauseOfProximity) { if (mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_ON) { if (mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_ON || mReportedScreenStateToPolicy == REPORTED_TO_POLICY_UNREPORTED) { setReportedScreenState(REPORTED_TO_POLICY_SCREEN_TURNING_OFF); blockScreenOff(); mWindowManagerPolicy.screenTurningOff(mDisplayId, mPendingScreenOffUnblocker); Loading @@ -1456,7 +1459,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } } if (!reportOnly) { if (!reportOnly && mPowerState.getScreenState() != state) { Trace.traceCounter(Trace.TRACE_TAG_POWER, "ScreenState", state); // TODO(b/153319140) remove when we can get this from the above trace invocation SystemProperties.set("debug.tracing.screen_state", String.valueOf(state)); Loading Loading @@ -1486,7 +1489,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mWindowManagerPolicy.screenTurnedOff(mDisplayId); setReportedScreenState(REPORTED_TO_POLICY_SCREEN_OFF); } if (!isOff && mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_OFF) { if (!isOff && (mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_OFF || mReportedScreenStateToPolicy == REPORTED_TO_POLICY_UNREPORTED)) { setReportedScreenState(REPORTED_TO_POLICY_SCREEN_TURNING_ON); if (mPowerState.getColorFadeLevel() == 0.0f) { blockScreenOn(); Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +34 −11 Original line number Diff line number Diff line Loading @@ -405,6 +405,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { private boolean mEnableCarDockHomeCapture = true; boolean mBootMessageNeedsHiding; volatile boolean mBootAnimationDismissable; private KeyguardServiceDelegate mKeyguardDelegate; private boolean mKeyguardBound; final Runnable mWindowManagerDrawCallback = new Runnable() { Loading Loading @@ -4305,6 +4306,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { 0 /* cookie */); updateScreenOffSleepToken(false); mDefaultDisplayPolicy.screenTurnedOn(screenOnListener); mBootAnimationDismissable = false; synchronized (mLock) { if (mKeyguardDelegate != null && mKeyguardDelegate.hasKeyguard()) { Loading Loading @@ -4379,6 +4381,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurningOn", 0 /* cookie */); enableScreen(listener, true /* report */); } private void enableScreen(ScreenOnListener listener, boolean report) { final boolean enableScreen; final boolean awake = mDefaultDisplayPolicy.isAwake(); synchronized (mLock) { Loading @@ -4396,6 +4402,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } if (report) { if (listener != null) { listener.onScreenOn(); } Loading @@ -4407,6 +4414,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } mScreenOnListeners.clear(); } if (enableScreen) { try { Loading Loading @@ -4614,13 +4622,28 @@ public class PhoneWindowManager implements WindowManagerPolicy { } startedWakingUp(PowerManager.WAKE_REASON_UNKNOWN); finishedWakingUp(PowerManager.WAKE_REASON_UNKNOWN); int defaultDisplayState = mDisplayManager.getDisplay(DEFAULT_DISPLAY).getState(); boolean defaultDisplayOn = defaultDisplayState == Display.STATE_ON; boolean defaultScreenTurningOn = mDefaultDisplayPolicy.getScreenOnListener() != null; if (defaultDisplayOn || defaultScreenTurningOn) { // Now that system is booted, wait for keyguard and windows to be drawn before // updating the orientation listener, stopping the boot animation and enabling screen. screenTurningOn(DEFAULT_DISPLAY, mDefaultDisplayPolicy.getScreenOnListener()); screenTurnedOn(DEFAULT_DISPLAY); } else { // We're not turning the screen on, so don't wait for keyguard to be drawn // to dismiss the boot animation and finish booting mBootAnimationDismissable = true; enableScreen(null, false /* report */); } } @Override public boolean canDismissBootAnimation() { return mDefaultDisplayPolicy.isKeyguardDrawComplete(); // Allow to dismiss the boot animation if the keyguard has finished drawing, // or mBootAnimationDismissable has been set return mDefaultDisplayPolicy.isKeyguardDrawComplete() || mBootAnimationDismissable; } ProgressDialog mBootMsgDialog = null; Loading