diff options
| author | 2023-05-01 21:11:16 -0700 | |
|---|---|---|
| committer | 2023-05-01 22:11:37 -0700 | |
| commit | 07cac275a676ef6df8de92f7f27a69274f3ca89e (patch) | |
| tree | 31eae04816d0049c87c9cba48b79b97cdc2bf7fd | |
| parent | ba26bf97c512403710670ee31eb018c6185194ab (diff) | |
Forward auto-enter property to app's onPause
Pause happens in a different code-path in shell vs
legacy during auto-pip. This path doesn't have auto-enter
context so the app was being told to pause without
being told the pause was due to auto-pip. This CL
adds a state to the ActivityRecord so that when it
pauses, it can send the corresponding autoPip value.
Bug: 280065861
Test: play video in netflix, swipe-to-pip.
Or, monitor logs and check that pause during autopip has
autopip set.
Change-Id: I37ef091f3daf483cd12b5c20a796170f49f6db08
3 files changed, 14 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 25e5dacb25e3..95a5abf84616 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -582,6 +582,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A boolean mPauseSchedulePendingForPip = false; + // Gets set to indicate that the activity is currently being auto-pipped. + boolean mAutoEnteringPip = false; + private void updateEnterpriseThumbnailDrawable(Context context) { DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class); mEnterpriseThumbnailDrawable = dpm.getResources().getDrawable( @@ -6094,8 +6097,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A try { mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, PauseActivityItem.obtain(finishing, false /* userLeaving */, - configChangeFlags, false /* dontReport */, - false /* autoEnteringPip */)); + configChangeFlags, false /* dontReport */, mAutoEnteringPip)); } catch (Exception e) { Slog.w(TAG, "Exception thrown sending pause: " + intent.getComponent(), e); } diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index a0ea1c3dbdbf..f86df2aa9bed 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -3592,15 +3592,21 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } + boolean enterPictureInPictureMode(@NonNull ActivityRecord r, + @NonNull PictureInPictureParams params, boolean fromClient) { + return enterPictureInPictureMode(r, params, fromClient, false /* isAutoEnter */); + } + /** * Puts the given activity in picture in picture mode if possible. * * @param fromClient true if this comes from a client call (eg. Activity.enterPip). + * @param isAutoEnter true if this comes from an automatic pip-enter. * @return true if the activity is now in picture-in-picture mode, or false if it could not * enter picture-in-picture mode. */ boolean enterPictureInPictureMode(@NonNull ActivityRecord r, - @NonNull PictureInPictureParams params, boolean fromClient) { + @NonNull PictureInPictureParams params, boolean fromClient, boolean isAutoEnter) { // If the activity is already in picture in picture mode, then just return early if (r.inPinnedWindowingMode()) { return true; @@ -3635,6 +3641,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { return; } r.setPictureInPictureParams(params); + r.mAutoEnteringPip = isAutoEnter; mRootWindowContainer.moveActivityToPinnedRootTask(r, null /* launchIntoPipHostActivity */, "enterPictureInPictureMode", transition); @@ -3643,6 +3650,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { r.getTask().schedulePauseActivity(r, false /* userLeaving */, false /* pauseImmediately */, true /* autoEnteringPip */, "auto-pip"); } + r.mAutoEnteringPip = false; } }; diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 7bd3b3253614..5cb104784853 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -955,7 +955,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { ar.supportsEnterPipOnTaskSwitch = true; } return mController.mAtm.enterPictureInPictureMode(ar, ar.pictureInPictureArgs, - false /* fromClient */); + false /* fromClient */, true /* isAutoEnter */); } // Legacy pip-entry (not via isAutoEnterEnabled). |