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

Commit d029e237 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Auto resize to min size if pip too small

Make sure to resize the pip to minimum size
if pip task is pinch resized to a smaller than allowed
minimum size spec (due to the dampening factor).

Bug: 301414095
Test: manually repro the steps in the bugs
Test: atest WMShellFlickerTestsPip:PipPinchInTest

Change-Id: I01437076abd69cc4493b4f12b29751b486ea8e6b
parent 2f33338a
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -622,6 +622,8 @@ public class PipBoundsState {
        pw.println(innerPrefix + "mShelfHeight=" + mShelfHeight);
        pw.println(innerPrefix + "mShelfHeight=" + mShelfHeight);
        pw.println(innerPrefix + "mHasUserMovedPip=" + mHasUserMovedPip);
        pw.println(innerPrefix + "mHasUserMovedPip=" + mHasUserMovedPip);
        pw.println(innerPrefix + "mHasUserResizedPip=" + mHasUserResizedPip);
        pw.println(innerPrefix + "mHasUserResizedPip=" + mHasUserResizedPip);
        pw.println(innerPrefix + "mMinSize=" + mMinSize);
        pw.println(innerPrefix + "mMaxSize=" + mMaxSize);
        if (mPipReentryState == null) {
        if (mPipReentryState == null) {
            pw.println(innerPrefix + "mPipReentryState=null");
            pw.println(innerPrefix + "mPipReentryState=null");
        } else {
        } else {
+8 −0
Original line number Original line Diff line number Diff line
@@ -579,6 +579,12 @@ public class PipResizeGestureHandler {
                    resizeRectAboutCenter(mLastResizeBounds, mMaxSize.x, mMaxSize.y);
                    resizeRectAboutCenter(mLastResizeBounds, mMaxSize.x, mMaxSize.y);
                }
                }


                // If user resize is smaller than min size, auto resize to min
                if (mLastResizeBounds.width() < mMinSize.x
                        || mLastResizeBounds.height() < mMinSize.y) {
                    resizeRectAboutCenter(mLastResizeBounds, mMinSize.x, mMinSize.y);
                }

                // get the current movement bounds
                // get the current movement bounds
                final Rect movementBounds = mPipBoundsAlgorithm
                final Rect movementBounds = mPipBoundsAlgorithm
                        .getMovementBounds(mLastResizeBounds);
                        .getMovementBounds(mLastResizeBounds);
@@ -679,6 +685,8 @@ public class PipResizeGestureHandler {
        pw.println(innerPrefix + "mEnablePinchResize=" + mEnablePinchResize);
        pw.println(innerPrefix + "mEnablePinchResize=" + mEnablePinchResize);
        pw.println(innerPrefix + "mThresholdCrossed=" + mThresholdCrossed);
        pw.println(innerPrefix + "mThresholdCrossed=" + mThresholdCrossed);
        pw.println(innerPrefix + "mOhmOffset=" + mOhmOffset);
        pw.println(innerPrefix + "mOhmOffset=" + mOhmOffset);
        pw.println(innerPrefix + "mMinSize=" + mMinSize);
        pw.println(innerPrefix + "mMaxSize=" + mMaxSize);
    }
    }


    class PipResizeInputEventReceiver extends BatchedInputEventReceiver {
    class PipResizeInputEventReceiver extends BatchedInputEventReceiver {
+16 −3
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.flicker.pip


import android.platform.test.annotations.Presubmit
import android.platform.test.annotations.Presubmit
import android.tools.common.Rotation
import android.tools.common.Rotation
import android.tools.common.flicker.subject.exceptions.IncorrectRegionException
import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTest
@@ -40,14 +41,26 @@ class PipPinchInTest(flicker: LegacyFlickerTest) : PipTransition(flicker) {
        transitions { pipApp.pinchInPipWindow(wmHelper, 0.4f, 30) }
        transitions { pipApp.pinchInPipWindow(wmHelper, 0.4f, 30) }
    }
    }


    /** Checks that the visible region area of [pipApp] always decreases during the animation. */
    /**
     * Checks that the visible region area of [pipApp] decreases
     * and then increases during the animation.
     */
    @Presubmit
    @Presubmit
    @Test
    @Test
    fun pipLayerAreaDecreases() {
    fun pipLayerAreaDecreasesThenIncreases() {
        val isAreaDecreasing = arrayOf(true)
        flicker.assertLayers {
        flicker.assertLayers {
            val pipLayerList = this.layers { pipApp.layerMatchesAnyOf(it) && it.isVisible }
            val pipLayerList = this.layers { pipApp.layerMatchesAnyOf(it) && it.isVisible }
            pipLayerList.zipWithNext { previous, current ->
            pipLayerList.zipWithNext { previous, current ->
                if (isAreaDecreasing[0]) {
                    try {
                        current.visibleRegion.notBiggerThan(previous.visibleRegion.region)
                        current.visibleRegion.notBiggerThan(previous.visibleRegion.region)
                    } catch (e: IncorrectRegionException) {
                        isAreaDecreasing[0] = false
                    }
                } else {
                    previous.visibleRegion.notBiggerThan(current.visibleRegion.region)
                }
            }
            }
        }
        }
    }
    }