Merge "Fix SplitContainer not updated when folded." into tm-qpr-dev am: c0ee7bde68
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20064106 Change-Id: I8ae09e2cbb543028eff417fb289402a46473af15 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -33,19 +33,19 @@ public class TaskFragmentParentInfo implements Parcelable {
|
|||||||
|
|
||||||
private final int mDisplayId;
|
private final int mDisplayId;
|
||||||
|
|
||||||
private final boolean mVisibleRequested;
|
private final boolean mVisible;
|
||||||
|
|
||||||
public TaskFragmentParentInfo(@NonNull Configuration configuration, int displayId,
|
public TaskFragmentParentInfo(@NonNull Configuration configuration, int displayId,
|
||||||
boolean visibleRequested) {
|
boolean visible) {
|
||||||
mConfiguration.setTo(configuration);
|
mConfiguration.setTo(configuration);
|
||||||
mDisplayId = displayId;
|
mDisplayId = displayId;
|
||||||
mVisibleRequested = visibleRequested;
|
mVisible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TaskFragmentParentInfo(@NonNull TaskFragmentParentInfo info) {
|
public TaskFragmentParentInfo(@NonNull TaskFragmentParentInfo info) {
|
||||||
mConfiguration.setTo(info.getConfiguration());
|
mConfiguration.setTo(info.getConfiguration());
|
||||||
mDisplayId = info.mDisplayId;
|
mDisplayId = info.mDisplayId;
|
||||||
mVisibleRequested = info.mVisibleRequested;
|
mVisible = info.mVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The {@link Configuration} of the parent Task */
|
/** The {@link Configuration} of the parent Task */
|
||||||
@@ -62,9 +62,9 @@ public class TaskFragmentParentInfo implements Parcelable {
|
|||||||
return mDisplayId;
|
return mDisplayId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Whether the parent Task is requested to be visible or not */
|
/** Whether the parent Task is visible or not */
|
||||||
public boolean isVisibleRequested() {
|
public boolean isVisible() {
|
||||||
return mVisibleRequested;
|
return mVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +80,7 @@ public class TaskFragmentParentInfo implements Parcelable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return getWindowingMode() == that.getWindowingMode() && mDisplayId == that.mDisplayId
|
return getWindowingMode() == that.getWindowingMode() && mDisplayId == that.mDisplayId
|
||||||
&& mVisibleRequested == that.mVisibleRequested;
|
&& mVisible == that.mVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@WindowConfiguration.WindowingMode
|
@WindowConfiguration.WindowingMode
|
||||||
@@ -93,7 +93,7 @@ public class TaskFragmentParentInfo implements Parcelable {
|
|||||||
return TaskFragmentParentInfo.class.getSimpleName() + ":{"
|
return TaskFragmentParentInfo.class.getSimpleName() + ":{"
|
||||||
+ "config=" + mConfiguration
|
+ "config=" + mConfiguration
|
||||||
+ ", displayId=" + mDisplayId
|
+ ", displayId=" + mDisplayId
|
||||||
+ ", visibleRequested=" + mVisibleRequested
|
+ ", visible=" + mVisible
|
||||||
+ "}";
|
+ "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,14 +114,14 @@ public class TaskFragmentParentInfo implements Parcelable {
|
|||||||
final TaskFragmentParentInfo that = (TaskFragmentParentInfo) obj;
|
final TaskFragmentParentInfo that = (TaskFragmentParentInfo) obj;
|
||||||
return mConfiguration.equals(that.mConfiguration)
|
return mConfiguration.equals(that.mConfiguration)
|
||||||
&& mDisplayId == that.mDisplayId
|
&& mDisplayId == that.mDisplayId
|
||||||
&& mVisibleRequested == that.mVisibleRequested;
|
&& mVisible == that.mVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = mConfiguration.hashCode();
|
int result = mConfiguration.hashCode();
|
||||||
result = 31 * result + mDisplayId;
|
result = 31 * result + mDisplayId;
|
||||||
result = 31 * result + (mVisibleRequested ? 1 : 0);
|
result = 31 * result + (mVisible ? 1 : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,13 +129,13 @@ public class TaskFragmentParentInfo implements Parcelable {
|
|||||||
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||||
mConfiguration.writeToParcel(dest, flags);
|
mConfiguration.writeToParcel(dest, flags);
|
||||||
dest.writeInt(mDisplayId);
|
dest.writeInt(mDisplayId);
|
||||||
dest.writeBoolean(mVisibleRequested);
|
dest.writeBoolean(mVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TaskFragmentParentInfo(Parcel in) {
|
private TaskFragmentParentInfo(Parcel in) {
|
||||||
mConfiguration.readFromParcel(in);
|
mConfiguration.readFromParcel(in);
|
||||||
mDisplayId = in.readInt();
|
mDisplayId = in.readInt();
|
||||||
mVisibleRequested = in.readBoolean();
|
mVisible = in.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<TaskFragmentParentInfo> CREATOR =
|
public static final Creator<TaskFragmentParentInfo> CREATOR =
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ class TaskContainer {
|
|||||||
void updateTaskFragmentParentInfo(@NonNull TaskFragmentParentInfo info) {
|
void updateTaskFragmentParentInfo(@NonNull TaskFragmentParentInfo info) {
|
||||||
mConfiguration.setTo(info.getConfiguration());
|
mConfiguration.setTo(info.getConfiguration());
|
||||||
mDisplayId = info.getDisplayId();
|
mDisplayId = info.getDisplayId();
|
||||||
mIsVisible = info.isVisibleRequested();
|
mIsVisible = info.isVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3547,12 +3547,16 @@ class Task extends TaskFragment {
|
|||||||
* {@link android.window.TaskFragmentOrganizer}
|
* {@link android.window.TaskFragmentOrganizer}
|
||||||
*/
|
*/
|
||||||
TaskFragmentParentInfo getTaskFragmentParentInfo() {
|
TaskFragmentParentInfo getTaskFragmentParentInfo() {
|
||||||
return new TaskFragmentParentInfo(getConfiguration(), getDisplayId(), isVisibleRequested());
|
return new TaskFragmentParentInfo(getConfiguration(), getDisplayId(),
|
||||||
|
shouldBeVisible(null /* starting */));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onActivityVisibleRequestedChanged() {
|
void onActivityVisibleRequestedChanged() {
|
||||||
if (mVisibleRequested != isVisibleRequested()) {
|
final boolean prevVisibleRequested = mVisibleRequested;
|
||||||
|
// mVisibleRequested is updated in super method.
|
||||||
|
super.onActivityVisibleRequestedChanged();
|
||||||
|
if (prevVisibleRequested != mVisibleRequested) {
|
||||||
sendTaskFragmentParentInfoChangedIfNeeded();
|
sendTaskFragmentParentInfoChangedIfNeeded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2690,12 +2690,26 @@ class TaskFragment extends WindowContainer<WindowContainer> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mVisibleRequested = isVisibleRequested;
|
mVisibleRequested = isVisibleRequested;
|
||||||
final TaskFragment parentTf = getParent().asTaskFragment();
|
final WindowContainer<?> parent = getParent();
|
||||||
|
if (parent == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final TaskFragment parentTf = parent.asTaskFragment();
|
||||||
if (parentTf != null) {
|
if (parentTf != null) {
|
||||||
parentTf.onActivityVisibleRequestedChanged();
|
parentTf.onActivityVisibleRequestedChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
TaskFragment getTaskFragment(Predicate<TaskFragment> callback) {
|
||||||
|
final TaskFragment taskFragment = super.getTaskFragment(callback);
|
||||||
|
if (taskFragment != null) {
|
||||||
|
return taskFragment;
|
||||||
|
}
|
||||||
|
return callback.test(this) ? this : null;
|
||||||
|
}
|
||||||
|
|
||||||
String toFullString() {
|
String toFullString() {
|
||||||
final StringBuilder sb = new StringBuilder(128);
|
final StringBuilder sb = new StringBuilder(128);
|
||||||
sb.append(this);
|
sb.append(this);
|
||||||
|
|||||||
@@ -920,6 +920,7 @@ public class TaskFragmentOrganizerController extends ITaskFragmentOrganizerContr
|
|||||||
for (int i = 0, n = pendingEvents.size(); i < n; i++) {
|
for (int i = 0, n = pendingEvents.size(); i < n; i++) {
|
||||||
final PendingTaskFragmentEvent event = pendingEvents.get(i);
|
final PendingTaskFragmentEvent event = pendingEvents.get(i);
|
||||||
final Task task = event.mTaskFragment != null ? event.mTaskFragment.getTask() : null;
|
final Task task = event.mTaskFragment != null ? event.mTaskFragment.getTask() : null;
|
||||||
|
// TODO(b/251132298): move visibility check to the client side.
|
||||||
if (task != null && (task.lastActiveTime <= event.mDeferTime
|
if (task != null && (task.lastActiveTime <= event.mDeferTime
|
||||||
|| !(isTaskVisible(task, visibleTasks, invisibleTasks)
|
|| !(isTaskVisible(task, visibleTasks, invisibleTasks)
|
||||||
|| shouldSendEventWhenTaskInvisible(event)))) {
|
|| shouldSendEventWhenTaskInvisible(event)))) {
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
|
|||||||
mController.onTaskFragmentAppeared(mTaskFragment.getTaskFragmentOrganizer(), mTaskFragment);
|
mController.onTaskFragmentAppeared(mTaskFragment.getTaskFragmentOrganizer(), mTaskFragment);
|
||||||
mController.dispatchPendingEvents();
|
mController.dispatchPendingEvents();
|
||||||
|
|
||||||
|
assertTaskFragmentParentInfoChangedTransaction(mTask);
|
||||||
assertTaskFragmentAppearedTransaction();
|
assertTaskFragmentAppearedTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,6 +366,7 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
|
|||||||
mController.onActivityReparentedToTask(activity);
|
mController.onActivityReparentedToTask(activity);
|
||||||
mController.dispatchPendingEvents();
|
mController.dispatchPendingEvents();
|
||||||
|
|
||||||
|
assertTaskFragmentParentInfoChangedTransaction(task);
|
||||||
assertActivityReparentedToTaskTransaction(task.mTaskId, activity.intent, activity.token);
|
assertActivityReparentedToTaskTransaction(task.mTaskId, activity.intent, activity.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1205,7 +1207,8 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link TaskFragment} with the {@link WindowContainerTransaction}. Calls
|
* Creates a {@link TaskFragment} with the {@link WindowContainerTransaction}. Calls
|
||||||
* {@link WindowOrganizerController#applyTransaction} to apply the transaction,
|
* {@link WindowOrganizerController#applyTransaction(WindowContainerTransaction)} to apply the
|
||||||
|
* transaction,
|
||||||
*/
|
*/
|
||||||
private void createTaskFragmentFromOrganizer(WindowContainerTransaction wct,
|
private void createTaskFragmentFromOrganizer(WindowContainerTransaction wct,
|
||||||
ActivityRecord ownerActivity, IBinder fragmentToken) {
|
ActivityRecord ownerActivity, IBinder fragmentToken) {
|
||||||
@@ -1239,8 +1242,8 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
|
|||||||
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
||||||
assertFalse(changes.isEmpty());
|
assertFalse(changes.isEmpty());
|
||||||
|
|
||||||
// Appeared will come with parent info changed.
|
// Use remove to verify multiple transaction changes.
|
||||||
final TaskFragmentTransaction.Change change = changes.get(changes.size() - 1);
|
final TaskFragmentTransaction.Change change = changes.remove(0);
|
||||||
assertEquals(TYPE_TASK_FRAGMENT_APPEARED, change.getType());
|
assertEquals(TYPE_TASK_FRAGMENT_APPEARED, change.getType());
|
||||||
assertEquals(mTaskFragmentInfo, change.getTaskFragmentInfo());
|
assertEquals(mTaskFragmentInfo, change.getTaskFragmentInfo());
|
||||||
assertEquals(mFragmentToken, change.getTaskFragmentToken());
|
assertEquals(mFragmentToken, change.getTaskFragmentToken());
|
||||||
@@ -1253,8 +1256,8 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
|
|||||||
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
||||||
assertFalse(changes.isEmpty());
|
assertFalse(changes.isEmpty());
|
||||||
|
|
||||||
// InfoChanged may come with parent info changed.
|
// Use remove to verify multiple transaction changes.
|
||||||
final TaskFragmentTransaction.Change change = changes.get(changes.size() - 1);
|
final TaskFragmentTransaction.Change change = changes.remove(0);
|
||||||
assertEquals(TYPE_TASK_FRAGMENT_INFO_CHANGED, change.getType());
|
assertEquals(TYPE_TASK_FRAGMENT_INFO_CHANGED, change.getType());
|
||||||
assertEquals(mTaskFragmentInfo, change.getTaskFragmentInfo());
|
assertEquals(mTaskFragmentInfo, change.getTaskFragmentInfo());
|
||||||
assertEquals(mFragmentToken, change.getTaskFragmentToken());
|
assertEquals(mFragmentToken, change.getTaskFragmentToken());
|
||||||
@@ -1266,7 +1269,9 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
|
|||||||
final TaskFragmentTransaction transaction = mTransactionCaptor.getValue();
|
final TaskFragmentTransaction transaction = mTransactionCaptor.getValue();
|
||||||
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
||||||
assertFalse(changes.isEmpty());
|
assertFalse(changes.isEmpty());
|
||||||
final TaskFragmentTransaction.Change change = changes.get(0);
|
|
||||||
|
// Use remove to verify multiple transaction changes.
|
||||||
|
final TaskFragmentTransaction.Change change = changes.remove(0);
|
||||||
assertEquals(TYPE_TASK_FRAGMENT_VANISHED, change.getType());
|
assertEquals(TYPE_TASK_FRAGMENT_VANISHED, change.getType());
|
||||||
assertEquals(mTaskFragmentInfo, change.getTaskFragmentInfo());
|
assertEquals(mTaskFragmentInfo, change.getTaskFragmentInfo());
|
||||||
assertEquals(mFragmentToken, change.getTaskFragmentToken());
|
assertEquals(mFragmentToken, change.getTaskFragmentToken());
|
||||||
@@ -1278,7 +1283,9 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
|
|||||||
final TaskFragmentTransaction transaction = mTransactionCaptor.getValue();
|
final TaskFragmentTransaction transaction = mTransactionCaptor.getValue();
|
||||||
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
||||||
assertFalse(changes.isEmpty());
|
assertFalse(changes.isEmpty());
|
||||||
final TaskFragmentTransaction.Change change = changes.get(0);
|
|
||||||
|
// Use remove to verify multiple transaction changes.
|
||||||
|
final TaskFragmentTransaction.Change change = changes.remove(0);
|
||||||
assertEquals(TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED, change.getType());
|
assertEquals(TYPE_TASK_FRAGMENT_PARENT_INFO_CHANGED, change.getType());
|
||||||
assertEquals(task.mTaskId, change.getTaskId());
|
assertEquals(task.mTaskId, change.getTaskId());
|
||||||
assertEquals(task.getTaskFragmentParentInfo(), change.getTaskFragmentParentInfo());
|
assertEquals(task.getTaskFragmentParentInfo(), change.getTaskFragmentParentInfo());
|
||||||
@@ -1290,7 +1297,9 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
|
|||||||
final TaskFragmentTransaction transaction = mTransactionCaptor.getValue();
|
final TaskFragmentTransaction transaction = mTransactionCaptor.getValue();
|
||||||
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
||||||
assertFalse(changes.isEmpty());
|
assertFalse(changes.isEmpty());
|
||||||
final TaskFragmentTransaction.Change change = changes.get(0);
|
|
||||||
|
// Use remove to verify multiple transaction changes.
|
||||||
|
final TaskFragmentTransaction.Change change = changes.remove(0);
|
||||||
assertEquals(TYPE_TASK_FRAGMENT_ERROR, change.getType());
|
assertEquals(TYPE_TASK_FRAGMENT_ERROR, change.getType());
|
||||||
assertEquals(mErrorToken, change.getErrorCallbackToken());
|
assertEquals(mErrorToken, change.getErrorCallbackToken());
|
||||||
final Bundle errorBundle = change.getErrorBundle();
|
final Bundle errorBundle = change.getErrorBundle();
|
||||||
@@ -1306,7 +1315,9 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
|
|||||||
final TaskFragmentTransaction transaction = mTransactionCaptor.getValue();
|
final TaskFragmentTransaction transaction = mTransactionCaptor.getValue();
|
||||||
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
final List<TaskFragmentTransaction.Change> changes = transaction.getChanges();
|
||||||
assertFalse(changes.isEmpty());
|
assertFalse(changes.isEmpty());
|
||||||
final TaskFragmentTransaction.Change change = changes.get(0);
|
|
||||||
|
// Use remove to verify multiple transaction changes.
|
||||||
|
final TaskFragmentTransaction.Change change = changes.remove(0);
|
||||||
assertEquals(TYPE_ACTIVITY_REPARENTED_TO_TASK, change.getType());
|
assertEquals(TYPE_ACTIVITY_REPARENTED_TO_TASK, change.getType());
|
||||||
assertEquals(taskId, change.getTaskId());
|
assertEquals(taskId, change.getTaskId());
|
||||||
assertEquals(intent, change.getActivityIntent());
|
assertEquals(intent, change.getActivityIntent());
|
||||||
|
|||||||
@@ -1454,6 +1454,21 @@ public class TaskTests extends WindowTestsBase {
|
|||||||
verify(tfBehind, never()).resumeTopActivity(any(), any(), anyBoolean());
|
verify(tfBehind, never()).resumeTopActivity(any(), any(), anyBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetTaskFragment() {
|
||||||
|
final Task parentTask = createTask(mDisplayContent);
|
||||||
|
final TaskFragment tf0 = createTaskFragmentWithParentTask(parentTask);
|
||||||
|
final TaskFragment tf1 = createTaskFragmentWithParentTask(parentTask);
|
||||||
|
|
||||||
|
assertNull("Could not find it because there's no organized TaskFragment",
|
||||||
|
parentTask.getTaskFragment(TaskFragment::isOrganizedTaskFragment));
|
||||||
|
|
||||||
|
doReturn(true).when(tf0).isOrganizedTaskFragment();
|
||||||
|
|
||||||
|
assertEquals("tf0 must be return because it's the organized TaskFragment.",
|
||||||
|
tf0, parentTask.getTaskFragment(TaskFragment::isOrganizedTaskFragment));
|
||||||
|
}
|
||||||
|
|
||||||
private Task getTestTask() {
|
private Task getTestTask() {
|
||||||
final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).build();
|
final Task task = new TaskBuilder(mSupervisor).setCreateActivity(true).build();
|
||||||
return task.getBottomMostTask();
|
return task.getBottomMostTask();
|
||||||
|
|||||||
@@ -718,6 +718,10 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
|||||||
activity.mVisibleRequested = true;
|
activity.mVisibleRequested = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static TaskFragment createTaskFragmentWithParentTask(@NonNull Task parentTask) {
|
||||||
|
return createTaskFragmentWithParentTask(parentTask, false /* createEmbeddedTask */);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link TaskFragment} and attach it to the {@code parentTask}.
|
* Creates a {@link TaskFragment} and attach it to the {@code parentTask}.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user