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

Commit c88709cb authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6748432 from 607893c9 to rvc-qpr1-release

Change-Id: I7f3e71f67c2f1ff3feba9cff5176608ed1992fd8
parents 7a2cc11f 607893c9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ private:
    void dispatchHotplug(nsecs_t timestamp, PhysicalDisplayId displayId, bool connected) override;
    void dispatchConfigChanged(nsecs_t timestamp, PhysicalDisplayId displayId,
                               int32_t configId, nsecs_t vsyncPeriod) override;
    void dispatchNullEvent(nsecs_t timestamp, PhysicalDisplayId displayId) override {}
};


+9 −8
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ public class PipBoundsHandler {
        }
        if (isValidPictureInPictureAspectRatio(mAspectRatio)) {
            transformBoundsToAspectRatio(normalBounds, mAspectRatio,
                    false /* useCurrentMinEdgeSize */);
                    false /* useCurrentMinEdgeSize */, false /* useCurrentSize */);
        }
        displayInfo.copyFrom(mDisplayInfo);
    }
@@ -278,7 +278,9 @@ public class PipBoundsHandler {
            destinationBounds = new Rect(bounds);
        }
        if (isValidPictureInPictureAspectRatio(aspectRatio)) {
            transformBoundsToAspectRatio(destinationBounds, aspectRatio, useCurrentMinEdgeSize);
            boolean useCurrentSize = bounds == null && mReentrySize != null;
            transformBoundsToAspectRatio(destinationBounds, aspectRatio, useCurrentMinEdgeSize,
                    useCurrentSize);
        }
        mAspectRatio = aspectRatio;
        return destinationBounds;
@@ -384,7 +386,8 @@ public class PipBoundsHandler {
     * @param stackBounds
     */
    public void transformBoundsToAspectRatio(Rect stackBounds) {
        transformBoundsToAspectRatio(stackBounds, mAspectRatio, true);
        transformBoundsToAspectRatio(stackBounds, mAspectRatio, true /* useCurrentMinEdgeSize */,
                true /* useCurrentSize */);
    }

    /**
@@ -392,18 +395,16 @@ public class PipBoundsHandler {
     * specified aspect ratio.
     */
    private void transformBoundsToAspectRatio(Rect stackBounds, float aspectRatio,
            boolean useCurrentMinEdgeSize) {
            boolean useCurrentMinEdgeSize, boolean useCurrentSize) {
        // Save the snap fraction and adjust the size based on the new aspect ratio.
        final float snapFraction = mSnapAlgorithm.getSnapFraction(stackBounds,
                getMovementBounds(stackBounds));
        final int minEdgeSize;
        final int minEdgeSize = useCurrentMinEdgeSize ? mCurrentMinSize : mDefaultMinSize;
        final Size size;
        if (useCurrentMinEdgeSize) {
            minEdgeSize = mCurrentMinSize;
        if (useCurrentMinEdgeSize || useCurrentSize) {
            size = mSnapAlgorithm.getSizeForAspectRatio(
                    new Size(stackBounds.width(), stackBounds.height()), aspectRatio, minEdgeSize);
        } else {
            minEdgeSize = mDefaultMinSize;
            size = mSnapAlgorithm.getSizeForAspectRatio(aspectRatio, minEdgeSize,
                    mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight);
        }
+19 −11
Original line number Diff line number Diff line
@@ -355,17 +355,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
    @Override
    public void onPipTransitionStarted(ComponentName activity, int direction) {
        if (isOutPipDirection(direction)) {
            // On phones, the expansion animation that happens on pip tap before restoring
            // to fullscreen makes it so that the bounds received here are the expanded
            // bounds. We want to restore to the unexpanded bounds when re-entering pip,
            // so we save the bounds before expansion (normal) instead of the current
            // bounds.
            mReentryBounds.set(mTouchHandler.getNormalBounds());
            // Apply the snap fraction of the current bounds to the normal bounds.
            final Rect bounds = mPipTaskOrganizer.getLastReportedBounds();
            float snapFraction = mPipBoundsHandler.getSnapFraction(bounds);
            mPipBoundsHandler.applySnapFraction(mReentryBounds, snapFraction);
            // Save reentry bounds (normal non-expand bounds with current position applied).
            // Exiting PIP, save the reentry bounds to restore to when re-entering.
            updateReentryBounds();
            mPipBoundsHandler.onSaveReentryBounds(activity, mReentryBounds);
        }
        // Disable touches while the animation is running
@@ -379,6 +370,23 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
        }
    }

    /**
     * Update the bounds used to save the re-entry size and snap fraction when exiting PIP.
     */
    public void updateReentryBounds() {
        // On phones, the expansion animation that happens on pip tap before restoring
        // to fullscreen makes it so that the last reported bounds are the expanded
        // bounds. We want to restore to the unexpanded bounds when re-entering pip,
        // so we use the bounds before expansion (normal) instead of the reported
        // bounds.
        Rect reentryBounds = mTouchHandler.getNormalBounds();
        // Apply the snap fraction of the current bounds to the normal bounds.
        final Rect bounds = mPipTaskOrganizer.getLastReportedBounds();
        float snapFraction = mPipBoundsHandler.getSnapFraction(bounds);
        mPipBoundsHandler.applySnapFraction(reentryBounds, snapFraction);
        mReentryBounds.set(reentryBounds);
    }

    @Override
    public void onPipTransitionFinished(ComponentName activity, int direction) {
        onPipTransitionFinishedOrCanceled(direction);
+17 −0
Original line number Diff line number Diff line
@@ -192,6 +192,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
    private int mLayoutDirection;

    private boolean mForceNavBarHandleOpaque;
    private boolean mIsCurrentUserSetup;

    /** @see android.view.WindowInsetsController#setSystemBarsAppearance(int) */
    private @Appearance int mAppearance;
@@ -311,6 +312,10 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback

        @Override
        public void onNavBarButtonAlphaChanged(float alpha, boolean animate) {
            if (!mIsCurrentUserSetup) {
                // If the current user is not yet setup, then don't update any button alphas
                return;
            }
            ButtonDispatcher buttonDispatcher = null;
            boolean forceVisible = false;
            if (QuickStepContract.isSwipeUpMode(mNavBarMode)) {
@@ -384,6 +389,14 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
        }
    };

    private final DeviceProvisionedController.DeviceProvisionedListener mUserSetupListener =
            new DeviceProvisionedController.DeviceProvisionedListener() {
        @Override
        public void onUserSetupChanged() {
            mIsCurrentUserSetup = mDeviceProvisionedController.isCurrentUserSetup();
        }
    };

    @Inject
    public NavigationBarFragment(AccessibilityManagerWrapper accessibilityManagerWrapper,
            DeviceProvisionedController deviceProvisionedController, MetricsLogger metricsLogger,
@@ -451,6 +464,9 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
                /* defaultValue = */ true);
        DeviceConfig.addOnPropertiesChangedListener(
                DeviceConfig.NAMESPACE_SYSTEMUI, mHandler::post, mOnPropertiesChangedListener);

        mIsCurrentUserSetup = mDeviceProvisionedController.isCurrentUserSetup();
        mDeviceProvisionedController.addCallback(mUserSetupListener);
    }

    @Override
@@ -459,6 +475,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
        mNavigationModeController.removeListener(this);
        mAccessibilityManagerWrapper.removeCallback(mAccessibilityListener);
        mContentResolver.unregisterContentObserver(mAssistContentObserver);
        mDeviceProvisionedController.removeCallback(mUserSetupListener);

        DeviceConfig.removeOnPropertiesChangedListener(mOnPropertiesChangedListener);
    }
+31 −0
Original line number Diff line number Diff line
@@ -269,6 +269,21 @@ public class PipBoundsHandlerTest extends SysuiTestCase {
        assertBoundsInclusionWithMargin("restoreLastPosition", oldPosition, newPosition);
    }

    @Test
    public void onSaveReentryBounds_restoreLastSize() {
        final Rect oldSize = mPipBoundsHandler.getDestinationBounds(mTestComponentName1,
                DEFAULT_ASPECT_RATIO, EMPTY_CURRENT_BOUNDS, EMPTY_MINIMAL_SIZE);

        oldSize.scale(1.25f);
        mPipBoundsHandler.onSaveReentryBounds(mTestComponentName1, oldSize);

        final Rect newSize = mPipBoundsHandler.getDestinationBounds(mTestComponentName1,
                DEFAULT_ASPECT_RATIO, EMPTY_CURRENT_BOUNDS, EMPTY_MINIMAL_SIZE);

        assertEquals(oldSize.width(), newSize.width());
        assertEquals(oldSize.height(), newSize.height());
    }

    @Test
    public void onResetReentryBounds_useDefaultBounds() {
        final Rect defaultBounds = mPipBoundsHandler.getDestinationBounds(mTestComponentName1,
@@ -299,6 +314,22 @@ public class PipBoundsHandlerTest extends SysuiTestCase {
        assertBoundsInclusionWithMargin("restoreLastPosition", newBounds, actualBounds);
    }

    @Test
    public void onSaveReentryBounds_componentMismatch_restoreLastSize() {
        final Rect oldSize = mPipBoundsHandler.getDestinationBounds(mTestComponentName1,
                DEFAULT_ASPECT_RATIO, EMPTY_CURRENT_BOUNDS, EMPTY_MINIMAL_SIZE);

        oldSize.scale(1.25f);
        mPipBoundsHandler.onSaveReentryBounds(mTestComponentName1, oldSize);

        mPipBoundsHandler.onResetReentryBounds(mTestComponentName2);
        final Rect newSize = mPipBoundsHandler.getDestinationBounds(mTestComponentName1,
                DEFAULT_ASPECT_RATIO, EMPTY_CURRENT_BOUNDS, EMPTY_MINIMAL_SIZE);

        assertEquals(oldSize.width(), newSize.width());
        assertEquals(oldSize.height(), newSize.height());
    }

    private void assertBoundsInclusionWithMargin(String from, Rect expected, Rect actual) {
        final Rect expectedWithMargin = new Rect(expected);
        expectedWithMargin.inset(-ROUNDING_ERROR_MARGIN, -ROUNDING_ERROR_MARGIN);