Loading api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -3850,7 +3850,7 @@ package android.app { method public void onPerformDirectAction(@NonNull String, @NonNull android.os.Bundle, @NonNull android.os.CancellationSignal, @NonNull java.util.function.Consumer<android.os.Bundle>); method public void onPictureInPictureModeChanged(boolean, android.content.res.Configuration); method @Deprecated public void onPictureInPictureModeChanged(boolean); method public void onPictureInPictureRequested(); method public boolean onPictureInPictureRequested(); method @CallSuper protected void onPostCreate(@Nullable android.os.Bundle); method public void onPostCreate(@Nullable android.os.Bundle, @Nullable android.os.PersistableBundle); method @CallSuper protected void onPostResume(); core/java/android/app/Activity.java +7 −6 Original line number Diff line number Diff line Loading @@ -2880,13 +2880,14 @@ public class Activity extends ContextThemeWrapper * {@link #enterPictureInPictureMode(PictureInPictureParams)} at this time. For example, the * system will call this method when the activity is being put into the background, so the app * developer might want to switch an activity into PIP mode instead.</p> * * @return {@code true} if the activity received this callback regardless of if it acts on it * or not. If {@code false}, the framework will assume the app hasn't been updated to leverage * this callback and will in turn send a legacy callback of {@link #onUserLeaveHint()} for the * app to enter picture-in-picture mode. */ public void onPictureInPictureRequested() { // Previous recommendation was for apps to enter picture-in-picture in onUserLeaveHint() // which is sent after onPause(). This new method allows the system to request the app to // go into picture-in-picture decoupling it from life cycle events. For backwards // compatibility we schedule the life cycle events if the app didn't override this method. mMainThread.schedulePauseAndReturnToCurrentState(mToken); public boolean onPictureInPictureRequested() { return false; } void dispatchMovedToDisplay(int displayId, Configuration config) { Loading core/java/android/app/ActivityThread.java +10 −15 Original line number Diff line number Diff line Loading @@ -3772,7 +3772,15 @@ public final class ActivityThread extends ClientTransactionHandler { return; } r.activity.onPictureInPictureRequested(); final boolean receivedByApp = r.activity.onPictureInPictureRequested(); if (!receivedByApp) { // Previous recommendation was for apps to enter picture-in-picture in // onUserLeavingHint() for cases such as the app being put into the background. For // backwards compatibility with apps that are not using the newer // onPictureInPictureRequested() callback, we schedule the life cycle events needed to // trigger onUserLeavingHint(), then we return the activity to its previous state. schedulePauseWithUserLeaveHintAndReturnToCurrentState(r); } } /** Loading @@ -3780,18 +3788,7 @@ public final class ActivityThread extends ClientTransactionHandler { * return to its previous state. This allows activities that rely on onUserLeaveHint instead of * onPictureInPictureRequested to enter picture-in-picture. */ public void schedulePauseAndReturnToCurrentState(IBinder token) { final ActivityClientRecord r = mActivities.get(token); if (r == null) { Log.w(TAG, "Activity to request pause with user leaving hint to no longer exists"); return; } if (r.mIsUserLeaving) { // The activity is about to perform user leaving, so there's no need to cycle ourselves. return; } private void schedulePauseWithUserLeaveHintAndReturnToCurrentState(ActivityClientRecord r) { final int prevState = r.getLifecycleState(); if (prevState != ON_RESUME && prevState != ON_PAUSE) { return; Loading Loading @@ -4544,7 +4541,6 @@ public final class ActivityThread extends ClientTransactionHandler { if (r != null) { if (userLeaving) { performUserLeavingActivity(r); r.mIsUserLeaving = false; } r.activity.mConfigChangeFlags |= configChanges; Loading @@ -4559,7 +4555,6 @@ public final class ActivityThread extends ClientTransactionHandler { } final void performUserLeavingActivity(ActivityClientRecord r) { r.mIsUserLeaving = true; mInstrumentation.callActivityOnPictureInPictureRequested(r.activity); mInstrumentation.callActivityOnUserLeaving(r.activity); } Loading core/tests/coretests/src/android/app/activity/ActivityThreadTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -504,15 +504,17 @@ public class ActivityThreadTest { } @Override public void onPictureInPictureRequested() { public boolean onPictureInPictureRequested() { mPipRequested = true; if (getIntent().getBooleanExtra(PIP_REQUESTED_OVERRIDE_ENTER, false)) { enterPictureInPictureMode(new PictureInPictureParams.Builder().build()); mPipEntered = true; return true; } else if (getIntent().getBooleanExtra(PIP_REQUESTED_OVERRIDE_SKIP, false)) { mPipEnterSkipped = true; return false; } super.onPictureInPictureRequested(); return super.onPictureInPictureRequested(); } boolean pipRequested() { Loading Loading
api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -3850,7 +3850,7 @@ package android.app { method public void onPerformDirectAction(@NonNull String, @NonNull android.os.Bundle, @NonNull android.os.CancellationSignal, @NonNull java.util.function.Consumer<android.os.Bundle>); method public void onPictureInPictureModeChanged(boolean, android.content.res.Configuration); method @Deprecated public void onPictureInPictureModeChanged(boolean); method public void onPictureInPictureRequested(); method public boolean onPictureInPictureRequested(); method @CallSuper protected void onPostCreate(@Nullable android.os.Bundle); method public void onPostCreate(@Nullable android.os.Bundle, @Nullable android.os.PersistableBundle); method @CallSuper protected void onPostResume();
core/java/android/app/Activity.java +7 −6 Original line number Diff line number Diff line Loading @@ -2880,13 +2880,14 @@ public class Activity extends ContextThemeWrapper * {@link #enterPictureInPictureMode(PictureInPictureParams)} at this time. For example, the * system will call this method when the activity is being put into the background, so the app * developer might want to switch an activity into PIP mode instead.</p> * * @return {@code true} if the activity received this callback regardless of if it acts on it * or not. If {@code false}, the framework will assume the app hasn't been updated to leverage * this callback and will in turn send a legacy callback of {@link #onUserLeaveHint()} for the * app to enter picture-in-picture mode. */ public void onPictureInPictureRequested() { // Previous recommendation was for apps to enter picture-in-picture in onUserLeaveHint() // which is sent after onPause(). This new method allows the system to request the app to // go into picture-in-picture decoupling it from life cycle events. For backwards // compatibility we schedule the life cycle events if the app didn't override this method. mMainThread.schedulePauseAndReturnToCurrentState(mToken); public boolean onPictureInPictureRequested() { return false; } void dispatchMovedToDisplay(int displayId, Configuration config) { Loading
core/java/android/app/ActivityThread.java +10 −15 Original line number Diff line number Diff line Loading @@ -3772,7 +3772,15 @@ public final class ActivityThread extends ClientTransactionHandler { return; } r.activity.onPictureInPictureRequested(); final boolean receivedByApp = r.activity.onPictureInPictureRequested(); if (!receivedByApp) { // Previous recommendation was for apps to enter picture-in-picture in // onUserLeavingHint() for cases such as the app being put into the background. For // backwards compatibility with apps that are not using the newer // onPictureInPictureRequested() callback, we schedule the life cycle events needed to // trigger onUserLeavingHint(), then we return the activity to its previous state. schedulePauseWithUserLeaveHintAndReturnToCurrentState(r); } } /** Loading @@ -3780,18 +3788,7 @@ public final class ActivityThread extends ClientTransactionHandler { * return to its previous state. This allows activities that rely on onUserLeaveHint instead of * onPictureInPictureRequested to enter picture-in-picture. */ public void schedulePauseAndReturnToCurrentState(IBinder token) { final ActivityClientRecord r = mActivities.get(token); if (r == null) { Log.w(TAG, "Activity to request pause with user leaving hint to no longer exists"); return; } if (r.mIsUserLeaving) { // The activity is about to perform user leaving, so there's no need to cycle ourselves. return; } private void schedulePauseWithUserLeaveHintAndReturnToCurrentState(ActivityClientRecord r) { final int prevState = r.getLifecycleState(); if (prevState != ON_RESUME && prevState != ON_PAUSE) { return; Loading Loading @@ -4544,7 +4541,6 @@ public final class ActivityThread extends ClientTransactionHandler { if (r != null) { if (userLeaving) { performUserLeavingActivity(r); r.mIsUserLeaving = false; } r.activity.mConfigChangeFlags |= configChanges; Loading @@ -4559,7 +4555,6 @@ public final class ActivityThread extends ClientTransactionHandler { } final void performUserLeavingActivity(ActivityClientRecord r) { r.mIsUserLeaving = true; mInstrumentation.callActivityOnPictureInPictureRequested(r.activity); mInstrumentation.callActivityOnUserLeaving(r.activity); } Loading
core/tests/coretests/src/android/app/activity/ActivityThreadTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -504,15 +504,17 @@ public class ActivityThreadTest { } @Override public void onPictureInPictureRequested() { public boolean onPictureInPictureRequested() { mPipRequested = true; if (getIntent().getBooleanExtra(PIP_REQUESTED_OVERRIDE_ENTER, false)) { enterPictureInPictureMode(new PictureInPictureParams.Builder().build()); mPipEntered = true; return true; } else if (getIntent().getBooleanExtra(PIP_REQUESTED_OVERRIDE_SKIP, false)) { mPipEnterSkipped = true; return false; } super.onPictureInPictureRequested(); return super.onPictureInPictureRequested(); } boolean pipRequested() { Loading