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

Commit 4db00fb2 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Delay insets updates similar to KCA updates

If onInsetsChanged comes in before onDisplayConfigurationChanged
when folding/unfolding, this can update the display layout and
leave pip bounds unchanged, leading to wrong snap fraction
when a follow-up onDisplayConfigurationChanged() comes in.

Bug: 365685556
Flag: EXEMPT bugfix
Test: manually reproduce the steps in the bug
Change-Id: I0b5056cd73bae2fe747fa018087e8b1ed4dc333f
parent bf7c62bc
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -2020,7 +2020,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
        tx.apply();
    }

    private void cancelCurrentAnimator() {
    /**
     * Cancels the currently running animator if there is one and removes an overlay if present.
     */
    public void cancelCurrentAnimator() {
        final PipAnimationController.PipTransitionAnimator<?> animator =
                mPipAnimationController.getCurrentAnimator();
        // remove any overlays if present
+7 −5
Original line number Diff line number Diff line
@@ -324,7 +324,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
                        return;
                    }
                    onDisplayChanged(mDisplayController.getDisplayLayout(displayId),
                            false /* saveRestoreSnapFraction */);
                            true /* saveRestoreSnapFraction */);
                }

                @Override
@@ -652,9 +652,11 @@ public class PipController implements PipTransitionController.PipTransitionCallb
                            // there's a keyguard present
                            return;
                        }
                        onDisplayChangedUncheck(mDisplayController
                                        .getDisplayLayout(mPipDisplayLayoutState.getDisplayId()),
                        mMainExecutor.executeDelayed(() -> {
                            onDisplayChangedUncheck(mDisplayController.getDisplayLayout(
                                    mPipDisplayLayoutState.getDisplayId()),
                                    false /* saveRestoreSnapFraction */);
                        }, PIP_KEEP_CLEAR_AREAS_DELAY);
                    }
                });

@@ -800,7 +802,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
            }
        };

        if (mPipTaskOrganizer.isInPip() && saveRestoreSnapFraction) {
        if (mPipTransitionState.hasEnteredPip() && saveRestoreSnapFraction) {
            mMenuController.attachPipMenuView();
            // Calculate the snap fraction of the current stack along the old movement bounds
            final PipSnapAlgorithm pipSnapAlgorithm = mPipBoundsAlgorithm.getSnapAlgorithm();
+1 −1
Original line number Diff line number Diff line
@@ -256,7 +256,7 @@ public class PipControllerTest extends ShellTestCase {
        when(mMockPipDisplayLayoutState.getDisplayLayout()).thenReturn(mMockDisplayLayout1);
        when(mMockDisplayController.getDisplayLayout(displayId)).thenReturn(mMockDisplayLayout2);

        when(mMockPipTaskOrganizer.isInPip()).thenReturn(true);
        when(mMockPipTransitionState.hasEnteredPip()).thenReturn(true);
        mPipController.mDisplaysChangedListener.onDisplayConfigurationChanged(
                displayId, new Configuration());