Merge "Set isInPictureInPictureMode earlier" into rvc-dev am: 3da602b640

Change-Id: Ib8f177257139994942df787a1f93cd5b06bd130b
This commit is contained in:
Hongwei Wang
2020-05-28 20:59:34 +00:00
committed by Automerger Merge Worker

View File

@@ -2838,7 +2838,13 @@ public class Activity extends ContextThemeWrapper
throw new IllegalStateException("Activity must be resumed to enter"
+ " picture-in-picture");
}
return ActivityTaskManager.getService().enterPictureInPictureMode(mToken, params);
// Set mIsInPictureInPictureMode earlier and don't wait for
// onPictureInPictureModeChanged callback here. This is to ensure that
// isInPictureInPictureMode returns true in the following onPause callback.
// See https://developer.android.com/guide/topics/ui/picture-in-picture for guidance.
mIsInPictureInPictureMode = ActivityTaskManager.getService().enterPictureInPictureMode(
mToken, params);
return mIsInPictureInPictureMode;
} catch (RemoteException e) {
return false;
}