diff --git a/core/java/android/app/PictureInPictureParams.java b/core/java/android/app/PictureInPictureParams.java index 32252a3f4baef..29c9c67e12c3c 100644 --- a/core/java/android/app/PictureInPictureParams.java +++ b/core/java/android/app/PictureInPictureParams.java @@ -26,6 +26,7 @@ import android.util.Rational; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * Represents a set of parameters used to initialize and update an Activity in picture-in-picture @@ -193,6 +194,16 @@ public final class PictureInPictureParams implements Parcelable { mAutoEnterEnabled = autoEnterEnabled; } + /** + * Makes a copy from the other picture-in-picture args. + * @hide + */ + public PictureInPictureParams(PictureInPictureParams other) { + this(other.mAspectRatio, other.mUserActions, + other.hasSourceBoundsHint() ? new Rect(other.getSourceRectHint()) : null, + other.mAutoEnterEnabled); + } + /** * Copies the set parameters from the other picture-in-picture args. * @hide @@ -296,6 +307,22 @@ public final class PictureInPictureParams implements Parcelable { && !mAutoEnterEnabled; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof PictureInPictureParams)) return false; + PictureInPictureParams that = (PictureInPictureParams) o; + return mAutoEnterEnabled == that.mAutoEnterEnabled + && Objects.equals(mAspectRatio, that.mAspectRatio) + && Objects.equals(mUserActions, that.mUserActions) + && Objects.equals(mSourceRectHint, that.mSourceRectHint); + } + + @Override + public int hashCode() { + return Objects.hash(mAspectRatio, mUserActions, mSourceRectHint, mAutoEnterEnabled); + } + @Override public int describeContents() { return 0; diff --git a/core/java/android/app/RemoteAction.java b/core/java/android/app/RemoteAction.java index 5a4244f86ca30..26f324b578490 100644 --- a/core/java/android/app/RemoteAction.java +++ b/core/java/android/app/RemoteAction.java @@ -23,6 +23,7 @@ import android.os.Parcelable; import android.text.TextUtils; import java.io.PrintWriter; +import java.util.Objects; /** * Represents a remote action that can be called from another process. The action can have an @@ -126,6 +127,25 @@ public final class RemoteAction implements Parcelable { return action; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof RemoteAction)) return false; + RemoteAction that = (RemoteAction) o; + return mEnabled == that.mEnabled + && mShouldShowIcon == that.mShouldShowIcon + && mIcon.equals(that.mIcon) + && mTitle.equals(that.mTitle) + && mContentDescription.equals(that.mContentDescription) + && mActionIntent.equals(that.mActionIntent); + } + + @Override + public int hashCode() { + return Objects.hash(mIcon, mTitle, mContentDescription, mActionIntent, mEnabled, + mShouldShowIcon); + } + @Override public int describeContents() { return 0; diff --git a/core/java/android/app/TaskInfo.java b/core/java/android/app/TaskInfo.java index 1a8a4b7f16da0..8367bde614038 100644 --- a/core/java/android/app/TaskInfo.java +++ b/core/java/android/app/TaskInfo.java @@ -313,7 +313,7 @@ public class TaskInfo { && isResizeable == that.isResizeable && Objects.equals(positionInParent, that.positionInParent) && equalsLetterboxParams(that) - && pictureInPictureParams == that.pictureInPictureParams + && Objects.equals(pictureInPictureParams, that.pictureInPictureParams) && getWindowingMode() == that.getWindowingMode() && Objects.equals(taskDescription, that.taskDescription) && isFocused == that.isFocused diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 4b65ce0f70885..00f545cfad88a 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -224,7 +224,6 @@ import com.android.server.uri.NeededUriGrants; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlSerializer; import java.io.FileDescriptor; import java.io.IOException; @@ -4108,7 +4107,7 @@ class Task extends WindowContainer { if (top == null) return null; final ActivityRecord rootActivity = top.getRootActivity(); return (rootActivity == null || rootActivity.pictureInPictureArgs.empty()) - ? null : rootActivity.pictureInPictureArgs; + ? null : new PictureInPictureParams(rootActivity.pictureInPictureArgs); } void maybeUpdateLetterboxBounds(