Snap for 8775066 from f6fc56bfc7 to udc-release
Change-Id: I2914394403902e32e317bf2dac4c4c49128e2b2e
This commit is contained in:
commit
a3ab906bdd
18 files changed
+392
-38
No files matched your search
@@ -268,7 +268,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
mLastRequestedNonFullscreenHeight,
|
||||
type,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||
| WindowManager.LayoutParams.FLAG_SLIPPERY,
|
||||
| WindowManager.LayoutParams.FLAG_SLIPPERY
|
||||
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
windowLayoutParams.setTitle(WINDOW_TITLE);
|
||||
windowLayoutParams.packageName = getPackageName();
|
||||
|
||||
@@ -207,7 +207,7 @@ public final class TaskbarAllAppsController {
|
||||
private LayoutParams createLayoutParams() {
|
||||
LayoutParams layoutParams = new LayoutParams(
|
||||
TYPE_APPLICATION_OVERLAY,
|
||||
0,
|
||||
WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
layoutParams.setTitle(WINDOW_TITLE);
|
||||
layoutParams.gravity = Gravity.BOTTOM;
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.quickstep.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.VelocityTracker;
|
||||
|
||||
@@ -31,6 +32,8 @@ import com.android.launcher3.testing.TestProtocol;
|
||||
*/
|
||||
public class MotionPauseDetector {
|
||||
|
||||
private static final String TAG = "MotionPauseDetector";
|
||||
|
||||
// The percentage of the previous speed that determines whether this is a rapid deceleration.
|
||||
// The bigger this number, the easier it is to trigger the first pause.
|
||||
private static final float RAPID_DECELERATION_FACTOR = 0.6f;
|
||||
@@ -85,7 +88,8 @@ public class MotionPauseDetector {
|
||||
mSpeedSomewhatFast = res.getDimension(R.dimen.motion_pause_detector_speed_somewhat_fast);
|
||||
mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast);
|
||||
mForcePauseTimeout = new Alarm();
|
||||
mForcePauseTimeout.setOnAlarmListener(alarm -> updatePaused(true /* isPaused */));
|
||||
mForcePauseTimeout.setOnAlarmListener(alarm -> updatePaused(true /* isPaused */,
|
||||
"Force pause timeout after " + alarm.getLastSetTimeout() + "ms" /* reason */));
|
||||
mMakePauseHarderToTrigger = makePauseHarderToTrigger;
|
||||
mVelocityProvider = new SystemVelocityProvider(axis);
|
||||
}
|
||||
@@ -102,7 +106,7 @@ public class MotionPauseDetector {
|
||||
*/
|
||||
public void setDisallowPause(boolean disallowPause) {
|
||||
mDisallowPause = disallowPause;
|
||||
updatePaused(mIsPaused);
|
||||
updatePaused(mIsPaused, "Set disallowPause=" + disallowPause);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,21 +138,27 @@ public class MotionPauseDetector {
|
||||
float speed = Math.abs(velocity);
|
||||
float previousSpeed = Math.abs(prevVelocity);
|
||||
boolean isPaused;
|
||||
String isPausedReason = "";
|
||||
if (mIsPaused) {
|
||||
// Continue to be paused until moving at a fast speed.
|
||||
isPaused = speed < mSpeedFast || previousSpeed < mSpeedFast;
|
||||
isPausedReason = "Was paused, but started moving at a fast speed";
|
||||
} else {
|
||||
if (velocity < 0 != prevVelocity < 0) {
|
||||
// We're just changing directions, not necessarily stopping.
|
||||
isPaused = false;
|
||||
isPausedReason = "Velocity changed directions";
|
||||
} else {
|
||||
isPaused = speed < mSpeedVerySlow && previousSpeed < mSpeedVerySlow;
|
||||
isPausedReason = "Pause requires back to back slow speeds";
|
||||
if (!isPaused && !mHasEverBeenPaused) {
|
||||
// We want to be more aggressive about detecting the first pause to ensure it
|
||||
// feels as responsive as possible; getting two very slow speeds back to back
|
||||
// takes too long, so also check for a rapid deceleration.
|
||||
boolean isRapidDeceleration = speed < previousSpeed * RAPID_DECELERATION_FACTOR;
|
||||
isPaused = isRapidDeceleration && speed < mSpeedSomewhatFast;
|
||||
isPausedReason = "Didn't have back to back slow speeds, checking for rapid"
|
||||
+ " deceleration on first pause only";
|
||||
}
|
||||
if (mMakePauseHarderToTrigger) {
|
||||
if (speed < mSpeedSlow) {
|
||||
@@ -156,22 +166,27 @@ public class MotionPauseDetector {
|
||||
mSlowStartTime = time;
|
||||
}
|
||||
isPaused = time - mSlowStartTime >= HARDER_TRIGGER_TIMEOUT;
|
||||
isPausedReason = "Maintained slow speed for sufficient duration when making"
|
||||
+ " pause harder to trigger";
|
||||
} else {
|
||||
mSlowStartTime = 0;
|
||||
isPaused = false;
|
||||
isPausedReason = "Intentionally making pause harder to trigger";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
updatePaused(isPaused);
|
||||
updatePaused(isPaused, isPausedReason);
|
||||
}
|
||||
|
||||
private void updatePaused(boolean isPaused) {
|
||||
private void updatePaused(boolean isPaused, String reason) {
|
||||
if (mDisallowPause) {
|
||||
reason = "Disallow pause; otherwise, would have been " + isPaused + " due to " + reason;
|
||||
isPaused = false;
|
||||
}
|
||||
if (mIsPaused != isPaused) {
|
||||
mIsPaused = isPaused;
|
||||
Log.d(TAG, "onMotionPauseChanged, paused=" + mIsPaused + " reason=" + reason);
|
||||
boolean isFirstDetectedPause = !mHasEverBeenPaused && mIsPaused;
|
||||
if (mIsPaused) {
|
||||
AccessibilityManagerCompat.sendPauseDetectedEventToTest(mContext);
|
||||
|
||||
@@ -30,6 +30,7 @@ public class Alarm implements Runnable{
|
||||
private Handler mHandler;
|
||||
private OnAlarmListener mAlarmListener;
|
||||
private boolean mAlarmPending = false;
|
||||
private long mLastSetTimeout;
|
||||
|
||||
public Alarm() {
|
||||
mHandler = new Handler();
|
||||
@@ -46,6 +47,7 @@ public class Alarm implements Runnable{
|
||||
mAlarmPending = true;
|
||||
long oldTriggerTime = mAlarmTriggerTime;
|
||||
mAlarmTriggerTime = currentTime + millisecondsInFuture;
|
||||
mLastSetTimeout = millisecondsInFuture;
|
||||
|
||||
// If the previous alarm was set for a longer duration, cancel it.
|
||||
if (mWaitingForCallback && oldTriggerTime > mAlarmTriggerTime) {
|
||||
@@ -84,4 +86,9 @@ public class Alarm implements Runnable{
|
||||
public boolean alarmPending() {
|
||||
return mAlarmPending;
|
||||
}
|
||||
|
||||
/** Returns the last value passed to {@link #setAlarm(long)} */
|
||||
public long getLastSetTimeout() {
|
||||
return mLastSetTimeout;
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,8 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
mTouchHandler.handleTouchEvent(ev, mFastScrollerOffset);
|
||||
return true;
|
||||
}
|
||||
if (isSearching()) {
|
||||
if (isSearching()
|
||||
&& mActivityContext.getDragLayer().isEventOverView(getVisibleContainerView(), ev)) {
|
||||
// if in search state, consume touch event.
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -277,6 +277,10 @@ public final class FeatureFlags {
|
||||
"ENABLE_DISMISS_PREDICTION_UNDO", false,
|
||||
"Show an 'Undo' snackbar when users dismiss a predicted hotseat item");
|
||||
|
||||
public static final BooleanFlag ENABLE_CACHED_WIDGET = getDebugFlag(
|
||||
"ENABLE_CACHED_WIDGET", true,
|
||||
"Show previously cached widgets as opposed to deferred widget where available");
|
||||
|
||||
public static void initialize(Context context) {
|
||||
synchronized (sDebugFlags) {
|
||||
for (DebugFlag flag : sDebugFlags) {
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.testing;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* Request object for querying a hotseat cell region in Rect.
|
||||
*/
|
||||
public class HotseatCellCenterRequest implements TestInformationRequest {
|
||||
public final int cellInd;
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(cellInd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestName() {
|
||||
return TestProtocol.REQUEST_HOTSEAT_CELL_CENTER;
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<HotseatCellCenterRequest> CREATOR =
|
||||
new Parcelable.Creator<HotseatCellCenterRequest>() {
|
||||
|
||||
@Override
|
||||
public HotseatCellCenterRequest createFromParcel(Parcel source) {
|
||||
return new HotseatCellCenterRequest(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HotseatCellCenterRequest[] newArray(int size) {
|
||||
return new HotseatCellCenterRequest[size];
|
||||
}
|
||||
};
|
||||
|
||||
private HotseatCellCenterRequest(int cellInd) {
|
||||
this.cellInd = cellInd;
|
||||
}
|
||||
|
||||
private HotseatCellCenterRequest(Parcel in) {
|
||||
this(in.readInt());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder for HotseatCellCenterRequest.
|
||||
*
|
||||
* @return HotseatCellCenterRequest builder.
|
||||
*/
|
||||
public static HotseatCellCenterRequest.Builder builder() {
|
||||
return new HotseatCellCenterRequest.Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* HotseatCellCenterRequest Builder.
|
||||
*/
|
||||
public static final class Builder {
|
||||
private int mCellInd;
|
||||
|
||||
private Builder() {
|
||||
mCellInd = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the index of hotseat cells.
|
||||
*/
|
||||
public HotseatCellCenterRequest.Builder setCellInd(int i) {
|
||||
this.mCellInd = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* build the HotseatCellCenterRequest.
|
||||
*/
|
||||
public HotseatCellCenterRequest build() {
|
||||
return new HotseatCellCenterRequest(mCellInd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.CellLayout;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Hotseat;
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
@@ -185,7 +186,7 @@ public class TestInformationHandler implements ResourceBasedOverride {
|
||||
return new int[]{cellLayout.getCountX(), cellLayout.getCountY()};
|
||||
});
|
||||
|
||||
case TestProtocol.REQUEST_WORKSPACE_CELL_CENTER:
|
||||
case TestProtocol.REQUEST_WORKSPACE_CELL_CENTER: {
|
||||
final WorkspaceCellCenterRequest request = extra.getParcelable(
|
||||
TestProtocol.TEST_INFO_REQUEST_FIELD);
|
||||
return getLauncherUIProperty(Bundle::putParcelable, launcher -> {
|
||||
@@ -197,6 +198,21 @@ public class TestInformationHandler implements ResourceBasedOverride {
|
||||
cellLayout, request.cellX, request.cellY, request.spanX, request.spanY);
|
||||
return new Point(cellRect.centerX(), cellRect.centerY());
|
||||
});
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_HOTSEAT_CELL_CENTER: {
|
||||
final HotseatCellCenterRequest request = extra.getParcelable(
|
||||
TestProtocol.TEST_INFO_REQUEST_FIELD);
|
||||
return getLauncherUIProperty(Bundle::putParcelable, launcher -> {
|
||||
final Hotseat hotseat = launcher.getHotseat();
|
||||
final Rect cellRect = getDescendantRectRelativeToDragLayerForCell(launcher,
|
||||
hotseat, request.cellInd, /* cellY= */ 0,
|
||||
/* spanX= */ 1, /* spanY= */ 1);
|
||||
// TODO(b/234322284): return the real center point.
|
||||
return new Point(cellRect.left + (cellRect.right - cellRect.left) / 3,
|
||||
cellRect.centerY());
|
||||
});
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_HAS_TIS: {
|
||||
response.putBoolean(
|
||||
|
||||
@@ -115,6 +115,8 @@ public final class TestProtocol {
|
||||
public static final String REQUEST_WORKSPACE_CELL_LAYOUT_SIZE = "workspace-cell-layout-size";
|
||||
public static final String REQUEST_WORKSPACE_CELL_CENTER = "workspace-cell-center";
|
||||
|
||||
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 =
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.SparseArray;
|
||||
import android.widget.RemoteViews;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -37,6 +38,7 @@ import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.WidgetsModel;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
@@ -70,13 +72,14 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
|
||||
private final ArrayList<ProviderChangedListener> mProviderChangeListeners = new ArrayList<>();
|
||||
private final SparseArray<LauncherAppWidgetHostView> mViews = new SparseArray<>();
|
||||
private final SparseArray<PendingAppWidgetHostView> mPendingViews = new SparseArray<>();
|
||||
private final SparseArray<LauncherAppWidgetHostView> mDeferredViews = new SparseArray<>();
|
||||
private final SparseArray<RemoteViews> mCachedRemoteViews = new SparseArray<>();
|
||||
|
||||
private final Context mContext;
|
||||
private int mFlags = FLAG_STATE_IS_NORMAL;
|
||||
|
||||
private IntConsumer mAppWidgetRemovedCallback = null;
|
||||
|
||||
|
||||
public LauncherAppWidgetHost(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -95,6 +98,11 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
|
||||
if (mPendingViews.get(appWidgetId) != null) {
|
||||
view = mPendingViews.get(appWidgetId);
|
||||
mPendingViews.remove(appWidgetId);
|
||||
} else if (mDeferredViews.get(appWidgetId) != null) {
|
||||
// In case the widget view is deferred, we will simply return the deferred view as
|
||||
// opposed to instantiate a new instance of LauncherAppWidgetHostView since launcher
|
||||
// already added the former to the workspace.
|
||||
view = mDeferredViews.get(appWidgetId);
|
||||
} else {
|
||||
view = new LauncherAppWidgetHostView(context);
|
||||
}
|
||||
@@ -120,12 +128,25 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
|
||||
// widgets upon bind anyway. See issue 14255011 for more context.
|
||||
}
|
||||
|
||||
// We go in reverse order and inflate any deferred widget
|
||||
// We go in reverse order and inflate any deferred or cached widget
|
||||
for (int i = mViews.size() - 1; i >= 0; i--) {
|
||||
LauncherAppWidgetHostView view = mViews.valueAt(i);
|
||||
if (view instanceof DeferredAppWidgetHostView) {
|
||||
view.reInflate();
|
||||
}
|
||||
if (FeatureFlags.ENABLE_CACHED_WIDGET.get()) {
|
||||
final int appWidgetId = mViews.keyAt(i);
|
||||
if (view == mDeferredViews.get(appWidgetId)) {
|
||||
// If the widget view was deferred, we'll need to call super.createView here
|
||||
// to make the binder call to system process to fetch cumulative updates to this
|
||||
// widget, as well as setting up this view for future updates.
|
||||
super.createView(view.mLauncher, appWidgetId, view.getAppWidgetInfo());
|
||||
// At this point #onCreateView should have been called, which in turn returned
|
||||
// the deferred view. There's no reason to keep the reference anymore, so we
|
||||
// removed it here.
|
||||
mDeferredViews.remove(appWidgetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,10 +242,28 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
|
||||
CustomWidgetManager.INSTANCE.get(context).onViewCreated(lahv);
|
||||
return lahv;
|
||||
} else if ((mFlags & FLAG_LISTENING) == 0) {
|
||||
DeferredAppWidgetHostView view = new DeferredAppWidgetHostView(context);
|
||||
view.setAppWidget(appWidgetId, appWidget);
|
||||
mViews.put(appWidgetId, view);
|
||||
return view;
|
||||
// Since the launcher hasn't started listening to widget updates, we can't simply call
|
||||
// super.createView here because the later will make a binder call to retrieve
|
||||
// RemoteViews from system process.
|
||||
// TODO: have launcher always listens to widget updates in background so that this
|
||||
// check can be removed altogether.
|
||||
if (FeatureFlags.ENABLE_CACHED_WIDGET.get()
|
||||
&& mCachedRemoteViews.get(appWidgetId) != null) {
|
||||
// We've found RemoteViews from cache for this widget, so we will instantiate a
|
||||
// widget host view and populate it with the cached RemoteViews.
|
||||
final LauncherAppWidgetHostView view = new LauncherAppWidgetHostView(context);
|
||||
view.setAppWidget(appWidgetId, appWidget);
|
||||
view.updateAppWidget(mCachedRemoteViews.get(appWidgetId));
|
||||
mDeferredViews.put(appWidgetId, view);
|
||||
mViews.put(appWidgetId, view);
|
||||
return view;
|
||||
} else {
|
||||
// When cache misses, a placeholder for the widget will be returned instead.
|
||||
DeferredAppWidgetHostView view = new DeferredAppWidgetHostView(context);
|
||||
view.setAppWidget(appWidgetId, appWidget);
|
||||
mViews.put(appWidgetId, view);
|
||||
return view;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return super.createView(context, appWidgetId, appWidget);
|
||||
@@ -281,6 +320,16 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
|
||||
@Override
|
||||
public void clearViews() {
|
||||
super.clearViews();
|
||||
if (FeatureFlags.ENABLE_CACHED_WIDGET.get()) {
|
||||
// First, we clear any previously cached content from existing widgets
|
||||
mCachedRemoteViews.clear();
|
||||
// Then we proceed to cache the content from the widgets
|
||||
for (int i = 0; i < mViews.size(); i++) {
|
||||
final int appWidgetId = mViews.keyAt(i);
|
||||
final LauncherAppWidgetHostView view = mViews.get(appWidgetId);
|
||||
mCachedRemoteViews.put(appWidgetId, view.mLastRemoteViews);
|
||||
}
|
||||
}
|
||||
mViews.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.android.launcher3.CheckLongPressHelper;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
@@ -85,7 +86,7 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
private Runnable mAutoAdvanceRunnable;
|
||||
|
||||
private long mDeferUpdatesUntilMillis = 0;
|
||||
private RemoteViews mDeferredRemoteViews;
|
||||
RemoteViews mLastRemoteViews;
|
||||
private boolean mHasDeferredColorChange = false;
|
||||
private @Nullable SparseIntArray mDeferredColorChange = null;
|
||||
|
||||
@@ -150,11 +151,18 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
TRACE_METHOD_NAME + getAppWidgetInfo().provider, getAppWidgetId());
|
||||
mTrackingWidgetUpdate = false;
|
||||
}
|
||||
if (isDeferringUpdates()) {
|
||||
mDeferredRemoteViews = remoteViews;
|
||||
return;
|
||||
if (FeatureFlags.ENABLE_CACHED_WIDGET.get()) {
|
||||
mLastRemoteViews = remoteViews;
|
||||
if (isDeferringUpdates()) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (isDeferringUpdates()) {
|
||||
mLastRemoteViews = remoteViews;
|
||||
return;
|
||||
}
|
||||
mLastRemoteViews = null;
|
||||
}
|
||||
mDeferredRemoteViews = null;
|
||||
|
||||
super.updateAppWidget(remoteViews);
|
||||
|
||||
@@ -218,8 +226,7 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView
|
||||
SparseIntArray deferredColors;
|
||||
boolean hasDeferredColors;
|
||||
mDeferUpdatesUntilMillis = 0;
|
||||
remoteViews = mDeferredRemoteViews;
|
||||
mDeferredRemoteViews = null;
|
||||
remoteViews = mLastRemoteViews;
|
||||
deferredColors = mDeferredColorChange;
|
||||
hasDeferredColors = mHasDeferredColorChange;
|
||||
mDeferredColorChange = null;
|
||||
|
||||
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Point;
|
||||
@@ -191,6 +192,17 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
|
||||
isInState(() -> LauncherState.ALL_APPS));
|
||||
}
|
||||
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
public void testAllAppsDeadzoneForTablet() throws Exception {
|
||||
assumeTrue(mLauncher.isTablet());
|
||||
|
||||
mLauncher.getWorkspace().switchToAllApps().dismissByTappingOutsideForTablet(
|
||||
true /* tapRight */);
|
||||
mLauncher.getWorkspace().switchToAllApps().dismissByTappingOutsideForTablet(
|
||||
false /* tapRight */);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenRecord // b/202433017
|
||||
public void testWorkspace() throws Exception {
|
||||
@@ -542,6 +554,18 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
public void testAddDeleteShortcutOnHotseat() {
|
||||
mLauncher.getWorkspace()
|
||||
.deleteAppIcon(mLauncher.getWorkspace().getHotseatAppIcon(0))
|
||||
.switchToAllApps()
|
||||
.getAppIcon(APP_NAME)
|
||||
.dragToHotseat(0);
|
||||
mLauncher.getWorkspace().deleteAppIcon(
|
||||
mLauncher.getWorkspace().getHotseatAppIcon(APP_NAME));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of workspace grid coordinates. Those are not pixels. See {@link
|
||||
* Workspace#getIconGridDimensions()}
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.SystemClock;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
|
||||
@@ -50,25 +45,15 @@ public class Folder {
|
||||
}
|
||||
}
|
||||
|
||||
private void touchOutsideFolder() {
|
||||
Rect containerBounds = mLauncher.getVisibleBounds(this.mContainer);
|
||||
final long downTime = SystemClock.uptimeMillis();
|
||||
Point containerLeftTopCorner = new Point(containerBounds.left - 1, containerBounds.top - 1);
|
||||
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN,
|
||||
containerLeftTopCorner, LauncherInstrumentation.GestureScope.INSIDE);
|
||||
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP,
|
||||
containerLeftTopCorner, LauncherInstrumentation.GestureScope.INSIDE);
|
||||
}
|
||||
|
||||
/**
|
||||
* CLose opened folder if possible. It throws assertion error if the folder is already closed.
|
||||
* Close opened folder if possible. It throws assertion error if the folder is already closed.
|
||||
*/
|
||||
public Workspace close() {
|
||||
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
|
||||
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
"Want to close opened folder")) {
|
||||
mLauncher.waitForLauncherObject(FOLDER_CONTENT_RES_ID);
|
||||
touchOutsideFolder();
|
||||
mLauncher.touchOutsideContainer(this.mContainer, false /* tapRight */);
|
||||
mLauncher.waitUntilLauncherObjectGone(FOLDER_CONTENT_RES_ID);
|
||||
return mLauncher.getWorkspace();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
|
||||
public class HomeAllApps extends AllApps {
|
||||
private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";
|
||||
|
||||
HomeAllApps(LauncherInstrumentation launcher) {
|
||||
super(launcher);
|
||||
@@ -45,4 +46,23 @@ public class HomeAllApps extends AllApps {
|
||||
protected boolean hasSearchBox() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Taps outside bottom sheet to dismiss and return to workspace. Available on tablets only.
|
||||
* @param tapRight Tap on the right of bottom sheet if true, or left otherwise.
|
||||
*/
|
||||
public Workspace dismissByTappingOutsideForTablet(boolean tapRight) {
|
||||
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
|
||||
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
"want to tap outside AllApps bottom sheet on the "
|
||||
+ (tapRight ? "right" : "left"))) {
|
||||
final UiObject2 allAppsBottomSheet =
|
||||
mLauncher.waitForLauncherObject(BOTTOM_SHEET_RES_ID);
|
||||
mLauncher.touchOutsideContainer(allAppsBottomSheet, tapRight);
|
||||
try (LauncherInstrumentation.Closable tapped = mLauncher.addContextLayer(
|
||||
"tapped outside AllApps bottom sheet")) {
|
||||
return mLauncher.getWorkspace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@ import android.graphics.Rect;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* App icon on the workspace or all apps.
|
||||
*/
|
||||
@@ -100,9 +102,46 @@ public abstract class HomeAppIcon extends AppIcon implements FolderDragTarget, W
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drag an object to the given cell in hotseat. The target cell should be expected to be empty.
|
||||
*
|
||||
* @param cellInd zero based index number of the hotseat cells.
|
||||
* @return the workspace app icon.
|
||||
*/
|
||||
@NonNull
|
||||
public WorkspaceAppIcon dragToHotseat(int cellInd) {
|
||||
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
|
||||
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
String.format("want to drag the icon to hotseat cell %d", cellInd))
|
||||
) {
|
||||
final Supplier<Point> dest = () -> Workspace.getHotseatCellCenter(mLauncher, cellInd);
|
||||
|
||||
Workspace.dragIconToHotseat(
|
||||
mLauncher,
|
||||
this,
|
||||
dest,
|
||||
() -> addExpectedEventsForLongClick(),
|
||||
/*expectDropEvents= */ null);
|
||||
try (LauncherInstrumentation.Closable ignore = mLauncher.addContextLayer("dragged")) {
|
||||
WorkspaceAppIcon appIcon =
|
||||
(WorkspaceAppIcon) mLauncher.getWorkspace().getHotseatAppIcon(mAppName);
|
||||
mLauncher.assertTrue(
|
||||
String.format("The %s icon should be in the hotseat cell %d.", mAppName,
|
||||
cellInd),
|
||||
appIcon.isInHotseatCell(cellInd));
|
||||
return appIcon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** This method requires public access, however should not be called in tests. */
|
||||
@Override
|
||||
public Launchable getLaunchable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
boolean isInHotseatCell(int cellInd) {
|
||||
final Point center = Workspace.getHotseatCellCenter(mLauncher, cellInd);
|
||||
return mObject.getVisibleBounds().contains(center.x, center.y);
|
||||
}
|
||||
}
|
||||
@@ -1831,4 +1831,26 @@ public final class LauncherInstrumentation {
|
||||
return ResourceUtils.getBoolByName(
|
||||
"config_supportsRoundedCornersOnWindows", resources, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Taps outside container to dismiss.
|
||||
* @param container container to be dismissed
|
||||
* @param tapRight tap on the right of the container if true, or left otherwise
|
||||
*/
|
||||
void touchOutsideContainer(UiObject2 container, boolean tapRight) {
|
||||
try (LauncherInstrumentation.Closable c = addContextLayer(
|
||||
"want to tap outside container on the " + (tapRight ? "right" : "left"))) {
|
||||
Rect containerBounds = getVisibleBounds(container);
|
||||
final long downTime = SystemClock.uptimeMillis();
|
||||
final Point tapTarget = new Point(
|
||||
tapRight
|
||||
? (containerBounds.right + getRealDisplaySize().x) / 2
|
||||
: containerBounds.left / 2,
|
||||
containerBounds.top + 1);
|
||||
sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, tapTarget,
|
||||
LauncherInstrumentation.GestureScope.INSIDE);
|
||||
sendPointer(downTime, downTime, MotionEvent.ACTION_UP, tapTarget,
|
||||
LauncherInstrumentation.GestureScope.INSIDE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import androidx.test.uiautomator.UiObject2;
|
||||
public class SearchResultFromQsb {
|
||||
// The input resource id in the search box.
|
||||
private static final String INPUT_RES = "input";
|
||||
private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";
|
||||
private final LauncherInstrumentation mLauncher;
|
||||
|
||||
SearchResultFromQsb(LauncherInstrumentation launcher) {
|
||||
@@ -47,4 +48,23 @@ public class SearchResultFromQsb {
|
||||
UiObject2 icon = mLauncher.waitForLauncherObject(By.clazz(TextView.class).text(appName));
|
||||
return new AllAppsAppIcon(mLauncher, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Taps outside bottom sheet to dismiss and return to workspace. Available on tablets only.
|
||||
* @param tapRight Tap on the right of bottom sheet if true, or left otherwise.
|
||||
*/
|
||||
public Workspace dismissByTappingOutsideForTablet(boolean tapRight) {
|
||||
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
|
||||
LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
"want to tap outside AllApps bottom sheet on the "
|
||||
+ (tapRight ? "right" : "left"))) {
|
||||
final UiObject2 allAppsBottomSheet =
|
||||
mLauncher.waitForLauncherObject(BOTTOM_SHEET_RES_ID);
|
||||
mLauncher.touchOutsideContainer(allAppsBottomSheet, tapRight);
|
||||
try (LauncherInstrumentation.Closable tapped = mLauncher.addContextLayer(
|
||||
"tapped outside AllApps bottom sheet")) {
|
||||
return mLauncher.getWorkspace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ import androidx.test.uiautomator.UiDevice;
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
import androidx.test.uiautomator.Until;
|
||||
|
||||
import com.android.launcher3.testing.HotseatCellCenterRequest;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.testing.WorkspaceCellCenterRequest;
|
||||
|
||||
@@ -250,6 +251,24 @@ public final class Workspace extends Home {
|
||||
mHotseat, AppIcon.getAppIconSelector(appName, mLauncher)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an icon for the given cell; fails if the icon doesn't exist.
|
||||
*
|
||||
* @param cellInd zero based index number of the hotseat cells.
|
||||
* @return app icon.
|
||||
*/
|
||||
@NonNull
|
||||
public HomeAppIcon getHotseatAppIcon(int cellInd) {
|
||||
List<UiObject2> icons = mHotseat.findObjects(AppIcon.getAnyAppIconSelector());
|
||||
final Point center = getHotseatCellCenter(mLauncher, cellInd);
|
||||
return icons.stream()
|
||||
.filter(icon -> icon.getVisibleBounds().contains(center.x, center.y))
|
||||
.findFirst()
|
||||
.map(icon -> new WorkspaceAppIcon(mLauncher, icon))
|
||||
.orElseThrow(() ->
|
||||
new AssertionError("Unable to get a hotseat icon on " + cellInd));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return map of text -> center of the view. In case of icons with the same name, the one with
|
||||
* lower x coordinate is selected.
|
||||
@@ -360,6 +379,11 @@ public final class Workspace extends Home {
|
||||
TestProtocol.TEST_INFO_RESPONSE_FIELD);
|
||||
}
|
||||
|
||||
static Point getHotseatCellCenter(LauncherInstrumentation launcher, int cellInd) {
|
||||
return launcher.getTestInfo(HotseatCellCenterRequest.builder()
|
||||
.setCellInd(cellInd).build()).getParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds folder icons in the current workspace.
|
||||
*
|
||||
@@ -471,6 +495,25 @@ public final class Workspace extends Home {
|
||||
() -> "Page scroll didn't happen", "Scrolling page");
|
||||
}
|
||||
|
||||
static void dragIconToHotseat(
|
||||
LauncherInstrumentation launcher,
|
||||
Launchable launchable,
|
||||
Supplier<Point> dest,
|
||||
Runnable expectLongClickEvents,
|
||||
@Nullable Runnable expectDropEvents) {
|
||||
final long downTime = SystemClock.uptimeMillis();
|
||||
Point dragStart = launchable.startDrag(
|
||||
downTime,
|
||||
expectLongClickEvents,
|
||||
/* runToSpringLoadedState= */ true);
|
||||
Point targetDest = dest.get();
|
||||
|
||||
launcher.movePointer(dragStart, targetDest, DEFAULT_DRAG_STEPS, true,
|
||||
downTime, SystemClock.uptimeMillis(), false,
|
||||
LauncherInstrumentation.GestureScope.INSIDE);
|
||||
dropDraggedIcon(launcher, targetDest, downTime, expectDropEvents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flings to get to screens on the right. Waits for scrolling and a possible overscroll
|
||||
* recoil to complete.
|
||||
|
||||
Reference in new issue
Block a user