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

Commit 2d4cbbfd authored by Yifei Zhang's avatar Yifei Zhang Committed by Android (Google) Code Review
Browse files

Merge "keyguard: don't skip the first listener dispatch" into main

parents d0e1453a 3f9935f3
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -545,3 +545,14 @@ flag {
    description: "Adds support for trackpad back gestures on connected displays"
    bug: "382774299"
}

flag {
    namespace: "wear_frameworks"
    name: "dispatch_first_keyguard_locked_state"
    description: "Ensures the first keyguard locked state is dispatched to listeners reigstered through KeyguardManager.addKeyguardLockedStateListener"
    bug: "375029840"
    is_fixed_read_only: true
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -55,5 +55,7 @@ class WindowManagerFlags {

    final boolean mAodTransition = Flags.aodTransition();

    final boolean mDispatchFirstKeyguardLockedState = Flags.dispatchFirstKeyguardLockedState();

    /* End Available Flags */
}
+17 −4
Original line number Diff line number Diff line
@@ -479,7 +479,11 @@ public class WindowManagerService extends IWindowManager.Stub

    private final List<OnWindowRemovedListener> mOnWindowRemovedListeners = new ArrayList<>();

    private boolean mDispatchedKeyguardLockedState = false;
    /** Indicates whether the first keyguard locked state has been dispatched. */
    private boolean mHasDispatchedKeyguardLockedState = false;

    /** The last dispatched keyguard locked state. */
    private boolean mLastDispatchedKeyguardLockedState = false;

    // VR Vr2d Display Id.
    int mVr2dDisplayId = INVALID_DISPLAY;
@@ -3531,9 +3535,17 @@ public class WindowManagerService extends IWindowManager.Stub
    private void dispatchKeyguardLockedState() {
        mH.post(() -> {
            final boolean isKeyguardLocked = mPolicy.isKeyguardShowing();
            if (mDispatchedKeyguardLockedState == isKeyguardLocked) {
            if (mFlags.mDispatchFirstKeyguardLockedState) {
                // Ensure we don't skip the call for the first dispatch
                if (!mHasDispatchedKeyguardLockedState
                        && mLastDispatchedKeyguardLockedState == isKeyguardLocked) {
                    return;
                }
            } else {
                if (mLastDispatchedKeyguardLockedState == isKeyguardLocked) {
                    return;
                }
            }
            final int n = mKeyguardLockedStateListeners.beginBroadcast();
            for (int i = 0; i < n; i++) {
                try {
@@ -3544,7 +3556,8 @@ public class WindowManagerService extends IWindowManager.Stub
                }
            }
            mKeyguardLockedStateListeners.finishBroadcast();
            mDispatchedKeyguardLockedState = isKeyguardLocked;
            mLastDispatchedKeyguardLockedState = isKeyguardLocked;
            mHasDispatchedKeyguardLockedState = true;
        });
    }