Merge "Rename split classes/variables for consistency" into tm-qpr-dev
This commit is contained in:
@@ -44,7 +44,7 @@ import com.android.wm.shell.common.annotations.ExternalThread;
|
||||
import com.android.wm.shell.common.annotations.ShellMainThread;
|
||||
import com.android.wm.shell.protolog.ShellProtoLogGroup;
|
||||
import com.android.wm.shell.util.GroupedRecentTaskInfo;
|
||||
import com.android.wm.shell.util.StagedSplitBounds;
|
||||
import com.android.wm.shell.util.SplitBounds;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
@@ -69,12 +69,12 @@ public class RecentTasksController implements TaskStackListenerCallback,
|
||||
// pair, then mSplitTasks[t1] = t2, and mSplitTasks[t2] = t1)
|
||||
private final SparseIntArray mSplitTasks = new SparseIntArray();
|
||||
/**
|
||||
* Maps taskId to {@link StagedSplitBounds} for both taskIDs.
|
||||
* Maps taskId to {@link SplitBounds} for both taskIDs.
|
||||
* Meaning there will be two taskId integers mapping to the same object.
|
||||
* If there's any ordering to the pairing than we can probably just get away with only one
|
||||
* taskID mapping to it, leaving both for consistency with {@link #mSplitTasks} for now.
|
||||
*/
|
||||
private final Map<Integer, StagedSplitBounds> mTaskSplitBoundsMap = new HashMap<>();
|
||||
private final Map<Integer, SplitBounds> mTaskSplitBoundsMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Creates {@link RecentTasksController}, returns {@code null} if the feature is not
|
||||
@@ -110,7 +110,7 @@ public class RecentTasksController implements TaskStackListenerCallback,
|
||||
/**
|
||||
* Adds a split pair. This call does not validate the taskIds, only that they are not the same.
|
||||
*/
|
||||
public void addSplitPair(int taskId1, int taskId2, StagedSplitBounds splitBounds) {
|
||||
public void addSplitPair(int taskId1, int taskId2, SplitBounds splitBounds) {
|
||||
if (taskId1 == taskId2) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ import com.android.wm.shell.recents.RecentTasksController;
|
||||
import com.android.wm.shell.splitscreen.SplitScreen.StageType;
|
||||
import com.android.wm.shell.splitscreen.SplitScreenController.ExitReason;
|
||||
import com.android.wm.shell.transition.Transitions;
|
||||
import com.android.wm.shell.util.StagedSplitBounds;
|
||||
import com.android.wm.shell.util.SplitBounds;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
@@ -927,7 +927,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
leftTopTaskId = mainStageTopTaskId;
|
||||
rightBottomTaskId = sideStageTopTaskId;
|
||||
}
|
||||
StagedSplitBounds splitBounds = new StagedSplitBounds(topLeftBounds, bottomRightBounds,
|
||||
SplitBounds splitBounds = new SplitBounds(topLeftBounds, bottomRightBounds,
|
||||
leftTopTaskId, rightBottomTaskId);
|
||||
if (mainStageTopTaskId != INVALID_TASK_ID && sideStageTopTaskId != INVALID_TASK_ID) {
|
||||
// Update the pair for the top tasks
|
||||
|
||||
@@ -30,7 +30,7 @@ import androidx.annotation.Nullable;
|
||||
public class GroupedRecentTaskInfo implements Parcelable {
|
||||
public @NonNull ActivityManager.RecentTaskInfo mTaskInfo1;
|
||||
public @Nullable ActivityManager.RecentTaskInfo mTaskInfo2;
|
||||
public @Nullable StagedSplitBounds mStagedSplitBounds;
|
||||
public @Nullable SplitBounds mSplitBounds;
|
||||
|
||||
public GroupedRecentTaskInfo(@NonNull ActivityManager.RecentTaskInfo task1) {
|
||||
this(task1, null, null);
|
||||
@@ -38,24 +38,24 @@ public class GroupedRecentTaskInfo implements Parcelable {
|
||||
|
||||
public GroupedRecentTaskInfo(@NonNull ActivityManager.RecentTaskInfo task1,
|
||||
@Nullable ActivityManager.RecentTaskInfo task2,
|
||||
@Nullable StagedSplitBounds stagedSplitBounds) {
|
||||
@Nullable SplitBounds splitBounds) {
|
||||
mTaskInfo1 = task1;
|
||||
mTaskInfo2 = task2;
|
||||
mStagedSplitBounds = stagedSplitBounds;
|
||||
mSplitBounds = splitBounds;
|
||||
}
|
||||
|
||||
GroupedRecentTaskInfo(Parcel parcel) {
|
||||
mTaskInfo1 = parcel.readTypedObject(ActivityManager.RecentTaskInfo.CREATOR);
|
||||
mTaskInfo2 = parcel.readTypedObject(ActivityManager.RecentTaskInfo.CREATOR);
|
||||
mStagedSplitBounds = parcel.readTypedObject(StagedSplitBounds.CREATOR);
|
||||
mSplitBounds = parcel.readTypedObject(SplitBounds.CREATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String taskString = "Task1: " + getTaskInfo(mTaskInfo1)
|
||||
+ ", Task2: " + getTaskInfo(mTaskInfo2);
|
||||
if (mStagedSplitBounds != null) {
|
||||
taskString += ", SplitBounds: " + mStagedSplitBounds.toString();
|
||||
if (mSplitBounds != null) {
|
||||
taskString += ", SplitBounds: " + mSplitBounds.toString();
|
||||
}
|
||||
return taskString;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class GroupedRecentTaskInfo implements Parcelable {
|
||||
public void writeToParcel(Parcel parcel, int flags) {
|
||||
parcel.writeTypedObject(mTaskInfo1, flags);
|
||||
parcel.writeTypedObject(mTaskInfo2, flags);
|
||||
parcel.writeTypedObject(mStagedSplitBounds, flags);
|
||||
parcel.writeTypedObject(mSplitBounds, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Objects;
|
||||
* Container of various information needed to display split screen
|
||||
* tasks/leashes/etc in Launcher
|
||||
*/
|
||||
public class StagedSplitBounds implements Parcelable {
|
||||
public class SplitBounds implements Parcelable {
|
||||
public final Rect leftTopBounds;
|
||||
public final Rect rightBottomBounds;
|
||||
/** This rect represents the actual gap between the two apps */
|
||||
@@ -43,7 +43,7 @@ public class StagedSplitBounds implements Parcelable {
|
||||
public final int leftTopTaskId;
|
||||
public final int rightBottomTaskId;
|
||||
|
||||
public StagedSplitBounds(Rect leftTopBounds, Rect rightBottomBounds,
|
||||
public SplitBounds(Rect leftTopBounds, Rect rightBottomBounds,
|
||||
int leftTopTaskId, int rightBottomTaskId) {
|
||||
this.leftTopBounds = leftTopBounds;
|
||||
this.rightBottomBounds = rightBottomBounds;
|
||||
@@ -66,7 +66,7 @@ public class StagedSplitBounds implements Parcelable {
|
||||
topTaskPercent = this.leftTopBounds.height() / (float) rightBottomBounds.bottom;
|
||||
}
|
||||
|
||||
public StagedSplitBounds(Parcel parcel) {
|
||||
public SplitBounds(Parcel parcel) {
|
||||
leftTopBounds = parcel.readTypedObject(Rect.CREATOR);
|
||||
rightBottomBounds = parcel.readTypedObject(Rect.CREATOR);
|
||||
visualDividerBounds = parcel.readTypedObject(Rect.CREATOR);
|
||||
@@ -96,11 +96,11 @@ public class StagedSplitBounds implements Parcelable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof StagedSplitBounds)) {
|
||||
if (!(obj instanceof SplitBounds)) {
|
||||
return false;
|
||||
}
|
||||
// Only need to check the base fields (the other fields are derived from these)
|
||||
final StagedSplitBounds other = (StagedSplitBounds) obj;
|
||||
final SplitBounds other = (SplitBounds) obj;
|
||||
return Objects.equals(leftTopBounds, other.leftTopBounds)
|
||||
&& Objects.equals(rightBottomBounds, other.rightBottomBounds)
|
||||
&& leftTopTaskId == other.leftTopTaskId
|
||||
@@ -120,15 +120,15 @@ public class StagedSplitBounds implements Parcelable {
|
||||
+ "AppsVertical? " + appsStackedVertically;
|
||||
}
|
||||
|
||||
public static final Creator<StagedSplitBounds> CREATOR = new Creator<StagedSplitBounds>() {
|
||||
public static final Creator<SplitBounds> CREATOR = new Creator<SplitBounds>() {
|
||||
@Override
|
||||
public StagedSplitBounds createFromParcel(Parcel in) {
|
||||
return new StagedSplitBounds(in);
|
||||
public SplitBounds createFromParcel(Parcel in) {
|
||||
return new SplitBounds(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StagedSplitBounds[] newArray(int size) {
|
||||
return new StagedSplitBounds[size];
|
||||
public SplitBounds[] newArray(int size) {
|
||||
return new SplitBounds[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -47,7 +47,7 @@ import com.android.wm.shell.TestShellExecutor;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
import com.android.wm.shell.common.TaskStackListenerImpl;
|
||||
import com.android.wm.shell.util.GroupedRecentTaskInfo;
|
||||
import com.android.wm.shell.util.StagedSplitBounds;
|
||||
import com.android.wm.shell.util.SplitBounds;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -89,7 +89,7 @@ public class RecentTasksControllerTest extends ShellTestCase {
|
||||
ActivityManager.RecentTaskInfo t2 = makeTaskInfo(2);
|
||||
setRawList(t1, t2);
|
||||
|
||||
mRecentTasksController.addSplitPair(t1.taskId, t2.taskId, mock(StagedSplitBounds.class));
|
||||
mRecentTasksController.addSplitPair(t1.taskId, t2.taskId, mock(SplitBounds.class));
|
||||
verify(mRecentTasksController).notifyRecentTasksChanged();
|
||||
|
||||
reset(mRecentTasksController);
|
||||
@@ -104,10 +104,10 @@ public class RecentTasksControllerTest extends ShellTestCase {
|
||||
setRawList(t1, t2);
|
||||
|
||||
// Verify only one update if the split info is the same
|
||||
StagedSplitBounds bounds1 = new StagedSplitBounds(new Rect(0, 0, 50, 50),
|
||||
SplitBounds bounds1 = new SplitBounds(new Rect(0, 0, 50, 50),
|
||||
new Rect(50, 50, 100, 100), t1.taskId, t2.taskId);
|
||||
mRecentTasksController.addSplitPair(t1.taskId, t2.taskId, bounds1);
|
||||
StagedSplitBounds bounds2 = new StagedSplitBounds(new Rect(0, 0, 50, 50),
|
||||
SplitBounds bounds2 = new SplitBounds(new Rect(0, 0, 50, 50),
|
||||
new Rect(50, 50, 100, 100), t1.taskId, t2.taskId);
|
||||
mRecentTasksController.addSplitPair(t1.taskId, t2.taskId, bounds2);
|
||||
verify(mRecentTasksController, times(1)).notifyRecentTasksChanged();
|
||||
@@ -139,8 +139,8 @@ public class RecentTasksControllerTest extends ShellTestCase {
|
||||
setRawList(t1, t2, t3, t4, t5, t6);
|
||||
|
||||
// Mark a couple pairs [t2, t4], [t3, t5]
|
||||
StagedSplitBounds pair1Bounds = new StagedSplitBounds(new Rect(), new Rect(), 2, 4);
|
||||
StagedSplitBounds pair2Bounds = new StagedSplitBounds(new Rect(), new Rect(), 3, 5);
|
||||
SplitBounds pair1Bounds = new SplitBounds(new Rect(), new Rect(), 2, 4);
|
||||
SplitBounds pair2Bounds = new SplitBounds(new Rect(), new Rect(), 3, 5);
|
||||
|
||||
mRecentTasksController.addSplitPair(t2.taskId, t4.taskId, pair1Bounds);
|
||||
mRecentTasksController.addSplitPair(t3.taskId, t5.taskId, pair2Bounds);
|
||||
@@ -162,7 +162,7 @@ public class RecentTasksControllerTest extends ShellTestCase {
|
||||
setRawList(t1, t2, t3);
|
||||
|
||||
// Add a pair
|
||||
StagedSplitBounds pair1Bounds = new StagedSplitBounds(new Rect(), new Rect(), 2, 3);
|
||||
SplitBounds pair1Bounds = new SplitBounds(new Rect(), new Rect(), 2, 3);
|
||||
mRecentTasksController.addSplitPair(t2.taskId, t3.taskId, pair1Bounds);
|
||||
reset(mRecentTasksController);
|
||||
|
||||
@@ -245,15 +245,15 @@ public class RecentTasksControllerTest extends ShellTestCase {
|
||||
: -1;
|
||||
|
||||
if (pair.mTaskInfo2 != null) {
|
||||
assertNotNull(pair.mStagedSplitBounds);
|
||||
int leftTopTaskId = pair.mStagedSplitBounds.leftTopTaskId;
|
||||
int bottomRightTaskId = pair.mStagedSplitBounds.rightBottomTaskId;
|
||||
assertNotNull(pair.mSplitBounds);
|
||||
int leftTopTaskId = pair.mSplitBounds.leftTopTaskId;
|
||||
int bottomRightTaskId = pair.mSplitBounds.rightBottomTaskId;
|
||||
// Unclear if pairs are ordered by split position, most likely not.
|
||||
assertTrue(leftTopTaskId == taskId1 || leftTopTaskId == pair.mTaskInfo2.taskId);
|
||||
assertTrue(bottomRightTaskId == taskId1
|
||||
|| bottomRightTaskId == pair.mTaskInfo2.taskId);
|
||||
} else {
|
||||
assertNull(pair.mStagedSplitBounds);
|
||||
assertNull(pair.mSplitBounds);
|
||||
}
|
||||
}
|
||||
assertTrue("Expected: " + Arrays.toString(expectedTaskIds)
|
||||
|
||||
@@ -9,7 +9,7 @@ import android.graphics.Rect;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.wm.shell.util.StagedSplitBounds;
|
||||
import com.android.wm.shell.util.SplitBounds;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -17,7 +17,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class StagedSplitBoundsTest {
|
||||
public class SplitBoundsTest {
|
||||
private static final int DEVICE_WIDTH = 100;
|
||||
private static final int DEVICE_LENGTH = 200;
|
||||
private static final int DIVIDER_SIZE = 20;
|
||||
@@ -42,21 +42,21 @@ public class StagedSplitBoundsTest {
|
||||
|
||||
@Test
|
||||
public void testVerticalStacked() {
|
||||
StagedSplitBounds ssb = new StagedSplitBounds(mTopRect, mBottomRect,
|
||||
SplitBounds ssb = new SplitBounds(mTopRect, mBottomRect,
|
||||
TASK_ID_1, TASK_ID_2);
|
||||
assertTrue(ssb.appsStackedVertically);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHorizontalStacked() {
|
||||
StagedSplitBounds ssb = new StagedSplitBounds(mLeftRect, mRightRect,
|
||||
SplitBounds ssb = new SplitBounds(mLeftRect, mRightRect,
|
||||
TASK_ID_1, TASK_ID_2);
|
||||
assertFalse(ssb.appsStackedVertically);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHorizontalDividerBounds() {
|
||||
StagedSplitBounds ssb = new StagedSplitBounds(mTopRect, mBottomRect,
|
||||
SplitBounds ssb = new SplitBounds(mTopRect, mBottomRect,
|
||||
TASK_ID_1, TASK_ID_2);
|
||||
Rect dividerBounds = ssb.visualDividerBounds;
|
||||
assertEquals(0, dividerBounds.left);
|
||||
@@ -67,7 +67,7 @@ public class StagedSplitBoundsTest {
|
||||
|
||||
@Test
|
||||
public void testVerticalDividerBounds() {
|
||||
StagedSplitBounds ssb = new StagedSplitBounds(mLeftRect, mRightRect,
|
||||
SplitBounds ssb = new SplitBounds(mLeftRect, mRightRect,
|
||||
TASK_ID_1, TASK_ID_2);
|
||||
Rect dividerBounds = ssb.visualDividerBounds;
|
||||
assertEquals(DEVICE_WIDTH / 2 - DIVIDER_SIZE / 2, dividerBounds.left);
|
||||
@@ -78,7 +78,7 @@ public class StagedSplitBoundsTest {
|
||||
|
||||
@Test
|
||||
public void testEqualVerticalTaskPercent() {
|
||||
StagedSplitBounds ssb = new StagedSplitBounds(mTopRect, mBottomRect,
|
||||
SplitBounds ssb = new SplitBounds(mTopRect, mBottomRect,
|
||||
TASK_ID_1, TASK_ID_2);
|
||||
float topPercentSpaceTaken = (float) (DEVICE_LENGTH / 2 - DIVIDER_SIZE / 2) / DEVICE_LENGTH;
|
||||
assertEquals(topPercentSpaceTaken, ssb.topTaskPercent, 0.01);
|
||||
@@ -86,7 +86,7 @@ public class StagedSplitBoundsTest {
|
||||
|
||||
@Test
|
||||
public void testEqualHorizontalTaskPercent() {
|
||||
StagedSplitBounds ssb = new StagedSplitBounds(mLeftRect, mRightRect,
|
||||
SplitBounds ssb = new SplitBounds(mLeftRect, mRightRect,
|
||||
TASK_ID_1, TASK_ID_2);
|
||||
float leftPercentSpaceTaken = (float) (DEVICE_WIDTH / 2 - DIVIDER_SIZE / 2) / DEVICE_WIDTH;
|
||||
assertEquals(leftPercentSpaceTaken, ssb.leftTaskPercent, 0.01);
|
||||
Reference in New Issue
Block a user