Merge "Play ActivityEmbedding animation if all changes in Task with embedded" into tm-qpr-dev
This commit is contained in:
@@ -110,8 +110,8 @@ public final class TransitionInfo implements Parcelable {
|
||||
/** The container is an input-method window. */
|
||||
public static final int FLAG_IS_INPUT_METHOD = 1 << 8;
|
||||
|
||||
/** The container is ActivityEmbedding embedded. */
|
||||
public static final int FLAG_IS_EMBEDDED = 1 << 9;
|
||||
/** The container is in a Task with embedded activity. */
|
||||
public static final int FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY = 1 << 9;
|
||||
|
||||
/** The first unused bit. This can be used by remotes to attach custom flags to this change. */
|
||||
public static final int FLAG_FIRST_CUSTOM = 1 << 10;
|
||||
@@ -137,7 +137,7 @@ public final class TransitionInfo implements Parcelable {
|
||||
FLAG_OCCLUDES_KEYGUARD,
|
||||
FLAG_DISPLAY_HAS_ALERT_WINDOWS,
|
||||
FLAG_IS_INPUT_METHOD,
|
||||
FLAG_IS_EMBEDDED,
|
||||
FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY,
|
||||
FLAG_FIRST_CUSTOM,
|
||||
FLAG_WILL_IME_SHOWN
|
||||
})
|
||||
@@ -322,28 +322,28 @@ public final class TransitionInfo implements Parcelable {
|
||||
sb.append("IS_INPUT_METHOD");
|
||||
}
|
||||
if ((flags & FLAG_TRANSLUCENT) != 0) {
|
||||
sb.append((sb.length() == 0 ? "" : "|") + "TRANSLUCENT");
|
||||
sb.append(sb.length() == 0 ? "" : "|").append("TRANSLUCENT");
|
||||
}
|
||||
if ((flags & FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT) != 0) {
|
||||
sb.append((sb.length() == 0 ? "" : "|") + "STARTING_WINDOW_TRANSFER");
|
||||
sb.append(sb.length() == 0 ? "" : "|").append("STARTING_WINDOW_TRANSFER");
|
||||
}
|
||||
if ((flags & FLAG_IS_VOICE_INTERACTION) != 0) {
|
||||
sb.append((sb.length() == 0 ? "" : "|") + "IS_VOICE_INTERACTION");
|
||||
sb.append(sb.length() == 0 ? "" : "|").append("IS_VOICE_INTERACTION");
|
||||
}
|
||||
if ((flags & FLAG_IS_DISPLAY) != 0) {
|
||||
sb.append((sb.length() == 0 ? "" : "|") + "IS_DISPLAY");
|
||||
sb.append(sb.length() == 0 ? "" : "|").append("IS_DISPLAY");
|
||||
}
|
||||
if ((flags & FLAG_OCCLUDES_KEYGUARD) != 0) {
|
||||
sb.append((sb.length() == 0 ? "" : "|") + "OCCLUDES_KEYGUARD");
|
||||
sb.append(sb.length() == 0 ? "" : "|").append("OCCLUDES_KEYGUARD");
|
||||
}
|
||||
if ((flags & FLAG_DISPLAY_HAS_ALERT_WINDOWS) != 0) {
|
||||
sb.append((sb.length() == 0 ? "" : "|") + "DISPLAY_HAS_ALERT_WINDOWS");
|
||||
sb.append(sb.length() == 0 ? "" : "|").append("DISPLAY_HAS_ALERT_WINDOWS");
|
||||
}
|
||||
if ((flags & FLAG_IS_EMBEDDED) != 0) {
|
||||
sb.append((sb.length() == 0 ? "" : "|") + "IS_EMBEDDED");
|
||||
if ((flags & FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY) != 0) {
|
||||
sb.append(sb.length() == 0 ? "" : "|").append("IN_TASK_WITH_EMBEDDED_ACTIVITY");
|
||||
}
|
||||
if ((flags & FLAG_FIRST_CUSTOM) != 0) {
|
||||
sb.append((sb.length() == 0 ? "" : "|") + "FIRST_CUSTOM");
|
||||
sb.append(sb.length() == 0 ? "" : "|").append("FIRST_CUSTOM");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.wm.shell.activityembedding;
|
||||
|
||||
import static android.window.TransitionInfo.FLAG_IS_EMBEDDED;
|
||||
import static android.window.TransitionInfo.FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@@ -85,9 +85,9 @@ public class ActivityEmbeddingController implements Transitions.TransitionHandle
|
||||
@NonNull SurfaceControl.Transaction finishTransaction,
|
||||
@NonNull Transitions.TransitionFinishCallback finishCallback) {
|
||||
// TODO(b/207070762) Handle AE animation as a part of other transitions.
|
||||
// Only handle the transition if all containers are embedded.
|
||||
for (TransitionInfo.Change change : info.getChanges()) {
|
||||
if (!isEmbedded(change)) {
|
||||
if (!change.hasFlags(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY)) {
|
||||
// Only animate the transition if all changes are in a Task with ActivityEmbedding.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -119,8 +119,4 @@ public class ActivityEmbeddingController implements Transitions.TransitionHandle
|
||||
}
|
||||
callback.onTransitionFinished(null /* wct */, null /* wctCB */);
|
||||
}
|
||||
|
||||
private static boolean isEmbedded(@NonNull TransitionInfo.Change change) {
|
||||
return (change.getFlags() & FLAG_IS_EMBEDDED) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.wm.shell.activityembedding;
|
||||
|
||||
import static android.view.WindowManager.TRANSIT_OPEN;
|
||||
import static android.window.TransitionInfo.FLAG_IS_EMBEDDED;
|
||||
import static android.window.TransitionInfo.FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -57,7 +57,7 @@ public class ActivityEmbeddingAnimationRunnerTests extends ActivityEmbeddingAnim
|
||||
public void testStartAnimation() {
|
||||
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
|
||||
final TransitionInfo.Change embeddingChange = createChange();
|
||||
embeddingChange.setFlags(FLAG_IS_EMBEDDED);
|
||||
embeddingChange.setFlags(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY);
|
||||
info.addChange(embeddingChange);
|
||||
doReturn(mAnimator).when(mAnimRunner).createAnimator(any(), any(), any(), any());
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.wm.shell.activityembedding;
|
||||
|
||||
import static android.view.WindowManager.TRANSIT_OPEN;
|
||||
import static android.window.TransitionInfo.FLAG_IS_EMBEDDED;
|
||||
import static android.window.TransitionInfo.FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;
|
||||
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ActivityEmbeddingControllerTests extends ActivityEmbeddingAnimation
|
||||
public void testStartAnimation_containsNonActivityEmbeddingChange() {
|
||||
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
|
||||
final TransitionInfo.Change embeddingChange = createChange();
|
||||
embeddingChange.setFlags(FLAG_IS_EMBEDDED);
|
||||
embeddingChange.setFlags(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY);
|
||||
final TransitionInfo.Change nonEmbeddingChange = createChange();
|
||||
info.addChange(embeddingChange);
|
||||
info.addChange(nonEmbeddingChange);
|
||||
@@ -96,7 +96,7 @@ public class ActivityEmbeddingControllerTests extends ActivityEmbeddingAnimation
|
||||
public void testStartAnimation_onlyActivityEmbeddingChange() {
|
||||
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
|
||||
final TransitionInfo.Change embeddingChange = createChange();
|
||||
embeddingChange.setFlags(FLAG_IS_EMBEDDED);
|
||||
embeddingChange.setFlags(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY);
|
||||
info.addChange(embeddingChange);
|
||||
|
||||
// No-op
|
||||
@@ -116,7 +116,7 @@ public class ActivityEmbeddingControllerTests extends ActivityEmbeddingAnimation
|
||||
|
||||
final TransitionInfo info = new TransitionInfo(TRANSIT_OPEN, 0);
|
||||
final TransitionInfo.Change embeddingChange = createChange();
|
||||
embeddingChange.setFlags(FLAG_IS_EMBEDDED);
|
||||
embeddingChange.setFlags(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY);
|
||||
info.addChange(embeddingChange);
|
||||
mController.startAnimation(mTransition, info, mStartTransaction,
|
||||
mFinishTransaction, mFinishCallback);
|
||||
|
||||
@@ -46,8 +46,8 @@ import static android.view.WindowManager.TransitionFlags;
|
||||
import static android.view.WindowManager.TransitionType;
|
||||
import static android.view.WindowManager.transitTypeToString;
|
||||
import static android.window.TransitionInfo.FLAG_DISPLAY_HAS_ALERT_WINDOWS;
|
||||
import static android.window.TransitionInfo.FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;
|
||||
import static android.window.TransitionInfo.FLAG_IS_DISPLAY;
|
||||
import static android.window.TransitionInfo.FLAG_IS_EMBEDDED;
|
||||
import static android.window.TransitionInfo.FLAG_IS_INPUT_METHOD;
|
||||
import static android.window.TransitionInfo.FLAG_IS_VOICE_INTERACTION;
|
||||
import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;
|
||||
@@ -1873,8 +1873,10 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
||||
flags |= FLAG_WILL_IME_SHOWN;
|
||||
}
|
||||
}
|
||||
Task parentTask = null;
|
||||
final ActivityRecord record = wc.asActivityRecord();
|
||||
if (record != null) {
|
||||
parentTask = record.getTask();
|
||||
if (record.mUseTransferredAnimation) {
|
||||
flags |= FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT;
|
||||
}
|
||||
@@ -1882,6 +1884,15 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
||||
flags |= FLAG_IS_VOICE_INTERACTION;
|
||||
}
|
||||
}
|
||||
final TaskFragment taskFragment = wc.asTaskFragment();
|
||||
if (taskFragment != null && task == null) {
|
||||
parentTask = taskFragment.getTask();
|
||||
}
|
||||
if (parentTask != null
|
||||
&& parentTask.forAllLeafTaskFragments(TaskFragment::isEmbedded)) {
|
||||
// Whether this is in a Task with embedded activity.
|
||||
flags |= FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;
|
||||
}
|
||||
final DisplayContent dc = wc.asDisplayContent();
|
||||
if (dc != null) {
|
||||
flags |= FLAG_IS_DISPLAY;
|
||||
@@ -1898,9 +1909,6 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
||||
if (occludesKeyguard(wc)) {
|
||||
flags |= FLAG_OCCLUDES_KEYGUARD;
|
||||
}
|
||||
if (wc.isEmbedded()) {
|
||||
flags |= FLAG_IS_EMBEDDED;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import static android.view.WindowManager.TRANSIT_CHANGE;
|
||||
import static android.view.WindowManager.TRANSIT_CLOSE;
|
||||
import static android.view.WindowManager.TRANSIT_OPEN;
|
||||
import static android.view.WindowManager.TRANSIT_TO_BACK;
|
||||
import static android.window.TransitionInfo.FLAG_IS_EMBEDDED;
|
||||
import static android.window.TransitionInfo.FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY;
|
||||
import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;
|
||||
import static android.window.TransitionInfo.FLAG_SHOW_WALLPAPER;
|
||||
import static android.window.TransitionInfo.FLAG_TRANSLUCENT;
|
||||
@@ -1062,12 +1062,14 @@ public class TransitionTests extends WindowTestsBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEmbeddedChange() {
|
||||
public void testFlagInTaskWithEmbeddedActivity() {
|
||||
final Transition transition = createTestTransition(TRANSIT_OPEN);
|
||||
final ArrayMap<WindowContainer, Transition.ChangeInfo> changes = transition.mChanges;
|
||||
final ArraySet<WindowContainer> participants = transition.mParticipants;
|
||||
|
||||
final Task task = createTask(mDisplayContent);
|
||||
final ActivityRecord nonEmbeddedActivity = createActivityRecord(task);
|
||||
assertFalse(nonEmbeddedActivity.isEmbedded());
|
||||
final TaskFragmentOrganizer organizer = new TaskFragmentOrganizer(Runnable::run);
|
||||
mAtm.mTaskFragmentOrganizerController.registerOrganizer(
|
||||
ITaskFragmentOrganizer.Stub.asInterface(organizer.getOrganizerToken().asBinder()));
|
||||
@@ -1082,20 +1084,27 @@ public class TransitionTests extends WindowTestsBase {
|
||||
changes.put(embeddedTf, new Transition.ChangeInfo(true /* vis */, false /* exChg */));
|
||||
changes.put(closingActivity, new Transition.ChangeInfo(true /* vis */, false /* exChg */));
|
||||
changes.put(openingActivity, new Transition.ChangeInfo(false /* vis */, true /* exChg */));
|
||||
changes.put(nonEmbeddedActivity, new Transition.ChangeInfo(true /* vis */,
|
||||
false /* exChg */));
|
||||
// End states.
|
||||
closingActivity.mVisibleRequested = false;
|
||||
openingActivity.mVisibleRequested = true;
|
||||
nonEmbeddedActivity.mVisibleRequested = false;
|
||||
|
||||
participants.add(closingActivity);
|
||||
participants.add(openingActivity);
|
||||
participants.add(nonEmbeddedActivity);
|
||||
final ArrayList<WindowContainer> targets = Transition.calculateTargets(
|
||||
participants, changes);
|
||||
final TransitionInfo info = Transition.calculateTransitionInfo(
|
||||
transition.mType, 0 /* flags */, targets, changes, mMockT);
|
||||
|
||||
assertEquals(2, info.getChanges().size());
|
||||
assertTrue((info.getChanges().get(0).getFlags() & FLAG_IS_EMBEDDED) != 0);
|
||||
assertTrue((info.getChanges().get(1).getFlags() & FLAG_IS_EMBEDDED) != 0);
|
||||
// All windows in the Task should have FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY because the Task
|
||||
// contains embedded activity.
|
||||
assertEquals(3, info.getChanges().size());
|
||||
assertTrue(info.getChanges().get(0).hasFlags(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY));
|
||||
assertTrue(info.getChanges().get(1).hasFlags(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY));
|
||||
assertTrue(info.getChanges().get(2).hasFlags(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user