Add flag to explicitly set setCanAffectSystemUiFlags

Within the PictureInPictureSurfaceTransaction class, one can explicitly
express the intention to call Task#setCanAffectSystemUiFlags(false) and
it is typically used if an Activity is entering PiP.

Video: http://recall/-/b1EZhgUkQcpML5OwZekLBN/dlG6qSf9pT2f4YlIe2Klb3
Video: http://recall/-/b1EZhgUkQcpML5OwZekLBN/cfXwlpol5vi2AER32rKu2x
Bug: 213598210
Test: 1. follow the reproduce steps in the bug. \
      2. make sure PiP from split-screen has no regressions. \
      see also the videos.
Change-Id: I7c4624a89ff812f874270fe0092617328b557393
This commit is contained in:
Hongwei Wang
2022-06-09 12:01:07 -07:00
parent 7544f10d0f
commit ce21971ecf
2 changed files with 28 additions and 9 deletions

View File

@@ -51,6 +51,8 @@ public final class PictureInPictureSurfaceTransaction implements Parcelable {
private final Rect mWindowCrop;
private boolean mShouldDisableCanAffectSystemUiFlags;
private PictureInPictureSurfaceTransaction(Parcel in) {
mAlpha = in.readFloat();
mPosition = in.readTypedObject(PointF.CREATOR);
@@ -60,6 +62,7 @@ public final class PictureInPictureSurfaceTransaction implements Parcelable {
mCornerRadius = in.readFloat();
mShadowRadius = in.readFloat();
mWindowCrop = in.readTypedObject(Rect.CREATOR);
mShouldDisableCanAffectSystemUiFlags = in.readBoolean();
}
private PictureInPictureSurfaceTransaction(float alpha, @Nullable PointF position,
@@ -84,6 +87,7 @@ public final class PictureInPictureSurfaceTransaction implements Parcelable {
this(other.mAlpha, other.mPosition,
other.mFloat9, other.mRotation, other.mCornerRadius, other.mShadowRadius,
other.mWindowCrop);
mShouldDisableCanAffectSystemUiFlags = other.mShouldDisableCanAffectSystemUiFlags;
}
/** @return {@link Matrix} from {@link #mFloat9} */
@@ -103,6 +107,16 @@ public final class PictureInPictureSurfaceTransaction implements Parcelable {
return mShadowRadius > 0;
}
/** Sets the internal {@link #mShouldDisableCanAffectSystemUiFlags}. */
public void setShouldDisableCanAffectSystemUiFlags(boolean shouldDisable) {
mShouldDisableCanAffectSystemUiFlags = shouldDisable;
}
/** @return {@code true} if we should disable Task#setCanAffectSystemUiFlags. */
public boolean getShouldDisableCanAffectSystemUiFlags() {
return mShouldDisableCanAffectSystemUiFlags;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -114,13 +128,16 @@ public final class PictureInPictureSurfaceTransaction implements Parcelable {
&& Objects.equals(mRotation, that.mRotation)
&& Objects.equals(mCornerRadius, that.mCornerRadius)
&& Objects.equals(mShadowRadius, that.mShadowRadius)
&& Objects.equals(mWindowCrop, that.mWindowCrop);
&& Objects.equals(mWindowCrop, that.mWindowCrop)
&& mShouldDisableCanAffectSystemUiFlags
== that.mShouldDisableCanAffectSystemUiFlags;
}
@Override
public int hashCode() {
return Objects.hash(mAlpha, mPosition, Arrays.hashCode(mFloat9),
mRotation, mCornerRadius, mShadowRadius, mWindowCrop);
mRotation, mCornerRadius, mShadowRadius, mWindowCrop,
mShouldDisableCanAffectSystemUiFlags);
}
@Override
@@ -137,6 +154,7 @@ public final class PictureInPictureSurfaceTransaction implements Parcelable {
out.writeFloat(mCornerRadius);
out.writeFloat(mShadowRadius);
out.writeTypedObject(mWindowCrop, 0 /* flags */);
out.writeBoolean(mShouldDisableCanAffectSystemUiFlags);
}
@Override
@@ -150,6 +168,7 @@ public final class PictureInPictureSurfaceTransaction implements Parcelable {
+ " cornerRadius=" + mCornerRadius
+ " shadowRadius=" + mShadowRadius
+ " crop=" + mWindowCrop
+ " shouldDisableCanAffectSystemUiFlags" + mShouldDisableCanAffectSystemUiFlags
+ ")";
}

View File

@@ -1335,16 +1335,16 @@ public class RecentsAnimationController implements DeathRecipient {
mDisplayContent.mPinnedTaskController.setEnterPipTransaction(
mFinishTransaction);
}
// In the case where we are transferring the transform to the task in preparation
// for entering PIP, we disable the task being able to affect sysui flags otherwise
// it may cause a flash
if (mTask.getActivityType() != mTargetActivityType
&& mFinishTransaction.getShouldDisableCanAffectSystemUiFlags()) {
mTask.setCanAffectSystemUiFlags(false);
}
mFinishTransaction = null;
mFinishOverlay = null;
pendingTransaction.apply();
// In the case where we are transferring the transform to the task in preparation
// for entering PIP, we disable the task being able to affect sysui flags otherwise
// it may cause a flash
if (mTask.getActivityType() != mTargetActivityType) {
mTask.setCanAffectSystemUiFlags(false);
}
} else if (!mTask.isAttached()) {
// Apply the task's pending transaction in case it is detached and its transaction
// is not reachable.