From dbdf49726f324f280f6bbab1833ce9ddeff4154d Mon Sep 17 00:00:00 2001 From: minch Date: Wed, 29 Jan 2025 23:42:53 +0000 Subject: [PATCH] Refactor TaskView to allow no TaskContainers Flag: EXEMPT refactor Bug: 391918297 Test: m Change-Id: I3343da2b6d73a0b0283334a37be5ae288d94f776 --- .../QuickSwitchTouchController.java | 6 +-- .../android/quickstep/AbsSwipeUpHandler.java | 9 ++-- .../quickstep/LauncherSwipeHandlerV2.java | 5 +- .../android/quickstep/TaskOverlayFactory.java | 4 +- .../quickstep/TaskShortcutFactory.java | 49 ++++++++++-------- .../com/android/quickstep/TaskViewUtils.java | 5 +- .../fallback/FallbackRecentsView.java | 5 +- .../quickstep/util/AppPairsController.java | 5 +- .../quickstep/views/GroupedTaskView.kt | 4 +- .../quickstep/views/LauncherRecentsView.java | 11 ++-- .../android/quickstep/views/RecentsView.java | 40 +++++++++------ .../quickstep/views/RecentsViewUtils.kt | 3 ++ .../com/android/quickstep/views/TaskView.kt | 50 ++++++++----------- .../quickstep/DigitalWellBeingToastTest.java | 4 +- 14 files changed, 111 insertions(+), 89 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java index 2b296c803e..f582324f23 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java @@ -149,9 +149,9 @@ public class QuickSwitchTouchController extends AbstractStateChangeTouchControll mOverviewPanel.setFullscreenProgress(progress); if (progress > UPDATE_SYSUI_FLAGS_THRESHOLD) { int sysuiFlags = 0; - TaskView tv = mOverviewPanel.getFirstTaskView(); - if (tv != null) { - sysuiFlags = tv.getSysUiStatusNavFlags(); + TaskView firstTaskView = mOverviewPanel.getFirstTaskView(); + if (firstTaskView != null) { + sysuiFlags = firstTaskView.getSysUiStatusNavFlags(); } mLauncher.getSystemUiController().updateUiState(UI_STATE_FULLSCREEN_TASK, sysuiFlags); } else { diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 78e543cd5d..5f8b89a86c 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -120,6 +120,7 @@ import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.dragndrop.DragView; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.logging.StatsLogManager.StatsLogger; +import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.statemanager.BaseState; import com.android.launcher3.statemanager.StatefulContainer; import com.android.launcher3.taskbar.TaskbarThresholdUtils; @@ -1527,8 +1528,9 @@ public abstract class AbsSwipeUpHandler< .withInputType(mGestureState.isTrackpadGesture() ? SysUiStatsLog.LAUNCHER_UICHANGED__INPUT_TYPE__TRACKPAD : SysUiStatsLog.LAUNCHER_UICHANGED__INPUT_TYPE__TOUCH); - if (targetTask != null) { - logger.withItemInfo(targetTask.getFirstItemInfo()); + ItemInfo itemInfo; + if (targetTask != null && (itemInfo = targetTask.getFirstItemInfo()) != null) { + logger.withItemInfo(itemInfo); } int pageIndex = endTarget == LAST_TASK || mRecentsView == null @@ -2369,9 +2371,6 @@ public abstract class AbsSwipeUpHandler< ActiveGestureLog.CompoundString nextTaskLog = ActiveGestureLog.CompoundString.newEmptyString(); for (TaskContainer container : nextTask.getTaskContainers()) { - if (container == null) { - continue; - } nextTaskLog.append("[id: %d, pkg: %s] | ", container.getTask().key.id, container.getTask().key.getPackageName()); diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java index c60d3e8d23..e1e9c99b3d 100644 --- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java +++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java @@ -56,6 +56,7 @@ import com.android.quickstep.views.FloatingWidgetView; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; import com.android.systemui.animation.TransitionAnimator; +import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.system.InputConsumerController; import java.util.Collections; @@ -300,7 +301,9 @@ public class LauncherSwipeHandlerV2 extends AbsSwipeUpHandler< // Disable if swiping to PIP return null; } - if (sourceTaskView == null || sourceTaskView.getFirstTask().key.getComponent() == null) { + Task firstTask; + if (sourceTaskView == null || ((firstTask = sourceTaskView.getFirstTask()) == null) + || firstTask.key.getComponent() == null) { // Disable if it's an invalid task return null; } diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java index ff9c9f65d0..0772159890 100644 --- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java +++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java @@ -233,7 +233,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride { RecentsView overviewPanel = mTaskContainer.getTaskView().getRecentsView(); // Task has already been dismissed if (overviewPanel == null) return; - overviewPanel.initiateSplitSelect(mTaskContainer.getTaskView()); + overviewPanel.initiateSplitSelect(mTaskContainer); } protected void saveAppPair() { @@ -369,7 +369,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride { @Override public void onClick(View view) { - saveScreenshot(mTaskContainer.getTaskView().getFirstTask()); + saveScreenshot(mTaskContainer.getTask()); dismissTaskMenuView(); } } diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java index ab5e830f67..ee1d8a6292 100644 --- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java +++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java @@ -48,6 +48,7 @@ import com.android.launcher3.model.WellbeingModel; import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.popup.SystemShortcut.AppInfo; import com.android.launcher3.util.InstantAppResolver; +import com.android.launcher3.util.SplitConfigurationOptions; import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption; import com.android.launcher3.views.ActivityContext; import com.android.quickstep.orientation.RecentsPagedOrientationHandler; @@ -128,20 +129,28 @@ public interface TaskShortcutFactory { }; class SplitSelectSystemShortcut extends SystemShortcut { - private final TaskView mTaskView; + private final TaskContainer mTaskContainer; private final SplitPositionOption mSplitPositionOption; - public SplitSelectSystemShortcut(RecentsViewContainer container, TaskView taskView, + public SplitSelectSystemShortcut(RecentsViewContainer container, + TaskContainer taskContainer, TaskView taskView, SplitPositionOption option) { super(option.iconResId, option.textResId, container, taskView.getFirstItemInfo(), taskView); - mTaskView = taskView; + mTaskContainer = taskContainer; mSplitPositionOption = option; } @Override public void onClick(View view) { - mTaskView.initiateSplitSelect(mSplitPositionOption); + RecentsView recentsView = mTaskContainer.getTaskView().getRecentsView(); + if (recentsView != null) { + recentsView.initiateSplitSelect( + mTaskContainer, + mSplitPositionOption.stagePosition, + SplitConfigurationOptions.getLogEventForPosition( + mSplitPositionOption.stagePosition)); + } } } @@ -152,7 +161,6 @@ public interface TaskShortcutFactory { class SaveAppPairSystemShortcut extends SystemShortcut { private final GroupedTaskView mTaskView; - public SaveAppPairSystemShortcut(RecentsViewContainer container, GroupedTaskView taskView, int iconResId) { super(iconResId, R.string.save_app_pair, container, taskView.getFirstItemInfo(), @@ -202,14 +210,14 @@ public interface TaskShortcutFactory { } private void startActivity() { - final Task.TaskKey taskKey = mTaskView.getFirstTask().key; - final int taskId = taskKey.id; final ActivityOptions options = makeLaunchOptions(mTarget); - if (options != null) { - options.setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_ICON); + if (options == null) { + return; } - if (options != null - && ActivityManagerWrapper.getInstance().startActivityFromRecents(taskId, + final Task.TaskKey taskKey = mTaskContainer.getTask().key; + final int taskId = taskKey.id; + options.setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_ICON); + if (ActivityManagerWrapper.getInstance().startActivityFromRecents(taskId, options)) { final Runnable animStartedListener = () -> { // Hide the task view and wait for the window to be resized @@ -252,8 +260,8 @@ public interface TaskShortcutFactory { overridePendingAppTransitionMultiThumbFuture( future, animStartedListener, mHandler, true /* scaleUp */, taskKey.displayId); - mTarget.getStatsLogManager().logger().withItemInfo(mTaskView.getFirstItemInfo()) - .log(mLauncherEvent); + mTarget.getStatsLogManager().logger().withItemInfo(mTaskContainer.getItemInfo()) + .log(mLauncherEvent); } } @@ -327,7 +335,8 @@ public interface TaskShortcutFactory { return orientationHandler.getSplitPositionOptions(deviceProfile) .stream() .map((Function) option -> - new SplitSelectSystemShortcut(container, taskView, option)) + new SplitSelectSystemShortcut(container, taskContainer, taskView, + option)) .collect(Collectors.toList()); } }; @@ -420,24 +429,24 @@ public interface TaskShortcutFactory { private static final String TAG = "PinSystemShortcut"; - private final TaskView mTaskView; + private final TaskContainer mTaskContainer; public PinSystemShortcut(RecentsViewContainer target, TaskContainer taskContainer) { super(R.drawable.ic_pin, R.string.recent_task_option_pin, target, taskContainer.getItemInfo(), taskContainer.getTaskView()); - mTaskView = taskContainer.getTaskView(); + mTaskContainer = taskContainer; } @Override public void onClick(View view) { - if (mTaskView.launchAsStaticTile() != null) { + if (mTaskContainer.getTaskView().launchAsStaticTile() != null) { SystemUiProxy.INSTANCE.get(mTarget.asContext()).startScreenPinning( - mTaskView.getFirstTask().key.id); + mTaskContainer.getTask().key.id); } dismissTaskMenuView(); - mTarget.getStatsLogManager().logger().withItemInfo(mTaskView.getFirstItemInfo()) - .log(LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_PIN_TAP); + mTarget.getStatsLogManager().logger().withItemInfo(mTaskContainer.getItemInfo()) + .log(LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_PIN_TAP); } } diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 3133907cab..e47223b7a1 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -123,8 +123,9 @@ public final class TaskViewUtils { int userId = itemInfo.user.getIdentifier(); if (componentName != null) { for (TaskView taskView : recentsView.getTaskViews()) { - if (recentsView.isTaskViewVisible(taskView)) { - Task.TaskKey key = taskView.getFirstTask().key; + Task firstTask = taskView.getFirstTask(); + if (firstTask != null && recentsView.isTaskViewVisible(taskView)) { + Task.TaskKey key = firstTask.key; if (componentName.equals(key.getComponent()) && userId == key.userId) { return taskView; } diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java index fff7e9be8f..8d010e248c 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java @@ -52,6 +52,7 @@ import com.android.quickstep.util.TaskViewSimulator; import com.android.quickstep.views.OverviewActionsView; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.RecentsViewContainer; +import com.android.quickstep.views.TaskContainer; import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.model.Task; @@ -239,10 +240,10 @@ public class FallbackRecentsView containers = gtv.getTaskContainers(); + // TODO(b/391918297): Replace `taskContainers[x]` with `leftTopTaskContainer` and + // `rightBottomTaskContainer`. ComponentKey taskKey1 = TaskUtils.getLaunchComponentKeyForTask( containers.get(0).getTask().key); ComponentKey taskKey2 = TaskUtils.getLaunchComponentKeyForTask( @@ -183,9 +185,8 @@ public class AppPairsController { return; } - List containers = gtv.getTaskContainers(); List recentsInfos = - containers.stream().map(TaskContainer::getItemInfo).toList(); + gtv.getTaskContainers().stream().map(TaskContainer::getItemInfo).toList(); List apps = recentsInfos.stream().map(this::resolveAppPairWorkspaceInfo).toList(); diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt index 38ffe5076e..0187b58539 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt @@ -191,9 +191,7 @@ class GroupedTaskView @JvmOverloads constructor(context: Context, attrs: Attribu val bottomRightTaskPercent = 1 - topLeftTaskPercent taskContainers[0] .iconView - .setFlexSplitAlpha( - if (topLeftTaskPercent < MINIMUM_RATIO_TO_SHOW_ICON) 0f else 1f - ) + .setFlexSplitAlpha(if (topLeftTaskPercent < MINIMUM_RATIO_TO_SHOW_ICON) 0f else 1f) taskContainers[1] .iconView .setFlexSplitAlpha( diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java index 9be462cbdc..c6bd6770fb 100644 --- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java @@ -36,7 +36,6 @@ import androidx.annotation.Nullable; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.desktop.DesktopRecentsTransitionController; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.statehandlers.DepthController; @@ -127,9 +126,11 @@ public class LauncherRecentsView extends RecentsView( () -> PackageManagerWrapper.getInstance() .getActivityInfo(taskKey.getComponent(), taskKey.userId) == null, @@ -847,7 +847,7 @@ public abstract class RecentsView< private final RecentsViewModel mRecentsViewModel; private final RecentsViewModelHelper mHelper; - private final RecentsViewUtils mUtils = new RecentsViewUtils(this); + protected final RecentsViewUtils mUtils = new RecentsViewUtils(this); private final Matrix mTmpMatrix = new Matrix(); @@ -1117,7 +1117,7 @@ public abstract class RecentsView< TaskView taskView = getTaskViewByTaskId(taskId); if (taskView != null) { for (TaskContainer container : taskView.getTaskContainers()) { - if (container == null || taskId != container.getTask().key.id) { + if (taskId != container.getTask().key.id) { continue; } container.getThumbnailViewDeprecated().setThumbnail(container.getTask(), @@ -1132,9 +1132,10 @@ public abstract class RecentsView< @Override public void onTaskIconChanged(@NonNull String pkg, @NonNull UserHandle user) { for (TaskView taskView : getTaskViews()) { - Task task = taskView.getFirstTask(); - if (pkg.equals(task.key.getPackageName()) && task.key.userId == user.getIdentifier()) { - task.icon = null; + Task firstTask = taskView.getFirstTask(); + if (firstTask != null && pkg.equals(firstTask.key.getPackageName()) + && firstTask.key.userId == user.getIdentifier()) { + firstTask.icon = null; if (taskView.getTaskContainers().stream().anyMatch( container -> container.getIconView().getDrawable() != null)) { taskView.onTaskListVisibilityChanged(true /* visible */); @@ -4084,6 +4085,7 @@ public abstract class RecentsView< } else { removeTaskInternal(dismissedTaskView); } + // TODO(b/391918297): Logging when the TaskView does not have tasks as well. mContainer.getStatsLogManager().logger() .withItemInfo(dismissedTaskView.getFirstItemInfo()) .log(LAUNCHER_TASK_DISMISS_SWIPE_UP); @@ -5171,18 +5173,20 @@ public abstract class RecentsView< * Primarily used by overview actions to initiate split from focused task, logs the source * of split invocation as such. */ - public void initiateSplitSelect(TaskView taskView) { + public void initiateSplitSelect(TaskContainer taskContainer) { int defaultSplitPosition = getPagedOrientationHandler() .getDefaultSplitPosition(mContainer.getDeviceProfile()); - initiateSplitSelect(taskView, defaultSplitPosition, LAUNCHER_OVERVIEW_ACTIONS_SPLIT); + initiateSplitSelect(taskContainer, defaultSplitPosition, LAUNCHER_OVERVIEW_ACTIONS_SPLIT); } /** TODO(b/266477929): Consolidate this call w/ the one below */ - public void initiateSplitSelect(TaskView taskView, @StagePosition int stagePosition, + public void initiateSplitSelect(TaskContainer taskContainer, + @StagePosition int stagePosition, StatsLogManager.EventEnum splitEvent) { + TaskView taskView = taskContainer.getTaskView(); mSplitHiddenTaskView = taskView; mSplitSelectStateController.setInitialTaskSelect(null /*intent*/, stagePosition, - taskView.getFirstItemInfo(), splitEvent, taskView.getFirstTask().key.id); + taskContainer.getItemInfo(), splitEvent, taskContainer.getTask().key.id); mSplitSelectStateController.setAnimateCurrentTaskDismissal( true /*animateCurrentTaskDismissal*/); mSplitHiddenTaskViewIndex = indexOfChild(taskView); @@ -5278,6 +5282,8 @@ public abstract class RecentsView< createInitialSplitSelectAnimation(builder); // Animate pair thumbnail into full thumbnail + // TODO(b/391918297): Use `leftTopTaskContainer` that will be introduced inside + // `appPairsController`. boolean primaryTaskSelected = mSplitHiddenTaskView.getTaskIds()[0] == mSplitSelectStateController.getInitialTaskId(); TaskContainer taskContainer = mSplitHiddenTaskView @@ -5767,8 +5773,12 @@ public abstract class RecentsView< } else { taskView.launchWithoutAnimation(this::onTaskLaunchAnimationEnd); } - mContainer.getStatsLogManager().logger().withItemInfo(taskView.getFirstItemInfo()) - .log(LAUNCHER_TASK_LAUNCH_SWIPE_DOWN); + // TODO(b/391918297): Logging when there is no associated task. + ItemInfo firstItemInfo = taskView.getFirstItemInfo(); + if (firstItemInfo != null) { + mContainer.getStatsLogManager().logger().withItemInfo(firstItemInfo) + .log(LAUNCHER_TASK_LAUNCH_SWIPE_DOWN); + } } else { onTaskLaunchAnimationEnd(false); } diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt index bce5a5e883..94e8c03360 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt +++ b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt @@ -224,6 +224,9 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) { /** Returns true if there are at least one TaskView has been added to the RecentsView. */ fun hasTaskViews() = taskViews.any() + fun getTaskContainerById(taskId: Int) = + taskViews.firstNotNullOfOrNull { it.getTaskContainerById(taskId) } + private fun getRowRect(firstView: View?, lastView: View?, outRowRect: Rect) { outRowRect.setEmpty() firstView?.let { diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 20a385f8d4..9807b0de74 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -33,7 +33,6 @@ import android.util.Log import android.view.Display import android.view.MotionEvent import android.view.View -import android.view.View.OnClickListener import android.view.ViewGroup import android.view.ViewStub import android.view.accessibility.AccessibilityNodeInfo @@ -64,9 +63,7 @@ import com.android.launcher3.util.MultiPropertyFactory import com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE import com.android.launcher3.util.MultiValueAlpha import com.android.launcher3.util.RunnableList -import com.android.launcher3.util.SplitConfigurationOptions import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED -import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption import com.android.launcher3.util.SplitConfigurationOptions.StagePosition import com.android.launcher3.util.TraceHelper import com.android.launcher3.util.TransformingTouchDelegate @@ -163,14 +160,15 @@ constructor( val pagedOrientationHandler: RecentsPagedOrientationHandler get() = orientedState.orientationHandler - @get:Deprecated("Use [taskContainers] instead.") - val firstTask: Task - /** Returns the first task bound to this TaskView. */ - get() = taskContainers[0].task + val firstTaskContainer: TaskContainer? + get() = taskContainers.firstOrNull() - @get:Deprecated("Use [taskContainers] instead.") - val firstItemInfo: ItemInfo - get() = taskContainers[0].itemInfo + val firstTask: Task? + /** Returns the first task bound to this TaskView. */ + get() = firstTaskContainer?.task + + val firstItemInfo: ItemInfo? + get() = firstTaskContainer?.itemInfo protected val container: RecentsViewContainer = RecentsViewContainer.containerFromContext(context) @@ -942,7 +940,7 @@ constructor( protected open fun updateThumbnailSize() { // TODO(b/271468547), we should default to setting translations only on the snapshot instead // of a hybrid of both margins and translations - taskContainers[0].snapshotView.updateLayoutParams { + firstTaskContainer?.snapshotView?.updateLayoutParams { topMargin = container.deviceProfile.overviewTaskThumbnailTopMarginPx } taskContainers.forEach { it.digitalWellBeingToast?.setupLayout() } @@ -1106,10 +1104,13 @@ constructor( } } Log.d("b/310064698", "${taskIds.contentToString()} - onClick - callbackList: $callbackList") - container.statsLogManager - .logger() - .withItemInfo(firstItemInfo) - .log(LauncherEvent.LAUNCHER_TASK_LAUNCH_TAP) + // TODO(b/391918297): Logging when there is no associated task. + firstItemInfo?.let { + container.statsLogManager + .logger() + .withItemInfo(it) + .log(LauncherEvent.LAUNCHER_TASK_LAUNCH_TAP) + } } /** Launch of the current task (both live and inactive tasks) with an animation. */ @@ -1212,6 +1213,7 @@ constructor( * @return CompletionStage to indicate the animation completion or null if the launch failed. */ open fun launchAsStaticTile(): RunnableList? { + val firstTaskContainer = firstTaskContainer ?: return null TestLogging.recordEvent( TestProtocol.SEQUENCE_MAIN, "startActivityFromRecentsAsync", @@ -1223,7 +1225,7 @@ constructor( } if ( ActivityManagerWrapper.getInstance() - .startActivityFromRecents(taskContainers[0].task.key, opts.options) + .startActivityFromRecents(firstTaskContainer.task.key, opts.options) ) { Log.d( TAG, @@ -1262,18 +1264,18 @@ constructor( isQuickSwitch: Boolean = false, callback: (launched: Boolean) -> Unit, ) { + val firstTaskContainer = firstTaskContainer ?: return TestLogging.recordEvent( TestProtocol.SEQUENCE_MAIN, "startActivityFromRecentsAsync", taskIds.contentToString(), ) - val firstContainer = taskContainers[0] val failureListener = TaskRemovedDuringLaunchListener(context.applicationContext) if (isQuickSwitch) { // We only listen for failures to launch in quickswitch because the during this // gesture launcher is in the background state, vs other launches which are in // the actual overview state - failureListener.register(container, firstContainer.task.key.id) { + failureListener.register(container, firstTaskContainer.task.key.id) { notifyTaskLaunchFailed("launchWithoutAnimation") recentsView?.let { // Disable animations for now, as it is an edge case and the app usually @@ -1305,12 +1307,12 @@ constructor( if (isQuickSwitch) { setFreezeRecentTasksReordering() } - disableStartingWindow = firstContainer.shouldShowSplashView + disableStartingWindow = firstTaskContainer.shouldShowSplashView } Executors.UI_HELPER_EXECUTOR.execute { if ( !ActivityManagerWrapper.getInstance() - .startActivityFromRecents(firstContainer.task.key, opts) + .startActivityFromRecents(firstTaskContainer.task.key, opts) ) { // If the call to start activity failed, then post the result immediately, // otherwise, wait for the animation start callback from the activity options @@ -1337,14 +1339,6 @@ constructor( Toast.makeText(context, R.string.activity_not_available, Toast.LENGTH_SHORT).show() } - fun initiateSplitSelect(splitPositionOption: SplitPositionOption) { - recentsView?.initiateSplitSelect( - this, - splitPositionOption.stagePosition, - SplitConfigurationOptions.getLogEventForPosition(splitPositionOption.stagePosition), - ) - } - /** * Returns `true` if user is already in split select mode and this tap was to choose the second * app. `false` otherwise diff --git a/quickstep/tests/src/com/android/quickstep/DigitalWellBeingToastTest.java b/quickstep/tests/src/com/android/quickstep/DigitalWellBeingToastTest.java index f92314205a..c78fe1cf54 100644 --- a/quickstep/tests/src/com/android/quickstep/DigitalWellBeingToastTest.java +++ b/quickstep/tests/src/com/android/quickstep/DigitalWellBeingToastTest.java @@ -21,6 +21,7 @@ import static com.android.launcher3.util.TestUtil.resolveSystemAppInfo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.app.PendingIntent; @@ -93,7 +94,8 @@ public class DigitalWellBeingToastTest extends BaseLauncherActivityTest getLatestTask(launcher)); return getFromLauncher(launcher -> { - TaskContainer taskContainer = task.getTaskContainers().get(0); + TaskContainer taskContainer = task.getFirstTaskContainer(); + assertNotNull(taskContainer); assertTrue("Latest task is not Calculator", calculatorPackage.equals( taskContainer.getTask().getTopComponent().getPackageName())); return taskContainer.getDigitalWellBeingToast();