From: Winson Chung Date: Tue, 13 Dec 2016 19:49:09 +0000 (-0800) Subject: Remove dependency on resizable activity to enter PiP. X-Git-Tag: android-x86-8.1-r1~4874^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d339538a67b7d6bb3d7ad73f31ad20ffc932f891;p=android-x86%2Fframeworks-base.git Remove dependency on resizable activity to enter PiP. - Removing the requirement for activities to have both the resizeableActivity and supportsPictureInPicture attribute to enter PiP. The activity may still be resized when entering picture-in-picture. Bug: 34256643 Test: android.server.cts.ActivityManagerPinnedStackTests Change-Id: If6bd4721c53072e5518f554a8c7598705517c132 --- diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index a9d1cf6e490f..8f169c85d676 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -3108,7 +3108,7 @@ public class Activity extends ContextThemeWrapper */ @Override public void enterPictureInPictureModeIfPossible() { - if (mActivityInfo.resizeMode == ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE) { + if (mActivityInfo.supportsPictureInPicture()) { enterPictureInPictureMode(); } } diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index c1a888d28428..3cb920a6f28d 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -1482,7 +1482,7 @@ public class ActivityManager { * True if the task can go in the docked stack. * @hide */ - public boolean isDockable; + public boolean supportsSplitScreenMultiWindow; /** * The resize mode of the task. See {@link ActivityInfo#resizeMode}. @@ -1533,7 +1533,7 @@ public class ActivityManager { } else { dest.writeInt(0); } - dest.writeInt(isDockable ? 1 : 0); + dest.writeInt(supportsSplitScreenMultiWindow ? 1 : 0); dest.writeInt(resizeMode); } @@ -1557,7 +1557,7 @@ public class ActivityManager { numActivities = source.readInt(); bounds = source.readInt() > 0 ? Rect.CREATOR.createFromParcel(source) : null; - isDockable = source.readInt() == 1; + supportsSplitScreenMultiWindow = source.readInt() == 1; resizeMode = source.readInt(); } @@ -1745,7 +1745,7 @@ public class ActivityManager { * True if the task can go in the docked stack. * @hide */ - public boolean isDockable; + public boolean supportsSplitScreenMultiWindow; /** * The resize mode of the task. See {@link ActivityInfo#resizeMode}. @@ -1775,7 +1775,7 @@ public class ActivityManager { Parcelable.PARCELABLE_WRITE_RETURN_VALUE); dest.writeInt(numActivities); dest.writeInt(numRunning); - dest.writeInt(isDockable ? 1 : 0); + dest.writeInt(supportsSplitScreenMultiWindow ? 1 : 0); dest.writeInt(resizeMode); } @@ -1792,7 +1792,7 @@ public class ActivityManager { description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source); numActivities = source.readInt(); numRunning = source.readInt(); - isDockable = source.readInt() != 0; + supportsSplitScreenMultiWindow = source.readInt() != 0; resizeMode = source.readInt(); } diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index 4bd091dae77e..4a94688315e8 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -177,10 +177,14 @@ public class ActivityInfo extends ComponentInfo */ public static final int RESIZE_MODE_RESIZEABLE = 2; /** - * Activity is resizeable and supported picture-in-picture mode. + * Activity is resizeable and supported picture-in-picture mode. This flag is now deprecated + * since activities do not need to be resizeable to support picture-in-picture. + * See {@link #FLAG_SUPPORTS_PICTURE_IN_PICTURE}. + * * @hide + * @deprecated */ - public static final int RESIZE_MODE_RESIZEABLE_AND_PIPABLE = 3; + public static final int RESIZE_MODE_RESIZEABLE_AND_PIPABLE_DEPRECATED = 3; /** * Activity does not support resizing, but we are forcing it to be resizeable. Only affects * certain pre-N apps where we force them to be resizeable. @@ -369,6 +373,13 @@ public class ActivityInfo extends ComponentInfo public static final int FLAG_VISIBLE_TO_EPHEMERAL = 0x100000; /** + * Bit in {@link #flags} indicating if the activity supports picture-in-picture mode. + * See {@link android.R.attr#supportsPictureInPicture}. + * @hide + */ + public static final int FLAG_SUPPORTS_PICTURE_IN_PICTURE = 0x200000; + + /** * @hide Bit in {@link #flags}: If set, this component will only be seen * by the system user. Only works with broadcast receivers. Set from the * android.R.attr#systemUserOnly attribute. @@ -926,10 +937,17 @@ public class ActivityInfo extends ComponentInfo || screenOrientation == SCREEN_ORIENTATION_USER_PORTRAIT; } + /** + * Returns true if the activity supports picture-in-picture. + * @hide + */ + public boolean supportsPictureInPicture() { + return (flags & FLAG_SUPPORTS_PICTURE_IN_PICTURE) != 0; + } + /** @hide */ public static boolean isResizeableMode(int mode) { return mode == RESIZE_MODE_RESIZEABLE - || mode == RESIZE_MODE_RESIZEABLE_AND_PIPABLE || mode == RESIZE_MODE_FORCE_RESIZEABLE || mode == RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY || mode == RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY @@ -953,8 +971,6 @@ public class ActivityInfo extends ComponentInfo return "RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION"; case RESIZE_MODE_RESIZEABLE: return "RESIZE_MODE_RESIZEABLE"; - case RESIZE_MODE_RESIZEABLE_AND_PIPABLE: - return "RESIZE_MODE_RESIZEABLE_AND_PIPABLE"; case RESIZE_MODE_FORCE_RESIZEABLE: return "RESIZE_MODE_FORCE_RESIZEABLE"; case RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY: diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index ca3011e0c7fb..43ebf46f4996 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -18,12 +18,12 @@ package android.content.pm; import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE; import static android.content.pm.ActivityInfo.FLAG_ON_TOP_LAUNCHER; +import static android.content.pm.ActivityInfo.FLAG_SUPPORTS_PICTURE_IN_PICTURE; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE; import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE; -import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE; import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION; import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; @@ -2402,7 +2402,7 @@ public class PackageParser { // cannot be windowed / resized. Note that an SDK version of 0 is common for // pre-Doughnut applications. if (pkg.applicationInfo.usesCompatibilityMode()) { - adjustPackageToBeUnresizeable(pkg); + adjustPackageToBeUnresizeableAndUnpipable(pkg); } return pkg; } @@ -2413,9 +2413,10 @@ public class PackageParser { * * @param pkg The package which needs to be marked as unresizable. */ - private void adjustPackageToBeUnresizeable(Package pkg) { + private void adjustPackageToBeUnresizeableAndUnpipable(Package pkg) { for (Activity a : pkg.activities) { a.info.resizeMode = RESIZE_MODE_UNRESIZEABLE; + a.info.flags &= ~FLAG_SUPPORTS_PICTURE_IN_PICTURE; } } @@ -4000,6 +4001,11 @@ public class PackageParser { setActivityResizeMode(a.info, sa, owner); + if (sa.getBoolean(R.styleable.AndroidManifestActivity_supportsPictureInPicture, + false)) { + a.info.flags |= FLAG_SUPPORTS_PICTURE_IN_PICTURE; + } + if (sa.getBoolean(R.styleable.AndroidManifestActivity_alwaysFocusable, false)) { a.info.flags |= FLAG_ALWAYS_FOCUSABLE; } @@ -4161,16 +4167,13 @@ public class PackageParser { private void setActivityResizeMode(ActivityInfo aInfo, TypedArray sa, Package owner) { final boolean appExplicitDefault = (owner.applicationInfo.privateFlags & PRIVATE_FLAG_RESIZEABLE_ACTIVITIES_EXPLICITLY_SET) != 0; - final boolean supportsPip = - sa.getBoolean(R.styleable.AndroidManifestActivity_supportsPictureInPicture, false); if (sa.hasValue(R.styleable.AndroidManifestActivity_resizeableActivity) || appExplicitDefault) { // Activity or app explicitly set if it is resizeable or not; if (sa.getBoolean(R.styleable.AndroidManifestActivity_resizeableActivity, appExplicitDefault)) { - aInfo.resizeMode = - supportsPip ? RESIZE_MODE_RESIZEABLE_AND_PIPABLE : RESIZE_MODE_RESIZEABLE; + aInfo.resizeMode = RESIZE_MODE_RESIZEABLE; } else { aInfo.resizeMode = RESIZE_MODE_UNRESIZEABLE; } diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index dfa672d6782c..64a64f79b4c3 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -1159,18 +1159,15 @@ resizeable activities when in multi-window mode. --> - +

The default value is false. -->