Merge "WindowContainerTransaction: Support PIP Transition" into rvc-dev

This commit is contained in:
Rob Carr
2020-03-12 18:39:18 +00:00
committed by Android (Google) Code Review
4 changed files with 88 additions and 2 deletions

View File

@@ -130,6 +130,31 @@ public class WindowContainerTransaction implements Parcelable {
return this; return this;
} }
/**
* Set the windowing mode of children of a given root task, without changing
* the windowing mode of the Task itself. This can be used during transitions
* for example to make the activity render it's fullscreen configuration
* while the Task is still in PIP, so you can complete the animation.
*
* TODO(b/134365562): Can be removed once TaskOrg drives full-screen
*/
public WindowContainerTransaction setActivityWindowingMode(IWindowContainer container,
int windowingMode) {
Change chg = getOrCreateChange(container.asBinder());
chg.mActivityWindowingMode = windowingMode;
return this;
}
/**
* Sets the windowing mode of the given container.
*/
public WindowContainerTransaction setWindowingMode(IWindowContainer container,
int windowingMode) {
Change chg = getOrCreateChange(container.asBinder());
chg.mWindowingMode = windowingMode;
return this;
}
/** /**
* Sets whether a container or any of its children can be focusable. When {@code false}, no * Sets whether a container or any of its children can be focusable. When {@code false}, no
* child can be focused; however, when {@code true}, it is still possible for children to be * child can be focused; however, when {@code true}, it is still possible for children to be
@@ -235,6 +260,9 @@ public class WindowContainerTransaction implements Parcelable {
private Rect mPinnedBounds = null; private Rect mPinnedBounds = null;
private SurfaceControl.Transaction mBoundsChangeTransaction = null; private SurfaceControl.Transaction mBoundsChangeTransaction = null;
private int mActivityWindowingMode = -1;
private int mWindowingMode = -1;
public Change() {} public Change() {}
protected Change(Parcel in) { protected Change(Parcel in) {
@@ -251,6 +279,17 @@ public class WindowContainerTransaction implements Parcelable {
mBoundsChangeTransaction = mBoundsChangeTransaction =
SurfaceControl.Transaction.CREATOR.createFromParcel(in); SurfaceControl.Transaction.CREATOR.createFromParcel(in);
} }
mWindowingMode = in.readInt();
mActivityWindowingMode = in.readInt();
}
public int getWindowingMode() {
return mWindowingMode;
}
public int getActivityWindowingMode() {
return mActivityWindowingMode;
} }
public Configuration getConfiguration() { public Configuration getConfiguration() {
@@ -340,6 +379,9 @@ public class WindowContainerTransaction implements Parcelable {
if (mBoundsChangeTransaction != null) { if (mBoundsChangeTransaction != null) {
mBoundsChangeTransaction.writeToParcel(dest, flags); mBoundsChangeTransaction.writeToParcel(dest, flags);
} }
dest.writeInt(mWindowingMode);
dest.writeInt(mActivityWindowingMode);
} }
@Override @Override

View File

@@ -4123,8 +4123,16 @@ class Task extends WindowContainer<WindowContainer> {
return mMainWindowSizeChangeTransaction; return mMainWindowSizeChangeTransaction;
} }
void setActivityWindowingMode(int windowingMode) {
PooledConsumer c = PooledLambda.obtainConsumer(ActivityRecord::setWindowingMode,
PooledLambda.__(ActivityRecord.class), windowingMode);
forAllActivities(c);
c.recycle();
}
@Override @Override
long getProtoFieldId() { long getProtoFieldId() {
return TASK; return TASK;
} }
} }

View File

@@ -553,18 +553,28 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub
WindowContainerTransaction.Change c) { WindowContainerTransaction.Change c) {
int effects = sanitizeAndApplyChange(wc, c); int effects = sanitizeAndApplyChange(wc, c);
final Task tr = wc.asTask();
final SurfaceControl.Transaction t = c.getBoundsChangeTransaction(); final SurfaceControl.Transaction t = c.getBoundsChangeTransaction();
if (t != null) { if (t != null) {
Task tr = (Task) wc;
tr.setMainWindowSizeChangeTransaction(t); tr.setMainWindowSizeChangeTransaction(t);
} }
Rect enterPipBounds = c.getEnterPipBounds(); Rect enterPipBounds = c.getEnterPipBounds();
if (enterPipBounds != null) { if (enterPipBounds != null) {
Task tr = (Task) wc;
mService.mStackSupervisor.updatePictureInPictureMode(tr, mService.mStackSupervisor.updatePictureInPictureMode(tr,
enterPipBounds, true); enterPipBounds, true);
} }
final int windowingMode = c.getWindowingMode();
if (windowingMode > -1) {
tr.setWindowingMode(windowingMode);
}
final int childWindowingMode = c.getActivityWindowingMode();
if (childWindowingMode > -1) {
tr.setActivityWindowingMode(childWindowingMode);
}
return effects; return effects;
} }

View File

@@ -240,6 +240,32 @@ public class TaskOrganizerTests extends WindowTestsBase {
assertEquals(newBounds, stack.getBounds()); assertEquals(newBounds, stack.getBounds());
} }
@Test
public void testSetWindowingMode() {
final ActivityStack stack = new ActivityTestsBase.StackBuilder(mWm.mRoot)
.setWindowingMode(WINDOWING_MODE_FREEFORM).build();
final WindowContainerTransaction t = new WindowContainerTransaction();
t.setWindowingMode(stack.mRemoteToken, WINDOWING_MODE_FULLSCREEN);
mWm.mAtmService.mTaskOrganizerController.applyContainerTransaction(t, null);
assertEquals(WINDOWING_MODE_FULLSCREEN, stack.getWindowingMode());
}
@Test
public void testSetActivityWindowingMode() {
final ActivityRecord record = makePipableActivity();
final ActivityStack stack = record.getStack();
final WindowContainerTransaction t = new WindowContainerTransaction();
t.setWindowingMode(stack.mRemoteToken, WINDOWING_MODE_PINNED);
t.setActivityWindowingMode(stack.mRemoteToken, WINDOWING_MODE_FULLSCREEN);
mWm.mAtmService.mTaskOrganizerController.applyContainerTransaction(t, null);
assertEquals(WINDOWING_MODE_FULLSCREEN, record.getWindowingMode());
assertEquals(WINDOWING_MODE_PINNED, stack.getWindowingMode());
}
@Test @Test
public void testContainerChanges() { public void testContainerChanges() {
removeGlobalMinSizeRestriction(); removeGlobalMinSizeRestriction();