Fix checking if PiP aspect ratio has changed
PipTaskOrganizer.applyPictureInPictureParams() by design should only return true if the PiP aspect ratio has changed. However, it's also retrurning true if the current mPictureInPictureParams are null (not specified). This is wrong in cases when the new PiP params do not specify aspect ration. This lead to stange PiP behaviours (see the test). This CL fixes it. Bug: 165794276 Test: atest CtsSystemUiTestCases:CustomPipActionsTests#pipMenu_doesNotClose_whenUpdating_customActions Change-Id: Ib3de6344601cd5a31b249381fd5e83275ed9c4e4
This commit is contained in:
@@ -47,6 +47,7 @@ import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.util.Rational;
|
||||
import android.util.Size;
|
||||
import android.view.SurfaceControl;
|
||||
import android.view.SurfaceControlViewHost;
|
||||
@@ -684,13 +685,16 @@ public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganize
|
||||
* {@link PictureInPictureParams} would affect the bounds.
|
||||
*/
|
||||
private boolean applyPictureInPictureParams(@NonNull PictureInPictureParams params) {
|
||||
final boolean changed = (mPictureInPictureParams == null) || !Objects.equals(
|
||||
mPictureInPictureParams.getAspectRatioRational(), params.getAspectRatioRational());
|
||||
if (changed) {
|
||||
mPictureInPictureParams = params;
|
||||
final Rational currentAspectRatio =
|
||||
mPictureInPictureParams != null ? mPictureInPictureParams.getAspectRatioRational()
|
||||
: null;
|
||||
final boolean aspectRatioChanged = !Objects.equals(currentAspectRatio,
|
||||
params.getAspectRatioRational());
|
||||
mPictureInPictureParams = params;
|
||||
if (aspectRatioChanged) {
|
||||
mPipBoundsHandler.onAspectRatioChanged(params.getAspectRatio());
|
||||
}
|
||||
return changed;
|
||||
return aspectRatioChanged;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user