Loading core/java/android/app/Activity.java +28 −13 Original line number Diff line number Diff line Loading @@ -762,6 +762,10 @@ public class Activity extends ContextThemeWrapper private boolean mDestroyed; private boolean mDoReportFullyDrawn = true; private boolean mRestoredFromBundle; /** {@code true} if the activity lifecycle is in a state which supports picture-in-picture. * This only affects the client-side exception, the actual state check still happens in AMS. */ private boolean mCanEnterPictureInPicture = false; /** true if the activity is going through a transient pause */ /*package*/ boolean mTemporaryPause = false; /** true if the activity is being destroyed in order to recreate it with a new configuration */ Loading Loading @@ -2091,6 +2095,10 @@ public class Activity extends ContextThemeWrapper if (params == null) { throw new IllegalArgumentException("Expected non-null picture-in-picture params"); } if (!mCanEnterPictureInPicture) { throw new IllegalStateException("Activity must be resumed to enter" + " picture-in-picture"); } return ActivityManagerNative.getDefault().enterPictureInPictureMode(mToken, params); } catch (RemoteException e) { return false; Loading Loading @@ -6957,25 +6965,29 @@ public class Activity extends ContextThemeWrapper return mParent != null ? mParent.getActivityToken() : mToken; } final void performCreateCommon() { mVisibleFromClient = !mWindow.getWindowStyle().getBoolean( com.android.internal.R.styleable.Window_windowNoDisplay, false); mFragments.dispatchActivityCreated(); mActivityTransitionState.setEnterActivityOptions(this, getActivityOptions()); } final void performCreate(Bundle icicle) { restoreHasCurrentPermissionRequest(icicle); onCreate(icicle); mActivityTransitionState.readState(icicle); performCreateCommon(); performCreate(icicle, null); } final void performCreate(Bundle icicle, PersistableBundle persistentState) { mCanEnterPictureInPicture = true; restoreHasCurrentPermissionRequest(icicle); if (persistentState != null) { onCreate(icicle, persistentState); } else { onCreate(icicle); } mActivityTransitionState.readState(icicle); performCreateCommon(); mVisibleFromClient = !mWindow.getWindowStyle().getBoolean( com.android.internal.R.styleable.Window_windowNoDisplay, false); mFragments.dispatchActivityCreated(); mActivityTransitionState.setEnterActivityOptions(this, getActivityOptions()); } final void performNewIntent(Intent intent) { mCanEnterPictureInPicture = true; onNewIntent(intent); } final void performStart() { Loading Loading @@ -7126,6 +7138,9 @@ public class Activity extends ContextThemeWrapper mDoReportFullyDrawn = false; mFragments.doLoaderStop(mChangingConfigurations /*retain*/); // Disallow entering picture-in-picture after the activity has been stopped mCanEnterPictureInPicture = false; if (!mStopped) { if (mWindow != null) { mWindow.closeAllPanels(); Loading core/java/android/app/Instrumentation.java +2 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.ViewConfiguration; import android.view.Window; import com.android.internal.content.ReferrerIntent; import java.io.File; Loading Loading @@ -1305,7 +1306,7 @@ public class Instrumentation { * @param intent The new intent being received. */ public void callActivityOnNewIntent(Activity activity, Intent intent) { activity.onNewIntent(intent); activity.performNewIntent(intent); } /** Loading services/core/java/com/android/server/am/ActivityManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -8046,7 +8046,7 @@ public class ActivityManagerService extends IActivityManager.Stub // Activity supports picture-in-picture, now check that we can enter PiP at this // point, if it is if (!r.checkEnterPictureInPictureState("enterPictureInPictureMode", false /* noThrow */, false /* beforeStopping */)) { false /* beforeStopping */)) { return false; } services/core/java/com/android/server/am/ActivityRecord.java +3 −10 Original line number Diff line number Diff line Loading @@ -1195,10 +1195,9 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo * @param beforeStopping Whether this check is for an auto-enter-pip operation, that is to say * the activity has requested to enter PiP when it would otherwise be stopped. * * @return whether this activity is currently allowed to enter PIP, throwing an exception if * the activity is not currently visible and {@param noThrow} is not set. * @return whether this activity is currently allowed to enter PIP. */ boolean checkEnterPictureInPictureState(String caller, boolean noThrow, boolean beforeStopping) { boolean checkEnterPictureInPictureState(String caller, boolean beforeStopping) { if (!supportsPictureInPicture()) { return false; } Loading Loading @@ -1246,13 +1245,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo return isNotLockedOrOnKeyguard && !hasPinnedStack; } default: if (noThrow) { return false; } else { throw new IllegalStateException(caller + ": Current activity is not visible (state=" + state.name() + ") " + "r=" + this); } } } Loading services/core/java/com/android/server/am/ActivityStack.java +2 −2 Original line number Diff line number Diff line Loading @@ -2081,7 +2081,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Making invisible: " + r + " " + r.state); try { final boolean canEnterPictureInPicture = r.checkEnterPictureInPictureState( "makeInvisible", true /* noThrow */, true /* beforeStopping */); "makeInvisible", true /* beforeStopping */); // Defer telling the client it is hidden if it can enter Pip and isn't current stopped // or stopping. This gives it a chance to enter Pip in onPause(). final boolean deferHidingClient = canEnterPictureInPicture Loading Loading @@ -2395,7 +2395,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai // represent the last resumed activity. However, the last focus stack does if it isn't null. final ActivityRecord lastResumed = lastFocusedStack.mResumedActivity; lastResumedCanPip = lastResumed != null && lastResumed.checkEnterPictureInPictureState( "resumeTopActivity", true /* noThrow */, userLeaving /* beforeStopping */); "resumeTopActivity", userLeaving /* beforeStopping */); } // If the flag RESUME_WHILE_PAUSING is set, then continue to schedule the previous activity // to be paused, while at the same time resuming the new resume activity only if the Loading Loading
core/java/android/app/Activity.java +28 −13 Original line number Diff line number Diff line Loading @@ -762,6 +762,10 @@ public class Activity extends ContextThemeWrapper private boolean mDestroyed; private boolean mDoReportFullyDrawn = true; private boolean mRestoredFromBundle; /** {@code true} if the activity lifecycle is in a state which supports picture-in-picture. * This only affects the client-side exception, the actual state check still happens in AMS. */ private boolean mCanEnterPictureInPicture = false; /** true if the activity is going through a transient pause */ /*package*/ boolean mTemporaryPause = false; /** true if the activity is being destroyed in order to recreate it with a new configuration */ Loading Loading @@ -2091,6 +2095,10 @@ public class Activity extends ContextThemeWrapper if (params == null) { throw new IllegalArgumentException("Expected non-null picture-in-picture params"); } if (!mCanEnterPictureInPicture) { throw new IllegalStateException("Activity must be resumed to enter" + " picture-in-picture"); } return ActivityManagerNative.getDefault().enterPictureInPictureMode(mToken, params); } catch (RemoteException e) { return false; Loading Loading @@ -6957,25 +6965,29 @@ public class Activity extends ContextThemeWrapper return mParent != null ? mParent.getActivityToken() : mToken; } final void performCreateCommon() { mVisibleFromClient = !mWindow.getWindowStyle().getBoolean( com.android.internal.R.styleable.Window_windowNoDisplay, false); mFragments.dispatchActivityCreated(); mActivityTransitionState.setEnterActivityOptions(this, getActivityOptions()); } final void performCreate(Bundle icicle) { restoreHasCurrentPermissionRequest(icicle); onCreate(icicle); mActivityTransitionState.readState(icicle); performCreateCommon(); performCreate(icicle, null); } final void performCreate(Bundle icicle, PersistableBundle persistentState) { mCanEnterPictureInPicture = true; restoreHasCurrentPermissionRequest(icicle); if (persistentState != null) { onCreate(icicle, persistentState); } else { onCreate(icicle); } mActivityTransitionState.readState(icicle); performCreateCommon(); mVisibleFromClient = !mWindow.getWindowStyle().getBoolean( com.android.internal.R.styleable.Window_windowNoDisplay, false); mFragments.dispatchActivityCreated(); mActivityTransitionState.setEnterActivityOptions(this, getActivityOptions()); } final void performNewIntent(Intent intent) { mCanEnterPictureInPicture = true; onNewIntent(intent); } final void performStart() { Loading Loading @@ -7126,6 +7138,9 @@ public class Activity extends ContextThemeWrapper mDoReportFullyDrawn = false; mFragments.doLoaderStop(mChangingConfigurations /*retain*/); // Disallow entering picture-in-picture after the activity has been stopped mCanEnterPictureInPicture = false; if (!mStopped) { if (mWindow != null) { mWindow.closeAllPanels(); Loading
core/java/android/app/Instrumentation.java +2 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.ViewConfiguration; import android.view.Window; import com.android.internal.content.ReferrerIntent; import java.io.File; Loading Loading @@ -1305,7 +1306,7 @@ public class Instrumentation { * @param intent The new intent being received. */ public void callActivityOnNewIntent(Activity activity, Intent intent) { activity.onNewIntent(intent); activity.performNewIntent(intent); } /** Loading
services/core/java/com/android/server/am/ActivityManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -8046,7 +8046,7 @@ public class ActivityManagerService extends IActivityManager.Stub // Activity supports picture-in-picture, now check that we can enter PiP at this // point, if it is if (!r.checkEnterPictureInPictureState("enterPictureInPictureMode", false /* noThrow */, false /* beforeStopping */)) { false /* beforeStopping */)) { return false; }
services/core/java/com/android/server/am/ActivityRecord.java +3 −10 Original line number Diff line number Diff line Loading @@ -1195,10 +1195,9 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo * @param beforeStopping Whether this check is for an auto-enter-pip operation, that is to say * the activity has requested to enter PiP when it would otherwise be stopped. * * @return whether this activity is currently allowed to enter PIP, throwing an exception if * the activity is not currently visible and {@param noThrow} is not set. * @return whether this activity is currently allowed to enter PIP. */ boolean checkEnterPictureInPictureState(String caller, boolean noThrow, boolean beforeStopping) { boolean checkEnterPictureInPictureState(String caller, boolean beforeStopping) { if (!supportsPictureInPicture()) { return false; } Loading Loading @@ -1246,13 +1245,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo return isNotLockedOrOnKeyguard && !hasPinnedStack; } default: if (noThrow) { return false; } else { throw new IllegalStateException(caller + ": Current activity is not visible (state=" + state.name() + ") " + "r=" + this); } } } Loading
services/core/java/com/android/server/am/ActivityStack.java +2 −2 Original line number Diff line number Diff line Loading @@ -2081,7 +2081,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Making invisible: " + r + " " + r.state); try { final boolean canEnterPictureInPicture = r.checkEnterPictureInPictureState( "makeInvisible", true /* noThrow */, true /* beforeStopping */); "makeInvisible", true /* beforeStopping */); // Defer telling the client it is hidden if it can enter Pip and isn't current stopped // or stopping. This gives it a chance to enter Pip in onPause(). final boolean deferHidingClient = canEnterPictureInPicture Loading Loading @@ -2395,7 +2395,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai // represent the last resumed activity. However, the last focus stack does if it isn't null. final ActivityRecord lastResumed = lastFocusedStack.mResumedActivity; lastResumedCanPip = lastResumed != null && lastResumed.checkEnterPictureInPictureState( "resumeTopActivity", true /* noThrow */, userLeaving /* beforeStopping */); "resumeTopActivity", userLeaving /* beforeStopping */); } // If the flag RESUME_WHILE_PAUSING is set, then continue to schedule the previous activity // to be paused, while at the same time resuming the new resume activity only if the Loading