Merge "Ensure isInPictureInPicture result in onPause" into tm-qpr-dev am: 121302c41d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19489109 Change-Id: I9dd06305bce7c87a4a0a09d705555d16a8dca228 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -980,7 +980,8 @@ public class Activity extends ContextThemeWrapper
|
||||
boolean mEnterAnimationComplete;
|
||||
|
||||
private boolean mIsInMultiWindowMode;
|
||||
private boolean mIsInPictureInPictureMode;
|
||||
/** @hide */
|
||||
boolean mIsInPictureInPictureMode;
|
||||
|
||||
private boolean mShouldDockBigOverlays;
|
||||
|
||||
|
||||
@@ -4162,7 +4162,8 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
private void schedulePauseWithUserLeavingHint(ActivityClientRecord r) {
|
||||
final ClientTransaction transaction = ClientTransaction.obtain(this.mAppThread, r.token);
|
||||
transaction.setLifecycleStateRequest(PauseActivityItem.obtain(r.activity.isFinishing(),
|
||||
/* userLeaving */ true, r.activity.mConfigChangeFlags, /* dontReport */ false));
|
||||
/* userLeaving */ true, r.activity.mConfigChangeFlags, /* dontReport */ false,
|
||||
/* autoEnteringPip */ false));
|
||||
executeTransaction(transaction);
|
||||
}
|
||||
|
||||
@@ -4952,12 +4953,18 @@ public final class ActivityThread extends ClientTransactionHandler
|
||||
|
||||
@Override
|
||||
public void handlePauseActivity(ActivityClientRecord r, boolean finished, boolean userLeaving,
|
||||
int configChanges, PendingTransactionActions pendingActions, String reason) {
|
||||
int configChanges, boolean autoEnteringPip, PendingTransactionActions pendingActions,
|
||||
String reason) {
|
||||
if (userLeaving) {
|
||||
performUserLeavingActivity(r);
|
||||
}
|
||||
|
||||
r.activity.mConfigChangeFlags |= configChanges;
|
||||
if (autoEnteringPip) {
|
||||
// Set mIsInPictureInPictureMode earlier in case of auto-enter-pip, see also
|
||||
// {@link Activity#enterPictureInPictureMode(PictureInPictureParams)}.
|
||||
r.activity.mIsInPictureInPictureMode = true;
|
||||
}
|
||||
performPauseActivity(r, finished, reason, pendingActions);
|
||||
|
||||
// Make sure any pending writes are now committed.
|
||||
|
||||
@@ -97,8 +97,8 @@ public abstract class ClientTransactionHandler {
|
||||
|
||||
/** Pause the activity. */
|
||||
public abstract void handlePauseActivity(@NonNull ActivityClientRecord r, boolean finished,
|
||||
boolean userLeaving, int configChanges, PendingTransactionActions pendingActions,
|
||||
String reason);
|
||||
boolean userLeaving, int configChanges, boolean autoEnteringPip,
|
||||
PendingTransactionActions pendingActions, String reason);
|
||||
|
||||
/**
|
||||
* Resume the activity.
|
||||
|
||||
@@ -39,13 +39,14 @@ public class PauseActivityItem extends ActivityLifecycleItem {
|
||||
private boolean mUserLeaving;
|
||||
private int mConfigChanges;
|
||||
private boolean mDontReport;
|
||||
private boolean mAutoEnteringPip;
|
||||
|
||||
@Override
|
||||
public void execute(ClientTransactionHandler client, ActivityClientRecord r,
|
||||
PendingTransactionActions pendingActions) {
|
||||
Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "activityPause");
|
||||
client.handlePauseActivity(r, mFinished, mUserLeaving, mConfigChanges, pendingActions,
|
||||
"PAUSE_ACTIVITY_ITEM");
|
||||
client.handlePauseActivity(r, mFinished, mUserLeaving, mConfigChanges, mAutoEnteringPip,
|
||||
pendingActions, "PAUSE_ACTIVITY_ITEM");
|
||||
Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ public class PauseActivityItem extends ActivityLifecycleItem {
|
||||
|
||||
/** Obtain an instance initialized with provided params. */
|
||||
public static PauseActivityItem obtain(boolean finished, boolean userLeaving, int configChanges,
|
||||
boolean dontReport) {
|
||||
boolean dontReport, boolean autoEnteringPip) {
|
||||
PauseActivityItem instance = ObjectPool.obtain(PauseActivityItem.class);
|
||||
if (instance == null) {
|
||||
instance = new PauseActivityItem();
|
||||
@@ -80,6 +81,7 @@ public class PauseActivityItem extends ActivityLifecycleItem {
|
||||
instance.mUserLeaving = userLeaving;
|
||||
instance.mConfigChanges = configChanges;
|
||||
instance.mDontReport = dontReport;
|
||||
instance.mAutoEnteringPip = autoEnteringPip;
|
||||
|
||||
return instance;
|
||||
}
|
||||
@@ -94,6 +96,7 @@ public class PauseActivityItem extends ActivityLifecycleItem {
|
||||
instance.mUserLeaving = false;
|
||||
instance.mConfigChanges = 0;
|
||||
instance.mDontReport = true;
|
||||
instance.mAutoEnteringPip = false;
|
||||
|
||||
return instance;
|
||||
}
|
||||
@@ -105,6 +108,7 @@ public class PauseActivityItem extends ActivityLifecycleItem {
|
||||
mUserLeaving = false;
|
||||
mConfigChanges = 0;
|
||||
mDontReport = false;
|
||||
mAutoEnteringPip = false;
|
||||
ObjectPool.recycle(this);
|
||||
}
|
||||
|
||||
@@ -117,6 +121,7 @@ public class PauseActivityItem extends ActivityLifecycleItem {
|
||||
dest.writeBoolean(mUserLeaving);
|
||||
dest.writeInt(mConfigChanges);
|
||||
dest.writeBoolean(mDontReport);
|
||||
dest.writeBoolean(mAutoEnteringPip);
|
||||
}
|
||||
|
||||
/** Read from Parcel. */
|
||||
@@ -125,6 +130,7 @@ public class PauseActivityItem extends ActivityLifecycleItem {
|
||||
mUserLeaving = in.readBoolean();
|
||||
mConfigChanges = in.readInt();
|
||||
mDontReport = in.readBoolean();
|
||||
mAutoEnteringPip = in.readBoolean();
|
||||
}
|
||||
|
||||
public static final @NonNull Creator<PauseActivityItem> CREATOR =
|
||||
@@ -148,7 +154,8 @@ public class PauseActivityItem extends ActivityLifecycleItem {
|
||||
}
|
||||
final PauseActivityItem other = (PauseActivityItem) o;
|
||||
return mFinished == other.mFinished && mUserLeaving == other.mUserLeaving
|
||||
&& mConfigChanges == other.mConfigChanges && mDontReport == other.mDontReport;
|
||||
&& mConfigChanges == other.mConfigChanges && mDontReport == other.mDontReport
|
||||
&& mAutoEnteringPip == other.mAutoEnteringPip;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,12 +165,14 @@ public class PauseActivityItem extends ActivityLifecycleItem {
|
||||
result = 31 * result + (mUserLeaving ? 1 : 0);
|
||||
result = 31 * result + mConfigChanges;
|
||||
result = 31 * result + (mDontReport ? 1 : 0);
|
||||
result = 31 * result + (mAutoEnteringPip ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PauseActivityItem{finished=" + mFinished + ",userLeaving=" + mUserLeaving
|
||||
+ ",configChanges=" + mConfigChanges + ",dontReport=" + mDontReport + "}";
|
||||
+ ",configChanges=" + mConfigChanges + ",dontReport=" + mDontReport
|
||||
+ ",autoEnteringPip=" + mAutoEnteringPip + "}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,8 @@ public class TransactionExecutor {
|
||||
break;
|
||||
case ON_PAUSE:
|
||||
mTransactionHandler.handlePauseActivity(r, false /* finished */,
|
||||
false /* userLeaving */, 0 /* configChanges */, mPendingActions,
|
||||
false /* userLeaving */, 0 /* configChanges */,
|
||||
false /* autoEnteringPip */, mPendingActions,
|
||||
"LIFECYCLER_PAUSE_ACTIVITY");
|
||||
break;
|
||||
case ON_STOP:
|
||||
|
||||
@@ -223,15 +223,15 @@ public class ObjectPoolTests {
|
||||
|
||||
@Test
|
||||
public void testRecyclePauseActivityItemItem() {
|
||||
PauseActivityItem emptyItem = PauseActivityItem.obtain(false, false, 0, false);
|
||||
PauseActivityItem item = PauseActivityItem.obtain(true, true, 5, true);
|
||||
PauseActivityItem emptyItem = PauseActivityItem.obtain(false, false, 0, false, false);
|
||||
PauseActivityItem item = PauseActivityItem.obtain(true, true, 5, true, true);
|
||||
assertNotSame(item, emptyItem);
|
||||
assertFalse(item.equals(emptyItem));
|
||||
|
||||
item.recycle();
|
||||
assertEquals(item, emptyItem);
|
||||
|
||||
PauseActivityItem item2 = PauseActivityItem.obtain(true, false, 5, true);
|
||||
PauseActivityItem item2 = PauseActivityItem.obtain(true, false, 5, true, true);
|
||||
assertSame(item, item2);
|
||||
assertFalse(item2.equals(emptyItem));
|
||||
}
|
||||
|
||||
@@ -235,7 +235,8 @@ public class TransactionParcelTests {
|
||||
public void testPause() {
|
||||
// Write to parcel
|
||||
PauseActivityItem item = PauseActivityItem.obtain(true /* finished */,
|
||||
true /* userLeaving */, 135 /* configChanges */, true /* dontReport */);
|
||||
true /* userLeaving */, 135 /* configChanges */, true /* dontReport */,
|
||||
true /* autoEnteringPip */);
|
||||
writeAndPrepareForReading(item);
|
||||
|
||||
// Read from parcel and assert
|
||||
|
||||
@@ -299,8 +299,8 @@ public class ActivityThreadClientTest {
|
||||
|
||||
private void pauseActivity(ActivityClientRecord r) {
|
||||
mThread.handlePauseActivity(r, false /* finished */,
|
||||
false /* userLeaving */, 0 /* configChanges */, null /* pendingActions */,
|
||||
"test");
|
||||
false /* userLeaving */, 0 /* configChanges */, false /* autoEnteringPip */,
|
||||
null /* pendingActions */, "test");
|
||||
}
|
||||
|
||||
private void stopActivity(ActivityClientRecord r) {
|
||||
|
||||
@@ -5896,7 +5896,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
try {
|
||||
mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token,
|
||||
PauseActivityItem.obtain(finishing, false /* userLeaving */,
|
||||
configChangeFlags, false /* dontReport */));
|
||||
configChangeFlags, false /* dontReport */,
|
||||
false /* autoEnteringPip */));
|
||||
} catch (Exception e) {
|
||||
Slog.w(TAG, "Exception thrown sending pause: " + intent.getComponent(), e);
|
||||
}
|
||||
|
||||
@@ -3563,7 +3563,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
// Continue the pausing process after entering pip.
|
||||
if (r.isState(PAUSING)) {
|
||||
r.getTask().schedulePauseActivity(r, false /* userLeaving */,
|
||||
false /* pauseImmediately */, "auto-pip");
|
||||
false /* pauseImmediately */, true /* autoEnteringPip */, "auto-pip");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1621,7 +1621,8 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
||||
ProtoLog.d(WM_DEBUG_STATES, "Auto-PIP allowed, entering PIP mode "
|
||||
+ "directly: %s, didAutoPip: %b", prev, didAutoPip);
|
||||
} else {
|
||||
schedulePauseActivity(prev, userLeaving, pauseImmediately, reason);
|
||||
schedulePauseActivity(prev, userLeaving, pauseImmediately,
|
||||
false /* autoEnteringPip */, reason);
|
||||
}
|
||||
} else {
|
||||
mPausingActivity = null;
|
||||
@@ -1675,7 +1676,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
||||
}
|
||||
|
||||
void schedulePauseActivity(ActivityRecord prev, boolean userLeaving,
|
||||
boolean pauseImmediately, String reason) {
|
||||
boolean pauseImmediately, boolean autoEnteringPip, String reason) {
|
||||
ProtoLog.v(WM_DEBUG_STATES, "Enqueueing pending pause: %s", prev);
|
||||
try {
|
||||
EventLogTags.writeWmPauseActivity(prev.mUserId, System.identityHashCode(prev),
|
||||
@@ -1683,7 +1684,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
||||
|
||||
mAtmService.getLifecycleManager().scheduleTransaction(prev.app.getThread(),
|
||||
prev.token, PauseActivityItem.obtain(prev.finishing, userLeaving,
|
||||
prev.configChangeFlags, pauseImmediately));
|
||||
prev.configChangeFlags, pauseImmediately, autoEnteringPip));
|
||||
} catch (Exception e) {
|
||||
// Ignore exception, if process died other code will cleanup.
|
||||
Slog.w(TAG, "Exception thrown during pause", e);
|
||||
|
||||
Reference in New Issue
Block a user