Restrict the overridden min size for PiP

Per go/cdd-proposal-pip-size, the absolute minimum size when overridden
should be 48dp.

Bug: 174302616
Test: atest PinnedStackTests#testEnterPipWithTinyMinimalSize
Merged-In: I2f0dfd9a79049aaf696fde8703994deaecce63f5
Change-Id: I2f0dfd9a79049aaf696fde8703994deaecce63f5
This commit is contained in:
Hongwei Wang
2021-03-02 09:21:22 -08:00
parent 3516e98daa
commit 2a18b15dfb
3 changed files with 20 additions and 1 deletions

View File

@@ -45,6 +45,7 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.util.EventLog;
import android.util.Log;
import android.util.Size;
import android.view.SurfaceControl;
@@ -193,6 +194,7 @@ public class PipTaskOrganizer extends TaskOrganizer implements
private PipSurfaceTransactionHelper.SurfaceControlTransactionFactory
mSurfaceControlTransactionFactory;
private PictureInPictureParams mPictureInPictureParams;
private int mOverridableMinSize;
/**
* If set to {@code true}, the entering animation will be skipped and we will wait for
@@ -211,6 +213,8 @@ public class PipTaskOrganizer extends TaskOrganizer implements
mPipBoundsHandler = boundsHandler;
mEnterExitAnimationDuration = context.getResources()
.getInteger(R.integer.config_pipResizeAnimationDuration);
mOverridableMinSize = context.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.overridable_minimal_size_pip_resizable_task);
mSurfaceTransactionHelper = surfaceTransactionHelper;
mPipAnimationController = pipAnimationController;
mSurfaceControlTransactionFactory = SurfaceControl.Transaction::new;
@@ -887,7 +891,14 @@ public class PipTaskOrganizer extends TaskOrganizer implements
// -1 will be populated if an activity specifies defaultWidth/defaultHeight in <layout>
// without minWidth/minHeight
if (windowLayout.minWidth > 0 && windowLayout.minHeight > 0) {
return new Size(windowLayout.minWidth, windowLayout.minHeight);
// If either dimension is smaller than the allowed minimum, adjust them
// according to mOverridableMinSize and log to SafeNet
if (windowLayout.minWidth < mOverridableMinSize
|| windowLayout.minHeight < mOverridableMinSize) {
EventLog.writeEvent(0x534e4554, "174302616", -1, "");
}
return new Size(Math.max(windowLayout.minWidth, mOverridableMinSize),
Math.max(windowLayout.minHeight, mOverridableMinSize));
}
return null;
}