Merge "Add symmetric Getters to PictureInPictureParams" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
aa61eeefa7
@@ -6645,6 +6645,15 @@ package android.app {
|
|||||||
|
|
||||||
public final class PictureInPictureParams implements android.os.Parcelable {
|
public final class PictureInPictureParams implements android.os.Parcelable {
|
||||||
method public int describeContents();
|
method public int describeContents();
|
||||||
|
method @NonNull public java.util.List<android.app.RemoteAction> getActions();
|
||||||
|
method @Nullable public android.util.Rational getAspectRatio();
|
||||||
|
method @Nullable public android.app.RemoteAction getCloseAction();
|
||||||
|
method @Nullable public android.util.Rational getExpandedAspectRatio();
|
||||||
|
method @Nullable public android.graphics.Rect getSourceRectHint();
|
||||||
|
method @Nullable public CharSequence getSubtitle();
|
||||||
|
method @Nullable public CharSequence getTitle();
|
||||||
|
method public boolean isAutoEnterEnabled();
|
||||||
|
method public boolean isSeamlessResizeEnabled();
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
field @NonNull public static final android.os.Parcelable.Creator<android.app.PictureInPictureParams> CREATOR;
|
field @NonNull public static final android.os.Parcelable.Creator<android.app.PictureInPictureParams> CREATOR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,14 +356,8 @@ package android.app {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class PictureInPictureParams implements android.os.Parcelable {
|
public final class PictureInPictureParams implements android.os.Parcelable {
|
||||||
method public java.util.List<android.app.RemoteAction> getActions();
|
method public float getAspectRatioFloat();
|
||||||
method public float getAspectRatio();
|
method public float getExpandedAspectRatioFloat();
|
||||||
method @Nullable public android.app.RemoteAction getCloseAction();
|
|
||||||
method public float getExpandedAspectRatio();
|
|
||||||
method public android.graphics.Rect getSourceRectHint();
|
|
||||||
method @Nullable public CharSequence getSubtitle();
|
|
||||||
method @Nullable public CharSequence getTitle();
|
|
||||||
method public boolean isSeamlessResizeEnabled();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class PictureInPictureUiState implements android.os.Parcelable {
|
public final class PictureInPictureUiState implements android.os.Parcelable {
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ public final class PictureInPictureParams implements Parcelable {
|
|||||||
private Rational mAspectRatio;
|
private Rational mAspectRatio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The expected aspect ratio of the vertically expanded picture-in-picture window.
|
* The expected aspect ratio of the expanded picture-in-picture window.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
private Rational mExpandedAspectRatio;
|
private Rational mExpandedAspectRatio;
|
||||||
@@ -441,15 +441,21 @@ public final class PictureInPictureParams implements Parcelable {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@TestApi
|
@TestApi
|
||||||
public float getAspectRatio() {
|
public float getAspectRatioFloat() {
|
||||||
if (mAspectRatio != null) {
|
if (mAspectRatio != null) {
|
||||||
return mAspectRatio.floatValue();
|
return mAspectRatio.floatValue();
|
||||||
}
|
}
|
||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/**
|
||||||
public Rational getAspectRatioRational() {
|
* Returns the expected aspect ratio of the picture-in-picture window.
|
||||||
|
*
|
||||||
|
* @return aspect ratio as the desired width / height or {@code null} if not set.
|
||||||
|
* @see PictureInPictureParams.Builder#setAspectRatio(Rational)
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Rational getAspectRatio() {
|
||||||
return mAspectRatio;
|
return mAspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,13 +472,24 @@ public final class PictureInPictureParams implements Parcelable {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@TestApi
|
@TestApi
|
||||||
public float getExpandedAspectRatio() {
|
public float getExpandedAspectRatioFloat() {
|
||||||
if (mExpandedAspectRatio != null) {
|
if (mExpandedAspectRatio != null) {
|
||||||
return mExpandedAspectRatio.floatValue();
|
return mExpandedAspectRatio.floatValue();
|
||||||
}
|
}
|
||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the desired aspect ratio of the expanded picture-in-picture window.
|
||||||
|
*
|
||||||
|
* @return aspect ratio as the desired width / height or {@code null} if not set.
|
||||||
|
* @see PictureInPictureParams.Builder#setExpandedAspectRatio(Rational)
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Rational getExpandedAspectRatio() {
|
||||||
|
return mExpandedAspectRatio;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether the expanded aspect ratio is set
|
* @return whether the expanded aspect ratio is set
|
||||||
* @hide
|
* @hide
|
||||||
@@ -482,11 +499,17 @@ public final class PictureInPictureParams implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the set of user actions.
|
* Returns the list of user actions that are associated with the activity when in
|
||||||
* @hide
|
* picture-in-picture mode.
|
||||||
|
*
|
||||||
|
* @return the user actions in a new list.
|
||||||
|
* @see PictureInPictureParams.Builder#setActions(List)
|
||||||
*/
|
*/
|
||||||
@TestApi
|
@NonNull
|
||||||
public List<RemoteAction> getActions() {
|
public List<RemoteAction> getActions() {
|
||||||
|
if (mUserActions == null) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
return mUserActions;
|
return mUserActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,10 +522,11 @@ public final class PictureInPictureParams implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the close action.
|
* Returns the action that is to replace the system close action.
|
||||||
* @hide
|
*
|
||||||
|
* @return the close action or {@code null} if not set.
|
||||||
|
* @see PictureInPictureParams.Builder#setCloseAction(RemoteAction)
|
||||||
*/
|
*/
|
||||||
@TestApi
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public RemoteAction getCloseAction() {
|
public RemoteAction getCloseAction() {
|
||||||
return mCloseAction;
|
return mCloseAction;
|
||||||
@@ -528,10 +552,12 @@ public final class PictureInPictureParams implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the source rect hint
|
* Returns the source rect hint.
|
||||||
* @hide
|
*
|
||||||
|
* @return the source rect hint also known as launch bounds or {@code null} if not set.
|
||||||
|
* @see PictureInPictureParams.Builder#setSourceRectHint(Rect)
|
||||||
*/
|
*/
|
||||||
@TestApi
|
@Nullable
|
||||||
public Rect getSourceRectHint() {
|
public Rect getSourceRectHint() {
|
||||||
return mSourceRectHint;
|
return mSourceRectHint;
|
||||||
}
|
}
|
||||||
@@ -545,18 +571,23 @@ public final class PictureInPictureParams implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether auto pip is enabled.
|
* Returns whether auto enter picture-in-picture is enabled.
|
||||||
* @hide
|
*
|
||||||
|
* @return {@code true} if the system will automatically put the activity in
|
||||||
|
* picture-in-picture mode.
|
||||||
|
* @see PictureInPictureParams.Builder#setAutoEnterEnabled(boolean)
|
||||||
*/
|
*/
|
||||||
public boolean isAutoEnterEnabled() {
|
public boolean isAutoEnterEnabled() {
|
||||||
return mAutoEnterEnabled == null ? false : mAutoEnterEnabled;
|
return mAutoEnterEnabled == null ? false : mAutoEnterEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return whether seamless resize is enabled.
|
* Returns whether seamless resize is enabled.
|
||||||
* @hide
|
*
|
||||||
|
* @return true if the system can seamlessly resize the window while activity is in
|
||||||
|
* picture-in-picture mode.
|
||||||
|
* @see PictureInPictureParams.Builder#setSeamlessResizeEnabled(boolean)
|
||||||
*/
|
*/
|
||||||
@TestApi
|
|
||||||
public boolean isSeamlessResizeEnabled() {
|
public boolean isSeamlessResizeEnabled() {
|
||||||
return mSeamlessResizeEnabled == null ? true : mSeamlessResizeEnabled;
|
return mSeamlessResizeEnabled == null ? true : mSeamlessResizeEnabled;
|
||||||
}
|
}
|
||||||
@@ -570,10 +601,11 @@ public final class PictureInPictureParams implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return title of the pip.
|
* Returns the title of the picture-in-picture window that may be displayed to the user.
|
||||||
* @hide
|
*
|
||||||
|
* @return title of the picture-in-picture window.
|
||||||
|
* @see PictureInPictureParams.Builder#setTitle(CharSequence)
|
||||||
*/
|
*/
|
||||||
@TestApi
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public CharSequence getTitle() {
|
public CharSequence getTitle() {
|
||||||
return mTitle;
|
return mTitle;
|
||||||
@@ -588,10 +620,11 @@ public final class PictureInPictureParams implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return subtitle of the pip.
|
* Returns the subtitle of the picture-in-picture window that may be displayed to the user.
|
||||||
* @hide
|
*
|
||||||
|
* @return subtitle of the picture-in-picture window.
|
||||||
|
* @see PictureInPictureParams.Builder#setSubtitle(CharSequence)
|
||||||
*/
|
*/
|
||||||
@TestApi
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public CharSequence getSubtitle() {
|
public CharSequence getSubtitle() {
|
||||||
return mSubtitle;
|
return mSubtitle;
|
||||||
@@ -716,7 +749,7 @@ public final class PictureInPictureParams implements Parcelable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PictureInPictureParams("
|
return "PictureInPictureParams("
|
||||||
+ " aspectRatio=" + getAspectRatioRational()
|
+ " aspectRatio=" + getAspectRatio()
|
||||||
+ " expandedAspectRatio=" + mExpandedAspectRatio
|
+ " expandedAspectRatio=" + mExpandedAspectRatio
|
||||||
+ " sourceRectHint=" + getSourceRectHint()
|
+ " sourceRectHint=" + getSourceRectHint()
|
||||||
+ " hasSetActions=" + hasSetActions()
|
+ " hasSetActions=" + hasSetActions()
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ public class PipBoundsAlgorithm {
|
|||||||
public float getAspectRatioOrDefault(
|
public float getAspectRatioOrDefault(
|
||||||
@android.annotation.Nullable PictureInPictureParams params) {
|
@android.annotation.Nullable PictureInPictureParams params) {
|
||||||
return params != null && params.hasSetAspectRatio()
|
return params != null && params.hasSetAspectRatio()
|
||||||
? params.getAspectRatio()
|
? params.getAspectRatioFloat()
|
||||||
: getDefaultAspectRatio();
|
: getDefaultAspectRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1071,13 +1071,13 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
|||||||
*/
|
*/
|
||||||
private boolean applyPictureInPictureParams(@NonNull PictureInPictureParams params) {
|
private boolean applyPictureInPictureParams(@NonNull PictureInPictureParams params) {
|
||||||
final Rational currentAspectRatio =
|
final Rational currentAspectRatio =
|
||||||
mPictureInPictureParams != null ? mPictureInPictureParams.getAspectRatioRational()
|
mPictureInPictureParams != null ? mPictureInPictureParams.getAspectRatio()
|
||||||
: null;
|
: null;
|
||||||
final boolean aspectRatioChanged = !Objects.equals(currentAspectRatio,
|
final boolean aspectRatioChanged = !Objects.equals(currentAspectRatio,
|
||||||
params.getAspectRatioRational());
|
params.getAspectRatio());
|
||||||
mPictureInPictureParams = params;
|
mPictureInPictureParams = params;
|
||||||
if (aspectRatioChanged) {
|
if (aspectRatioChanged) {
|
||||||
mPipBoundsState.setAspectRatio(params.getAspectRatio());
|
mPipBoundsState.setAspectRatio(params.getAspectRatioFloat());
|
||||||
}
|
}
|
||||||
return aspectRatioChanged;
|
return aspectRatioChanged;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class TvPipBoundsState extends PipBoundsState {
|
|||||||
public void setBoundsStateForEntry(ComponentName componentName, ActivityInfo activityInfo,
|
public void setBoundsStateForEntry(ComponentName componentName, ActivityInfo activityInfo,
|
||||||
PictureInPictureParams params, PipBoundsAlgorithm pipBoundsAlgorithm) {
|
PictureInPictureParams params, PipBoundsAlgorithm pipBoundsAlgorithm) {
|
||||||
super.setBoundsStateForEntry(componentName, activityInfo, params, pipBoundsAlgorithm);
|
super.setBoundsStateForEntry(componentName, activityInfo, params, pipBoundsAlgorithm);
|
||||||
setDesiredTvExpandedAspectRatio(params.getExpandedAspectRatio(), true);
|
setDesiredTvExpandedAspectRatio(params.getExpandedAspectRatioFloat(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resets the TV PiP state for a new activity. */
|
/** Resets the TV PiP state for a new activity. */
|
||||||
|
|||||||
@@ -746,8 +746,9 @@ class ActivityClientController extends IActivityClientController.Stub {
|
|||||||
// if it is not already expanding to fullscreen. Otherwise, the arguments will
|
// if it is not already expanding to fullscreen. Otherwise, the arguments will
|
||||||
// be used the next time the activity enters PiP.
|
// be used the next time the activity enters PiP.
|
||||||
final Task rootTask = r.getRootTask();
|
final Task rootTask = r.getRootTask();
|
||||||
rootTask.setPictureInPictureAspectRatio(r.pictureInPictureArgs.getAspectRatio(),
|
rootTask.setPictureInPictureAspectRatio(
|
||||||
r.pictureInPictureArgs.getExpandedAspectRatio());
|
r.pictureInPictureArgs.getAspectRatioFloat(),
|
||||||
|
r.pictureInPictureArgs.getExpandedAspectRatioFloat());
|
||||||
rootTask.setPictureInPictureActions(r.pictureInPictureArgs.getActions());
|
rootTask.setPictureInPictureActions(r.pictureInPictureArgs.getActions());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -828,7 +829,7 @@ class ActivityClientController extends IActivityClientController.Stub {
|
|||||||
|
|
||||||
if (params.hasSetAspectRatio()
|
if (params.hasSetAspectRatio()
|
||||||
&& !mService.mWindowManager.isValidPictureInPictureAspectRatio(
|
&& !mService.mWindowManager.isValidPictureInPictureAspectRatio(
|
||||||
r.mDisplayContent, params.getAspectRatio())) {
|
r.mDisplayContent, params.getAspectRatioFloat())) {
|
||||||
throw new IllegalArgumentException(String.format(caller
|
throw new IllegalArgumentException(String.format(caller
|
||||||
+ ": Aspect ratio is too extreme (must be between %f and %f).",
|
+ ": Aspect ratio is too extreme (must be between %f and %f).",
|
||||||
minAspectRatio, maxAspectRatio));
|
minAspectRatio, maxAspectRatio));
|
||||||
@@ -836,7 +837,7 @@ class ActivityClientController extends IActivityClientController.Stub {
|
|||||||
|
|
||||||
if (mService.mSupportsExpandedPictureInPicture && params.hasSetExpandedAspectRatio()
|
if (mService.mSupportsExpandedPictureInPicture && params.hasSetExpandedAspectRatio()
|
||||||
&& !mService.mWindowManager.isValidExpandedPictureInPictureAspectRatio(
|
&& !mService.mWindowManager.isValidExpandedPictureInPictureAspectRatio(
|
||||||
r.mDisplayContent, params.getExpandedAspectRatio())) {
|
r.mDisplayContent, params.getExpandedAspectRatioFloat())) {
|
||||||
throw new IllegalArgumentException(String.format(caller
|
throw new IllegalArgumentException(String.format(caller
|
||||||
+ ": Expanded aspect ratio is not extreme enough (must not be between"
|
+ ": Expanded aspect ratio is not extreme enough (must not be between"
|
||||||
+ " %f and %f).",
|
+ " %f and %f).",
|
||||||
|
|||||||
@@ -3523,8 +3523,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
}
|
}
|
||||||
// Only update the saved args from the args that are set
|
// Only update the saved args from the args that are set
|
||||||
r.setPictureInPictureParams(params);
|
r.setPictureInPictureParams(params);
|
||||||
final float aspectRatio = r.pictureInPictureArgs.getAspectRatio();
|
final float aspectRatio = r.pictureInPictureArgs.getAspectRatioFloat();
|
||||||
final float expandedAspectRatio = r.pictureInPictureArgs.getExpandedAspectRatio();
|
final float expandedAspectRatio =
|
||||||
|
r.pictureInPictureArgs.getExpandedAspectRatioFloat();
|
||||||
final List<RemoteAction> actions = r.pictureInPictureArgs.getActions();
|
final List<RemoteAction> actions = r.pictureInPictureArgs.getActions();
|
||||||
mRootWindowContainer.moveActivityToPinnedRootTask(r,
|
mRootWindowContainer.moveActivityToPinnedRootTask(r,
|
||||||
null /* launchIntoPipHostActivity */, "enterPictureInPictureMode");
|
null /* launchIntoPipHostActivity */, "enterPictureInPictureMode");
|
||||||
|
|||||||
@@ -932,7 +932,7 @@ public class WindowOrganizerTests extends WindowTestsBase {
|
|||||||
mWm.mAtmService.mTaskOrganizerController.dispatchPendingEvents();
|
mWm.mAtmService.mTaskOrganizerController.dispatchPendingEvents();
|
||||||
assertNotNull(o.mChangedInfo);
|
assertNotNull(o.mChangedInfo);
|
||||||
assertNotNull(o.mChangedInfo.pictureInPictureParams);
|
assertNotNull(o.mChangedInfo.pictureInPictureParams);
|
||||||
final Rational ratio = o.mChangedInfo.pictureInPictureParams.getAspectRatioRational();
|
final Rational ratio = o.mChangedInfo.pictureInPictureParams.getAspectRatio();
|
||||||
assertEquals(3, ratio.getNumerator());
|
assertEquals(3, ratio.getNumerator());
|
||||||
assertEquals(4, ratio.getDenominator());
|
assertEquals(4, ratio.getDenominator());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user