Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29aae6f3 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #4279860: previous UI flashes before showing lock screen...

...(when turning display on after recently turning it off)

Also clean up when we decide to turn the screen on to improve that
transition.  There are still problems here with turning it on
before the wallpaper gets dispayed.

Change-Id: I2bc56c12e5ad75a1ce5a0546f43a845bf0823e66
parent 5b56f7d6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -218,4 +218,9 @@ interface IWindowManager
     * Called by the settings application to temporarily set the pointer speed.
     */
    void setPointerSpeed(int speed);

    /**
     * Block until all windows the window manager knows about have been drawn.
     */
    void waitForAllDrawn();
}
+9 −1
Original line number Diff line number Diff line
@@ -177,7 +177,8 @@ public interface WindowManager extends ViewManager {
            @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"),
            @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"),
            @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"),
            @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY")
            @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY"),
            @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, to = "TYPE_BOOT_PROGRESS")
        })
        public int type;
    
@@ -400,6 +401,13 @@ public interface WindowManager extends ViewManager {
         */
        public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;

        /**
         * Window type: The boot progress dialog, goes on top of everything
         * in the world.
         * @hide
         */
        public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;

        /**
         * End of types of system windows.
         */
+6 −2
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.util.Log;

public class TargetDrawable {
    private static final String TAG = "TargetDrawable";
    private static final boolean DEBUG = false;

    public static final int[] STATE_ACTIVE =
            { android.R.attr.state_enabled, android.R.attr.state_active };
    public static final int[] STATE_INACTIVE =
@@ -139,11 +141,13 @@ public class TargetDrawable {
                maxWidth = Math.max(maxWidth, childDrawable.getIntrinsicWidth());
                maxHeight = Math.max(maxHeight, childDrawable.getIntrinsicHeight());
            }
            Log.v(TAG, "union of childDrawable rects " + d + " to: " + maxWidth + "x" + maxHeight);
            if (DEBUG) Log.v(TAG, "union of childDrawable rects " + d + " to: "
                        + maxWidth + "x" + maxHeight);
            d.setBounds(0, 0, maxWidth, maxHeight);
            for (int i = 0; i < d.getStateCount(); i++) {
                Drawable childDrawable = d.getStateDrawable(i);
                Log.v(TAG, "sizing drawable " + childDrawable + " to: " + maxWidth + "x" + maxHeight);
                if (DEBUG) Log.v(TAG, "sizing drawable " + childDrawable + " to: "
                            + maxWidth + "x" + maxHeight);
                childDrawable.setBounds(0, 0, maxWidth, maxHeight);
            }
        } else if (mDrawable != null) {
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ import android.widget.TextView;
 *
 */
class KeyguardStatusViewManager implements OnClickListener {
    private static final boolean DEBUG = true;
    private static final boolean DEBUG = false;
    private static final String TAG = "KeyguardStatusView";

    public static final int LOCK_ICON = 0; // R.drawable.ic_lock_idle_lock;
+137 −92
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
    private static final int KEYGUARD_DONE_AUTHENTICATING = 11;
    private static final int SET_HIDDEN = 12;
    private static final int KEYGUARD_TIMEOUT = 13;
    private static final int REPORT_SHOW_DONE = 14;

    /**
     * The default amount of time we stay awake (used for all key input)
@@ -238,6 +239,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback,

    private boolean mScreenOn = false;

    private boolean mShowPending = false;

    // last known state of the cellular connection
    private String mPhoneState = TelephonyManager.EXTRA_STATE_IDLE;

@@ -306,7 +309,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
        synchronized (this) {
            if (DEBUG) Log.d(TAG, "onSystemReady");
            mSystemReady = true;
            doKeyguard();
            doKeyguardLocked();
        }
    }

@@ -363,7 +366,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
                if (timeout <= 0) {
                    // Lock now
                    mSuppressNextLockSound = true;
                    doKeyguard();
                    doKeyguardLocked();
                } else {
                    // Lock in the future
                    long when = SystemClock.elapsedRealtime() + timeout;
@@ -379,7 +382,19 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
            } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR) {
                // Do not enable the keyguard if the prox sensor forced the screen off.
            } else {
                doKeyguard();
                if (!doKeyguardLocked() && why == WindowManagerPolicy.OFF_BECAUSE_OF_USER) {
                    // The user has explicitly turned off the screen, causing it
                    // to lock.  We want to block here until the keyguard window
                    // has shown, so the power manager won't complete the screen
                    // off flow until that point, so we know it won't turn *on*
                    // the screen until this is done.
                    while (mShowPending) {
                        try {
                            wait();
                        } catch (InterruptedException e) {
                        }
                    }
                }
            }
        }
    }
@@ -553,10 +568,11 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
    }

    /**
     * Enable the keyguard if the settings are appropriate.
     * Enable the keyguard if the settings are appropriate.  Return true if all
     * work that will happen is done; returns false if the caller can wait for
     * the keyguard to be shown.
     */
    private void doKeyguard() {
        synchronized (this) {
    private boolean doKeyguardLocked() {
        // if another app is disabling us, don't show
        if (!mExternallyEnabled) {
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled");
@@ -570,13 +586,13 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
            // ends (see the broadcast receiver below)
            // TODO: clean this up when we have better support at the window manager level
            // for apps that wish to be on top of the keyguard
                return;
            return true;
        }

        // if the keyguard is already showing, don't bother
        if (mKeyguardViewManager.isShowing()) {
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing");
                return;
            return true;
        }

        // if the setup wizard hasn't run yet, don't show
@@ -592,17 +608,18 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
        if (!lockedOrMissing && !provisioned) {
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because device isn't provisioned"
                    + " and the sim is not locked or missing");
                return;
            return true;
        }

        if (mLockPatternUtils.isLockScreenDisabled()) {
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off");
                return;
            return true;
        }

        if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
        mShowPending = true;
        showLocked();
        }
        return false;
    }

    /**
@@ -696,42 +713,50 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
            case ABSENT:
                // only force lock screen in case of missing sim if user hasn't
                // gone through setup wizard
                synchronized (this) {
                    if (!mUpdateMonitor.isDeviceProvisioned()) {
                        if (!isShowing()) {
                            if (DEBUG) Log.d(TAG, "ICC_ABSENT isn't showing,"
                                    + " we need to show the keyguard since the "
                                    + "device isn't provisioned yet.");
                        doKeyguard();
                            doKeyguardLocked();
                        } else {
                            resetStateLocked();
                        }
                    }
                }
                break;
            case PIN_REQUIRED:
            case PUK_REQUIRED:
                synchronized (this) {
                    if (!isShowing()) {
                        if (DEBUG) Log.d(TAG, "INTENT_VALUE_ICC_LOCKED and keygaurd isn't showing, we need "
                                + "to show the keyguard so the user can enter their sim pin");
                    doKeyguard();
                        doKeyguardLocked();
                    } else {
                        resetStateLocked();
                    }
                }
                break;
            case PERM_DISABLED:
                synchronized (this) {
                    if (!isShowing()) {
                        if (DEBUG) Log.d(TAG, "PERM_DISABLED and "
                              + "keygaurd isn't showing.");
                    doKeyguard();
                        doKeyguardLocked();
                    } else {
                        if (DEBUG) Log.d(TAG, "PERM_DISABLED, resetStateLocked to"
                              + "show permanently disabled message in lockscreen.");
                        resetStateLocked();
                    }
                }
                break;
            case READY:
                synchronized (this) {
                    if (isShowing()) {
                        resetStateLocked();
                    }
                }
                break;
        }
    }
@@ -751,16 +776,19 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
                if (DEBUG) Log.d(TAG, "received DELAYED_KEYGUARD_ACTION with seq = "
                        + sequence + ", mDelayedShowingSequence = " + mDelayedShowingSequence);

                synchronized (KeyguardViewMediator.this) {
                    if (mDelayedShowingSequence == sequence) {
                        // Don't play lockscreen SFX if the screen went off due to
                        // timeout.
                        mSuppressNextLockSound = true;
    
                    doKeyguard();
                        doKeyguardLocked();
                    }
                }
            } else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
                mPhoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);

                synchronized (KeyguardViewMediator.this) {
                    if (TelephonyManager.EXTRA_STATE_IDLE.equals(mPhoneState)  // call ending
                            && !mScreenOn                           // screen off
                            && mExternallyEnabled) {                // not disabled by any app
@@ -771,7 +799,8 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
                        // flicker while turning back on the screen and disabling the keyguard again).
                        if (DEBUG) Log.d(TAG, "screen is off and call ended, let's make sure the "
                                + "keyguard is showing");
                    doKeyguard();
                        doKeyguardLocked();
                    }
                }
            }
        }
@@ -962,7 +991,15 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
                    handleSetHidden(msg.arg1 != 0);
                    break;
                case KEYGUARD_TIMEOUT:
                    doKeyguard();
                    synchronized (KeyguardViewMediator.this) {
                        doKeyguardLocked();
                    }
                    break;
                case REPORT_SHOW_DONE:
                    synchronized (KeyguardViewMediator.this) {
                        mShowPending = false;
                        KeyguardViewMediator.this.notifyAll();
                    }
                    break;
            }
        }
@@ -1062,8 +1099,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
            if (DEBUG) Log.d(TAG, "handleShow");
            if (!mSystemReady) return;

            playSounds(true);

            mKeyguardViewManager.show();
            mShowing = true;
            adjustUserActivityLocked();
@@ -1072,7 +1107,17 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
                ActivityManagerNative.getDefault().closeSystemDialogs("lock");
            } catch (RemoteException e) {
            }

            // Do this at the end to not slow down display of the keyguard.
            playSounds(true);

            mShowKeyguardWakeLock.release();

            // We won't say the show is done yet because the view hierarchy
            // still needs to do the traversal.  Posting this message allows
            // us to hold off until that is done.
            Message msg = mHandler.obtainMessage(REPORT_SHOW_DONE);
            mHandler.sendMessage(msg);
        }
    }

Loading