summaryrefslogtreecommitdiff
path: root/core/java/android/app/Activity.java
diff options
context:
space:
mode:
authorjorgegil@google.com <jorgegil@google.com>2019-10-31 14:51:22 -0700
committerjorgegil@google.com <jorgegil@google.com>2019-12-20 14:38:25 -0800
commit06bc3233c75cd29ef02779ccc795a3a16f9f23f6 (patch)
tree0b510f6d44f727fac62589ae7798bf1b82c9f78f /core/java/android/app/Activity.java
parentfee05eb40bde02bb9238e95a851c6a7ee03e9f1d (diff)
Add #onPictureInPictureRequested to Activity and ATM
Allows vendors to signal that an activity should enter picture-in-picture if possible. Additionally, removes the need for an Activity to go through onPause to enter picture-in-picture. Apps can now override this new API and enter PIP from there instead of relying on #onUserLeaveHint. Bug: 143365086 Test: atest FrameworksCoreTests:android.app.activity.ActivityThreadTest Test: atest CtsWindowManagerDeviceTestCases:PinnedStackTests Test: atest WmTests:ActivityTaskManagerServiceTests Change-Id: Ib7ae9d1a7055ceed73e9643982033de9d4ad7350
Diffstat (limited to 'core/java/android/app/Activity.java')
-rw-r--r--core/java/android/app/Activity.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index ff581c059935..b397b3dc3eb9 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -2837,6 +2837,17 @@ public class Activity extends ContextThemeWrapper
return getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
}
+ /**
+ * Called by the system when picture in picture mode should be entered if supported.
+ */
+ 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);
+ }
+
void dispatchMovedToDisplay(int displayId, Configuration config) {
updateDisplay(displayId);
onMovedToDisplay(displayId, config);