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

Commit 8bdf5325 authored by Mateusz Cicheński's avatar Mateusz Cicheński
Browse files

Remove enable_pip_keep_clear_algorithm flag

Bug: 296239520
Test: presubmit, removing flag

Change-Id: Ief7aa01f1da827eefd8358d97cb9a25ae0edbe8b
parent 59e9f7fe
Loading
Loading
Loading
Loading
+17 −63
Original line number Diff line number Diff line
@@ -123,14 +123,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb
    private static final long PIP_KEEP_CLEAR_AREAS_DELAY =
            SystemProperties.getLong("persist.wm.debug.pip_keep_clear_areas_delay", 200);

    private boolean mEnablePipKeepClearAlgorithm =
            SystemProperties.getBoolean("persist.wm.debug.enable_pip_keep_clear_algorithm", true);

    @VisibleForTesting
    void setEnablePipKeepClearAlgorithm(boolean value) {
        mEnablePipKeepClearAlgorithm = value;
    }

    private Context mContext;
    protected ShellExecutor mMainExecutor;
    private DisplayController mDisplayController;
@@ -166,10 +158,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb
            // early bail out if the change was caused by keyguard showing up
            return;
        }
        if (!mEnablePipKeepClearAlgorithm) {
            // early bail out if the keep clear areas feature is disabled
            return;
        }
        if (mPipBoundsState.isStashed()) {
            // don't move when stashed
            return;
@@ -187,10 +175,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb
    }

    private void updatePipPositionForKeepClearAreas() {
        if (!mEnablePipKeepClearAlgorithm) {
            // early bail out if the keep clear areas feature is disabled
            return;
        }
        if (mIsKeyguardShowingOrAnimating) {
            // early bail out if the change was caused by keyguard showing up
            return;
@@ -343,7 +327,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb
                public void onKeepClearAreasChanged(int displayId, Set<Rect> restricted,
                        Set<Rect> unrestricted) {
                    if (mPipDisplayLayoutState.getDisplayId() == displayId) {
                        if (mEnablePipKeepClearAlgorithm) {
                        mPipBoundsState.setKeepClearAreas(restricted, unrestricted);

                        mMainExecutor.removeCallbacks(
@@ -357,7 +340,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb
                                restricted, unrestricted);
                    }
                }
                }
            };

    /**
@@ -660,25 +642,9 @@ public class PipController implements PipTransitionController.PipTransitionCallb
                            // there's a keyguard present
                            return;
                        }
                        int oldMaxMovementBound = mPipBoundsState.getMovementBounds().bottom;
                        onDisplayChangedUncheck(mDisplayController
                                        .getDisplayLayout(mPipDisplayLayoutState.getDisplayId()),
                                false /* saveRestoreSnapFraction */);
                        int newMaxMovementBound = mPipBoundsState.getMovementBounds().bottom;
                        if (!mEnablePipKeepClearAlgorithm) {
                            // offset PiP to adjust for bottom inset change
                            int pipTop = mPipBoundsState.getBounds().top;
                            int diff = newMaxMovementBound - oldMaxMovementBound;
                            if (diff < 0 && pipTop > newMaxMovementBound) {
                                // bottom inset has increased, move PiP up if it is too low
                                mPipMotionHelper.animateToOffset(mPipBoundsState.getBounds(),
                                        newMaxMovementBound - pipTop);
                            }
                            if (diff > 0 && oldMaxMovementBound == pipTop) {
                                // bottom inset has decreased, move PiP down if it was by the edge
                                mPipMotionHelper.animateToOffset(mPipBoundsState.getBounds(), diff);
                            }
                        }
                    }
                });

@@ -947,14 +913,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb
     * Sets both shelf visibility and its height.
     */
    private void setShelfHeight(boolean visible, int height) {
        if (mEnablePipKeepClearAlgorithm) {
        // turn this into Launcher keep clear area registration instead
        setLauncherKeepClearAreaHeight(visible, height);
            return;
        }
        if (!mIsKeyguardShowingOrAnimating) {
            setShelfHeightLocked(visible, height);
        }
    }

    private void setLauncherKeepClearAreaHeight(boolean visible, int height) {
@@ -1015,16 +975,10 @@ public class PipController implements PipTransitionController.PipTransitionCallb
    private Rect startSwipePipToHome(ComponentName componentName, ActivityInfo activityInfo,
            PictureInPictureParams pictureInPictureParams,
            int launcherRotation, Rect hotseatKeepClearArea) {

        if (mEnablePipKeepClearAlgorithm) {
        // preemptively add the keep clear area for Hotseat, so that it is taken into account
        // when calculating the entry destination bounds of PiP window
        mPipBoundsState.addNamedUnrestrictedKeepClearArea(LAUNCHER_KEEP_CLEAR_AREA_TAG,
                hotseatKeepClearArea);
        } else {
            int shelfHeight = hotseatKeepClearArea.height();
            setShelfHeightLocked(shelfHeight > 0 /* visible */, shelfHeight);
        }
        onDisplayRotationChangedNotInPip(mContext, launcherRotation);
        final Rect entryBounds = mPipTaskOrganizer.startSwipePipToHome(componentName, activityInfo,
                pictureInPictureParams);
+0 −51
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.SystemProperties;
import android.provider.DeviceConfig;
import android.util.Size;
import android.view.DisplayCutout;
@@ -73,14 +72,6 @@ public class PipTouchHandler {
    private static final String TAG = "PipTouchHandler";
    private static final float DEFAULT_STASH_VELOCITY_THRESHOLD = 18000.f;

    private boolean mEnablePipKeepClearAlgorithm =
            SystemProperties.getBoolean("persist.wm.debug.enable_pip_keep_clear_algorithm", true);

    @VisibleForTesting
    void setEnablePipKeepClearAlgorithm(boolean value) {
        mEnablePipKeepClearAlgorithm = value;
    }

    // Allow PIP to resize to a slightly bigger state upon touch
    private boolean mEnableResize;
    private final Context mContext;
@@ -430,48 +421,6 @@ public class PipTouchHandler {
                mIsImeShowing ? mImeOffset : 0,
                !mIsImeShowing && mIsShelfShowing ? mShelfHeight : 0);

        // If this is from an IME or shelf adjustment, then we should move the PiP so that it is not
        // occluded by the IME or shelf.
        if (fromImeAdjustment || fromShelfAdjustment) {
            if (mTouchState.isUserInteracting() && mTouchState.isDragging()) {
                // Defer the update of the current movement bounds until after the user finishes
                // touching the screen
            } else if (mEnablePipKeepClearAlgorithm) {
                // Ignore moving PiP if keep clear algorithm is enabled, since IME and shelf height
                // now are accounted for in the keep clear algorithm calculations
            } else {
                final boolean isExpanded = mMenuState == MENU_STATE_FULL && willResizeMenu();
                final Rect toMovementBounds = new Rect();
                mPipBoundsAlgorithm.getMovementBounds(curBounds, insetBounds,
                        toMovementBounds, mIsImeShowing ? mImeHeight : 0);
                final int prevBottom = mPipBoundsState.getMovementBounds().bottom
                        - mMovementBoundsExtraOffsets;
                // This is to handle landscape fullscreen IMEs, don't apply the extra offset in this
                // case
                final int toBottom = toMovementBounds.bottom < toMovementBounds.top
                        ? toMovementBounds.bottom
                        : toMovementBounds.bottom - extraOffset;

                if (isExpanded) {
                    curBounds.set(mPipBoundsState.getExpandedBounds());
                    mPipBoundsAlgorithm.getSnapAlgorithm().applySnapFraction(curBounds,
                            toMovementBounds, mSavedSnapFraction);
                }

                if (prevBottom < toBottom) {
                    // The movement bounds are expanding
                    if (curBounds.top > prevBottom - mBottomOffsetBufferPx) {
                        mMotionHelper.animateToOffset(curBounds, toBottom - curBounds.top);
                    }
                } else if (prevBottom > toBottom) {
                    // The movement bounds are shrinking
                    if (curBounds.top > toBottom - mBottomOffsetBufferPx) {
                        mMotionHelper.animateToOffset(curBounds, toBottom - curBounds.top);
                    }
                }
            }
        }

        // Update the movement bounds after doing the calculations based on the old movement bounds
        // above
        mPipBoundsState.setNormalMovementBounds(normalMovementBounds);
+1 −16
Original line number Diff line number Diff line
@@ -76,7 +76,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

import java.util.Optional;
@@ -329,21 +328,7 @@ public class PipControllerTest extends ShellTestCase {
    }

    @Test
    public void onKeepClearAreasChanged_featureDisabled_pipBoundsStateDoesntChange() {
        mPipController.setEnablePipKeepClearAlgorithm(false);
        final int displayId = 1;
        final Rect keepClearArea = new Rect(0, 0, 10, 10);
        when(mMockPipDisplayLayoutState.getDisplayId()).thenReturn(displayId);

        mPipController.mDisplaysChangedListener.onKeepClearAreasChanged(
                displayId, Set.of(keepClearArea), Set.of());

        verify(mMockPipBoundsState, never()).setKeepClearAreas(Mockito.anySet(), Mockito.anySet());
    }

    @Test
    public void onKeepClearAreasChanged_featureEnabled_updatesPipBoundsState() {
        mPipController.setEnablePipKeepClearAlgorithm(true);
    public void onKeepClearAreasChanged_updatesPipBoundsState() {
        final int displayId = 1;
        final Rect keepClearArea = new Rect(0, 0, 10, 10);
        when(mMockPipDisplayLayoutState.getDisplayId()).thenReturn(displayId);
+0 −13
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.wm.shell.pip.phone;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

@@ -174,16 +173,4 @@ public class PipTouchHandlerTest extends ShellTestCase {
        verify(mPipResizeGestureHandler, times(1))
                .updateMaxSize(expectedMaxSize.getWidth(), expectedMaxSize.getHeight());
    }

    @Test
    public void updateMovementBounds_withImeAdjustment_movesPip() {
        mPipTouchHandler.setEnablePipKeepClearAlgorithm(false);
        mFromImeAdjustment = true;
        mPipTouchHandler.onImeVisibilityChanged(true /* imeVisible */, mImeHeight);

        mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mPipBounds, mCurBounds,
                mFromImeAdjustment, mFromShelfAdjustment, mDisplayRotation);

        verify(mMotionHelper, times(1)).animateToOffset(any(), anyInt());
    }
}
+0 −5
Original line number Diff line number Diff line
@@ -512,11 +512,6 @@ object Flags {
    val ENABLE_FLING_TO_DISMISS_PIP =
        sysPropBooleanFlag("persist.wm.debug.fling_to_dismiss_pip", default = true)

    @Keep
    @JvmField
    val ENABLE_PIP_KEEP_CLEAR_ALGORITHM =
        sysPropBooleanFlag("persist.wm.debug.enable_pip_keep_clear_algorithm", default = true)

    // TODO(b/256873975): Tracking Bug
    @JvmField
    @Keep