Merge changes I485f6346,I24b0c646 into main
* changes:
Animate alpha for bubbles and background (3/n)
Use a reveal animator for bubble icons (2/n)
diff --git a/aconfig/launcher.aconfig b/aconfig/launcher.aconfig
index 40c3797..0da2df1 100644
--- a/aconfig/launcher.aconfig
+++ b/aconfig/launcher.aconfig
@@ -360,3 +360,31 @@
purpose: PURPOSE_BUGFIX
}
}
+
+flag {
+ name: "one_grid_specs"
+ namespace: "launcher"
+ description: "Defines the new specs for grids based on OneGrid"
+ bug: "364711064"
+}
+
+flag {
+ name: "one_grid_mounted_mode"
+ namespace: "launcher"
+ description: "Support a fixed landscape mode for handheld devices"
+ bug: "364711735"
+}
+
+flag {
+ name: "one_grid_rotation_handling"
+ namespace: "launcher"
+ description: "New landscape approach for the workspace using different rows and columns in landscape and portrait"
+ bug: "364711814"
+}
+
+flag {
+ name: "grid_migration_refactor"
+ namespace: "launcher"
+ description: "Refactor grid migration such that the code is simpler to understand and update"
+ bug: "358399271"
+}
diff --git a/aconfig/launcher_overview.aconfig b/aconfig/launcher_overview.aconfig
index e11b00c..23733a4 100644
--- a/aconfig/launcher_overview.aconfig
+++ b/aconfig/launcher_overview.aconfig
@@ -39,3 +39,12 @@
bug: "353947137"
}
+flag {
+ name: "enable_overview_command_helper_timeout"
+ namespace: "launcher_overview"
+ description: "Enables OverviewCommandHelper new version with a timeout to prevent the queue to be unresponsive."
+ bug: "351122926"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
\ No newline at end of file
diff --git a/quickstep/res/layout/digital_wellbeing_toast.xml b/quickstep/res/layout/digital_wellbeing_toast.xml
index 3973e56..0551c12 100644
--- a/quickstep/res/layout/digital_wellbeing_toast.xml
+++ b/quickstep/res/layout/digital_wellbeing_toast.xml
@@ -27,4 +27,5 @@
android:textColor="?attr/materialColorOnSecondaryFixed"
android:textSize="14sp"
android:autoSizeTextType="uniform"
- android:autoSizeMaxTextSize="14sp"/>
\ No newline at end of file
+ android:autoSizeMaxTextSize="14sp"
+ android:visibility="gone"/>
\ No newline at end of file
diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml
index bdfd241..760bcdb 100644
--- a/quickstep/res/layout/task.xml
+++ b/quickstep/res/layout/task.xml
@@ -49,6 +49,5 @@
android:layout_width="wrap_content" />
<include layout="@layout/digital_wellbeing_toast"
- android:id="@+id/digital_wellbeing_toast"
- android:visibility="invisible"/>
+ android:id="@+id/digital_wellbeing_toast"/>
</com.android.quickstep.views.TaskView>
\ No newline at end of file
diff --git a/quickstep/res/layout/task_grouped.xml b/quickstep/res/layout/task_grouped.xml
index 00a990b..c36a45e 100644
--- a/quickstep/res/layout/task_grouped.xml
+++ b/quickstep/res/layout/task_grouped.xml
@@ -75,10 +75,8 @@
android:layout_width="wrap_content" />
<include layout="@layout/digital_wellbeing_toast"
- android:id="@+id/digital_wellbeing_toast"
- android:visibility="invisible"/>
+ android:id="@+id/digital_wellbeing_toast"/>
<include layout="@layout/digital_wellbeing_toast"
- android:id="@+id/bottomRight_digital_wellbeing_toast"
- android:visibility="invisible"/>
+ android:id="@+id/bottomRight_digital_wellbeing_toast"/>
</com.android.quickstep.views.GroupedTaskView>
\ No newline at end of file
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index e51c956..621d226 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -56,7 +56,6 @@
import static com.android.launcher3.config.FeatureFlags.ENABLE_SCRIM_FOR_APP_LAUNCH;
import static com.android.launcher3.config.FeatureFlags.KEYGUARD_ANIMATION;
import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY;
-import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.testing.shared.TestProtocol.WALLPAPER_OPEN_ANIMATION_FINISHED_MESSAGE;
import static com.android.launcher3.util.DisplayController.isTransientTaskbar;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
@@ -138,8 +137,8 @@
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.DynamicResource;
-import com.android.launcher3.util.ObjectWrapper;
import com.android.launcher3.util.RunnableList;
+import com.android.launcher3.util.StableViewInfo;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.FloatingIconView;
import com.android.launcher3.views.ScrimView;
@@ -174,6 +173,7 @@
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -434,7 +434,7 @@
*/
private void addLaunchCookie(IBinder cookie, ItemInfo info, ActivityOptions options) {
if (cookie == null) {
- cookie = mLauncher.getLaunchCookie(info);
+ cookie = StableViewInfo.toLaunchCookie(info);
}
if (cookie != null) {
@@ -1433,20 +1433,12 @@
// Find the associated item info for the launch cookie (if available), note that predicted
// apps actually have an id of -1, so use another default id here
- final ArrayList<IBinder> launchCookies = runningTaskTarget.taskInfo.launchCookies == null
- ? new ArrayList<>()
+ final List<IBinder> launchCookies = runningTaskTarget.taskInfo.launchCookies == null
+ ? Collections.EMPTY_LIST
: runningTaskTarget.taskInfo.launchCookies;
- int launchCookieItemId = NO_MATCHING_ID;
- for (IBinder cookie : launchCookies) {
- Integer itemId = ObjectWrapper.unwrap(cookie);
- if (itemId != null) {
- launchCookieItemId = itemId;
- break;
- }
- }
-
- return mLauncher.getFirstMatchForAppClose(launchCookieItemId, packageName,
+ return mLauncher.getFirstMatchForAppClose(
+ StableViewInfo.fromLaunchCookies(launchCookies), packageName,
UserHandle.of(runningTaskTarget.taskInfo.userId), true /* supportsAllAppsState */);
}
diff --git a/quickstep/src/com/android/launcher3/WidgetPickerActivity.java b/quickstep/src/com/android/launcher3/WidgetPickerActivity.java
index 50e8e5e..955388d 100644
--- a/quickstep/src/com/android/launcher3/WidgetPickerActivity.java
+++ b/quickstep/src/com/android/launcher3/WidgetPickerActivity.java
@@ -41,6 +41,7 @@
import androidx.annotation.Nullable;
import com.android.launcher3.dragndrop.SimpleDragLayer;
+import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.model.WidgetPredictionsRequester;
import com.android.launcher3.model.WidgetsModel;
@@ -107,6 +108,7 @@
private SimpleDragLayer<WidgetPickerActivity> mDragLayer;
private WidgetsModel mModel;
private LauncherAppState mApp;
+ private StringCache mStringCache;
private WidgetPredictionsRequester mWidgetPredictionsRequester;
private final WidgetPickerDataProvider mWidgetPickerDataProvider =
new WidgetPickerDataProvider();
@@ -287,6 +289,11 @@
MODEL_EXECUTOR.execute(() -> {
LauncherAppState app = LauncherAppState.getInstance(this);
mModel.update(app, null);
+
+ StringCache stringCache = new StringCache();
+ stringCache.loadStrings(this);
+
+ bindStringCache(stringCache);
bindWidgets(mModel.getWidgetsByPackageItem());
// Open sheet once widgets are available, so that it doesn't interrupt the open
// animation.
@@ -299,6 +306,10 @@
});
}
+ private void bindStringCache(final StringCache stringCache) {
+ MAIN_EXECUTOR.execute(() -> mStringCache = stringCache);
+ }
+
private void bindWidgets(Map<PackageItemInfo, List<WidgetItem>> widgets) {
WidgetsListBaseEntriesBuilder builder = new WidgetsListBaseEntriesBuilder(
mApp.getContext());
@@ -336,6 +347,12 @@
}
}
+ @Nullable
+ @Override
+ public StringCache getStringCache() {
+ return mStringCache;
+ }
+
/**
* Animation callback for different predictive back animation states for the widget picker.
*/
diff --git a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
index ec710c5..fabf3a5 100644
--- a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java
@@ -94,6 +94,7 @@
// States that affect whether region sampling is enabled or not
private boolean mIsStashed;
private boolean mIsLumaSamplingEnabled;
+ private boolean mIsAppTransitionPending;
private boolean mTaskbarHidden;
private float mTranslationYForSwipe;
@@ -267,6 +268,11 @@
updateSamplingState();
}
+ public void setIsAppTransitionPending(boolean pending) {
+ mIsAppTransitionPending = pending;
+ updateSamplingState();
+ }
+
private void updateSamplingState() {
updateRegionSamplingWindowVisibility();
if (shouldSample()) {
@@ -278,7 +284,7 @@
}
private boolean shouldSample() {
- return mIsStashed && mIsLumaSamplingEnabled;
+ return mIsStashed && mIsLumaSamplingEnabled && !mIsAppTransitionPending;
}
protected void updateStashedHandleHintScale() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 47ae741..b10a59f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -914,11 +914,16 @@
mControllers.navbarButtonsViewController.transitionTo(barMode, animate);
}
+ public void appTransitionPending(boolean pending) {
+ mControllers.stashedHandleViewController.setIsAppTransitionPending(pending);
+ }
+
/**
* Called when this instance of taskbar is no longer needed
*/
public void onDestroy() {
mIsDestroyed = true;
+ mTaskbarFeatureEvaluator.onDestroy();
setUIController(TaskbarUIController.DEFAULT);
mControllers.onDestroy();
if (!enableTaskbarNoRecreate() && !ENABLE_TASKBAR_NAVBAR_UNIFICATION) {
@@ -1431,7 +1436,7 @@
&& !(foundTaskView instanceof DesktopTaskView)) {
TestLogging.recordEvent(
TestProtocol.SEQUENCE_MAIN, "start: taskbarAppIcon");
- foundTaskView.launchTasks();
+ foundTaskView.launchWithAnimation();
return;
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 63fae8c..4188a0f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -463,7 +463,8 @@
controllers.bubbleStashController.setBubblesShowingOnOverview(onOverview);
});
- mControllers.taskbarStashController.updateStateForFlag(FLAG_IN_OVERVIEW,
+ TaskbarStashController stashController = mControllers.taskbarStashController;
+ stashController.updateStateForFlag(FLAG_IN_OVERVIEW,
mLauncherState == LauncherState.OVERVIEW);
AnimatorSet animatorSet = new AnimatorSet();
@@ -495,8 +496,6 @@
public void onAnimationStart(Animator animation) {
mIsAnimatingToLauncher = isInLauncher;
- TaskbarStashController stashController =
- mControllers.taskbarStashController;
if (DEBUG) {
Log.d(TAG, "onAnimationStart - FLAG_IN_APP: " + !isInLauncher);
}
@@ -512,6 +511,8 @@
// Handle closing open popups when going home/overview
handleOpenFloatingViews = true;
+ } else {
+ stashController.applyState();
}
if (handleOpenFloatingViews && isInLauncher) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index 8c87fa6..8ecac96 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -549,7 +549,15 @@
public void transitionTo(@BarTransitions.TransitionMode int barMode,
boolean animate) {
- mTaskbarActivityContext.transitionTo(barMode, animate);
+ if (mTaskbarActivityContext != null) {
+ mTaskbarActivityContext.transitionTo(barMode, animate);
+ }
+ }
+
+ public void appTransitionPending(boolean pending) {
+ if (mTaskbarActivityContext != null) {
+ mTaskbarActivityContext.appTransitionPending(pending);
+ }
}
private boolean isTaskbarEnabled(DeviceProfile deviceProfile) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index 60e65b3..d07b011 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -1137,6 +1137,10 @@
TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_TRANSIENT_TASKBAR,
!hasAnyFlag(FLAG_STASHED_IN_APP_AUTO));
}
+ if (hasAnyFlag(changedFlags, FLAG_IN_OVERVIEW | FLAG_IN_APP)) {
+ mControllers.runAfterInit(() -> mControllers.taskbarInsetsController
+ .onTaskbarOrBubblebarWindowHeightOrInsetsChanged());
+ }
mActivity.applyForciblyShownFlagWhileTransientTaskbarUnstashed(!isStashedInApp());
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt
index c83ac50..7739a0e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt
@@ -26,23 +26,6 @@
private constructor(
private val taskbarActivityContext: TaskbarActivityContext,
) {
-
- companion object {
- @Volatile private lateinit var taskbarFeatureEvaluator: TaskbarFeatureEvaluator
-
- @JvmStatic
- fun getInstance(
- taskbarActivityContext: TaskbarActivityContext,
- ): TaskbarFeatureEvaluator {
- synchronized(this) {
- if (!::taskbarFeatureEvaluator.isInitialized) {
- taskbarFeatureEvaluator = TaskbarFeatureEvaluator(taskbarActivityContext)
- }
- return taskbarFeatureEvaluator
- }
- }
- }
-
val hasAllApps = true
val hasAppIcons = true
val hasBubbles = false
@@ -59,4 +42,24 @@
val isLandscape: Boolean
get() = taskbarActivityContext.deviceProfile.isLandscape
+
+ fun onDestroy() {
+ taskbarFeatureEvaluator = null
+ }
+
+ companion object {
+ @Volatile private var taskbarFeatureEvaluator: TaskbarFeatureEvaluator? = null
+
+ @JvmStatic
+ fun getInstance(
+ taskbarActivityContext: TaskbarActivityContext,
+ ): TaskbarFeatureEvaluator {
+ synchronized(this) {
+ if (taskbarFeatureEvaluator == null) {
+ taskbarFeatureEvaluator = TaskbarFeatureEvaluator(taskbarActivityContext)
+ }
+ return taskbarFeatureEvaluator!!
+ }
+ }
+ }
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarIconSpecs.kt b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarIconSpecs.kt
index 6be0828..e55cb1f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarIconSpecs.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarIconSpecs.kt
@@ -37,6 +37,8 @@
val minimumTaskbarIconTouchSize = TaskbarIconSize(48)
+ val transientOrPinnedTaskbarIconPaddingSize = iconSize52dp
+
val transientTaskbarIconSizeByGridSize =
mapOf(
TransientTaskbarIconSizeKey(6, 5, false) to iconSize52dp,
diff --git a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarSpecsEvaluator.kt b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarSpecsEvaluator.kt
index f37b2c1..822ca64 100644
--- a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarSpecsEvaluator.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarSpecsEvaluator.kt
@@ -31,7 +31,10 @@
private var taskbarContainer: List<TaskbarContainer> = emptyList()
val taskbarIconPadding: Int =
- if (TaskbarIconSpecs.iconSize52dp.size > taskbarIconSize.size) {
+ if (
+ TaskbarIconSpecs.transientOrPinnedTaskbarIconPaddingSize.size > taskbarIconSize.size &&
+ !taskbarFeatureEvaluator.hasNavButtons
+ ) {
(TaskbarIconSpecs.iconSize52dp.size - taskbarIconSize.size) / 2
} else {
0
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java
index 039c0a0..5b07926 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java
@@ -34,6 +34,7 @@
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.ActivityOptionsWrapper;
+import com.android.launcher3.util.StableViewInfo;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
/** Provides a Quickstep specific animation when launching an activity from an app widget. */
@@ -69,8 +70,8 @@
.getActivityLaunchOptions(hostView);
Object itemInfo = hostView.getTag();
IBinder launchCookie = null;
- if (itemInfo instanceof ItemInfo) {
- launchCookie = mLauncher.getLaunchCookie((ItemInfo) itemInfo);
+ if (itemInfo instanceof ItemInfo info) {
+ launchCookie = StableViewInfo.toLaunchCookie(info);
activityOptions.options.setLaunchCookie(launchCookie);
}
if (Utilities.ATLEAST_S && !pendingIntent.isActivity()) {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index 55c1885..b5b8909 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -41,7 +41,6 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SPLIT_SELECTION_EXIT_HOME;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SPLIT_SELECTION_EXIT_INTERRUPTED;
-import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition;
import static com.android.launcher3.popup.SystemShortcut.APP_INFO;
import static com.android.launcher3.popup.SystemShortcut.BUBBLE_SHORTCUT;
@@ -83,7 +82,6 @@
import android.media.permission.SafeCloseable;
import android.os.Build;
import android.os.Bundle;
-import android.os.IBinder;
import android.os.IRemoteCallback;
import android.os.SystemProperties;
import android.os.Trace;
@@ -610,7 +608,7 @@
.append(" is missing."),
QUICK_SWITCH_FROM_HOME_FALLBACK);
}
- taskToLaunch.launchTask(success -> {
+ taskToLaunch.launchWithoutAnimation(success -> {
if (!success) {
getStateManager().goToState(OVERVIEW);
} else {
@@ -1232,43 +1230,6 @@
mSplitWithKeyboardShortcutController.enterStageSplit(leftOrTop);
}
- /**
- * Return a new launch cookie for the activity launch if supported.
- *
- * @param info the item info for the launch
- */
- public IBinder getLaunchCookie(ItemInfo info) {
- if (info == null) {
- return null;
- }
- switch (info.container) {
- case Favorites.CONTAINER_DESKTOP:
- case Favorites.CONTAINER_HOTSEAT:
- case Favorites.CONTAINER_PRIVATESPACE:
- // Fall through and continue it's on the workspace (we don't support swiping back
- // to other containers like all apps or the hotseat predictions (which can change)
- break;
- default:
- if (info.container >= 0) {
- // Also allow swiping to folders
- break;
- }
- // Reset any existing launch cookies associated with the cookie
- return ObjectWrapper.wrap(NO_MATCHING_ID);
- }
- switch (info.itemType) {
- case Favorites.ITEM_TYPE_APPLICATION:
- case Favorites.ITEM_TYPE_DEEP_SHORTCUT:
- case Favorites.ITEM_TYPE_APPWIDGET:
- // Fall through and continue if it's an app, shortcut, or widget
- break;
- default:
- // Reset any existing launch cookies associated with the cookie
- return ObjectWrapper.wrap(NO_MATCHING_ID);
- }
- return ObjectWrapper.wrap(new Integer(info.id));
- }
-
@Override
public void onDisplayInfoChanged(Context context, DisplayController.Info info, int flags) {
super.onDisplayInfoChanged(context, info, flags);
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
index fa80dc2..030a7ac 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -26,7 +26,6 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
import com.android.quickstep.util.BaseDepthController;
@@ -202,17 +201,6 @@
}
@Override
- public float[] getOverviewScaleAndOffset(Launcher launcher) {
- if (!FeatureFlags.ENABLE_ALL_APPS_FROM_OVERVIEW.get()) {
- return super.getOverviewScaleAndOffset(launcher);
- }
- // This handles the case of returning to the previous app from Overview -> All Apps gesture.
- // This is the start scale/offset of overview that will be used for that transition.
- // TODO (b/283336332): Translate in Y direction (ideally with overview resistance).
- return new float[] {0.5f /* scale */, NO_OFFSET};
- }
-
- @Override
public int getWorkspaceScrimColor(Launcher launcher) {
return launcher.getDeviceProfile().isTablet
? launcher.getResources().getColor(R.color.widgets_picker_scrim)
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
index 6822f1b..b165cdd 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -209,7 +209,7 @@
TaskView taskView = recentsView.getRunningTaskView();
if (taskView != null) {
if (recentsView.isTaskViewFullyVisible(taskView)) {
- taskView.launchTasks();
+ taskView.launchWithAnimation();
} else {
recentsView.snapToPage(recentsView.indexOfChild(taskView));
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
index d1aa472..ff726e6 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
@@ -42,7 +42,6 @@
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.taskbar.LauncherTaskbarUIController;
import com.android.launcher3.uioverrides.QuickstepLauncher;
@@ -221,11 +220,6 @@
mCancelSplitRunnable.accept(animatorSet, duration);
animatorSet.start();
}
- if (FeatureFlags.ENABLE_PREMIUM_HAPTICS_ALL_APPS.get() &&
- ((mFromState == NORMAL && mToState == ALL_APPS)
- || (mFromState == ALL_APPS && mToState == NORMAL)) && isFling) {
- mVibratorWrapper.vibrateForDragBump();
- }
}
private void onMotionPauseDetected() {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
index b5914a1..b6a0ab3 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
@@ -29,7 +29,6 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.allapps.AllAppsTransitionController;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.touch.AbstractStateChangeTouchController;
import com.android.launcher3.touch.AllAppsSwipeController;
@@ -93,9 +92,7 @@
@Override
protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
if (fromState == ALL_APPS && !isDragTowardPositive) {
- return FeatureFlags.ENABLE_ALL_APPS_FROM_OVERVIEW.get()
- ? mLauncher.getStateManager().getLastState()
- : NORMAL;
+ return NORMAL;
} else if (fromState == NORMAL && shouldOpenAllApps(isDragTowardPositive)) {
return ALL_APPS;
}
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 38d08e0..978d8c4 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -45,7 +45,6 @@
import static com.android.launcher3.util.SystemUiController.UI_STATE_FULLSCREEN_TASK;
import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC;
import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs;
-import static com.android.quickstep.GestureState.GestureEndTarget.ALL_APPS;
import static com.android.quickstep.GestureState.GestureEndTarget.HOME;
import static com.android.quickstep.GestureState.GestureEndTarget.LAST_TASK;
import static com.android.quickstep.GestureState.GestureEndTarget.NEW_TASK;
@@ -265,8 +264,6 @@
getNextStateFlag("STATE_CURRENT_TASK_FINISHED");
private static final int STATE_FINISH_WITH_NO_END =
getNextStateFlag("STATE_FINISH_WITH_NO_END");
- private static final int STATE_SETTLED_ON_ALL_APPS =
- getNextStateFlag("STATE_SETTLED_ON_ALL_APPS");
private static final int LAUNCHER_UI_STATES =
STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN | STATE_LAUNCHER_STARTED |
@@ -320,7 +317,6 @@
private boolean mGestureStarted;
private boolean mLogDirectionUpOrLeft = true;
private boolean mIsLikelyToStartNewTask;
- private boolean mIsInAllAppsRegion;
private final long mTouchTimeMs;
private long mLauncherFrameDrawnTime;
@@ -457,9 +453,6 @@
this::finishCurrentTransitionToHome);
mStateCallback.runOnceAtState(STATE_SCALED_CONTROLLER_HOME | STATE_CURRENT_TASK_FINISHED,
this::reset);
- mStateCallback.runOnceAtState(STATE_SETTLED_ON_ALL_APPS | STATE_SCREENSHOT_CAPTURED
- | STATE_GESTURE_COMPLETED,
- this::finishCurrentTransitionToAllApps);
mStateCallback.runOnceAtState(STATE_LAUNCHER_PRESENT | STATE_APP_CONTROLLER_RECEIVED
| STATE_LAUNCHER_DRAWN | STATE_SCALED_CONTROLLER_RECENTS
@@ -724,9 +717,7 @@
maybeUpdateRecentsAttachedState(true/* animate */, true/* moveRunningTask */);
Optional.ofNullable(mContainerInterface.getTaskbarController())
.ifPresent(TaskbarUIController::startTranslationSpring);
- if (!mIsInAllAppsRegion) {
- performHapticFeedback();
- }
+ performHapticFeedback();
}
@Override
@@ -774,9 +765,7 @@
.findTask(mGestureState.getTopRunningTaskId())
: null;
final boolean recentsAttachedToAppWindow;
- if (mIsInAllAppsRegion) {
- recentsAttachedToAppWindow = false;
- } else if (mGestureState.getEndTarget() != null) {
+ if (mGestureState.getEndTarget() != null) {
recentsAttachedToAppWindow = mGestureState.getEndTarget().recentsAttachedToAppWindow;
} else if (mContinuingLastGesture
&& mRecentsView.getRunningTaskIndex() != mRecentsView.getNextPage()) {
@@ -833,31 +822,6 @@
}
}
- /**
- * Update whether user is currently dragging in a region that will trigger all apps.
- */
- private void setIsInAllAppsRegion(boolean isInAllAppsRegion) {
- if (mIsInAllAppsRegion == isInAllAppsRegion
- || !mContainerInterface.allowAllAppsFromOverview()) {
- return;
- }
- mIsInAllAppsRegion = isInAllAppsRegion;
-
- // Newly entering or exiting the zone - do haptic and animate recent tasks.
- VibratorWrapper.INSTANCE.get(mContext).vibrate(OVERVIEW_HAPTIC);
- maybeUpdateRecentsAttachedState(true);
-
- if (mContainer != null) {
- mContainer.getAppsView().getSearchUiManager()
- .prepareToFocusEditText(mIsInAllAppsRegion);
- }
-
- // Draw active task below Launcher so that All Apps can appear over it.
- runActionOnRemoteHandles(remoteTargetHandle ->
- remoteTargetHandle.getTaskViewSimulator().setDrawsBelowRecents(isInAllAppsRegion));
- }
-
-
private void buildAnimationController() {
if (!canCreateNewOrUpdateExistingLauncherTransitionController()) {
return;
@@ -917,8 +881,6 @@
@UiThread
@Override
public void onCurrentShiftUpdated() {
- float threshold = DeviceConfigWrapper.get().getAllAppsOverviewThreshold() / 100f;
- setIsInAllAppsRegion(mCurrentShift.value >= threshold);
updateSysUiFlags(mCurrentShift.value);
applyScrollAndTransform();
@@ -1203,9 +1165,6 @@
}
switch (endTarget) {
- case ALL_APPS:
- mStateCallback.setState(STATE_SETTLED_ON_ALL_APPS | STATE_CAPTURE_SCREENSHOT);
- break;
case HOME:
mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT);
// Notify the SysUI to use fade-in animation when entering PiP
@@ -1324,9 +1283,6 @@
final boolean willGoToNewTask =
isScrollingToNewTask() && Math.abs(velocity.x) > Math.abs(endVelocity);
final boolean isSwipeUp = endVelocity < 0;
- if (mIsInAllAppsRegion) {
- return isSwipeUp ? ALL_APPS : LAST_TASK;
- }
if (!isSwipeUp) {
final boolean isCenteredOnNewTask = mRecentsView != null
&& mRecentsView.getDestinationPage() != mRecentsView.getRunningTaskIndex();
@@ -1342,9 +1298,7 @@
// Fully gestural mode.
final boolean isFlingX = Math.abs(velocity.x) > mContext.getResources()
.getDimension(R.dimen.quickstep_fling_threshold_speed);
- if (mIsInAllAppsRegion) {
- return ALL_APPS;
- } else if (isScrollingToNewTask && isFlingX) {
+ if (isScrollingToNewTask && isFlingX) {
// Flinging towards new task takes precedence over mIsMotionPaused (which only
// checks y-velocity).
return NEW_TASK;
@@ -1399,8 +1353,7 @@
.setUserIsNotGoingHome(endTarget != GestureState.GestureEndTarget.HOME);
}
- float endShift = endTarget == ALL_APPS ? mDragLengthFactor
- : endTarget.isLauncher ? 1 : 0;
+ float endShift = endTarget.isLauncher ? 1 : 0;
final float startShift;
if (!isFling) {
long expectedDuration = Math.abs(Math.round((endShift - currentShift)
@@ -2027,12 +1980,6 @@
reset();
}
- @UiThread
- private void finishCurrentTransitionToAllApps() {
- finishCurrentTransitionToHome();
- reset();
- }
-
private void reset() {
mStateCallback.setStateOnUiThread(STATE_HANDLER_INVALIDATED);
if (mContainer != null) {
@@ -2174,7 +2121,6 @@
private void updateThumbnail() {
if (mGestureState.getEndTarget() == HOME
|| mGestureState.getEndTarget() == NEW_TASK
- || mGestureState.getEndTarget() == ALL_APPS
|| mRecentsView == null) {
// Capture the screenshot before finishing the transition to home or quickswitching to
// ensure it's taken in the correct orientation, but no need to update the thumbnail.
@@ -2370,7 +2316,7 @@
ActiveGestureLog.INSTANCE.trackEvent(EXPECTING_TASK_APPEARED);
}
ActiveGestureLog.INSTANCE.addLog(nextTaskLog);
- nextTask.launchTask(success -> {
+ nextTask.launchWithoutAnimation(true, success -> {
resultCallback.accept(success);
if (success) {
if (hasTaskPreviouslyAppeared) {
@@ -2383,7 +2329,7 @@
}
}
return Unit.INSTANCE;
- }, true /* freezeTaskList */);
+ } /* freezeTaskList */);
} else {
mContainerInterface.onLaunchTaskFailed();
Toast.makeText(mContext, R.string.activity_not_available, LENGTH_SHORT).show();
diff --git a/quickstep/src/com/android/quickstep/BaseContainerInterface.java b/quickstep/src/com/android/quickstep/BaseContainerInterface.java
index 777761b..d7378ec 100644
--- a/quickstep/src/com/android/quickstep/BaseContainerInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseContainerInterface.java
@@ -74,9 +74,6 @@
public abstract boolean deferStartingActivity(RecentsAnimationDeviceState deviceState,
MotionEvent ev);
- /** @return whether to allow going to All Apps from Overview. */
- public abstract boolean allowAllAppsFromOverview();
-
/**
* Returns the color of the scrim behind overview when at rest in this state.
* Return {@link Color#TRANSPARENT} for no scrim.
diff --git a/quickstep/src/com/android/quickstep/DeviceConfigWrapper.kt b/quickstep/src/com/android/quickstep/DeviceConfigWrapper.kt
index 904ed69..f610014 100644
--- a/quickstep/src/com/android/quickstep/DeviceConfigWrapper.kt
+++ b/quickstep/src/com/android/quickstep/DeviceConfigWrapper.kt
@@ -52,7 +52,11 @@
)
val lpnhTimeoutMs =
- propReader.get("LPNH_TIMEOUT_MS", 450, "Controls lpnh timeout in milliseconds")
+ propReader.get(
+ "LPNH_TIMEOUT_MS",
+ DEFAULT_LPNH_TIMEOUT_MS,
+ "Controls lpnh timeout in milliseconds"
+ )
val lpnhSlopPercentage =
propReader.get("LPNH_SLOP_PERCENTAGE", 100, "Controls touch slop percentage for lpnh")
@@ -138,13 +142,6 @@
"Controls extra dp on the nav bar sides to trigger LPNH. Can be negative for a smaller touch region."
)
- val allAppsOverviewThreshold =
- propReader.get(
- "ALL_APPS_OVERVIEW_THRESHOLD",
- 180,
- "Threshold to open All Apps from Overview"
- )
-
/** Dump config values. */
fun dump(prefix: String, writer: PrintWriter) {
writer.println("$prefix DeviceConfigWrapper:")
@@ -165,12 +162,13 @@
writer.println("$prefix\tenableLpnhDeepPress=$enableLpnhDeepPress")
writer.println("$prefix\tlpnhHapticHintDelay=$lpnhHapticHintDelay")
writer.println("$prefix\tlpnhExtraTouchWidthDp=$lpnhExtraTouchWidthDp")
- writer.println("$prefix\tallAppsOverviewThreshold=$allAppsOverviewThreshold")
}
companion object {
@JvmStatic val configHelper by lazy { DeviceConfigHelper(::DeviceConfigWrapper) }
@JvmStatic fun get() = configHelper.config
+
+ const val DEFAULT_LPNH_TIMEOUT_MS = 450
}
}
diff --git a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
index 94a4527..df83eb2 100644
--- a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
@@ -133,11 +133,6 @@
}
@Override
- public boolean allowAllAppsFromOverview() {
- return false;
- }
-
- @Override
public boolean deferStartingActivity(RecentsAnimationDeviceState deviceState, MotionEvent ev) {
// In non-gesture mode, user might be clicking on the home button which would directly
// start the home activity instead of going through recents. In that case, defer starting
diff --git a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
index e9fe2f7..abd71d5 100644
--- a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
@@ -18,7 +18,6 @@
import static com.android.app.animation.Interpolators.LINEAR;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
-import static com.android.launcher3.LauncherState.FLOATING_SEARCH_BAR;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
@@ -40,7 +39,6 @@
import com.android.launcher3.LauncherInitListener;
import com.android.launcher3.LauncherState;
import com.android.launcher3.anim.PendingAnimation;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.statehandlers.DesktopVisibilityController;
import com.android.launcher3.statemanager.StateManager;
@@ -271,13 +269,6 @@
}
@Override
- public boolean allowAllAppsFromOverview() {
- return FeatureFlags.ENABLE_ALL_APPS_FROM_OVERVIEW.get()
- // If floating search bar would not show in overview, don't allow all apps gesture.
- && OVERVIEW.areElementsVisible(getCreatedContainer(), FLOATING_SEARCH_BAR);
- }
-
- @Override
public boolean isInLiveTileMode() {
QuickstepLauncher launcher = getCreatedContainer();
diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
index f653e60..d2dcd7b 100644
--- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
+++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
@@ -20,7 +20,6 @@
import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.Utilities.mapBoundToRange;
-import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION;
import static com.android.launcher3.views.FloatingIconView.getFloatingIconView;
@@ -42,7 +41,7 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.uioverrides.QuickstepLauncher;
-import com.android.launcher3.util.ObjectWrapper;
+import com.android.launcher3.util.StableViewInfo;
import com.android.launcher3.views.ClipIconView;
import com.android.launcher3.views.FloatingIconView;
import com.android.launcher3.views.FloatingView;
@@ -301,18 +300,7 @@
return null;
}
- // Find the associated item info for the launch cookie (if available), note that predicted
- // apps actually have an id of -1, so use another default id here
- int launchCookieItemId = NO_MATCHING_ID;
- for (IBinder cookie : launchCookies) {
- Integer itemId = ObjectWrapper.unwrap(cookie);
- if (itemId != null) {
- launchCookieItemId = itemId;
- break;
- }
- }
-
- return mContainer.getFirstMatchForAppClose(launchCookieItemId,
+ return mContainer.getFirstMatchForAppClose(StableViewInfo.fromLaunchCookies(launchCookies),
sourceTaskView.getFirstTask().key.getComponent().getPackageName(),
UserHandle.of(sourceTaskView.getFirstTask().key.userId),
false /* supportsAllAppsState */);
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt b/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
index 8873275..c1f9963 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
@@ -25,16 +25,26 @@
import android.view.View
import androidx.annotation.BinderThread
import androidx.annotation.UiThread
+import androidx.annotation.VisibleForTesting
import com.android.internal.jank.Cuj
+import com.android.launcher3.Flags.enableOverviewCommandHelperTimeout
import com.android.launcher3.PagedView
import com.android.launcher3.config.FeatureFlags
import com.android.launcher3.logger.LauncherAtom
import com.android.launcher3.logging.StatsLogManager
-import com.android.launcher3.logging.StatsLogManager.LauncherEvent.*
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_OVERVIEW_SHOW_OVERVIEW_FROM_3_BUTTON
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_OVERVIEW_SHOW_OVERVIEW_FROM_KEYBOARD_QUICK_SWITCH
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_OVERVIEW_SHOW_OVERVIEW_FROM_KEYBOARD_SHORTCUT
import com.android.launcher3.util.Executors
import com.android.launcher3.util.RunnableList
+import com.android.launcher3.util.coroutines.DispatcherProvider
+import com.android.launcher3.util.coroutines.ProductionDispatchers
import com.android.quickstep.OverviewCommandHelper.CommandInfo.CommandStatus
-import com.android.quickstep.OverviewCommandHelper.CommandType.*
+import com.android.quickstep.OverviewCommandHelper.CommandType.HIDE
+import com.android.quickstep.OverviewCommandHelper.CommandType.HOME
+import com.android.quickstep.OverviewCommandHelper.CommandType.KEYBOARD_INPUT
+import com.android.quickstep.OverviewCommandHelper.CommandType.SHOW
+import com.android.quickstep.OverviewCommandHelper.CommandType.TOGGLE
import com.android.quickstep.util.ActiveGestureLog
import com.android.quickstep.views.RecentsView
import com.android.quickstep.views.RecentsViewContainer
@@ -43,13 +53,25 @@
import com.android.systemui.shared.system.InteractionJankMonitorWrapper
import java.io.PrintWriter
import java.util.concurrent.ConcurrentLinkedDeque
+import kotlin.coroutines.resume
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.SupervisorJob
+import kotlinx.coroutines.ensureActive
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.suspendCancellableCoroutine
+import kotlinx.coroutines.withTimeout
/** Helper class to handle various atomic commands for switching between Overview. */
-class OverviewCommandHelper(
+class OverviewCommandHelper
+@JvmOverloads
+constructor(
private val touchInteractionService: TouchInteractionService,
private val overviewComponentObserver: OverviewComponentObserver,
- private val taskAnimationManager: TaskAnimationManager
+ private val taskAnimationManager: TaskAnimationManager,
+ private val dispatcherProvider: DispatcherProvider = ProductionDispatchers,
) {
+ private val coroutineScope = CoroutineScope(SupervisorJob() + dispatcherProvider.default)
+
private val commandQueue = ConcurrentLinkedDeque<CommandInfo>()
/**
@@ -79,10 +101,10 @@
* dropped.
*/
@BinderThread
- fun addCommand(type: CommandType) {
+ fun addCommand(type: CommandType): CommandInfo? {
if (commandQueue.size >= MAX_QUEUE_SIZE) {
- Log.d(TAG, "commands queue is full ($commandQueue). command not added: $type")
- return
+ Log.d(TAG, "command not added: $type - queue is full ($commandQueue).")
+ return null
}
val command = CommandInfo(type)
@@ -90,8 +112,17 @@
Log.d(TAG, "command added: $command")
if (commandQueue.size == 1) {
- Executors.MAIN_EXECUTOR.execute { executeNext() }
+ Log.d(TAG, "execute: $command - queue size: ${commandQueue.size}")
+ if (enableOverviewCommandHelperTimeout()) {
+ coroutineScope.launch(dispatcherProvider.main) { processNextCommand() }
+ } else {
+ Executors.MAIN_EXECUTOR.execute { processNextCommand() }
+ }
+ } else {
+ Log.d(TAG, "not executed: $command - queue size: ${commandQueue.size}")
}
+
+ return command
}
fun canStartHomeSafely(): Boolean = commandQueue.isEmpty() || commandQueue.first().type == HOME
@@ -108,7 +139,7 @@
* completion (returns false).
*/
@UiThread
- private fun executeNext() {
+ private fun processNextCommand() {
val command: CommandInfo =
commandQueue.firstOrNull()
?: run {
@@ -119,12 +150,22 @@
command.status = CommandStatus.PROCESSING
Log.d(TAG, "executing command: $command")
- val result = executeCommand(command)
- Log.d(TAG, "command executed: $command with result: $result")
- if (result) {
- onCommandFinished(command)
+ if (enableOverviewCommandHelperTimeout()) {
+ coroutineScope.launch(dispatcherProvider.main) {
+ withTimeout(QUEUE_WAIT_DURATION_IN_MS) {
+ executeCommandSuspended(command)
+ ensureActive()
+ onCommandFinished(command)
+ }
+ }
} else {
- Log.d(TAG, "waiting for command callback: $command")
+ val result = executeCommand(command, onCallbackResult = { onCommandFinished(command) })
+ Log.d(TAG, "command executed: $command with result: $result")
+ if (result) {
+ onCommandFinished(command)
+ } else {
+ Log.d(TAG, "waiting for command callback: $command")
+ }
}
}
@@ -132,7 +173,9 @@
* Executes the task and returns true if next task can be executed. If false, then the next task
* is deferred until [.scheduleNextTask] is called
*/
- private fun executeCommand(command: CommandInfo): Boolean {
+ @VisibleForTesting
+ fun executeCommand(command: CommandInfo, onCallbackResult: () -> Unit): Boolean {
+ // This shouldn't happen if we execute 1 command per time.
if (waitForToggleCommandComplete && command.type == TOGGLE) {
Log.d(TAG, "executeCommand: $command - waiting for toggle command complete")
return true
@@ -141,15 +184,37 @@
val recentsView = visibleRecentsView
Log.d(TAG, "executeCommand: $command - visibleRecentsView: $recentsView")
return if (recentsView != null) {
- executeWhenRecentsIsVisible(command, recentsView)
+ executeWhenRecentsIsVisible(command, recentsView, onCallbackResult)
} else {
- executeWhenRecentsIsNotVisible(command)
+ executeWhenRecentsIsNotVisible(command, onCallbackResult)
}
}
+ /**
+ * Executes the task and returns true if next task can be executed. If false, then the next task
+ * is deferred until [.scheduleNextTask] is called
+ */
+ private suspend fun executeCommandSuspended(command: CommandInfo) =
+ suspendCancellableCoroutine { continuation ->
+ fun processResult(isCompleted: Boolean) {
+ Log.d(TAG, "command executed: $command with result: $isCompleted")
+ if (isCompleted) {
+ continuation.resume(Unit)
+ } else {
+ Log.d(TAG, "waiting for command callback: $command")
+ }
+ }
+
+ val result = executeCommand(command, onCallbackResult = { processResult(true) })
+ processResult(result)
+
+ continuation.invokeOnCancellation { cancelCommand(command, it) }
+ }
+
private fun executeWhenRecentsIsVisible(
command: CommandInfo,
recentsView: RecentsView<*, *>,
+ onCallbackResult: () -> Unit,
): Boolean =
when (command.type) {
SHOW -> true // already visible
@@ -161,7 +226,7 @@
keyboardTaskFocusIndex = PagedView.INVALID_PAGE
val currentPage = recentsView.nextPage
val taskView = recentsView.getTaskViewAt(currentPage)
- launchTask(recentsView, taskView, command)
+ launchTask(recentsView, taskView, command, onCallbackResult)
}
}
TOGGLE -> {
@@ -171,7 +236,7 @@
} else {
recentsView.nextTaskView ?: recentsView.runningTaskView
}
- launchTask(recentsView, taskView, command)
+ launchTask(recentsView, taskView, command, onCallbackResult)
}
HOME -> {
recentsView.startHome()
@@ -182,19 +247,20 @@
private fun launchTask(
recents: RecentsView<*, *>,
taskView: TaskView?,
- command: CommandInfo
+ command: CommandInfo,
+ onCallbackResult: () -> Unit
): Boolean {
var callbackList: RunnableList? = null
if (taskView != null) {
waitForToggleCommandComplete = true
taskView.isEndQuickSwitchCuj = true
- callbackList = taskView.launchTasks()
+ callbackList = taskView.launchWithAnimation()
}
if (callbackList != null) {
callbackList.add {
Log.d(TAG, "launching task callback: $command")
- onCommandFinished(command)
+ onCallbackResult()
waitForToggleCommandComplete = false
}
Log.d(TAG, "launching task - waiting for callback: $command")
@@ -206,7 +272,10 @@
}
}
- private fun executeWhenRecentsIsNotVisible(command: CommandInfo): Boolean {
+ private fun executeWhenRecentsIsNotVisible(
+ command: CommandInfo,
+ onCallbackResult: () -> Unit
+ ): Boolean {
val recentsViewContainer = activityInterface.getCreatedContainer() as? RecentsViewContainer
val recentsView: RecentsView<*, *>? = recentsViewContainer?.getOverviewPanel()
val deviceProfile = recentsViewContainer?.getDeviceProfile()
@@ -263,7 +332,7 @@
Log.d(TAG, "switching to Overview state - onAnimationEnd: $command")
super.onAnimationEnd(animation)
onRecentsViewFocusUpdated(command)
- onCommandFinished(command)
+ onCallbackResult()
}
}
if (activityInterface.switchToRecentsIfVisible(animatorListener)) {
@@ -289,7 +358,7 @@
command.createTime
)
interactionHandler.setGestureEndCallback {
- onTransitionComplete(command, interactionHandler)
+ onTransitionComplete(command, interactionHandler, onCallbackResult)
}
interactionHandler.initWhenReady("OverviewCommandHelper: command.type=${command.type}")
@@ -321,11 +390,6 @@
}
}
- // TODO(b/361768912): Dead code. Remove or update after this bug is fixed.
- // if (visibleRecentsView != null) {
- // visibleRecentsView.moveRunningTaskToFront();
- // }
-
if (taskAnimationManager.isRecentsAnimationRunning) {
command.setAnimationCallbacks(
taskAnimationManager.continueRecentsAnimation(gestureState)
@@ -351,29 +415,40 @@
return false
}
- private fun onTransitionComplete(command: CommandInfo, handler: AbsSwipeUpHandler<*, *, *>) {
+ private fun onTransitionComplete(
+ command: CommandInfo,
+ handler: AbsSwipeUpHandler<*, *, *>,
+ onCommandResult: () -> Unit
+ ) {
Log.d(TAG, "switching via recents animation - onTransitionComplete: $command")
command.removeListener(handler)
Trace.endAsyncSection(TRANSITION_NAME, 0)
onRecentsViewFocusUpdated(command)
- onCommandFinished(command)
+ onCommandResult()
}
/** Called when the command finishes execution. */
private fun onCommandFinished(command: CommandInfo) {
command.status = CommandStatus.COMPLETED
- if (commandQueue.first() !== command) {
+ if (commandQueue.firstOrNull() !== command) {
Log.d(
TAG,
"next task not scheduled. First pending command type " +
- "is ${commandQueue.first()} - command type is: $command"
+ "is ${commandQueue.firstOrNull()} - command type is: $command"
)
return
}
Log.d(TAG, "command executed successfully! $command")
commandQueue.remove(command)
- executeNext()
+ processNextCommand()
+ }
+
+ private fun cancelCommand(command: CommandInfo, throwable: Throwable?) {
+ command.status = CommandStatus.CANCELED
+ Log.e(TAG, "command cancelled: $command - $throwable")
+ commandQueue.remove(command)
+ processNextCommand()
}
private fun updateRecentsViewFocus(command: CommandInfo) {
@@ -447,7 +522,8 @@
pw.println(" waitForToggleCommandComplete=$waitForToggleCommandComplete")
}
- private data class CommandInfo(
+ @VisibleForTesting
+ data class CommandInfo(
val type: CommandType,
var status: CommandStatus = CommandStatus.IDLE,
val createTime: Long = SystemClock.elapsedRealtime(),
@@ -468,7 +544,8 @@
enum class CommandStatus {
IDLE,
PROCESSING,
- COMPLETED
+ COMPLETED,
+ CANCELED
}
}
@@ -489,5 +566,6 @@
* should be enough. We'll toss in one more because we're kind hearted.
*/
private const val MAX_QUEUE_SIZE = 3
+ private const val QUEUE_WAIT_DURATION_IN_MS = 5000L
}
}
diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
index 49ec597..da967ab 100644
--- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java
+++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
@@ -329,10 +329,7 @@
final ActivityOptions options = ActivityOptions.makeBasic();
options.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS);
- // Use regular (non-transient) launch for all apps page to control IME.
- if (!containerInterface.allowAllAppsFromOverview()) {
- options.setTransientLaunch();
- }
+ options.setTransientLaunch();
options.setSourceInfo(ActivityOptions.SourceInfo.TYPE_RECENTS_ANIMATION, eventTime);
// Notify taskbar that we should skip reacting to launcher visibility change to
diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
index 9e6e2f3..785666f 100644
--- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
@@ -431,7 +431,7 @@
@Override
public void onClick(View view) {
- if (mTaskView.launchTaskAnimated() != null) {
+ if (mTaskView.launchAsStaticTile() != null) {
SystemUiProxy.INSTANCE.get(mTarget.asContext()).startScreenPinning(
mTaskView.getFirstTask().key.id);
}
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 4587bdd..98e7fed 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -379,6 +379,15 @@
));
}
+ @BinderThread
+ @Override
+ public void appTransitionPending(boolean pending) {
+ MAIN_EXECUTOR.execute(() -> executeForTouchInteractionService(tis ->
+ executeForTaskbarManager(
+ taskbarManager -> taskbarManager.appTransitionPending(pending))
+ ));
+ }
+
/**
* Preloads the Overview activity.
* <p>
diff --git a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
index 32d9052..cc022b2 100644
--- a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
+++ b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
@@ -535,6 +535,18 @@
int parentWidth, int parentHeight, SplitBounds splitBoundsConfig,
DeviceProfile dp, boolean isRtl) {
int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
+
+ FrameLayout.LayoutParams primaryParams =
+ (FrameLayout.LayoutParams) primarySnapshot.getLayoutParams();
+ FrameLayout.LayoutParams secondaryParams =
+ (FrameLayout.LayoutParams) secondarySnapshot.getLayoutParams();
+
+ // Reset margin and translations that aren't used in this method, but are used in other
+ // `RecentsPagedOrientationHandler` variants.
+ secondaryParams.topMargin = 0;
+ primaryParams.topMargin = spaceAboveSnapshot;
+ primarySnapshot.setTranslationY(0);
+
int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
float dividerScale = splitBoundsConfig.appsStackedVertically
? splitBoundsConfig.dividerHeightPercent
@@ -552,24 +564,14 @@
secondarySnapshot.setTranslationX(translationX);
primarySnapshot.setTranslationX(0);
}
- secondarySnapshot.setTranslationY(spaceAboveSnapshot);
- // Reset unused translations
- primarySnapshot.setTranslationY(0);
+ secondarySnapshot.setTranslationY(spaceAboveSnapshot);
} else {
float finalDividerHeight = Math.round(totalThumbnailHeight * dividerScale);
float translationY = taskViewSizes.first.y + spaceAboveSnapshot + finalDividerHeight;
secondarySnapshot.setTranslationY(translationY);
- FrameLayout.LayoutParams primaryParams =
- (FrameLayout.LayoutParams) primarySnapshot.getLayoutParams();
- FrameLayout.LayoutParams secondaryParams =
- (FrameLayout.LayoutParams) secondarySnapshot.getLayoutParams();
- secondaryParams.topMargin = 0;
- primaryParams.topMargin = spaceAboveSnapshot;
-
- // Reset unused translations
- primarySnapshot.setTranslationY(0);
+ // Reset unused translations.
secondarySnapshot.setTranslationX(0);
primarySnapshot.setTranslationX(0);
}
diff --git a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java
index c7c04ed..b583a4b 100644
--- a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java
+++ b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java
@@ -21,7 +21,6 @@
import static com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY;
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION;
-import android.animation.AnimatorSet;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.graphics.Matrix;
@@ -34,18 +33,11 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
-import com.android.launcher3.statemanager.StateManager;
-import com.android.launcher3.statemanager.StatefulActivity;
-import com.android.launcher3.states.StateAnimationConfig;
-import com.android.launcher3.touch.AllAppsSwipeController;
-import com.android.quickstep.DeviceConfigWrapper;
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
import com.android.quickstep.views.RecentsView;
-import com.android.quickstep.views.RecentsViewContainer;
/**
* Controls an animation that can go beyond progress = 1, at which point resistance should be
@@ -57,10 +49,8 @@
private enum RecentsResistanceParams {
FROM_APP(0.75f, 0.5f, 1f, false),
- FROM_APP_TO_ALL_APPS(1f, 0.6f, 0.8f, false),
FROM_APP_TABLET(1f, 0.7f, 1f, true),
FROM_APP_TABLET_GRID_ONLY(1f, 1f, 1f, true),
- FROM_APP_TO_ALL_APPS_TABLET(1f, 0.5f, 0.5f, false),
FROM_OVERVIEW(1f, 0.75f, 0.5f, false);
RecentsResistanceParams(float scaleStartResist, float scaleMaxResist,
@@ -157,46 +147,10 @@
RecentsParams params = new RecentsParams(context, recentsOrientedState, dp, scaleTarget,
scaleProperty, translationTarget, translationProperty);
PendingAnimation resistAnim = createRecentsResistanceAnim(params);
-
- // Apply All Apps animation during the resistance animation.
- if (recentsOrientedState.getContainerInterface().allowAllAppsFromOverview()) {
- RecentsViewContainer container =
- recentsOrientedState.getContainerInterface().getCreatedContainer();
- if (container != null) {
- RecentsView recentsView = container.getOverviewPanel();
- StateManager<LauncherState, StatefulActivity<LauncherState>> stateManager =
- recentsView.getStateManager();
- if (stateManager.isInStableState(LauncherState.BACKGROUND_APP)
- && stateManager.isInTransition()) {
-
- // Calculate the resistance progress threshold where All Apps will trigger.
- float threshold = getAllAppsThreshold(context, recentsOrientedState, dp);
-
- StateAnimationConfig config = new StateAnimationConfig();
- AllAppsSwipeController.applyOverviewToAllAppsAnimConfig(dp, config, threshold);
- AnimatorSet allAppsAnimator = stateManager.createAnimationToNewWorkspace(
- LauncherState.ALL_APPS, config).getTarget();
- resistAnim.add(allAppsAnimator);
- }
- }
- }
-
AnimatorPlaybackController resistanceController = resistAnim.createPlaybackController();
return new AnimatorControllerWithResistance(normalController, resistanceController);
}
- private static float getAllAppsThreshold(Context context,
- RecentsOrientedState recentsOrientedState, DeviceProfile dp) {
- int transitionDragLength =
- recentsOrientedState.getContainerInterface().getSwipeUpDestinationAndLength(
- dp, context, TEMP_RECT,
- recentsOrientedState.getOrientationHandler());
- float dragLengthFactor = (float) dp.heightPx / transitionDragLength;
- // -1s are because 0-1 is reserved for the normal transition.
- float threshold = DeviceConfigWrapper.get().getAllAppsOverviewThreshold() / 100f;
- return (threshold - 1) / (dragLengthFactor - 1);
- }
-
/**
* Creates the resistance animation for {@link #createForRecents}, or can be used separately
* when starting from recents, i.e. {@link #createRecentsResistanceFromOverviewAnim}.
@@ -305,17 +259,11 @@
this.translationTarget = translationTarget;
this.translationProperty = translationProperty;
if (dp.isTablet) {
- resistanceParams =
- recentsOrientedState.getContainerInterface().allowAllAppsFromOverview()
- ? RecentsResistanceParams.FROM_APP_TO_ALL_APPS_TABLET
- : enableGridOnlyOverview()
- ? RecentsResistanceParams.FROM_APP_TABLET_GRID_ONLY
- : RecentsResistanceParams.FROM_APP_TABLET;
+ resistanceParams = enableGridOnlyOverview()
+ ? RecentsResistanceParams.FROM_APP_TABLET_GRID_ONLY
+ : RecentsResistanceParams.FROM_APP_TABLET;
} else {
- resistanceParams =
- recentsOrientedState.getContainerInterface().allowAllAppsFromOverview()
- ? RecentsResistanceParams.FROM_APP_TO_ALL_APPS
- : RecentsResistanceParams.FROM_APP;
+ resistanceParams = RecentsResistanceParams.FROM_APP;
}
}
diff --git a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt
index cf08391..ffc345f 100644
--- a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt
+++ b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt
@@ -50,32 +50,30 @@
}
/**
- * Counts [numChildren] that are [DesktopTaskView] instances.
+ * Counts [TaskView]s that are [DesktopTaskView] instances.
*
- * @param numChildren Quantity of children to transverse
- * @param getTaskViewAt Function that provides a TaskView given an index
+ * @param taskViews List of [TaskView]s
*/
- fun getDesktopTaskViewCount(numChildren: Int, getTaskViewAt: (Int) -> TaskView?): Int =
- (0 until numChildren).count { getTaskViewAt(it) is DesktopTaskView }
+ fun getDesktopTaskViewCount(taskViews: List<TaskView>): Int =
+ taskViews.count { it is DesktopTaskView }
/**
* Returns the first TaskView that should be displayed as a large tile.
*
- * @param numChildren Quantity of children to transverse
- * @param getTaskViewAt Function that provides a TaskView given an index
+ * @param taskViews List of [TaskView]s
*/
- fun getFirstLargeTaskView(numChildren: Int, getTaskViewAt: (Int) -> TaskView?): TaskView? {
- return (0 until numChildren).firstNotNullOfOrNull { index ->
- val taskView = getTaskViewAt(index)
- if (taskView?.isLargeTile == true) taskView else null
- }
- }
+ fun getFirstLargeTaskView(taskViews: List<TaskView>): TaskView? =
+ taskViews.firstOrNull { it.isLargeTile }
fun screenshotTasks(
taskView: TaskView,
- recentsAnimationController: RecentsAnimationController
+ recentsAnimationController: RecentsAnimationController,
): Map<Int, ThumbnailData> =
taskView.taskContainers.associate {
it.task.key.id to recentsAnimationController.screenshotTask(it.task.key.id)
}
+
+ /** Returns the current list of [TaskView] children. */
+ fun getTaskViews(taskViewCount: Int, requireTaskViewAt: (Int) -> TaskView): List<TaskView> =
+ (0 until taskViewCount).map(requireTaskViewAt)
}
diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
index fa5a67a..256e29e 100644
--- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
+++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
@@ -731,16 +731,19 @@
val mainRootCandidate = splitRoots.first
// Will contain changes (1) and (2) in diagram above
val leafRoots: List<Change> = splitRoots.second
+ // Don't rely on DP.isLeftRightSplit because if launcher is portrait apps could still
+ // launch in landscape if system auto-rotate is enabled and phone is held horizontally
+ val isLeftRightSplit = leafRoots.all { it.endAbsBounds.top == 0 }
// Find the place where our left/top app window meets the divider (used for the
// launcher side animation)
val leftTopApp =
leafRoots.single { change ->
- (dp.isLeftRightSplit && change.endAbsBounds.left == 0) ||
- (!dp.isLeftRightSplit && change.endAbsBounds.top == 0)
+ (isLeftRightSplit && change.endAbsBounds.left == 0) ||
+ (!isLeftRightSplit && change.endAbsBounds.top == 0)
}
val dividerPos =
- if (dp.isLeftRightSplit) leftTopApp.endAbsBounds.right
+ if (isLeftRightSplit) leftTopApp.endAbsBounds.right
else leftTopApp.endAbsBounds.bottom
// Create a new floating view in Launcher, positioned above the launching icon
diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt
index 41add54..6db0923 100644
--- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt
+++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt
@@ -262,7 +262,7 @@
}
Log.d(
TAG,
- "launchTaskAnimated - launchTaskWithDesktopController: ${taskIds.contentToString()}, withRemoteTransition: $animated"
+ "launchTaskWithDesktopController: ${taskIds.contentToString()}, withRemoteTransition: $animated"
)
// Callbacks get run from recentsView for case when recents animation already running
@@ -270,11 +270,12 @@
return endCallback
}
- override fun launchTaskAnimated() = launchTaskWithDesktopController(animated = true)
+ override fun launchAsStaticTile() = launchTaskWithDesktopController(animated = true)
- override fun launchTask(callback: (launched: Boolean) -> Unit, isQuickSwitch: Boolean) {
- launchTaskWithDesktopController(animated = false)?.add { callback(true) } ?: callback(false)
- }
+ override fun launchWithoutAnimation(
+ isQuickSwitch: Boolean,
+ callback: (launched: Boolean) -> Unit
+ ) = launchTaskWithDesktopController(animated = false)?.add { callback(true) } ?: callback(false)
// Desktop tile can't be in split screen
override fun confirmSecondSplitSelectApp(): Boolean = false
diff --git a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt
index f0fdd81..7b97c23 100644
--- a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt
+++ b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt
@@ -39,6 +39,7 @@
import androidx.annotation.VisibleForTesting
import androidx.core.util.component1
import androidx.core.util.component2
+import androidx.core.view.isVisible
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.util.Executors
@@ -108,18 +109,18 @@
}
private fun setNoLimit() {
+ isVisible = false
hasLimit = false
- setContentDescription(appUsageLimitTimeMs = -1, appRemainingTimeMs = -1)
- visibility = INVISIBLE
appRemainingTimeMs = -1
+ setContentDescription(appUsageLimitTimeMs = -1, appRemainingTimeMs = -1)
}
private fun setLimit(appUsageLimitTimeMs: Long, appRemainingTimeMs: Long) {
- this.appRemainingTimeMs = appRemainingTimeMs
+ isVisible = true
hasLimit = true
- text = Utilities.prefixTextWithIcon(context, R.drawable.ic_hourglass_top, getBannerText())
- visibility = VISIBLE
+ this.appRemainingTimeMs = appRemainingTimeMs
setContentDescription(appUsageLimitTimeMs, appRemainingTimeMs)
+ text = Utilities.prefixTextWithIcon(context, R.drawable.ic_hourglass_top, getBannerText())
}
private fun setContentDescription(appUsageLimitTimeMs: Long, appRemainingTimeMs: Long) {
@@ -172,7 +173,7 @@
/** Mark the DWB toast as destroyed and hide it. */
fun destroy() {
- visibility = INVISIBLE
+ isVisible = false
isDestroyed = true
}
diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt
index 4fae01e..3fd1a6b 100644
--- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt
+++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt
@@ -218,11 +218,7 @@
invalidate()
}
- override fun launchTaskAnimated(): RunnableList? {
- if (taskContainers.isEmpty()) {
- Log.d(TAG, "launchTaskAnimated - task is not bound")
- return null
- }
+ override fun launchAsStaticTile(): RunnableList? {
val recentsView = recentsView ?: return null
val endCallback = RunnableList()
// Callbacks run from remote animation when recents animation not currently running
@@ -241,8 +237,11 @@
return endCallback
}
- override fun launchTask(callback: (launched: Boolean) -> Unit, isQuickSwitch: Boolean) {
- launchTaskInternal(isQuickSwitch, false, callback /*launchingExistingTaskview*/)
+ override fun launchWithoutAnimation(
+ isQuickSwitch: Boolean,
+ callback: (launched: Boolean) -> Unit
+ ) {
+ launchTaskInternal(isQuickSwitch, launchingExistingTaskView = false, callback)
}
/**
@@ -266,7 +265,10 @@
isQuickSwitch,
snapPosition
)
- Log.d(TAG, "launchTaskInternal - launchExistingSplitPair: ${taskIds.contentToString()}")
+ Log.d(
+ TAG,
+ "launchTaskInternal - launchExistingSplitPair: ${taskIds.contentToString()}, launchingExistingTaskView: $launchingExistingTaskView"
+ )
}
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 226ecf5..f8a0f45 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -635,13 +635,16 @@
@Override
public void onTaskRemoved(int taskId) {
if (!mHandleTaskStackChanges) {
+ Log.d(TAG, "onTaskRemoved: " + taskId + ", not handling task stack changes");
return;
}
TaskView taskView = getTaskViewByTaskId(taskId);
if (taskView == null) {
+ Log.d(TAG, "onTaskRemoved: " + taskId + ", no associated TaskView");
return;
}
+ Log.d(TAG, "onTaskRemoved: " + taskId);
Task.TaskKey taskKey = taskView.getFirstTask().key;
UI_HELPER_EXECUTOR.execute(new CancellableTask<>(
() -> PackageManagerWrapper.getInstance()
@@ -838,8 +841,7 @@
private final RecentsViewModel mRecentsViewModel;
private final RecentsViewModelHelper mHelper;
-
- private final RecentsViewUtils mRecentsViewUtils = new RecentsViewUtils();
+ private final RecentsViewUtils mUtils = new RecentsViewUtils();
public RecentsView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
BaseContainerInterface sizeStrategy) {
@@ -1100,14 +1102,13 @@
@Override
public void onTaskIconChanged(@NonNull String pkg, @NonNull UserHandle user) {
- for (int i = 0; i < getTaskViewCount(); i++) {
- TaskView tv = requireTaskViewAt(i);
- Task task = tv.getFirstTask();
+ for (TaskView taskView : getTaskViews()) {
+ Task task = taskView.getFirstTask();
if (pkg.equals(task.key.getPackageName()) && task.key.userId == user.getIdentifier()) {
task.icon = null;
- if (tv.getTaskContainers().stream().anyMatch(
+ if (taskView.getTaskContainers().stream().anyMatch(
container -> container.getIconView().getDrawable() != null)) {
- tv.onTaskListVisibilityChanged(true /* visible */);
+ taskView.onTaskListVisibilityChanged(true /* visible */);
}
}
}
@@ -1496,8 +1497,7 @@
return null;
}
- for (int i = 0; i < getTaskViewCount(); i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
if (taskView.containsTaskId(taskId)) {
return taskView;
}
@@ -1518,8 +1518,7 @@
int[] taskIdsCopy = Arrays.copyOf(taskIds, taskIds.length);
Arrays.sort(taskIdsCopy);
- for (int i = 0; i < getTaskViewCount(); i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
int[] taskViewIdsCopy = taskView.getTaskIds();
Arrays.sort(taskViewIdsCopy);
if (Arrays.equals(taskIdsCopy, taskViewIdsCopy)) {
@@ -1555,9 +1554,7 @@
*/
public void setTaskBorderEnabled(boolean enabled) {
mBorderEnabled = enabled;
- int taskCount = getTaskViewCount();
- for (int i = 0; i < taskCount; i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
taskView.setBorderEnabled(enabled);
}
mClearAllButton.setBorderEnabled(enabled);
@@ -1624,9 +1621,7 @@
super.onTouchEvent(ev);
if (showAsGrid()) {
- int taskCount = getTaskViewCount();
- for (int i = 0; i < taskCount; i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
if (isTaskViewVisible(taskView) && taskView.offerTouchToChildren(ev)) {
// Keep consuming events to pass to delegate
return true;
@@ -1880,7 +1875,7 @@
// Move Desktop Tasks to the end of the list
if (enableLargeDesktopWindowingTile()) {
- taskGroups = mRecentsViewUtils.sortDesktopTasksToFront(taskGroups);
+ taskGroups = mUtils.sortDesktopTasksToFront(taskGroups);
}
// Add views as children based on whether it's grouped or single task. Looping through
@@ -1936,7 +1931,7 @@
// Keep same previous focused task
TaskView newFocusedTaskView = getTaskViewByTaskIds(focusedTaskIds);
// If the list changed, maybe the focused task doesn't exist anymore
- int newFocusedTaskViewIndex = mRecentsViewUtils.getFocusedTaskIndex(taskGroups);
+ int newFocusedTaskViewIndex = mUtils.getFocusedTaskIndex(taskGroups);
if (newFocusedTaskView == null && getTaskViewCount() > newFocusedTaskViewIndex) {
newFocusedTaskView = getTaskViewAt(newFocusedTaskViewIndex);
}
@@ -2027,15 +2022,13 @@
}
private void removeTasksViewsAndClearAllButton() {
- // This handles an edge case where applyLoadPlan happens during a gesture when the
- // only Task is one with excludeFromRecents, in which case we should not remove it.
- final int stubRunningTaskIndex = isGestureActive() ? getRunningTaskIndex() : -1;
-
- for (int i = getTaskViewCount() - 1; i >= 0; i--) {
- if (i == stubRunningTaskIndex) {
+ for (TaskView taskView : getTaskViews()) {
+ if (isGestureActive() && taskView.isRunningTask()) {
+ // This handles an edge case where applyLoadPlan happens during a gesture when the
+ // only Task is one with excludeFromRecents, in which case we should not remove it.
continue;
}
- removeView(requireTaskViewAt(i));
+ removeView(taskView);
}
if (getTaskViewCount() == 0 && indexOfChild(mClearAllButton) != -1) {
removeView(mClearAllButton);
@@ -2056,7 +2049,7 @@
* @return Number of children that are instances of DesktopTaskView
*/
private int getDesktopTaskViewCount() {
- return mRecentsViewUtils.getDesktopTaskViewCount(getChildCount(), this::getTaskViewAt);
+ return mUtils.getDesktopTaskViewCount(getTaskViews());
}
/**
@@ -2079,8 +2072,7 @@
}
public void resetTaskVisuals() {
- for (int i = getTaskViewCount() - 1; i >= 0; i--) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
if (Arrays.stream(taskView.getTaskIds()).noneMatch(
taskId -> taskId == mIgnoreResetTaskId)) {
taskView.resetViewTransforms();
@@ -2123,9 +2115,8 @@
if (enableRefactorTaskThumbnail()) {
mRecentsViewModel.updateFullscreenProgress(mFullscreenProgress);
}
- int taskCount = getTaskViewCount();
- for (int i = 0; i < taskCount; i++) {
- requireTaskViewAt(i).setFullscreenProgress(mFullscreenProgress);
+ for (TaskView taskView : getTaskViews()) {
+ taskView.setFullscreenProgress(mFullscreenProgress);
}
mClearAllButton.setFullscreenProgress(fullscreenProgress);
@@ -2138,6 +2129,7 @@
boolean handleTaskStackChanges = mOverviewStateEnabled && isAttachedToWindow()
&& getWindowVisibility() == VISIBLE;
if (handleTaskStackChanges != mHandleTaskStackChanges) {
+ Log.d(TAG, "updateTaskStackListenerState: " + handleTaskStackChanges);
mHandleTaskStackChanges = handleTaskStackChanges;
if (handleTaskStackChanges) {
reloadIfNeeded();
@@ -2270,8 +2262,7 @@
? mLastComputedCarouselTaskSize.right - mLastComputedTaskSize.right
: mLastComputedCarouselTaskSize.left - mLastComputedTaskSize.left;
}
- for (int i = 0; i < taskCount; i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
taskView.updateTaskSize(mLastComputedTaskSize, mLastComputedGridTaskSize,
mLastComputedCarouselTaskSize);
taskView.setNonGridTranslationX(accumulatedTranslationX);
@@ -2660,7 +2651,7 @@
}
private @Nullable TaskView getFirstLargeTaskView() {
- return mRecentsViewUtils.getFirstLargeTaskView(getChildCount(), this::getTaskViewAt);
+ return mUtils.getFirstLargeTaskView(getTaskViews());
}
@Nullable
@@ -2669,8 +2660,7 @@
return null;
}
- for (int i = 0; i < getTaskViewCount(); i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
if (taskView.getTaskViewId() == taskViewId) {
return taskView;
}
@@ -2731,9 +2721,12 @@
if (!mModel.isTaskListValid(mTaskListChangeId)) {
mTaskListChangeId = mModel.getTasks(this::applyLoadPlan, RecentsFilterState
.getFilter(mFilterState.getPackageNameToFilter()));
+ Log.d(TAG, "reloadIfNeeded - getTasks: " + mTaskListChangeId);
if (enableRefactorTaskThumbnail()) {
mRecentsViewModel.refreshAllTaskData();
}
+ } else {
+ Log.d(TAG, "reloadIfNeeded - task list still valid: " + mTaskListChangeId);
}
}
@@ -2816,8 +2809,8 @@
}
private void updateChildTaskOrientations() {
- for (int i = 0; i < getTaskViewCount(); i++) {
- requireTaskViewAt(i).setOrientationState(mOrientationState);
+ for (TaskView taskView : getTaskViews()) {
+ taskView.setOrientationState(mOrientationState);
}
boolean shouldRotateMenuForFakeRotation =
!mOrientationState.isRecentsActivityRotationAllowed();
@@ -3076,9 +3069,8 @@
public void setTaskIconScaledDown(boolean isScaledDown) {
if (mTaskIconScaledDown != isScaledDown) {
mTaskIconScaledDown = isScaledDown;
- int taskCount = getTaskViewCount();
- for (int i = 0; i < taskCount; i++) {
- requireTaskViewAt(i).setIconScaleAndDim(mTaskIconScaledDown ? 0 : 1);
+ for (TaskView taskView : getTaskViews()) {
+ taskView.setIconScaleAndDim(mTaskIconScaledDown ? 0 : 1);
}
}
}
@@ -3091,9 +3083,7 @@
public void animateUpTaskIconScale() {
mTaskIconScaledDown = false;
- int taskCount = getTaskViewCount();
- for (int i = 0; i < taskCount; i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
taskView.animateIconScaleAndDimIntoView();
}
}
@@ -3388,9 +3378,8 @@
private void setGridProgress(float gridProgress) {
mGridProgress = gridProgress;
- int taskCount = getTaskViewCount();
- for (int i = 0; i < taskCount; i++) {
- requireTaskViewAt(i).setGridProgress(gridProgress);
+ for (TaskView taskView : getTaskViews()) {
+ taskView.setGridProgress(gridProgress);
}
mClearAllButton.setGridProgress(gridProgress);
}
@@ -3400,14 +3389,10 @@
mRecentsViewModel.updateThumbnailSplashProgress(taskThumbnailSplashAlpha);
return;
}
- int taskCount = getTaskViewCount();
- if (taskCount == 0) {
- return;
- }
mTaskThumbnailSplashAlpha = taskThumbnailSplashAlpha;
- for (int i = 0; i < taskCount; i++) {
- requireTaskViewAt(i).setTaskThumbnailSplashAlpha(taskThumbnailSplashAlpha);
+ for (TaskView taskView : getTaskViews()) {
+ taskView.setTaskThumbnailSplashAlpha(taskThumbnailSplashAlpha);
}
}
@@ -3630,8 +3615,7 @@
nextFocusedTaskFromTop =
!mTopRowIdSet.isEmpty() && mTopRowIdSet.size() >= (taskCount - 1) / 2f;
// Pick the next focused task from the preferred row.
- for (int i = 0; i < taskCount; i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
if (taskView == dismissedTaskView || taskView.isLargeTile()) {
continue;
}
@@ -3759,8 +3743,7 @@
END_DISMISS_TRANSLATION_INTERPOLATION_OFFSET
+ (taskCount - 1) * halfAdditionalDismissTranslationOffset,
END_DISMISS_TRANSLATION_INTERPOLATION_OFFSET, 1);
- for (int i = 0; i < taskCount; i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
anim.setFloat(taskView, TaskView.GRID_END_TRANSLATION_X, longGridRowWidthDiff,
clampToProgress(LINEAR, dismissTranslationInterpolationEnd, 1));
dismissTranslationInterpolationEnd = Utilities.boundToRange(
@@ -4220,9 +4203,8 @@
return new IntArray(0);
}
IntArray topArray = new IntArray(mTopRowIdSet.size());
- int taskViewCount = getTaskViewCount();
- for (int i = 0; i < taskViewCount; i++) {
- int taskViewId = requireTaskViewAt(i).getTaskViewId();
+ for (TaskView taskView : getTaskViews()) {
+ int taskViewId = taskView.getTaskViewId();
if (mTopRowIdSet.contains(taskViewId)) {
topArray.add(taskViewId);
}
@@ -4239,9 +4221,7 @@
return new IntArray(0);
}
IntArray bottomArray = new IntArray(bottomRowIdArraySize);
- int taskViewCount = getTaskViewCount();
- for (int i = 0; i < taskViewCount; i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
int taskViewId = taskView.getTaskViewId();
if (!mTopRowIdSet.contains(taskViewId) && !taskView.isLargeTile()) {
bottomArray.add(taskViewId);
@@ -4301,9 +4281,8 @@
}
PendingAnimation anim = new PendingAnimation(duration);
- int count = getTaskViewCount();
- for (int i = 0; i < count; i++) {
- addDismissedTaskAnimations(requireTaskViewAt(i), duration, anim);
+ for (TaskView taskView : getTaskViews()) {
+ addDismissedTaskAnimations(taskView, duration, anim);
}
mPendingAnimation = anim;
@@ -4382,8 +4361,10 @@
private void dismissTask(int taskId) {
TaskView taskView = getTaskViewByTaskId(taskId);
if (taskView == null) {
+ Log.d(TAG, "dismissTask: " + taskId + ", no associated TaskView");
return;
}
+ Log.d(TAG, "dismissTask: " + taskId);
dismissTask(taskView, true /* animate */, false /* removeTask */);
}
@@ -4468,12 +4449,11 @@
mContentAlpha = alpha;
TaskView runningTaskView = getRunningTaskView();
- for (int i = getTaskViewCount() - 1; i >= 0; i--) {
- TaskView child = requireTaskViewAt(i);
- if (runningTaskView != null && mRunningTaskTileHidden && child == runningTaskView) {
+ for (TaskView taskView : getTaskViews()) {
+ if (runningTaskView != null && mRunningTaskTileHidden && taskView == runningTaskView) {
continue;
}
- child.setStableAlpha(alpha);
+ taskView.setStableAlpha(alpha);
}
mClearAllButton.setContentAlpha(mContentAlpha);
int alphaInt = Math.round(alpha * 255);
@@ -4582,6 +4562,13 @@
return Objects.requireNonNull(getTaskViewAt(index));
}
+ /**
+ * Returns the current list of [TaskView] children.
+ */
+ private List<TaskView> getTaskViews() {
+ return mUtils.getTaskViews(getTaskViewCount(), this::requireTaskViewAt);
+ }
+
public void setOnEmptyMessageUpdatedListener(OnEmptyMessageUpdatedListener listener) {
mOnEmptyMessageUpdatedListener = listener;
}
@@ -4886,9 +4873,9 @@
protected void setTaskViewsResistanceTranslation(float translation) {
mTaskViewsSecondaryTranslation = translation;
- for (int i = 0; i < getTaskViewCount(); i++) {
- TaskView task = requireTaskViewAt(i);
- task.getTaskResistanceTranslationProperty().set(task, translation / getScaleY());
+ for (TaskView taskView : getTaskViews()) {
+ taskView.getTaskResistanceTranslationProperty().set(taskView,
+ translation / getScaleY());
}
runActionOnRemoteHandles(
remoteTargetHandle -> remoteTargetHandle.getTaskViewSimulator()
@@ -4896,23 +4883,21 @@
}
private void updateTaskViewsSnapshotRadius() {
- for (int i = 0; i < getTaskViewCount(); i++) {
- requireTaskViewAt(i).updateSnapshotRadius();
+ for (TaskView taskView : getTaskViews()) {
+ taskView.updateSnapshotRadius();
}
}
protected void setTaskViewsPrimarySplitTranslation(float translation) {
mTaskViewsPrimarySplitTranslation = translation;
- for (int i = 0; i < getTaskViewCount(); i++) {
- TaskView task = requireTaskViewAt(i);
- task.getPrimarySplitTranslationProperty().set(task, translation);
+ for (TaskView taskView : getTaskViews()) {
+ taskView.getPrimarySplitTranslationProperty().set(taskView, translation);
}
}
protected void setTaskViewsSecondarySplitTranslation(float translation) {
mTaskViewsSecondarySplitTranslation = translation;
- for (int i = 0; i < getTaskViewCount(); i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
if (taskView == mSplitHiddenTaskView && !taskView.containsMultipleTasks()) {
continue;
}
@@ -5485,7 +5470,7 @@
finishRecentsAnimation(false /* toRecents */, null);
onTaskLaunchAnimationEnd(true /* success */);
} else {
- taskView.launchTask(this::onTaskLaunchAnimationEnd);
+ taskView.launchWithoutAnimation(this::onTaskLaunchAnimationEnd);
}
mContainer.getStatsLogManager().logger().withItemInfo(taskView.getFirstItemInfo())
.log(LAUNCHER_TASK_LAUNCH_SWIPE_DOWN);
@@ -6079,9 +6064,7 @@
private void updateEnabledOverlays() {
TaskView focusedTaskView = getFocusedTaskView();
- int taskCount = getTaskViewCount();
- for (int i = 0; i < taskCount; i++) {
- TaskView taskView = requireTaskViewAt(i);
+ for (TaskView taskView : getTaskViews()) {
if (taskView == focusedTaskView) {
continue;
}
@@ -6155,7 +6138,7 @@
return;
}
- Map<Integer, ThumbnailData> updatedThumbnails = mRecentsViewUtils.screenshotTasks(taskView,
+ Map<Integer, ThumbnailData> updatedThumbnails = mUtils.screenshotTasks(taskView,
mRecentsAnimationController);
if (enableRefactorTaskThumbnail()) {
mHelper.switchToScreenshot(taskView, updatedThumbnails, onFinishRunnable);
@@ -6253,8 +6236,8 @@
mRecentsViewModel.setTintAmount(tintAmount);
}
- for (int i = 0; i < getTaskViewCount(); i++) {
- requireTaskViewAt(i).setColorTint(mColorTint, mTintingColor);
+ for (TaskView taskView : getTaskViews()) {
+ taskView.setColorTint(mColorTint, mTintingColor);
}
Drawable scrimBg = mContainer.getScrimView().getBackground();
diff --git a/quickstep/src/com/android/quickstep/views/TaskContainer.kt b/quickstep/src/com/android/quickstep/views/TaskContainer.kt
index d34a93b..13c4f78 100644
--- a/quickstep/src/com/android/quickstep/views/TaskContainer.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskContainer.kt
@@ -177,6 +177,7 @@
addAccessibleChildToList(iconView.asView(), outChildren)
addAccessibleChildToList(snapshotView, outChildren)
showWindowsView?.let { addAccessibleChildToList(it, outChildren) }
+ digitalWellBeingToast?.let { addAccessibleChildToList(it, outChildren) }
}
private fun addAccessibleChildToList(view: View, outChildren: ArrayList<View>) {
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt
index 5614af6..601dae8 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskView.kt
@@ -1003,7 +1003,7 @@
return
}
val callbackList =
- launchTasks()?.apply {
+ launchWithAnimation()?.apply {
add {
Log.d("b/310064698", "${taskIds.contentToString()} - onClick - launchCompleted")
}
@@ -1015,12 +1015,106 @@
.log(LauncherEvent.LAUNCHER_TASK_LAUNCH_TAP)
}
+ /** Launch of the current task (both live and inactive tasks) with an animation. */
+ fun launchWithAnimation(): RunnableList? {
+ return if (isRunningTask && recentsView?.remoteTargetHandles != null) {
+ launchAsLiveTile()
+ } else {
+ launchAsStaticTile()
+ }
+ }
+
+ private fun launchAsLiveTile(): RunnableList? {
+ val recentsView = recentsView ?: return null
+ val remoteTargetHandles = recentsView.remoteTargetHandles
+ if (!isClickableAsLiveTile) {
+ Log.e(
+ TAG,
+ "launchAsLiveTile - TaskView is not clickable as a live tile; returning to home: ${taskIds.contentToString()}"
+ )
+ return null
+ }
+ isClickableAsLiveTile = false
+ val targets =
+ if (remoteTargetHandles.size == 1) {
+ remoteTargetHandles[0].transformParams.targetSet
+ } else {
+ val apps =
+ remoteTargetHandles.flatMap { it.transformParams.targetSet.apps.asIterable() }
+ val wallpapers =
+ remoteTargetHandles.flatMap {
+ it.transformParams.targetSet.wallpapers.asIterable()
+ }
+ RemoteAnimationTargets(
+ apps.toTypedArray(),
+ wallpapers.toTypedArray(),
+ remoteTargetHandles[0].transformParams.targetSet.nonApps,
+ remoteTargetHandles[0].transformParams.targetSet.targetMode
+ )
+ }
+ if (targets == null) {
+ // If the recents animation is cancelled somehow between the parent if block and
+ // here, try to launch the task as a non live tile task.
+ val runnableList = launchAsStaticTile()
+ if (runnableList == null) {
+ Log.e(
+ TAG,
+ "launchAsLiveTile - Recents animation cancelled and cannot launch task as non-live tile; returning to home: ${taskIds.contentToString()}"
+ )
+ }
+ isClickableAsLiveTile = true
+ return runnableList
+ }
+ TestLogging.recordEvent(
+ TestProtocol.SEQUENCE_MAIN,
+ "composeRecentsLaunchAnimator",
+ taskIds.contentToString()
+ )
+ val runnableList = RunnableList()
+ with(AnimatorSet()) {
+ TaskViewUtils.composeRecentsLaunchAnimator(
+ this,
+ this@TaskView,
+ targets.apps,
+ targets.wallpapers,
+ targets.nonApps,
+ true /* launcherClosing */,
+ recentsView.stateManager,
+ recentsView,
+ recentsView.depthController
+ )
+ addListener(
+ object : AnimatorListenerAdapter() {
+ override fun onAnimationEnd(animator: Animator) {
+ if (taskContainers.any { it.task.key.displayId != rootViewDisplayId }) {
+ launchAsStaticTile()
+ }
+ isClickableAsLiveTile = true
+ runEndCallback()
+ }
+
+ override fun onAnimationCancel(animation: Animator) {
+ runEndCallback()
+ }
+
+ private fun runEndCallback() {
+ runnableList.executeAllAndDestroy()
+ }
+ }
+ )
+ start()
+ }
+ Log.d(TAG, "launchAsLiveTile - composeRecentsLaunchAnimator: ${taskIds.contentToString()}")
+ recentsView.onTaskLaunchedInLiveTileMode()
+ return runnableList
+ }
+
/**
* Starts the task associated with this view and animates the startup.
*
* @return CompletionStage to indicate the animation completion or null if the launch failed.
*/
- open fun launchTaskAnimated(): RunnableList? {
+ open fun launchAsStaticTile(): RunnableList? {
TestLogging.recordEvent(
TestProtocol.SEQUENCE_MAIN,
"startActivityFromRecentsAsync",
@@ -1036,7 +1130,7 @@
) {
Log.d(
TAG,
- "launchTaskAnimated - startActivityFromRecents: ${taskIds.contentToString()}"
+ "launchAsStaticTile - startActivityFromRecents: ${taskIds.contentToString()}"
)
ActiveGestureLog.INSTANCE.trackEvent(
ActiveGestureErrorDetector.GestureEvent.EXPECTING_TASK_APPEARED
@@ -1060,18 +1154,17 @@
recentsView.addSideTaskLaunchCallback(opts.onEndCallback)
return opts.onEndCallback
} else {
- notifyTaskLaunchFailed()
+ notifyTaskLaunchFailed("launchAsStaticTile")
return null
}
}
/** Starts the task associated with this view without any animation */
- fun launchTask(callback: (launched: Boolean) -> Unit) {
- launchTask(callback, isQuickSwitch = false)
- }
-
- /** Starts the task associated with this view without any animation */
- open fun launchTask(callback: (launched: Boolean) -> Unit, isQuickSwitch: Boolean) {
+ @JvmOverloads
+ open fun launchWithoutAnimation(
+ isQuickSwitch: Boolean = false,
+ callback: (launched: Boolean) -> Unit
+ ) {
TestLogging.recordEvent(
TestProtocol.SEQUENCE_MAIN,
"startActivityFromRecentsAsync",
@@ -1084,7 +1177,7 @@
// gesture launcher is in the background state, vs other launches which are in
// the actual overview state
failureListener.register(container, firstContainer.task.key.id) {
- notifyTaskLaunchFailed()
+ notifyTaskLaunchFailed("launchWithoutAnimation")
recentsView?.let {
// Disable animations for now, as it is an edge case and the app usually
// covers launcher and also any state transition animation also gets
@@ -1128,103 +1221,20 @@
// otherwise, wait for the animation start callback from the activity options
// above
Executors.MAIN_EXECUTOR.post {
- notifyTaskLaunchFailed()
+ notifyTaskLaunchFailed("launchTask")
callback(false)
}
}
- Log.d(TAG, "launchTask - startActivityFromRecents: ${taskIds.contentToString()}")
+ Log.d(
+ TAG,
+ "launchWithoutAnimation - startActivityFromRecents: ${taskIds.contentToString()}"
+ )
}
}
- /** Launch of the current task (both live and inactive tasks) with an animation. */
- fun launchTasks(): RunnableList? {
- val recentsView = recentsView ?: return null
- val remoteTargetHandles = recentsView.mRemoteTargetHandles
- if (!isRunningTask || remoteTargetHandles == null) {
- return launchTaskAnimated()
- }
- if (!isClickableAsLiveTile) {
- Log.e(TAG, "TaskView is not clickable as a live tile; returning to home.")
- return null
- }
- isClickableAsLiveTile = false
- val targets =
- if (remoteTargetHandles.size == 1) {
- remoteTargetHandles[0].transformParams.targetSet
- } else {
- val apps =
- remoteTargetHandles.flatMap { it.transformParams.targetSet.apps.asIterable() }
- val wallpapers =
- remoteTargetHandles.flatMap {
- it.transformParams.targetSet.wallpapers.asIterable()
- }
- RemoteAnimationTargets(
- apps.toTypedArray(),
- wallpapers.toTypedArray(),
- remoteTargetHandles[0].transformParams.targetSet.nonApps,
- remoteTargetHandles[0].transformParams.targetSet.targetMode
- )
- }
- if (targets == null) {
- // If the recents animation is cancelled somehow between the parent if block and
- // here, try to launch the task as a non live tile task.
- val runnableList = launchTaskAnimated()
- if (runnableList == null) {
- Log.e(
- TAG,
- "Recents animation cancelled and cannot launch task as non-live tile" +
- "; returning to home"
- )
- }
- isClickableAsLiveTile = true
- return runnableList
- }
- TestLogging.recordEvent(
- TestProtocol.SEQUENCE_MAIN,
- "composeRecentsLaunchAnimator",
- taskIds.contentToString()
- )
- val runnableList = RunnableList()
- with(AnimatorSet()) {
- TaskViewUtils.composeRecentsLaunchAnimator(
- this,
- this@TaskView,
- targets.apps,
- targets.wallpapers,
- targets.nonApps,
- true /* launcherClosing */,
- recentsView.stateManager,
- recentsView,
- recentsView.depthController
- )
- addListener(
- object : AnimatorListenerAdapter() {
- override fun onAnimationEnd(animator: Animator) {
- if (taskContainers.any { it.task.key.displayId != rootViewDisplayId }) {
- launchTaskAnimated()
- }
- isClickableAsLiveTile = true
- runEndCallback()
- }
-
- override fun onAnimationCancel(animation: Animator) {
- runEndCallback()
- }
-
- private fun runEndCallback() {
- runnableList.executeAllAndDestroy()
- }
- }
- )
- start()
- }
- Log.d(TAG, "launchTasks - composeRecentsLaunchAnimator: ${taskIds.contentToString()}")
- recentsView.onTaskLaunchedInLiveTileMode()
- return runnableList
- }
-
- private fun notifyTaskLaunchFailed() {
- val sb = StringBuilder("Failed to launch task \n")
+ private fun notifyTaskLaunchFailed(launchMethod: String) {
+ val sb =
+ StringBuilder("$launchMethod - Failed to launch task: ${taskIds.contentToString()}\n")
taskContainers.forEach {
sb.append("(task=${it.task.key.baseIntent} userId=${it.task.key.userId})\n")
}
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/OverviewCommandHelperTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/OverviewCommandHelperTest.kt
new file mode 100644
index 0000000..0ae710f
--- /dev/null
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/OverviewCommandHelperTest.kt
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2024 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.quickstep
+
+import android.platform.test.flag.junit.SetFlagsRule
+import androidx.test.filters.SmallTest
+import com.android.launcher3.Flags
+import com.android.launcher3.util.LauncherMultivalentJUnit
+import com.android.launcher3.util.TestDispatcherProvider
+import com.android.launcher3.util.rule.setFlags
+import com.android.quickstep.OverviewCommandHelper.CommandInfo
+import com.android.quickstep.OverviewCommandHelper.CommandInfo.CommandStatus
+import com.android.quickstep.OverviewCommandHelper.CommandType
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.test.StandardTestDispatcher
+import kotlinx.coroutines.test.TestScope
+import kotlinx.coroutines.test.advanceTimeBy
+import kotlinx.coroutines.test.runCurrent
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mockito.doAnswer
+import org.mockito.Mockito.spy
+import org.mockito.Mockito.`when`
+import org.mockito.kotlin.any
+import org.mockito.kotlin.mock
+
+@SmallTest
+@RunWith(LauncherMultivalentJUnit::class)
+@OptIn(ExperimentalCoroutinesApi::class)
+class OverviewCommandHelperTest {
+ @get:Rule val setFlagsRule: SetFlagsRule = SetFlagsRule()
+
+ private lateinit var sut: OverviewCommandHelper
+ private val dispatcher = StandardTestDispatcher()
+ private val testScope = TestScope(dispatcher)
+
+ private var pendingCallbacksWithDelays = mutableListOf<Long>()
+
+ @Suppress("UNCHECKED_CAST")
+ @Before
+ fun setup() {
+ setFlagsRule.setFlags(true, Flags.FLAG_ENABLE_OVERVIEW_COMMAND_HELPER_TIMEOUT)
+
+ sut =
+ spy(
+ OverviewCommandHelper(
+ touchInteractionService = mock(),
+ overviewComponentObserver = mock(),
+ taskAnimationManager = mock(),
+ dispatcherProvider = TestDispatcherProvider(dispatcher)
+ )
+ )
+
+ doAnswer { invocation ->
+ val pendingCallback = invocation.arguments[1] as () -> Unit
+
+ val delayInMillis = pendingCallbacksWithDelays.removeFirstOrNull()
+ if (delayInMillis != null) {
+ runBlocking {
+ testScope.backgroundScope.launch {
+ delay(delayInMillis)
+ pendingCallback.invoke()
+ }
+ }
+ }
+ delayInMillis == null // if no callback to execute, returns success
+ }
+ .`when`(sut)
+ .executeCommand(any<CommandInfo>(), any())
+ }
+
+ private fun addCallbackDelay(delayInMillis: Long = 0) {
+ pendingCallbacksWithDelays.add(delayInMillis)
+ }
+
+ @Test
+ fun whenFirstCommandIsAdded_executeCommandImmediately() =
+ testScope.runTest {
+ // Add command to queue
+ val commandInfo: CommandInfo = sut.addCommand(CommandType.HOME)!!
+ assertThat(commandInfo.status).isEqualTo(CommandStatus.IDLE)
+ runCurrent()
+ assertThat(commandInfo.status).isEqualTo(CommandStatus.COMPLETED)
+ }
+
+ @Test
+ fun whenFirstCommandIsAdded_executeCommandImmediately_WithCallbackDelay() =
+ testScope.runTest {
+ addCallbackDelay(100)
+
+ // Add command to queue
+ val commandType = CommandType.HOME
+ val commandInfo: CommandInfo = sut.addCommand(commandType)!!
+ assertThat(commandInfo.status).isEqualTo(CommandStatus.IDLE)
+
+ runCurrent()
+ assertThat(commandInfo.status).isEqualTo(CommandStatus.PROCESSING)
+
+ advanceTimeBy(200L)
+ assertThat(commandInfo.status).isEqualTo(CommandStatus.COMPLETED)
+ }
+
+ @Test
+ fun whenFirstCommandIsPendingCallback_NextCommandWillWait() =
+ testScope.runTest {
+ // Add command to queue
+ addCallbackDelay(100)
+ val commandType1 = CommandType.HOME
+ val commandInfo1: CommandInfo = sut.addCommand(commandType1)!!
+ assertThat(commandInfo1.status).isEqualTo(CommandStatus.IDLE)
+
+ addCallbackDelay(100)
+ val commandType2 = CommandType.SHOW
+ val commandInfo2: CommandInfo = sut.addCommand(commandType2)!!
+ assertThat(commandInfo2.status).isEqualTo(CommandStatus.IDLE)
+
+ runCurrent()
+ assertThat(commandInfo1.status).isEqualTo(CommandStatus.PROCESSING)
+ assertThat(commandInfo2.status).isEqualTo(CommandStatus.IDLE)
+
+ advanceTimeBy(101L)
+ assertThat(commandInfo1.status).isEqualTo(CommandStatus.COMPLETED)
+ assertThat(commandInfo2.status).isEqualTo(CommandStatus.PROCESSING)
+
+ advanceTimeBy(101L)
+ assertThat(commandInfo2.status).isEqualTo(CommandStatus.COMPLETED)
+ }
+
+ @Test
+ fun whenCommandTakesTooLong_TriggerTimeout_AndExecuteNextCommand() =
+ testScope.runTest {
+ // Add command to queue
+ addCallbackDelay(QUEUE_TIMEOUT)
+ val commandType1 = CommandType.HOME
+ val commandInfo1: CommandInfo = sut.addCommand(commandType1)!!
+ assertThat(commandInfo1.status).isEqualTo(CommandStatus.IDLE)
+
+ addCallbackDelay(100)
+ val commandType2 = CommandType.SHOW
+ val commandInfo2: CommandInfo = sut.addCommand(commandType2)!!
+ assertThat(commandInfo2.status).isEqualTo(CommandStatus.IDLE)
+
+ runCurrent()
+ assertThat(commandInfo1.status).isEqualTo(CommandStatus.PROCESSING)
+ assertThat(commandInfo2.status).isEqualTo(CommandStatus.IDLE)
+
+ advanceTimeBy(QUEUE_TIMEOUT)
+ assertThat(commandInfo1.status).isEqualTo(CommandStatus.CANCELED)
+ assertThat(commandInfo2.status).isEqualTo(CommandStatus.PROCESSING)
+
+ advanceTimeBy(101)
+ assertThat(commandInfo2.status).isEqualTo(CommandStatus.COMPLETED)
+ }
+
+ private companion object {
+ const val QUEUE_TIMEOUT = 5001L
+ }
+}
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java
index 80b9489..c18f604 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java
@@ -25,6 +25,7 @@
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
+import static com.android.quickstep.DeviceConfigWrapper.DEFAULT_LPNH_TIMEOUT_MS;
import static com.google.common.truth.Truth.assertThat;
@@ -39,7 +40,6 @@
import android.os.SystemClock;
import android.view.MotionEvent;
-import android.view.ViewConfiguration;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
@@ -142,7 +142,7 @@
@Test
public void testLongPressTriggered() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
@@ -156,7 +156,7 @@
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
mUnderTest.onMotionEvent(generateCenteredMotionEventWithYOffset(ACTION_MOVE,
-(TOUCH_SLOP - 1)));
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
@@ -170,7 +170,7 @@
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
mUnderTest.onMotionEvent(generateMotionEvent(ACTION_MOVE,
mScreenWidth / 2f - (TOUCH_SLOP - 1), 0));
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
@@ -189,7 +189,7 @@
mUnderTest.onMotionEvent(generateMotionEvent(ACTION_MOVE,
mScreenWidth / 2f - (TOUCH_SLOP - 1), 0));
// We have entered the second stage, so the normal timeout shouldn't trigger.
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
@@ -200,7 +200,7 @@
// After an extended time, the long press should trigger.
float extendedDurationMultiplier =
(DeviceConfigWrapper.get().getTwoStageDurationPercentage() / 100f);
- SystemClock.sleep((long) (ViewConfiguration.getLongPressTimeout()
+ SystemClock.sleep((long) (DEFAULT_LPNH_TIMEOUT_MS
* (extendedDurationMultiplier - 1))); // -1 because we already waited 1x
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
@@ -221,7 +221,7 @@
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
// We have not entered the second stage, so the normal timeout should trigger.
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
@@ -236,7 +236,7 @@
@Test
public void testLongPressAbortedByTouchUp() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout() - 10);
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS - 10);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
@@ -256,7 +256,7 @@
@Test
public void testLongPressAbortedByTouchCancel() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout() - 10);
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS - 10);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
@@ -276,7 +276,7 @@
@Test
public void testLongPressAbortedByTouchSlopPassedVertically() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout() - 10);
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS - 10);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
@@ -297,7 +297,7 @@
@Test
public void testLongPressAbortedByTouchSlopPassedHorizontally() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout() - 10);
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS - 10);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
@@ -326,7 +326,7 @@
mUnderTest.onMotionEvent(generateCenteredMotionEventWithYOffset(ACTION_MOVE,
-(TOUCH_SLOP - 1)));
// Normal duration shouldn't trigger.
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
@@ -338,7 +338,7 @@
// Wait past the extended long press timeout, to be sure it wouldn't have triggered.
float extendedDurationMultiplier =
(DeviceConfigWrapper.get().getTwoStageDurationPercentage() / 100f);
- SystemClock.sleep((long) (ViewConfiguration.getLongPressTimeout()
+ SystemClock.sleep((long) (DEFAULT_LPNH_TIMEOUT_MS
* (extendedDurationMultiplier - 1))); // -1 because we already waited 1x
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
@@ -363,7 +363,7 @@
mUnderTest.onMotionEvent(generateMotionEvent(ACTION_MOVE,
mScreenWidth / 2f - (TOUCH_SLOP - 1), 0));
// Normal duration shouldn't trigger.
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
@@ -375,7 +375,7 @@
// Wait past the extended long press timeout, to be sure it wouldn't have triggered.
float extendedDurationMultiplier =
(DeviceConfigWrapper.get().getTwoStageDurationPercentage() / 100f);
- SystemClock.sleep((long) (ViewConfiguration.getLongPressTimeout()
+ SystemClock.sleep((long) (DEFAULT_LPNH_TIMEOUT_MS
* (extendedDurationMultiplier - 1))); // -1 because we already waited 1x
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
@@ -393,7 +393,7 @@
public void testTouchOutsideNavHandleIgnored() {
// Touch the far left side of the screen. (y=0 is top of navbar region, picked arbitrarily)
mUnderTest.onMotionEvent(generateMotionEvent(ACTION_DOWN, 0, 0));
- SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+ SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
// Should be ignored because the x position was not centered in the navbar region.
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt
index d2479bc..7c48ea4 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt
@@ -34,9 +34,6 @@
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NOTIFICATION_DOT_ENABLED
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_THEMED_ICON_DISABLED
import com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY
-import com.google.android.apps.nexuslauncher.PrefKey.KEY_ENABLE_MINUS_ONE
-import com.google.android.apps.nexuslauncher.PrefKey.OVERVIEW_SUGGESTED_ACTIONS
-import com.google.android.apps.nexuslauncher.PrefKey.SMARTSPACE_ON_HOME_SCREEN
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Before
@@ -141,7 +138,14 @@
.isTrue()
assertThat(capturedEvents.any { it.id == LAUNCHER_HOME_SCREEN_SUGGESTIONS_ENABLED.id })
.isTrue()
- // LAUNCHER_GOOGLE_APP_SWIPE_LEFT_ENABLED
- assertThat(capturedEvents.any { it.id == 617 }).isTrue()
+ assertThat(capturedEvents.any { it.id == LAUNCHER_GOOGLE_APP_SWIPE_LEFT_ENABLED }).isTrue()
+ }
+
+ companion object {
+ private const val KEY_ENABLE_MINUS_ONE = "pref_enable_minus_one"
+ private const val OVERVIEW_SUGGESTED_ACTIONS = "pref_overview_action_suggestions"
+ private const val SMARTSPACE_ON_HOME_SCREEN = "pref_smartspace_home_screen"
+
+ private const val LAUNCHER_GOOGLE_APP_SWIPE_LEFT_ENABLED = 617
}
}
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsPersistentTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsPersistentTaskbar.java
index c419cd2..a16811e 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsPersistentTaskbar.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsPersistentTaskbar.java
@@ -23,7 +23,6 @@
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
import org.junit.Assert;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -31,8 +30,6 @@
@RunWith(AndroidJUnit4.class)
public class TaplTestsPersistentTaskbar extends AbstractTaplTestsTaskbar {
- //TODO(b/359277238): fix falling tests
- @Ignore
@Test
@NavigationModeSwitch
public void testTaskbarFillsWidth() {
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
index 943c1bd..3e6436b 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
@@ -516,8 +516,6 @@
isInState(() -> LauncherState.NORMAL));
}
- //TODO(b/359277238): fix falling tests
- @Ignore
@Test
@PortraitLandscape
@TaskbarModeSwitch
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 8ae6d73..cc5baea 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -25,7 +25,6 @@
import static com.android.launcher3.InvariantDeviceProfile.INDEX_TWO_PANEL_PORTRAIT;
import static com.android.launcher3.Utilities.dpiFromPx;
import static com.android.launcher3.Utilities.pxFromSp;
-import static com.android.launcher3.config.FeatureFlags.ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH;
import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.ICON_OVERLAP_FACTOR;
import static com.android.launcher3.icons.GraphicsUtils.getShapePath;
import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR;
@@ -503,7 +502,7 @@
bottomSheetCloseDuration = res.getInteger(R.integer.config_bottomSheetCloseDuration);
if (isTablet) {
bottomSheetWorkspaceScale = workspaceContentScale;
- if (isMultiDisplay && !ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH.get()) {
+ if (isMultiDisplay) {
// TODO(b/259893832): Revert to use maxWallpaperScale to calculate bottomSheetDepth
// when screen recorder bug is fixed.
if (enableScalingRevealHomeAnimation()) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index bafb528..365e3d4 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -241,6 +241,7 @@
import com.android.launcher3.util.ScreenOnTracker;
import com.android.launcher3.util.ScreenOnTracker.ScreenOnListener;
import com.android.launcher3.util.SettingsCache;
+import com.android.launcher3.util.StableViewInfo;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.Thunk;
@@ -2424,17 +2425,16 @@
* Similar to {@link #getFirstMatch} but optimized to finding a suitable view for the app close
* animation.
*
- * @param preferredItemId The id of the preferred item to match to if it exists,
- * or ItemInfo#NO_MATCHING_ID if you want to not match by item id
+ * @param svi The StableViewInfo of the preferred item to match to if it exists or null
* @param packageName The package name of the app to match.
* @param user The user of the app to match.
* @param supportsAllAppsState If true and we are in All Apps state, looks for view in All Apps.
* Else we only looks on the workspace.
*/
- public @Nullable View getFirstMatchForAppClose(int preferredItemId, String packageName,
+ public @Nullable View getFirstMatchForAppClose(
+ @Nullable StableViewInfo svi, String packageName,
UserHandle user, boolean supportsAllAppsState) {
- final Predicate<ItemInfo> preferredItem = info ->
- info != null && info.id == preferredItemId;
+ final Predicate<ItemInfo> preferredItem = svi == null ? i -> false : svi::matches;
final Predicate<ItemInfo> packageAndUserAndApp = info ->
info != null
&& info.itemType == ITEM_TYPE_APPLICATION
@@ -2525,6 +2525,9 @@
final int itemCount = container.getChildCount();
for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
View item = container.getChildAt(itemIdx);
+ if (item.getVisibility() != View.VISIBLE) {
+ continue;
+ }
if (item instanceof ViewGroup viewGroup) {
View view = mapOverViewGroup(viewGroup, op);
if (view != null) {
@@ -3036,6 +3039,7 @@
return mPopupDataProvider.getDotInfoForItem(info);
}
+ @NonNull
public LauncherOverlayManager getOverlayManager() {
return mOverlayManager;
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 365fbd3..0ec3b79 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -1463,6 +1463,15 @@
mEdgeGlowLeft.onFlingVelocity(velocity);
mEdgeGlowRight.onFlingVelocity(velocity);
}
+
+ // Detect if user tries to swipe to -1 page but gets disallowed by checking if there was
+ // left-over values in mEdgeGlowLeft (or mEdgeGlowRight in RLT).
+ final int layoutDir = getLayoutDirection();
+ if ((mEdgeGlowLeft.getDistance() > 0 && layoutDir == LAYOUT_DIRECTION_LTR)
+ || (mEdgeGlowRight.getDistance() > 0 && layoutDir == LAYOUT_DIRECTION_RTL)) {
+ onDisallowSwipeToMinusOnePage();
+ }
+
mEdgeGlowLeft.onRelease(ev);
mEdgeGlowRight.onRelease(ev);
// End any intermediate reordering states
@@ -1487,6 +1496,8 @@
return true;
}
+ protected void onDisallowSwipeToMinusOnePage() {}
+
protected void onNotSnappingToPageInFreeScroll() { }
/**
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 255260e..0e9c861 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1123,6 +1123,11 @@
return super.onTouchEvent(ev);
}
+ @Override
+ protected void onDisallowSwipeToMinusOnePage() {
+ mLauncher.getOverlayManager().onDisallowSwipeToMinusOnePage();
+ }
+
/**
* Called directly from a CellLayout (not by the framework), after we've been added as a
* listener via setOnInterceptTouchEventListener(). This allows us to tell the CellLayout
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 1b0ad04..742648e 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -37,7 +37,6 @@
import android.animation.Animator;
import android.animation.ObjectAnimator;
-import android.animation.ValueAnimator;
import android.util.FloatProperty;
import android.view.HapticFeedbackConstants;
import android.view.View;
@@ -52,7 +51,6 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PropertySetter;
@@ -359,22 +357,6 @@
});
}
- if (FeatureFlags.ENABLE_PREMIUM_HAPTICS_ALL_APPS.get() && config.isUserControlled()
- && Utilities.ATLEAST_S) {
- if (toState == ALL_APPS) {
- builder.addOnFrameListener(
- new VibrationAnimatorUpdateListener(this, mVibratorWrapper,
- SWIPE_DRAG_COMMIT_THRESHOLD, 1));
- } else {
- builder.addOnFrameListener(
- new VibrationAnimatorUpdateListener(this, mVibratorWrapper,
- 0, SWIPE_DRAG_COMMIT_THRESHOLD));
- }
- builder.addEndListener((unused) -> {
- mVibratorWrapper.cancelVibrate();
- });
- }
-
float targetProgress = toState.getVerticalProgress(mLauncher);
if (Float.compare(mProgress, targetProgress) == 0) {
setAlphas(toState, config, builder);
@@ -391,8 +373,7 @@
setAlphas(toState, config, builder);
// This controls both haptics for tapping on QSB and going to all apps.
- if (ALL_APPS.equals(toState) && mLauncher.isInState(NORMAL) &&
- !FeatureFlags.ENABLE_PREMIUM_HAPTICS_ALL_APPS.get()) {
+ if (ALL_APPS.equals(toState) && mLauncher.isInState(NORMAL)) {
mLauncher.getAppsView().performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
}
@@ -445,45 +426,4 @@
public void setShiftRange(float shiftRange) {
mShiftRange = shiftRange;
}
-
- /**
- * This VibrationAnimatorUpdateListener class takes in four parameters, a controller, start
- * threshold, end threshold, and a Vibrator wrapper. We use the progress given by the controller
- * as it gives an accurate progress that dictates where the vibrator should vibrate.
- * Note: once the user begins a gesture and does the commit haptic, there should not be anymore
- * haptics played for that gesture.
- */
- private static class VibrationAnimatorUpdateListener implements
- ValueAnimator.AnimatorUpdateListener {
- private final VibratorWrapper mVibratorWrapper;
- private final AllAppsTransitionController mController;
- private final float mStartThreshold;
- private final float mEndThreshold;
- private boolean mHasCommitted;
-
- VibrationAnimatorUpdateListener(AllAppsTransitionController controller,
- VibratorWrapper vibratorWrapper, float startThreshold,
- float endThreshold) {
- mController = controller;
- mVibratorWrapper = vibratorWrapper;
- mStartThreshold = startThreshold;
- mEndThreshold = endThreshold;
- }
-
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- if (mHasCommitted) {
- return;
- }
- float currentProgress =
- AllAppsTransitionController.ALL_APPS_PROGRESS.get(mController);
- if (currentProgress > mStartThreshold && currentProgress < mEndThreshold) {
- mVibratorWrapper.vibrateForDragTexture();
- } else if (!(currentProgress == 0 || currentProgress == 1)) {
- // This check guards against committing at the location of the start of the gesture
- mVibratorWrapper.vibrateForDragCommit();
- mHasCommitted = true;
- }
- }
- }
}
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index d0596fa..aa8c5a5 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -62,11 +62,6 @@
* and set a default value for the flag. This will be the default value on Debug builds.
* <p>
*/
- // TODO(Block 2): Clean up flags
- public static final BooleanFlag ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH = getDebugFlag(270395073,
- "ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH", DISABLED,
- "Allow bottom sheet depth to be smaller than 1 for multi-display devices.");
-
// TODO(Block 3): Clean up flags
public static final BooleanFlag ENABLE_DISMISS_PREDICTION_UNDO = getDebugFlag(270394476,
"ENABLE_DISMISS_PREDICTION_UNDO", DISABLED,
@@ -85,26 +80,10 @@
+ "data preparation for loading the home screen");
// TODO(Block 4): Cleanup flags
- public static final BooleanFlag ENABLE_ALL_APPS_FROM_OVERVIEW =
- getDebugFlag(275132633, "ENABLE_ALL_APPS_FROM_OVERVIEW", DISABLED,
- "Allow entering All Apps from Overview (e.g. long swipe up from app)");
-
public static final BooleanFlag ENABLE_SHOW_KEYBOARD_OPTION_IN_ALL_APPS = getReleaseFlag(
270394468, "ENABLE_SHOW_KEYBOARD_OPTION_IN_ALL_APPS", ENABLED,
"Enable option to show keyboard when going to all-apps");
- // TODO(Block 5): Clean up flags
- public static final BooleanFlag ENABLE_TWOLINE_DEVICESEARCH = getDebugFlag(201388851,
- "ENABLE_TWOLINE_DEVICESEARCH", DISABLED,
- "Enable two line label for icons with labels on device search.");
-
- public static final BooleanFlag ENABLE_ICON_IN_TEXT_HEADER = getDebugFlag(270395143,
- "ENABLE_ICON_IN_TEXT_HEADER", DISABLED, "Show icon in textheader");
-
- public static final BooleanFlag ENABLE_PREMIUM_HAPTICS_ALL_APPS = getDebugFlag(270396358,
- "ENABLE_PREMIUM_HAPTICS_ALL_APPS", DISABLED,
- "Enables haptics opening/closing All apps");
-
// TODO(Block 6): Clean up flags
public static final BooleanFlag ENABLE_ALL_APPS_SEARCH_IN_TASKBAR = getDebugFlag(270393900,
"ENABLE_ALL_APPS_SEARCH_IN_TASKBAR", ENABLED,
diff --git a/src/com/android/launcher3/model/data/ItemInfo.java b/src/com/android/launcher3/model/data/ItemInfo.java
index 62198cb..b706d24 100644
--- a/src/com/android/launcher3/model/data/ItemInfo.java
+++ b/src/com/android/launcher3/model/data/ItemInfo.java
@@ -81,8 +81,6 @@
public static final boolean DEBUG = false;
public static final int NO_ID = -1;
- // An id that doesn't match any item, including predicted apps with have an id=NO_ID
- public static final int NO_MATCHING_ID = Integer.MIN_VALUE;
/** Hidden field Settings.Secure.NAV_BAR_KIDS_MODE */
private static final Uri NAV_BAR_KIDS_MODE = Settings.Secure.getUriFor("nav_bar_kids_mode");
@@ -545,6 +543,14 @@
this.title = title;
}
+ /**
+ * Returns a string ID that is stable for a user session, but may not be persisted
+ */
+ @Nullable
+ public Object getStableId() {
+ return getComponentKey();
+ }
+
private int getUserType(UserIconInfo info) {
if (info == null) {
return SysUiStatsLog.LAUNCHER_UICHANGED__USER_TYPE__TYPE_UNKNOWN;
diff --git a/src/com/android/launcher3/touch/AllAppsSwipeController.java b/src/com/android/launcher3/touch/AllAppsSwipeController.java
index fe4a83b..9dcdf22 100644
--- a/src/com/android/launcher3/touch/AllAppsSwipeController.java
+++ b/src/com/android/launcher3/touch/AllAppsSwipeController.java
@@ -22,13 +22,9 @@
import static com.android.app.animation.Interpolators.FINAL_FRAME;
import static com.android.app.animation.Interpolators.INSTANT;
import static com.android.app.animation.Interpolators.LINEAR;
-import static com.android.app.animation.Interpolators.clampToProgress;
-import static com.android.app.animation.Interpolators.mapToProgress;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
-import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_BOTTOM_SHEET_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
-import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_KEYBOARD_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_DEPTH;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_SCALE;
@@ -37,15 +33,12 @@
import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE;
-import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE;
-import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW;
import android.view.MotionEvent;
import android.view.animation.Interpolator;
import com.android.app.animation.Interpolators;
import com.android.launcher3.AbstractFloatingView;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.states.StateAnimationConfig;
@@ -281,36 +274,6 @@
}
}
- /**
- * Applies Animation config values for transition from overview to all apps.
- *
- * @param threshold progress at which all apps will open upon release
- */
- public static void applyOverviewToAllAppsAnimConfig(
- DeviceProfile deviceProfile, StateAnimationConfig config, float threshold) {
- config.animProps |= StateAnimationConfig.USER_CONTROLLED;
- config.animFlags = SKIP_OVERVIEW;
- if (deviceProfile.isTablet) {
- config.setInterpolator(ANIM_ALL_APPS_FADE, INSTANT);
- config.setInterpolator(ANIM_SCRIM_FADE, ALL_APPS_SCRIM_RESPONDER);
- // The fact that we end on Workspace is not very ideal, but since we do, fade it in at
- // the end of the transition. Don't scale/translate it.
- config.setInterpolator(ANIM_WORKSPACE_FADE, clampToProgress(LINEAR, 0.8f, 1));
- config.setInterpolator(ANIM_WORKSPACE_SCALE, INSTANT);
- config.setInterpolator(ANIM_WORKSPACE_TRANSLATE, INSTANT);
- } else {
- // Pop the background panel, keyboard, and content in at full opacity at the threshold.
- config.setInterpolator(ANIM_ALL_APPS_BOTTOM_SHEET_FADE,
- thresholdInterpolator(threshold, INSTANT));
- config.setInterpolator(ANIM_ALL_APPS_KEYBOARD_FADE,
- thresholdInterpolator(threshold, INSTANT));
- config.setInterpolator(ANIM_ALL_APPS_FADE, thresholdInterpolator(threshold, INSTANT));
-
- config.setInterpolator(ANIM_VERTICAL_PROGRESS,
- thresholdInterpolator(threshold, mapToProgress(LINEAR, threshold, 1f)));
- }
- }
-
/** Creates an interpolator that is 0 until the threshold, then follows given interpolator. */
private static Interpolator thresholdInterpolator(float threshold, Interpolator interpolator) {
return progress -> progress <= threshold ? 0 : interpolator.getInterpolation(progress);
diff --git a/src/com/android/launcher3/util/StableViewInfo.kt b/src/com/android/launcher3/util/StableViewInfo.kt
new file mode 100644
index 0000000..29dcd59
--- /dev/null
+++ b/src/com/android/launcher3/util/StableViewInfo.kt
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2024 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.util
+
+import android.os.IBinder
+import com.android.launcher3.model.data.ItemInfo
+import com.android.launcher3.model.data.ItemInfo.NO_ID
+
+/** Info parameters that can be used to identify a Launcher object */
+data class StableViewInfo(val itemId: Int, val containerId: Int, val stableId: Any) {
+
+ fun matches(info: ItemInfo?) =
+ info != null &&
+ itemId == info.id &&
+ containerId == info.container &&
+ stableId == info.stableId
+
+ companion object {
+
+ private fun ItemInfo.toStableViewInfo() =
+ stableId?.let { sId ->
+ if (id != NO_ID || container != NO_ID) StableViewInfo(id, container, sId) else null
+ }
+
+ /**
+ * Return a new launch cookie for the activity launch if supported.
+ *
+ * @param info the item info for the launch
+ */
+ @JvmStatic
+ fun toLaunchCookie(info: ItemInfo?) =
+ info?.toStableViewInfo()?.let { ObjectWrapper.wrap(it) }
+
+ /**
+ * Unwraps the binder and returns the first non-null StableViewInfo in the list or null if
+ * none can be found
+ */
+ @JvmStatic
+ fun fromLaunchCookies(launchCookies: List<IBinder>) =
+ launchCookies.firstNotNullOfOrNull { ObjectWrapper.unwrap<StableViewInfo>(it) }
+ }
+}
diff --git a/src/com/android/launcher3/util/VibratorWrapper.java b/src/com/android/launcher3/util/VibratorWrapper.java
index 6bae1ba..a4b8eb0 100644
--- a/src/com/android/launcher3/util/VibratorWrapper.java
+++ b/src/com/android/launcher3/util/VibratorWrapper.java
@@ -25,12 +25,10 @@
import android.content.Context;
import android.media.AudioAttributes;
import android.net.Uri;
-import android.os.SystemClock;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.Settings;
-import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.Utilities;
@@ -54,20 +52,6 @@
static final Uri HAPTIC_FEEDBACK_URI = Settings.System.getUriFor(HAPTIC_FEEDBACK_ENABLED);
@VisibleForTesting static final float LOW_TICK_SCALE = 0.9f;
- @VisibleForTesting static final float DRAG_TEXTURE_SCALE = 0.03f;
- @VisibleForTesting static final float DRAG_COMMIT_SCALE = 0.5f;
- @VisibleForTesting static final float DRAG_BUMP_SCALE = 0.4f;
- @VisibleForTesting static final int DRAG_TEXTURE_EFFECT_SIZE = 200;
-
- @Nullable
- private final VibrationEffect mDragEffect;
- @Nullable
- private final VibrationEffect mCommitEffect;
- @Nullable
- private final VibrationEffect mBumpEffect;
-
- private long mLastDragTime;
- private final int mThresholdUntilNextDragCallMillis;
/**
* Haptic when entering overview.
@@ -100,28 +84,6 @@
} else {
mIsHapticFeedbackEnabled = false;
}
-
- if (Utilities.ATLEAST_S && mVibrator.areAllPrimitivesSupported(
- PRIMITIVE_LOW_TICK)) {
-
- // Drag texture, Commit, and Bump should only be used for premium phones.
- // Before using these haptics make sure check if the device can use it
- mDragEffect = getDragEffect();
- mCommitEffect = VibrationEffect.startComposition().addPrimitive(
- VibrationEffect.Composition.PRIMITIVE_TICK, DRAG_COMMIT_SCALE).compose();
- mBumpEffect = VibrationEffect.startComposition().addPrimitive(
- PRIMITIVE_LOW_TICK, DRAG_BUMP_SCALE).compose();
- int primitiveDuration = mVibrator.getPrimitiveDurations(
- PRIMITIVE_LOW_TICK)[0];
-
- mThresholdUntilNextDragCallMillis =
- DRAG_TEXTURE_EFFECT_SIZE * primitiveDuration + 100;
- } else {
- mDragEffect = null;
- mCommitEffect = null;
- mBumpEffect = null;
- mThresholdUntilNextDragCallMillis = 0;
- }
}
@Override
@@ -132,52 +94,11 @@
}
/**
- * This is called when the user swipes to/from all apps. This is meant to be used in between
- * long animation progresses so that it gives a dragging texture effect. For a better
- * experience, this should be used in combination with vibrateForDragCommit().
- */
- public void vibrateForDragTexture() {
- if (mDragEffect == null) {
- return;
- }
- long currentTime = SystemClock.elapsedRealtime();
- long elapsedTimeSinceDrag = currentTime - mLastDragTime;
- if (elapsedTimeSinceDrag >= mThresholdUntilNextDragCallMillis) {
- vibrate(mDragEffect);
- mLastDragTime = currentTime;
- }
- }
-
- /**
- * This is used when user reaches the commit threshold when swiping to/from from all apps.
- */
- public void vibrateForDragCommit() {
- if (mCommitEffect != null) {
- vibrate(mCommitEffect);
- }
- // resetting dragTexture timestamp to be able to play dragTexture again
- mLastDragTime = 0;
- }
-
- /**
- * The bump haptic is used to be called at the end of a swipe and only if it the gesture is a
- * FLING going to/from all apps. Client can just call this method elsewhere just for the
- * effect.
- */
- public void vibrateForDragBump() {
- if (mBumpEffect != null) {
- vibrate(mBumpEffect);
- }
- }
-
- /**
* This should be used to cancel a haptic in case where the haptic shouldn't be vibrating. For
* example, when no animation is happening but a vibrator happens to be vibrating still.
*/
public void cancelVibrate() {
UI_HELPER_EXECUTOR.execute(mVibrator::cancel);
- // reset dragTexture timestamp to be able to play dragTexture again whenever cancelled
- mLastDragTime = 0;
}
/** Vibrates with the given effect if haptic feedback is available and enabled. */
@@ -217,13 +138,4 @@
vibrate(primitiveLowTickEffect);
}
}
-
- static VibrationEffect getDragEffect() {
- VibrationEffect.Composition dragEffect = VibrationEffect.startComposition();
- for (int i = 0; i < DRAG_TEXTURE_EFFECT_SIZE; i++) {
- dragEffect.addPrimitive(
- PRIMITIVE_LOW_TICK, DRAG_TEXTURE_SCALE);
- }
- return dragEffect.compose();
- }
}
diff --git a/src/com/android/launcher3/views/FloatingSurfaceView.java b/src/com/android/launcher3/views/FloatingSurfaceView.java
index 7fa7517..5f8e2c0 100644
--- a/src/com/android/launcher3/views/FloatingSurfaceView.java
+++ b/src/com/android/launcher3/views/FloatingSurfaceView.java
@@ -15,7 +15,6 @@
*/
package com.android.launcher3.views;
-import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.views.FloatingIconView.getLocationBoundsForView;
import static com.android.launcher3.views.FloatingIconViewCompanion.setPropertiesVisible;
@@ -160,7 +159,7 @@
if (mContract == null) {
return;
}
- View icon = mLauncher.getFirstMatchForAppClose(NO_MATCHING_ID,
+ View icon = mLauncher.getFirstMatchForAppClose(null /* StableViewInfo */,
mContract.componentName.getPackageName(), mContract.user,
false /* supportsAllAppsState */);
diff --git a/src_plugins/com/android/systemui/plugins/shared/LauncherOverlayManager.java b/src_plugins/com/android/systemui/plugins/shared/LauncherOverlayManager.java
index a940774..eaa9ef0 100644
--- a/src_plugins/com/android/systemui/plugins/shared/LauncherOverlayManager.java
+++ b/src_plugins/com/android/systemui/plugins/shared/LauncherOverlayManager.java
@@ -49,6 +49,8 @@
default void onActivityDestroyed() { }
+ default void onDisallowSwipeToMinusOnePage() {}
+
/**
* @deprecated use LauncherOverlayTouchProxy directly
*/
diff --git a/tests/multivalentTests/src/com/android/launcher3/util/VibratorWrapperTest.kt b/tests/multivalentTests/src/com/android/launcher3/util/VibratorWrapperTest.kt
index 330c394..d321e41 100644
--- a/tests/multivalentTests/src/com/android/launcher3/util/VibratorWrapperTest.kt
+++ b/tests/multivalentTests/src/com/android/launcher3/util/VibratorWrapperTest.kt
@@ -17,7 +17,6 @@
package com.android.launcher3.util
import android.media.AudioAttributes
-import android.os.SystemClock
import android.os.VibrationEffect
import android.os.VibrationEffect.Composition.PRIMITIVE_LOW_TICK
import android.os.VibrationEffect.Composition.PRIMITIVE_TICK
@@ -35,13 +34,11 @@
import org.mockito.Captor
import org.mockito.Mock
import org.mockito.Mockito.any
-import org.mockito.Mockito.reset
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
import org.mockito.kotlin.never
import org.mockito.kotlin.same
-import org.mockito.kotlin.verifyNoMoreInteractions
@SmallTest
@RunWith(AndroidJUnit4::class)
@@ -118,55 +115,6 @@
}
@Test
- fun vibrate_for_drag_bump() {
- underTest.vibrateForDragBump()
-
- awaitTasksCompleted()
- verify(vibrator).vibrate(vibrationEffectCaptor.capture(), same(VIBRATION_ATTRS))
- val expectedEffect =
- VibrationEffect.startComposition()
- .addPrimitive(PRIMITIVE_LOW_TICK, VibratorWrapper.DRAG_BUMP_SCALE)
- .compose()
- assertThat(vibrationEffectCaptor.value).isEqualTo(expectedEffect)
- }
-
- @Test
- fun vibrate_for_drag_commit() {
- underTest.vibrateForDragCommit()
-
- awaitTasksCompleted()
- verify(vibrator).vibrate(vibrationEffectCaptor.capture(), same(VIBRATION_ATTRS))
- val expectedEffect =
- VibrationEffect.startComposition()
- .addPrimitive(PRIMITIVE_TICK, VibratorWrapper.DRAG_COMMIT_SCALE)
- .compose()
- assertThat(vibrationEffectCaptor.value).isEqualTo(expectedEffect)
- }
-
- @Test
- fun vibrate_for_drag_texture() {
- SystemClock.setCurrentTimeMillis(40000)
-
- underTest.vibrateForDragTexture()
-
- awaitTasksCompleted()
- verify(vibrator).vibrate(vibrationEffectCaptor.capture(), same(VIBRATION_ATTRS))
- assertThat(vibrationEffectCaptor.value).isEqualTo(VibratorWrapper.getDragEffect())
- }
-
- @Test
- fun vibrate_for_drag_texture_within_time_window_noOp() {
- SystemClock.setCurrentTimeMillis(40000)
- underTest.vibrateForDragTexture()
- awaitTasksCompleted()
- reset(vibrator)
-
- underTest.vibrateForDragTexture()
-
- verifyNoMoreInteractions(vibrator)
- }
-
- @Test
fun haptic_feedback_disabled_no_vibrate() {
`when`(vibrator.hasVibrator()).thenReturn(false)
underTest = VibratorWrapper(vibrator, settingsCache)
diff --git a/tests/tapl/com/android/launcher3/tapl/AppIcon.java b/tests/tapl/com/android/launcher3/tapl/AppIcon.java
index 7c6d684..02a862d 100644
--- a/tests/tapl/com/android/launcher3/tapl/AppIcon.java
+++ b/tests/tapl/com/android/launcher3/tapl/AppIcon.java
@@ -18,6 +18,7 @@
import static com.android.launcher3.testing.shared.TestProtocol.TEST_DRAG_APP_ICON_TO_MULTIPLE_WORKSPACES_FAILURE;
+import android.graphics.Point;
import android.util.Log;
import android.widget.TextView;
@@ -129,6 +130,14 @@
}
/**
+ * @return the center coordinates of the icon
+ */
+ @NonNull
+ public Point getVisibleCenter() {
+ return getObject().getVisibleCenter();
+ }
+
+ /**
* Create a regular expression pattern that matches strings containing all of the non-whitespace
* characters of the app name, with any amount of whitespace added between characters (e.g.
* newline for multiline app labels).
diff --git a/tests/tapl/com/android/launcher3/tapl/Taskbar.java b/tests/tapl/com/android/launcher3/tapl/Taskbar.java
index e6315f3..b4aaab7 100644
--- a/tests/tapl/com/android/launcher3/tapl/Taskbar.java
+++ b/tests/tapl/com/android/launcher3/tapl/Taskbar.java
@@ -52,7 +52,7 @@
if (!mLauncher.isTransientTaskbar()) {
Assert.assertEquals("Persistent taskbar should fill screen width",
- getVisibleBounds().width(), mLauncher.getRealDisplaySize().x);
+ mLauncher.getRealDisplaySize().x, getVisibleBounds().width());
}
}