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

Commit 8e2e0c37 authored by Hongwei Wang's avatar Hongwei Wang Committed by Android (Google) Code Review
Browse files

Merge "Ignore mismatched hint for button nav" into main

parents cefb0e81 eb2a345a
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -27,7 +27,9 @@ import android.util.DisplayMetrics;
import android.util.Size;
import android.view.Gravity;

import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.R;
import com.android.wm.shell.protolog.ShellProtoLogGroup;

import java.io.PrintWriter;

@@ -39,6 +41,9 @@ public class PipBoundsAlgorithm {
    private static final String TAG = PipBoundsAlgorithm.class.getSimpleName();
    private static final float INVALID_SNAP_FRACTION = -1f;

    // The same value (with the same name) is used in Launcher.
    private static final float PIP_ASPECT_RATIO_MISMATCH_THRESHOLD = 0.01f;

    @NonNull private final PipBoundsState mPipBoundsState;
    @NonNull protected final PipDisplayLayoutState mPipDisplayLayoutState;
    @NonNull protected final SizeSpecSource mSizeSpecSource;
@@ -206,9 +211,27 @@ public class PipBoundsAlgorithm {
     */
    public static boolean isSourceRectHintValidForEnterPip(Rect sourceRectHint,
            Rect destinationBounds) {
        return sourceRectHint != null
                && sourceRectHint.width() > destinationBounds.width()
                && sourceRectHint.height() > destinationBounds.height();
        if (sourceRectHint == null || sourceRectHint.isEmpty()) {
            ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                    "isSourceRectHintValidForEnterPip=false, empty hint");
            return false;
        }
        if (sourceRectHint.width() <= destinationBounds.width()
                || sourceRectHint.height() <= destinationBounds.height()) {
            ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                    "isSourceRectHintValidForEnterPip=false, hint(%s) is smaller"
                            + " than destination(%s)", sourceRectHint, destinationBounds);
            return false;
        }
        final float reportedRatio = destinationBounds.width() / (float) destinationBounds.height();
        final float inferredRatio = sourceRectHint.width() / (float) sourceRectHint.height();
        if (Math.abs(reportedRatio - inferredRatio) > PIP_ASPECT_RATIO_MISMATCH_THRESHOLD) {
            ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                    "isSourceRectHintValidForEnterPip=false, hint(%s) does not match"
                            + " destination(%s) aspect ratio", sourceRectHint, destinationBounds);
            return false;
        }
        return true;
    }

    public float getDefaultAspectRatio() {
+0 −34
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.util.Rational;
import android.view.Choreographer;
import android.view.Display;
import android.view.Surface;
@@ -128,8 +127,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
            SystemProperties.getInt(
                    "persist.wm.debug.extra_content_overlay_fade_out_delay_ms", 400);

    private static final float PIP_ASPECT_RATIO_MISMATCH_THRESHOLD = 0.005f;

    private final Context mContext;
    private final SyncTransactionQueue mSyncTransactionQueue;
    private final PipBoundsState mPipBoundsState;
@@ -822,37 +819,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
                    mPictureInPictureParams.getTitle());
            mPipParamsChangedForwarder.notifySubtitleChanged(
                    mPictureInPictureParams.getSubtitle());

            if (mPictureInPictureParams.hasSourceBoundsHint()
                    && mPictureInPictureParams.hasSetAspectRatio()) {
                Rational sourceRectHintAspectRatio = new Rational(
                        mPictureInPictureParams.getSourceRectHint().width(),
                        mPictureInPictureParams.getSourceRectHint().height());
                if (sourceRectHintAspectRatio.compareTo(
                        mPictureInPictureParams.getAspectRatio()) != 0) {
                    ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                            "Aspect ratio of source rect hint (%d/%d) does not match the provided "
                                    + "aspect ratio value (%d/%d). Consider matching them for "
                                    + "improved animation. Future releases might override the "
                                    + "value to match.",
                            mPictureInPictureParams.getSourceRectHint().width(),
                            mPictureInPictureParams.getSourceRectHint().height(),
                            mPictureInPictureParams.getAspectRatio().getNumerator(),
                            mPictureInPictureParams.getAspectRatio().getDenominator());
                }
                if (Math.abs(sourceRectHintAspectRatio.floatValue()
                        - mPictureInPictureParams.getAspectRatioFloat())
                        > PIP_ASPECT_RATIO_MISMATCH_THRESHOLD) {
                    ProtoLog.w(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                            "Aspect ratio of source rect hint (%f) does not match the provided "
                                    + "aspect ratio value (%f) and is above threshold of %f. "
                                    + "Consider matching them for improved animation. Future "
                                    + "releases might override the value to match.",
                            sourceRectHintAspectRatio.floatValue(),
                            mPictureInPictureParams.getAspectRatioFloat(),
                            PIP_ASPECT_RATIO_MISMATCH_THRESHOLD);
                }
            }
        }

        mPipUiEventLoggerLogger.setTaskInfo(mTaskInfo);