Merge "Determine whether to support activities in multi window (8/n)" into sc-dev
This commit is contained in:
@@ -182,6 +182,11 @@ class AppPair implements ShellTaskOrganizer.TaskListener, SplitLayout.LayoutChan
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTaskInfoChanged(ActivityManager.RunningTaskInfo taskInfo) {
|
public void onTaskInfoChanged(ActivityManager.RunningTaskInfo taskInfo) {
|
||||||
|
if (!taskInfo.supportsMultiWindow) {
|
||||||
|
// Dismiss AppPair if the task no longer supports multi window.
|
||||||
|
mController.unpair(mRootTaskInfo.taskId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (taskInfo.taskId == getRootTaskId()) {
|
if (taskInfo.taskId == getRootTaskId()) {
|
||||||
if (mRootTaskInfo.isVisible != taskInfo.isVisible) {
|
if (mRootTaskInfo.isVisible != taskInfo.isVisible) {
|
||||||
mSyncQueue.runInSync(t -> {
|
mSyncQueue.runInSync(t -> {
|
||||||
|
|||||||
@@ -203,6 +203,22 @@ class LegacySplitScreenTaskListener implements ShellTaskOrganizer.TaskListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
if (!taskInfo.supportsMultiWindow) {
|
||||||
|
if (mSplitScreenController.isDividerVisible()) {
|
||||||
|
// Dismiss the split screen if the task no longer supports multi window.
|
||||||
|
if (taskInfo.taskId == mPrimary.taskId
|
||||||
|
|| taskInfo.parentTaskId == mPrimary.taskId) {
|
||||||
|
// If the primary is focused, dismiss to primary.
|
||||||
|
mSplitScreenController
|
||||||
|
.startDismissSplit(taskInfo.isFocused /* toPrimaryTask */);
|
||||||
|
} else {
|
||||||
|
// If the secondary is not focused, dismiss to primary.
|
||||||
|
mSplitScreenController
|
||||||
|
.startDismissSplit(!taskInfo.isFocused /* toPrimaryTask */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (taskInfo.hasParentTask()) {
|
if (taskInfo.hasParentTask()) {
|
||||||
// changed messages are noisy since it reports on every ensureVisibility. This
|
// changed messages are noisy since it reports on every ensureVisibility. This
|
||||||
// conflicts with legacy app-transitions which "swaps" the position to a
|
// conflicts with legacy app-transitions which "swaps" the position to a
|
||||||
|
|||||||
@@ -908,6 +908,13 @@ class StageCoordinator implements SplitLayout.LayoutChangeListener,
|
|||||||
StageCoordinator.this.onStageRootTaskVanished(this);
|
StageCoordinator.this.onStageRootTaskVanished(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNoLongerSupportMultiWindow() {
|
||||||
|
if (mMainStage.isActive()) {
|
||||||
|
StageCoordinator.this.exitSplitScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void reset() {
|
private void reset() {
|
||||||
mHasRootTask = false;
|
mHasRootTask = false;
|
||||||
mVisible = false;
|
mVisible = false;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
|
|||||||
void onStatusChanged(boolean visible, boolean hasChildren);
|
void onStatusChanged(boolean visible, boolean hasChildren);
|
||||||
void onChildTaskStatusChanged(int taskId, boolean present, boolean visible);
|
void onChildTaskStatusChanged(int taskId, boolean present, boolean visible);
|
||||||
void onRootTaskVanished();
|
void onRootTaskVanished();
|
||||||
|
void onNoLongerSupportMultiWindow();
|
||||||
}
|
}
|
||||||
private final StageListenerCallbacks mCallbacks;
|
private final StageListenerCallbacks mCallbacks;
|
||||||
private final SyncTransactionQueue mSyncQueue;
|
private final SyncTransactionQueue mSyncQueue;
|
||||||
@@ -113,6 +114,11 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
|
|||||||
@Override
|
@Override
|
||||||
@CallSuper
|
@CallSuper
|
||||||
public void onTaskInfoChanged(ActivityManager.RunningTaskInfo taskInfo) {
|
public void onTaskInfoChanged(ActivityManager.RunningTaskInfo taskInfo) {
|
||||||
|
if (!taskInfo.supportsMultiWindow) {
|
||||||
|
// Leave split screen if the task no longer supports multi window.
|
||||||
|
mCallbacks.onNoLongerSupportMultiWindow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mRootTaskInfo.taskId == taskInfo.taskId) {
|
if (mRootTaskInfo.taskId == taskInfo.taskId) {
|
||||||
mRootTaskInfo = taskInfo;
|
mRootTaskInfo = taskInfo;
|
||||||
} else if (taskInfo.parentTaskId == mRootTaskInfo.taskId) {
|
} else if (taskInfo.parentTaskId == mRootTaskInfo.taskId) {
|
||||||
|
|||||||
@@ -18,9 +18,12 @@ package com.android.wm.shell.apppairs;
|
|||||||
|
|
||||||
import static android.view.Display.DEFAULT_DISPLAY;
|
import static android.view.Display.DEFAULT_DISPLAY;
|
||||||
|
|
||||||
|
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
@@ -43,7 +46,11 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
/** Tests for {@link AppPair} */
|
/**
|
||||||
|
* Tests for {@link AppPair}
|
||||||
|
* Build/Install/Run:
|
||||||
|
* atest WMShellUnitTests:AppPairTests
|
||||||
|
*/
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class AppPairTests extends ShellTestCase {
|
public class AppPairTests extends ShellTestCase {
|
||||||
@@ -63,6 +70,7 @@ public class AppPairTests extends ShellTestCase {
|
|||||||
mTaskOrganizer,
|
mTaskOrganizer,
|
||||||
mSyncQueue,
|
mSyncQueue,
|
||||||
mDisplayController);
|
mDisplayController);
|
||||||
|
spyOn(mController);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -97,4 +105,19 @@ public class AppPairTests extends ShellTestCase {
|
|||||||
assertThat(pair.contains(task1.taskId)).isFalse();
|
assertThat(pair.contains(task1.taskId)).isFalse();
|
||||||
assertThat(pair.contains(task2.taskId)).isFalse();
|
assertThat(pair.contains(task2.taskId)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UiThreadTest
|
||||||
|
public void testOnTaskInfoChanged_notSupportsMultiWindow() {
|
||||||
|
final ActivityManager.RunningTaskInfo task1 = new TestRunningTaskInfoBuilder().build();
|
||||||
|
final ActivityManager.RunningTaskInfo task2 = new TestRunningTaskInfoBuilder().build();
|
||||||
|
|
||||||
|
final AppPair pair = mController.pairInner(task1, task2);
|
||||||
|
assertThat(pair.contains(task1.taskId)).isTrue();
|
||||||
|
assertThat(pair.contains(task2.taskId)).isTrue();
|
||||||
|
|
||||||
|
task1.supportsMultiWindow = false;
|
||||||
|
pair.onTaskInfoChanged(task1);
|
||||||
|
verify(mController).unpair(pair.getRootTaskId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
/** Tests for {@link StageTaskListener} */
|
/**
|
||||||
|
* Tests for {@link StageTaskListener}
|
||||||
|
* Build/Install/Run:
|
||||||
|
* atest WMShellUnitTests:StageTaskListenerTests
|
||||||
|
*/
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public final class StageTaskListenerTests {
|
public final class StageTaskListenerTests {
|
||||||
@@ -101,4 +105,14 @@ public final class StageTaskListenerTests {
|
|||||||
mStageTaskListener.onTaskVanished(mRootTask);
|
mStageTaskListener.onTaskVanished(mRootTask);
|
||||||
verify(mCallbacks).onRootTaskVanished();
|
verify(mCallbacks).onRootTaskVanished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTaskInfoChanged_notSupportsMultiWindow() {
|
||||||
|
final ActivityManager.RunningTaskInfo childTask =
|
||||||
|
new TestRunningTaskInfoBuilder().setParentTaskId(mRootTask.taskId).build();
|
||||||
|
childTask.supportsMultiWindow = false;
|
||||||
|
|
||||||
|
mStageTaskListener.onTaskInfoChanged(childTask);
|
||||||
|
verify(mCallbacks).onNoLongerSupportMultiWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user