Merge "Read task size info from RecentsView directly" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
eda0a92d52
@@ -274,6 +274,15 @@ public final class OverviewComponentObserver {
|
||||
return mActivityInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current container control helper for managing interactions to the overview activity.
|
||||
*
|
||||
* @return the current container control helper
|
||||
*/
|
||||
public BaseContainerInterface<?, ?> getContainerInterface() {
|
||||
return mActivityInterface;
|
||||
}
|
||||
|
||||
public void dump(PrintWriter pw) {
|
||||
pw.println("OverviewComponentObserver:");
|
||||
pw.println(" isDefaultHome=" + mIsDefaultHome);
|
||||
|
||||
@@ -7,6 +7,7 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -22,6 +23,7 @@ import com.android.quickstep.util.GroupTask;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
import com.android.quickstep.util.TISBindHelper;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.RecentsViewContainer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -79,39 +81,39 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
|
||||
return response;
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET: {
|
||||
case TestProtocol.REQUEST_GET_OVERVIEW_TASK_SIZE: {
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "== REQUEST_GET_OVERVIEW_TASK_SIZE ==");
|
||||
Rect gridSize = new Rect();
|
||||
LauncherActivityInterface.INSTANCE.calculateGridSize(mDeviceProfile, mContext,
|
||||
gridSize);
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "gridSize: " + gridSize);
|
||||
PointF taskDimension = new PointF();
|
||||
LauncherActivityInterface.getTaskDimension(mContext, mDeviceProfile, taskDimension);
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH,
|
||||
"=== REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET ===");
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "isTablet: " + mDeviceProfile.isTablet);
|
||||
if (!mDeviceProfile.isTablet) {
|
||||
return null;
|
||||
}
|
||||
Rect focusedTaskRect = new Rect();
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "widthPx: " + mDeviceProfile.widthPx);
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "heightPx: " + mDeviceProfile.heightPx);
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "insets: " + mDeviceProfile.getInsets());
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "overviewTaskThumbnailTopMarginPx: "
|
||||
+ mDeviceProfile.overviewTaskThumbnailTopMarginPx);
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "overviewActionsClaimedSpace: "
|
||||
+ mDeviceProfile.getOverviewActionsClaimedSpace());
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH,
|
||||
"overviewGridSideMargin: " + mDeviceProfile.overviewGridSideMargin);
|
||||
"taskbarHeight: " + mDeviceProfile.taskbarHeight);
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "taskDimension: " + taskDimension);
|
||||
Rect taskSize = new Rect();
|
||||
LauncherActivityInterface.INSTANCE.calculateTaskSize(mContext, mDeviceProfile,
|
||||
focusedTaskRect, RecentsPagedOrientationHandler.PORTRAIT);
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "focusedTaskRect: " + focusedTaskRect);
|
||||
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, focusedTaskRect.height());
|
||||
return response;
|
||||
taskSize, RecentsPagedOrientationHandler.PORTRAIT);
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "calculateTaskSize: " + taskSize);
|
||||
return getUIProperty(Bundle::putParcelable,
|
||||
recentsViewContainer -> {
|
||||
Rect lastComputedTaskSize =
|
||||
recentsViewContainer.<RecentsView<?, ?>>getOverviewPanel()
|
||||
.getLastComputedTaskSize();
|
||||
Log.d(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH,
|
||||
"lastComputedTaskSize: " + lastComputedTaskSize);
|
||||
return lastComputedTaskSize;
|
||||
},
|
||||
this::getRecentsViewContainer);
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_GET_GRID_TASK_SIZE_RECT_FOR_TABLET: {
|
||||
if (!mDeviceProfile.isTablet) {
|
||||
return null;
|
||||
}
|
||||
Rect gridTaskRect = new Rect();
|
||||
LauncherActivityInterface.INSTANCE.calculateGridTaskSize(mContext, mDeviceProfile,
|
||||
gridTaskRect, RecentsPagedOrientationHandler.PORTRAIT);
|
||||
response.putParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD, gridTaskRect);
|
||||
return response;
|
||||
case TestProtocol.REQUEST_GET_OVERVIEW_GRID_TASK_SIZE: {
|
||||
return getUIProperty(Bundle::putParcelable,
|
||||
recentsViewContainer ->
|
||||
recentsViewContainer.<RecentsView<?, ?>>getOverviewPanel()
|
||||
.getLastComputedGridTaskSize(),
|
||||
this::getRecentsViewContainer);
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_GET_OVERVIEW_PAGE_SPACING: {
|
||||
@@ -236,6 +238,17 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private RecentsViewContainer getRecentsViewContainer() {
|
||||
RecentsAnimationDeviceState rads = new RecentsAnimationDeviceState(mContext);
|
||||
OverviewComponentObserver observer = new OverviewComponentObserver(mContext, rads);
|
||||
try {
|
||||
return observer.getContainerInterface().getCreatedContainer();
|
||||
} finally {
|
||||
observer.onDestroy();
|
||||
rads.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isLauncherInitialized() {
|
||||
return super.isLauncherInitialized() && TouchInteractionService.isInitialized();
|
||||
|
||||
@@ -501,7 +501,7 @@ public class TestInformationHandler implements ResourceBasedOverride {
|
||||
/**
|
||||
* Returns the result by getting a generic property on UI thread
|
||||
*/
|
||||
private static <S, T> Bundle getUIProperty(
|
||||
protected static <S, T> Bundle getUIProperty(
|
||||
BundleSetter<T> bundleSetter, Function<S, T> provider, Supplier<S> targetSupplier) {
|
||||
return getFromExecutorSync(MAIN_EXECUTOR, () -> {
|
||||
S target = targetSupplier.get();
|
||||
|
||||
+2
-4
@@ -148,10 +148,8 @@ public final class TestProtocol {
|
||||
|
||||
public static final String REQUEST_HOTSEAT_CELL_CENTER = "hotseat-cell-center";
|
||||
|
||||
public static final String REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET =
|
||||
"get-focused-task-height-for-tablet";
|
||||
public static final String REQUEST_GET_GRID_TASK_SIZE_RECT_FOR_TABLET =
|
||||
"get-grid-task-size-rect-for-tablet";
|
||||
public static final String REQUEST_GET_OVERVIEW_TASK_SIZE = "get-overivew-task-size";
|
||||
public static final String REQUEST_GET_OVERVIEW_GRID_TASK_SIZE = "get-overivew-grid-task-size";
|
||||
public static final String REQUEST_GET_OVERVIEW_PAGE_SPACING = "get-overview-page-spacing";
|
||||
public static final String REQUEST_GET_OVERVIEW_CURRENT_PAGE_INDEX =
|
||||
"get-overview-current-page-index";
|
||||
|
||||
@@ -280,7 +280,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
|
||||
if (mLauncher.isTablet()) {
|
||||
mLauncher.assertTrue("current task is not grid height",
|
||||
getCurrentTask().getVisibleHeight() == mLauncher
|
||||
.getGridTaskRectForTablet().height());
|
||||
.getOverviewGridTaskSize().height());
|
||||
}
|
||||
mLauncher.assertTrue("Current task not scrolled off screen",
|
||||
!getCurrentTask().equals(task));
|
||||
@@ -356,7 +356,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
|
||||
final List<UiObject2> taskViews = getTasks();
|
||||
mLauncher.assertNotEquals("Unable to find a task", 0, taskViews.size());
|
||||
|
||||
final int gridTaskWidth = mLauncher.getGridTaskRectForTablet().width();
|
||||
final int gridTaskWidth = mLauncher.getOverviewGridTaskSize().width();
|
||||
|
||||
return taskViews.stream().filter(t -> t.getVisibleBounds().width() == gridTaskWidth).map(
|
||||
t -> new OverviewTask(mLauncher, t, this)).collect(Collectors.toList());
|
||||
@@ -531,12 +531,12 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
|
||||
throw new IllegalStateException("Must be run on tablet device.");
|
||||
}
|
||||
final List<UiObject2> taskViews = getTasks();
|
||||
if (taskViews.size() == 0) {
|
||||
if (taskViews.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
int focusedTaskHeight = mLauncher.getFocusedTaskHeightForTablet();
|
||||
testLogD(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH,
|
||||
"getFocusedTaskForTablet: " + focusedTaskHeight);
|
||||
Rect focusTaskSize = mLauncher.getOverviewTaskSize();
|
||||
testLogD(OVERVIEW_FOCUS_TASK_HEIGHT_MISMATCH, "focusTaskSize: " + focusTaskSize);
|
||||
int focusedTaskHeight = focusTaskSize.height();
|
||||
for (UiObject2 task : taskViews) {
|
||||
OverviewTask overviewTask = new OverviewTask(mLauncher, task, this);
|
||||
|
||||
|
||||
@@ -428,14 +428,14 @@ public final class LauncherInstrumentation {
|
||||
.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
|
||||
}
|
||||
|
||||
int getFocusedTaskHeightForTablet() {
|
||||
return getTestInfo(TestProtocol.REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET).getInt(
|
||||
TestProtocol.TEST_INFO_RESPONSE_FIELD);
|
||||
Rect getOverviewTaskSize() {
|
||||
return getTestInfo(TestProtocol.REQUEST_GET_OVERVIEW_TASK_SIZE)
|
||||
.getParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD, Rect.class);
|
||||
}
|
||||
|
||||
Rect getGridTaskRectForTablet() {
|
||||
return ((Rect) getTestInfo(TestProtocol.REQUEST_GET_GRID_TASK_SIZE_RECT_FOR_TABLET)
|
||||
.getParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD));
|
||||
Rect getOverviewGridTaskSize() {
|
||||
return getTestInfo(TestProtocol.REQUEST_GET_OVERVIEW_GRID_TASK_SIZE)
|
||||
.getParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD, Rect.class);
|
||||
}
|
||||
|
||||
int getOverviewPageSpacing() {
|
||||
|
||||
@@ -156,8 +156,8 @@ public final class OverviewTask {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean taskWasFocused = mLauncher.isTablet() && getVisibleHeight() == mLauncher
|
||||
.getFocusedTaskHeightForTablet();
|
||||
boolean taskWasFocused = mLauncher.isTablet()
|
||||
&& getVisibleHeight() == mLauncher.getOverviewTaskSize().height();
|
||||
List<Integer> originalTasksCenterX =
|
||||
getCurrentTasksCenterXList().stream().sorted().toList();
|
||||
boolean isClearAllVisibleBeforeDismiss = mOverview.isClearAllVisible();
|
||||
|
||||
Reference in New Issue
Block a user