Merge "Use equals() to check equality of PictureInPictureParams."

This commit is contained in:
Garfield Tan
2020-12-08 00:00:01 +00:00
committed by Android (Google) Code Review
4 changed files with 49 additions and 3 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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<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(