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

Commit 702ef360 authored by Tiger's avatar Tiger
Browse files

Don't reset mWindowsInsetsChanged

It should only be modified when the state of mInsetsChanged of a window
is changed, or when a window is removed. Otherwise, we might fail to
send INSETS_CHANGED unexpectedly.

Bug: 311026631
Bug: 315500042
Test: presubmit
Change-Id: Ie72dfc25844e483c681e173cd8e0c3967d2297a6
parent 237a75b1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5748,7 +5748,6 @@ public class WindowManagerService extends IWindowManager.Stub
                case INSETS_CHANGED: {
                    synchronized (mGlobalLock) {
                        if (mWindowsInsetsChanged > 0) {
                            mWindowsInsetsChanged = 0;
                            // We need to update resizing windows and dispatch the new insets state
                            // to them.
                            mWindowPlacerLocked.performSurfacePlacement();
@@ -6848,6 +6847,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    pw.println(defaultDisplayContent.getLastOrientation());
            pw.print("  mWaitingForConfig=");
                    pw.println(defaultDisplayContent.mWaitingForConfig);
            pw.print("  mWindowsInsetsChanged="); pw.println(mWindowsInsetsChanged);
            mRotationWatcherController.dump(pw);

            pw.print("  Animation settings: disabled="); pw.print(mAnimationsDisabled);
+14 −11
Original line number Diff line number Diff line
@@ -1474,16 +1474,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                        this, mWindowFrames.getInsetsChangedInfo(),
                        configChanged, didFrameInsetsChange);

            if (insetsChanged) {
                mWindowFrames.setInsetsChanged(false);
                if (mWmService.mWindowsInsetsChanged > 0) {
                    mWmService.mWindowsInsetsChanged--;
                }
                if (mWmService.mWindowsInsetsChanged == 0) {
                    mWmService.mH.removeMessages(WindowManagerService.H.INSETS_CHANGED);
                }
            }

            consumeInsetsChange();
            onResizeHandled();
            mWmService.makeWindowFreezingScreenIfNeededLocked(this);

@@ -2380,6 +2371,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP

        mWmService.mTrustedPresentationListenerController.removeIgnoredWindowTokens(
                getWindowToken());

        consumeInsetsChange();
    }

    @Override
@@ -3753,6 +3746,16 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return mClient instanceof IWindow.Stub;
    }

    private void consumeInsetsChange() {
        if (mWindowFrames.hasInsetsChanged()) {
            mWindowFrames.setInsetsChanged(false);
            mWmService.mWindowsInsetsChanged--;
            if (mWmService.mWindowsInsetsChanged == 0) {
                mWmService.mH.removeMessages(WindowManagerService.H.INSETS_CHANGED);
            }
        }
    }

    /**
     * Called when the insets state changed.
     */
@@ -3760,10 +3763,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        ProtoLog.d(WM_DEBUG_WINDOW_INSETS, "notifyInsetsChanged for %s ", this);
        if (!mWindowFrames.hasInsetsChanged()) {
            mWindowFrames.setInsetsChanged(true);
            mWmService.mWindowsInsetsChanged++;

            // If the new InsetsState won't be dispatched before releasing WM lock, the following
            // message will be executed.
            mWmService.mWindowsInsetsChanged++;
            mWmService.mH.removeMessages(WindowManagerService.H.INSETS_CHANGED);
            mWmService.mH.sendEmptyMessage(WindowManagerService.H.INSETS_CHANGED);
        }