summaryrefslogtreecommitdiff
path: root/core/java/android/app/ActivityThread.java
diff options
context:
space:
mode:
authorjorgegil@google.com <jorgegil@google.com>2020-02-03 13:21:27 -0800
committerjorgegil@google.com <jorgegil@google.com>2020-02-04 13:38:25 -0800
commitb8ee18f00287ed2bbf3589bd132e66e6623eac26 (patch)
tree5452924c24cecee868689a25526bf4ba6a4004fd /core/java/android/app/ActivityThread.java
parent7bbfd92d84a54a88e585572b15efe58359b09076 (diff)
Move compat behavior in #onPipRequested to ActivityThread
Removes the pause-hint-resume cycle to trigger PiP out of the default implementation of #onPictureInPictureRequested and replaces it with a bool check in its caller in ActivityThread. This prevents exposing the pause/resume cycle to the public API. Bug: 148011369 Test: atest FrameworksCoreTests:android.app.activity.ActivityThreadTest Test: atest CtsWindowManagerDeviceTestCases:PinnedStackTests Test: atest WmTests:ActivityTaskManagerServiceTests Change-Id: Iec4f602ccf411a31f0cee5a4599cf2fea6f25994
Diffstat (limited to 'core/java/android/app/ActivityThread.java')
-rw-r--r--core/java/android/app/ActivityThread.java25
1 files changed, 10 insertions, 15 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index c901d2a29821..192156726984 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -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);
+ }
}
/**
@@ -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;
@@ -4544,7 +4541,6 @@ public final class ActivityThread extends ClientTransactionHandler {
if (r != null) {
if (userLeaving) {
performUserLeavingActivity(r);
- r.mIsUserLeaving = false;
}
r.activity.mConfigChangeFlags |= configChanges;
@@ -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);
}