diff --git a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java index 62cc0bb90a..6c7fe5be90 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java @@ -19,10 +19,9 @@ import static android.view.View.VISIBLE; import static com.android.launcher3.LauncherState.BACKGROUND_APP; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; -import static com.android.window.flags.Flags.enableDesktopWindowingWallpaperActivity; +import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.WALLPAPER_ACTIVITY; import android.os.Debug; -import android.os.SystemProperties; import android.util.Log; import android.view.View; @@ -145,7 +144,7 @@ public class DesktopVisibilityController { notifyDesktopVisibilityListeners(areDesktopTasksVisibleNow); } - if (!enableDesktopWindowingWallpaperActivity() && wasVisible != isVisible) { + if (!WALLPAPER_ACTIVITY.isEnabled(mLauncher) && wasVisible != isVisible) { // TODO: b/333533253 - Remove after flag rollout if (mVisibleDesktopTasksCount > 0) { setLauncherViewsVisibility(View.INVISIBLE); @@ -189,7 +188,7 @@ public class DesktopVisibilityController { notifyDesktopVisibilityListeners(areDesktopTasksVisibleNow); } - if (enableDesktopWindowingWallpaperActivity()) { + if (WALLPAPER_ACTIVITY.isEnabled(mLauncher)) { return; } // TODO: b/333533253 - Clean up after flag rollout @@ -289,7 +288,7 @@ public class DesktopVisibilityController { * TODO: b/333533253 - Remove after flag rollout */ private void setLauncherViewsVisibility(int visibility) { - if (enableDesktopWindowingWallpaperActivity()) { + if (WALLPAPER_ACTIVITY.isEnabled(mLauncher)) { return; } if (DEBUG) { @@ -314,7 +313,7 @@ public class DesktopVisibilityController { * TODO: b/333533253 - Remove after flag rollout */ private void markLauncherPaused() { - if (enableDesktopWindowingWallpaperActivity()) { + if (WALLPAPER_ACTIVITY.isEnabled(mLauncher)) { return; } if (DEBUG) { @@ -331,7 +330,7 @@ public class DesktopVisibilityController { * TODO: b/333533253 - Remove after flag rollout */ private void markLauncherResumed() { - if (enableDesktopWindowingWallpaperActivity()) { + if (WALLPAPER_ACTIVITY.isEnabled(mLauncher)) { return; } if (DEBUG) { diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index 0add1c41de..93a023dbdd 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -21,7 +21,7 @@ import static com.android.launcher3.taskbar.TaskbarEduTooltipControllerKt.TOOLTI import static com.android.launcher3.taskbar.TaskbarLauncherStateController.FLAG_VISIBLE; import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IGNORE_IN_APP; import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITIONS; -import static com.android.window.flags.Flags.enableDesktopWindowingWallpaperActivity; +import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.WALLPAPER_ACTIVITY; import android.animation.Animator; import android.animation.AnimatorSet; @@ -214,7 +214,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController { DesktopVisibilityController desktopController = LauncherActivityInterface.INSTANCE.getDesktopVisibilityController(); - if (!enableDesktopWindowingWallpaperActivity() + if (!WALLPAPER_ACTIVITY.isEnabled(mLauncher) && desktopController != null && desktopController.areDesktopTasksVisible()) { // TODO: b/333533253 - Remove after flag rollout diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 30482436fd..800c594604 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -315,6 +315,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { new TaskbarTranslationController(this), new TaskbarSpringOnStashController(this), new TaskbarRecentAppsController( + this, RecentsModel.INSTANCE.get(this), LauncherActivityInterface.INSTANCE::getDesktopVisibilityController), TaskbarEduTooltipController.newInstance(this), diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt index 5c081163cc..2cb950c7e9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt @@ -15,6 +15,7 @@ */ package com.android.launcher3.taskbar +import android.content.Context import androidx.annotation.VisibleForTesting import com.android.launcher3.Flags.enableRecentsInTaskbar import com.android.launcher3.model.data.ItemInfo @@ -26,8 +27,8 @@ import com.android.launcher3.util.CancellableTask import com.android.quickstep.RecentsModel import com.android.quickstep.util.DesktopTask import com.android.quickstep.util.GroupTask -import com.android.window.flags.Flags.enableDesktopWindowingMode import com.android.window.flags.Flags.enableDesktopWindowingTaskbarRunningApps +import com.android.wm.shell.shared.desktopmode.DesktopModeFlags.DESKTOP_WINDOWING_MODE import java.io.PrintWriter /** @@ -36,6 +37,7 @@ import java.io.PrintWriter * - When in Desktop Mode: show the currently running (open) Tasks */ class TaskbarRecentAppsController( + context: Context, private val recentsModel: RecentsModel, // Pass a provider here instead of the actual DesktopVisibilityController instance since that // instance might not be available when this constructor is called. @@ -44,7 +46,7 @@ class TaskbarRecentAppsController( // TODO(b/335401172): unify DesktopMode checks in Launcher. var canShowRunningApps = - enableDesktopWindowingMode() && enableDesktopWindowingTaskbarRunningApps() + DESKTOP_WINDOWING_MODE.isEnabled(context) && enableDesktopWindowingTaskbarRunningApps() @VisibleForTesting set(isEnabledFromTest) { field = isEnabledFromTest diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index be6f69069d..df8c05c3df 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -64,10 +64,10 @@ import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.QUICK_SWITCH_FROM_HOME_FALLBACK; import static com.android.quickstep.util.AnimUtils.completeRunnableListCallback; import static com.android.quickstep.util.SplitAnimationTimings.TABLET_HOME_TO_SPLIT; +import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.WALLPAPER_ACTIVITY; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY; -import static com.android.window.flags.Flags.enableDesktopWindowingMode; -import static com.android.window.flags.Flags.enableDesktopWindowingWallpaperActivity; import static com.android.wm.shell.common.split.SplitScreenConstants.SNAP_TO_50_50; +import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.DESKTOP_WINDOWING_MODE; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -201,6 +201,8 @@ import com.android.systemui.unfold.dagger.UnfoldMain; import com.android.systemui.unfold.progress.RemoteUnfoldTransitionReceiver; import com.android.systemui.unfold.updates.RotationChangeProvider; +import kotlin.Unit; + import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; @@ -213,8 +215,6 @@ import java.util.function.BiConsumer; import java.util.function.Predicate; import java.util.stream.Stream; -import kotlin.Unit; - public class QuickstepLauncher extends Launcher implements RecentsViewContainer { private static final boolean TRACE_LAYOUTS = SystemProperties.getBoolean("persist.debug.trace_layouts", false); @@ -276,7 +276,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer // TODO(b/337863494): Explore use of the same OverviewComponentObserver across launcher OverviewComponentObserver overviewComponentObserver = new OverviewComponentObserver( asContext(), deviceState); - if (enableDesktopWindowingMode()) { + if (DESKTOP_WINDOWING_MODE.isEnabled(this)) { mDesktopRecentsTransitionController = new DesktopRecentsTransitionController( getStateManager(), systemUiProxy, getIApplicationThread(), getDepthController()); @@ -296,7 +296,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer mTISBindHelper = new TISBindHelper(this, this::onTISConnected); mDepthController = new DepthController(this); - if (enableDesktopWindowingMode()) { + if (DESKTOP_WINDOWING_MODE.isEnabled(this)) { mDesktopVisibilityController = new DesktopVisibilityController(this); mDesktopVisibilityController.registerSystemUiListener(); mSplitSelectStateController.initSplitFromDesktopController(this, @@ -1004,7 +1004,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer @Override public void setResumed() { - if (!enableDesktopWindowingWallpaperActivity() + if (!WALLPAPER_ACTIVITY.isEnabled(this) && mDesktopVisibilityController != null && mDesktopVisibilityController.areDesktopTasksVisible() && !mDesktopVisibilityController.isRecentsGestureInProgress()) { diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 20eaddc6f9..b05918648e 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -62,6 +62,8 @@ import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.ON_SETTLED_ON_END_TARGET; import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; +import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.DESKTOP_WINDOWING_MODE; +import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.WALLPAPER_ACTIVITY; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -152,6 +154,8 @@ import com.android.window.flags.Flags; import com.android.wm.shell.common.TransactionPool; import com.android.wm.shell.startingsurface.SplashScreenExitAnimationUtils; +import kotlin.Unit; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -161,8 +165,6 @@ import java.util.Optional; import java.util.OptionalInt; import java.util.function.Consumer; -import kotlin.Unit; - /** * Handles the navigation gestures when Launcher is the default home activity. */ @@ -952,7 +954,7 @@ public abstract class AbsSwipeUpHandler mRunningTasks; - public RecentTasksList(LooperExecutor mainThreadExecutor, KeyguardManager keyguardManager, - SystemUiProxy sysUiProxy, TopTaskTracker topTaskTracker) { + public RecentTasksList(Context context, LooperExecutor mainThreadExecutor, + KeyguardManager keyguardManager, SystemUiProxy sysUiProxy, + TopTaskTracker topTaskTracker) { + mContext = context; mMainThreadExecutor = mainThreadExecutor; mKeyguardManager = keyguardManager; mChangeId = 1; @@ -325,9 +329,9 @@ public class RecentTasksList { int numVisibleTasks = 0; for (GroupedRecentTaskInfo rawTask : rawTasks) { if (rawTask.getType() == TYPE_FREEFORM) { - // TYPE_FREEFORM tasks is only created when enableDesktopWindowingMode() is true, + // TYPE_FREEFORM tasks is only created whenDESKTOP_WINDOWING_MODE.isEnabled is true, // leftover TYPE_FREEFORM tasks created when flag was on should be ignored. - if (enableDesktopWindowingMode()) { + if (DESKTOP_WINDOWING_MODE.isEnabled(mContext)) { GroupTask desktopTask = createDesktopTask(rawTask); if (desktopTask != null) { allTasks.add(desktopTask); diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index 18461a6440..e84200d1d5 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -27,7 +27,7 @@ import static com.android.launcher3.testing.shared.TestProtocol.OVERVIEW_STATE_O import static com.android.quickstep.OverviewComponentObserver.startHomeIntentSafely; import static com.android.quickstep.TaskUtils.taskIsATargetWithMode; import static com.android.quickstep.TaskViewUtils.createRecentsWindowAnimator; -import static com.android.window.flags.Flags.enableDesktopWindowingMode; +import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.DESKTOP_WINDOWING_MODE; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -147,7 +147,7 @@ public final class RecentsActivity extends StatefulActivity implem mActionsView = findViewById(R.id.overview_actions_view); getRootView().getSysUiScrim().getSysUIProgress().updateValue(0); mDragLayer.recreateControllers(); - if (enableDesktopWindowingMode()) { + if (DESKTOP_WINDOWING_MODE.isEnabled(this)) { mDesktopRecentsTransitionController = new DesktopRecentsTransitionController( getStateManager(), systemUiProxy, getIApplicationThread(), null /* depthController */ diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationTargets.java b/quickstep/src/com/android/quickstep/RecentsAnimationTargets.java index 82bb453807..d104911915 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationTargets.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationTargets.java @@ -18,9 +18,10 @@ package com.android.quickstep; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.view.RemoteAnimationTarget.MODE_CLOSING; -import static com.android.window.flags.Flags.enableDesktopWindowingMode; +import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.DESKTOP_WINDOWING_MODE; import android.app.WindowConfiguration; +import android.content.Context; import android.graphics.Rect; import android.os.Bundle; import android.view.RemoteAnimationTarget; @@ -54,8 +55,8 @@ public class RecentsAnimationTargets extends RemoteAnimationTargets { * * @return {@code true} if at least one target app is a desktop task */ - public boolean hasDesktopTasks() { - if (!enableDesktopWindowingMode()) { + public boolean hasDesktopTasks(Context context) { + if (!DESKTOP_WINDOWING_MODE.isEnabled(context)) { return false; } for (RemoteAnimationTarget target : apps) { diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java index f2b6005a4a..db03dac608 100644 --- a/quickstep/src/com/android/quickstep/RecentsModel.java +++ b/quickstep/src/com/android/quickstep/RecentsModel.java @@ -90,7 +90,9 @@ public class RecentsModel implements RecentTasksDataSource, IconChangeListener, private RecentsModel(Context context, IconProvider iconProvider) { this(context, - new RecentTasksList(MAIN_EXECUTOR, + new RecentTasksList( + context, + MAIN_EXECUTOR, context.getSystemService(KeyguardManager.class), SystemUiProxy.INSTANCE.get(context), TopTaskTracker.INSTANCE.get(context)), diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index 3f73959254..f2db5af0f8 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -23,8 +23,8 @@ import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.SplitConfigurationOptions.StagePosition; import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.RECENT_TASKS_MISSING; import static com.android.quickstep.util.LogUtils.splitFailureMessage; -import static com.android.window.flags.Flags.enableDesktopWindowingMode; import static com.android.window.flags.Flags.enableDesktopWindowingTaskbarRunningApps; +import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.DESKTOP_WINDOWING_MODE; import android.app.ActivityManager; import android.app.ActivityOptions; @@ -1444,7 +1444,8 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { private boolean shouldEnableRunningTasksForDesktopMode() { // TODO(b/335401172): unify DesktopMode checks in Launcher - return enableDesktopWindowingMode() && enableDesktopWindowingTaskbarRunningApps(); + return DESKTOP_WINDOWING_MODE.isEnabled(mContext) + && enableDesktopWindowingTaskbarRunningApps(); } private boolean handleMessageAsync(Message msg) { diff --git a/quickstep/src/com/android/quickstep/util/AnimUtils.java b/quickstep/src/com/android/quickstep/util/AnimUtils.java index 8e3d44f8d8..31aca03ce6 100644 --- a/quickstep/src/com/android/quickstep/util/AnimUtils.java +++ b/quickstep/src/com/android/quickstep/util/AnimUtils.java @@ -17,18 +17,28 @@ package com.android.quickstep.util; import static com.android.app.animation.Interpolators.clampToProgress; +import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; +import android.animation.AnimatorSet; +import android.annotation.NonNull; import android.os.Bundle; import android.os.IRemoteCallback; import android.view.animation.Interpolator; +import com.android.launcher3.logging.StatsLogManager; +import com.android.launcher3.statemanager.BaseState; +import com.android.launcher3.statemanager.StateManager; +import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.util.RunnableList; +import com.android.quickstep.views.RecentsViewContainer; /** * Utility class containing methods to help manage animations, interpolators, and timings. */ public class AnimUtils { + private static final int DURATION_DEFAULT_SPLIT_DISMISS = 350; + /** * Fetches device-specific timings for the Overview > Split animation * (splitscreen initiated from Overview). @@ -58,6 +68,33 @@ public class AnimUtils { : SplitAnimationTimings.PHONE_APP_PAIR_LAUNCH; } + /** + * Synchronizes the timing for the split dismiss animation to the current transition to + * NORMAL (launcher home/workspace) + */ + public static void goToNormalStateWithSplitDismissal(@NonNull StateManager stateManager, + @NonNull RecentsViewContainer container, + @NonNull StatsLogManager.LauncherEvent exitReason, + @NonNull SplitAnimationController animationController) { + StateAnimationConfig config = new StateAnimationConfig(); + BaseState startState = stateManager.getState(); + long duration = startState.getTransitionDuration(container.asContext(), + false /*isToState*/); + if (duration == 0) { + // Case where we're in contextual on workspace (NORMAL), which by default has 0 + // transition duration + duration = DURATION_DEFAULT_SPLIT_DISMISS; + } + config.duration = duration; + AnimatorSet stateAnim = stateManager.createAtomicAnimation( + startState, NORMAL, config); + AnimatorSet dismissAnim = animationController + .createPlaceholderDismissAnim(container, exitReason, duration); + stateAnim.play(dismissAnim); + stateManager.setCurrentAnimation(stateAnim, NORMAL); + stateAnim.start(); + } + /** * Returns a IRemoteCallback which completes the provided list as a result */ diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java index e48a7c6053..d20d0a5781 100644 --- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java @@ -26,7 +26,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK; import static com.android.launcher3.LauncherState.OVERVIEW_SPLIT_SELECT; import static com.android.launcher3.LauncherState.SPRING_LOADED; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SPLIT_SELECTION_EXIT_HOME; -import static com.android.window.flags.Flags.enableDesktopWindowingWallpaperActivity; +import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.WALLPAPER_ACTIVITY; import android.annotation.TargetApi; import android.content.Context; @@ -54,6 +54,7 @@ import com.android.quickstep.GestureState; import com.android.quickstep.LauncherActivityInterface; import com.android.quickstep.RotationTouchHelper; import com.android.quickstep.SystemUiProxy; +import com.android.quickstep.util.AnimUtils; import com.android.quickstep.util.SplitSelectStateController; import com.android.systemui.shared.recents.model.Task; @@ -91,10 +92,12 @@ public class LauncherRecentsView extends RecentsView(Collections.singletonList(recentTaskInfos))); List taskList = mRecentTasksList.loadTasksInBackground(Integer.MAX_VALUE, -1, @@ -94,7 +97,7 @@ public class RecentTasksListTest { @Test public void loadTasksInBackground_GetRecentTasksException() throws Exception { - when(mockSystemUiProxy.getRecentTasks(anyInt(), anyInt())) + when(mSystemUiProxy.getRecentTasks(anyInt(), anyInt())) .thenThrow(new SystemUiProxy.GetRecentTasksException("task load failed")); RecentTasksList.TaskLoadResult taskList = mRecentTasksList.loadTasksInBackground( @@ -113,7 +116,7 @@ public class RecentTasksListTest { task2.taskDescription = new ActivityManager.TaskDescription(); GroupedRecentTaskInfo recentTaskInfos = GroupedRecentTaskInfo.forSplitTasks(task1, task2, null); - when(mockSystemUiProxy.getRecentTasks(anyInt(), anyInt())) + when(mSystemUiProxy.getRecentTasks(anyInt(), anyInt())) .thenReturn(new ArrayList<>(Collections.singletonList(recentTaskInfos))); List taskList = mRecentTasksList.loadTasksInBackground(Integer.MAX_VALUE, -1, @@ -132,7 +135,7 @@ public class RecentTasksListTest { createRecentTaskInfo(5 /* taskId */)}; GroupedRecentTaskInfo recentTaskInfos = GroupedRecentTaskInfo.forFreeformTasks( tasks, Collections.emptySet() /* minimizedTaskIds */); - when(mockSystemUiProxy.getRecentTasks(anyInt(), anyInt())) + when(mSystemUiProxy.getRecentTasks(anyInt(), anyInt())) .thenReturn(new ArrayList<>(Collections.singletonList(recentTaskInfos))); List taskList = mRecentTasksList.loadTasksInBackground( @@ -158,7 +161,7 @@ public class RecentTasksListTest { Arrays.stream(new Integer[]{1, 4, 5}).collect(Collectors.toSet()); GroupedRecentTaskInfo recentTaskInfos = GroupedRecentTaskInfo.forFreeformTasks(tasks, minimizedTaskIds); - when(mockSystemUiProxy.getRecentTasks(anyInt(), anyInt())) + when(mSystemUiProxy.getRecentTasks(anyInt(), anyInt())) .thenReturn(new ArrayList<>(Collections.singletonList(recentTaskInfos))); List taskList = mRecentTasksList.loadTasksInBackground( diff --git a/res/drawable/rounded_action_button.xml b/res/drawable/rounded_action_button.xml index ddd3042cb9..ebfa996ac5 100644 --- a/res/drawable/rounded_action_button.xml +++ b/res/drawable/rounded_action_button.xml @@ -22,8 +22,5 @@ - diff --git a/res/layout/work_apps_edu.xml b/res/layout/work_apps_edu.xml index c581ae325f..a45d58521d 100644 --- a/res/layout/work_apps_edu.xml +++ b/res/layout/work_apps_edu.xml @@ -44,8 +44,7 @@ + android:background="@drawable/rounded_action_button"> 48dp 48dp 200dp - 8dp - 8dp diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index a448228c9f..53fed204a2 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -746,7 +746,8 @@ public final class Utilities { * | +--+ | * | | * +----------------+ - * This would be case delta % 4 == 2: + * This would be case delta % 4 == 2: // This is case was reverted to previous behaviour which + * doesn't match the illustration due to b/353965234 * +-------------+ * | | * | | @@ -768,7 +769,6 @@ public final class Utilities { int delta) { int rdelta = ((delta % 4) + 4) % 4; int origLeft = inOutBounds.left; - int origTop = inOutBounds.top; switch (rdelta) { case 0: return; @@ -780,8 +780,6 @@ public final class Utilities { return; case 2: inOutBounds.left = parentWidth - inOutBounds.right; - inOutBounds.top = parentHeight - inOutBounds.bottom; - inOutBounds.bottom = parentHeight - origTop; inOutBounds.right = parentWidth - origLeft; return; case 3: diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java index 89e6adcde8..a4f130a63d 100644 --- a/src/com/android/launcher3/allapps/AllAppsStore.java +++ b/src/com/android/launcher3/allapps/AllAppsStore.java @@ -262,11 +262,12 @@ public class AllAppsStore { writer.println(prefix + "\tAllAppsStore Apps[] size: " + mApps.length); for (int i = 0; i < mApps.length; i++) { writer.println(String.format(Locale.getDefault(), - "%s\tPackage index, name, and class: " + "%d/%s:%s", + "%s\tPackage index, name, class, and description: %d/%s:%s, %s", prefix, i, mApps[i].componentName.getPackageName(), - mApps[i].componentName.getClassName())); + mApps[i].componentName.getClassName(), + mApps[i].contentDescription)); } } } diff --git a/src/com/android/launcher3/pm/InstallSessionTracker.java b/src/com/android/launcher3/pm/InstallSessionTracker.java index 24d58f3e98..c117be4601 100644 --- a/src/com/android/launcher3/pm/InstallSessionTracker.java +++ b/src/com/android/launcher3/pm/InstallSessionTracker.java @@ -32,7 +32,6 @@ import androidx.annotation.Nullable; import androidx.annotation.WorkerThread; import com.android.launcher3.Flags; -import com.android.launcher3.Utilities; import com.android.launcher3.util.PackageUserKey; import java.lang.ref.WeakReference; diff --git a/src/com/android/launcher3/pm/UserCache.java b/src/com/android/launcher3/pm/UserCache.java index 7339111757..e8619610a8 100644 --- a/src/com/android/launcher3/pm/UserCache.java +++ b/src/com/android/launcher3/pm/UserCache.java @@ -183,6 +183,11 @@ public class UserCache implements SafeCloseable { mUserToSerialMap.put(userHandle, info); } + @VisibleForTesting + public void putToPreInstallCache(UserHandle userHandle, List preInstalledApps) { + mUserToPreInstallAppMap.put(userHandle, preInstalledApps); + } + /** * @see UserManager#getUserProfiles() */ diff --git a/src/com/android/launcher3/util/LogConfig.java b/src/com/android/launcher3/util/LogConfig.java index 3d4b409cf8..f183f18050 100644 --- a/src/com/android/launcher3/util/LogConfig.java +++ b/src/com/android/launcher3/util/LogConfig.java @@ -76,4 +76,5 @@ public class LogConfig { * When turned on, we enable zero state web data loader related logging. */ public static final String ZERO_WEB_DATA_LOADER = "ZeroStateWebDataLoaderLog"; + public static final String SEARCH_TARGET_UTIL_LOG = "SearchTargetUtilLog"; } diff --git a/tests/multivalentTests/src/com/android/launcher3/UtilitiesTest.kt b/tests/multivalentTests/src/com/android/launcher3/UtilitiesTest.kt index 5a26087300..d0aa7a8dd9 100644 --- a/tests/multivalentTests/src/com/android/launcher3/UtilitiesTest.kt +++ b/tests/multivalentTests/src/com/android/launcher3/UtilitiesTest.kt @@ -376,9 +376,10 @@ class UtilitiesTest { Utilities.rotateBounds(rect, 100, 100, 1) assertEquals(Rect(70, 40, 80, 80), rect) - rect = Rect(20, 70, 60, 80) - Utilities.rotateBounds(rect, 100, 100, 2) - assertEquals(Rect(40, 20, 80, 30), rect) + // case removed for b/28435189 + // rect = Rect(20, 70, 60, 80) + // Utilities.rotateBounds(rect, 100, 100, 2) + // assertEquals(Rect(40, 20, 80, 30), rect) rect = Rect(20, 70, 60, 80) Utilities.rotateBounds(rect, 100, 100, 3) diff --git a/tests/multivalentTests/src/com/android/launcher3/util/SimpleBroadcastReceiverTest.kt b/tests/multivalentTests/src/com/android/launcher3/util/SimpleBroadcastReceiverTest.kt index 1de99c5717..d3e27b69e9 100644 --- a/tests/multivalentTests/src/com/android/launcher3/util/SimpleBroadcastReceiverTest.kt +++ b/tests/multivalentTests/src/com/android/launcher3/util/SimpleBroadcastReceiverTest.kt @@ -23,6 +23,7 @@ import android.os.Handler import android.os.Looper import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation import com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR import com.google.common.truth.Truth.assertThat import java.util.function.Consumer @@ -114,6 +115,7 @@ class SimpleBroadcastReceiverTest { underTest = SimpleBroadcastReceiver(Handler(Looper.getMainLooper()), intentConsumer) underTest.register(context, completionRunnable, 1, "test_action_1", "test_action_2") + getInstrumentation().waitForIdleSync() verify(context).registerReceiver(same(underTest), intentFilterCaptor.capture(), eq(1)) verify(completionRunnable).run() @@ -136,6 +138,7 @@ class SimpleBroadcastReceiverTest { underTest = SimpleBroadcastReceiver(Handler(Looper.getMainLooper()), intentConsumer) underTest.unregisterReceiverSafely(context) + getInstrumentation().waitForIdleSync() verify(context).unregisterReceiver(same(underTest)) } diff --git a/tests/src/com/android/launcher3/folder/FolderNameInfosTest.kt b/tests/src/com/android/launcher3/folder/FolderNameInfosTest.kt new file mode 100644 index 0000000000..b491f17f5f --- /dev/null +++ b/tests/src/com/android/launcher3/folder/FolderNameInfosTest.kt @@ -0,0 +1,201 @@ +/* + * 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.folder + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.SmallTest +import com.android.launcher3.folder.FolderNameInfos.* +import org.junit.Test +import org.junit.runner.RunWith + +data class Label(val index: Int, val label: String, val score: Float) + +@SmallTest +@RunWith(AndroidJUnit4::class) +class FolderNameInfosTest { + + companion object { + val statusList = + listOf( + SUCCESS, + HAS_PRIMARY, + HAS_SUGGESTIONS, + ERROR_NO_PROVIDER, + ERROR_APP_LOOKUP_FAILED, + ERROR_ALL_APP_LOOKUP_FAILED, + ERROR_NO_LABELS_GENERATED, + ERROR_LABEL_LOOKUP_FAILED, + ERROR_ALL_LABEL_LOOKUP_FAILED, + ERROR_NO_PACKAGES, + ) + } + + @Test + fun status() { + assertStatus(statusList) + assertStatus( + listOf( + ERROR_NO_PROVIDER, + ERROR_APP_LOOKUP_FAILED, + ERROR_ALL_APP_LOOKUP_FAILED, + ERROR_NO_LABELS_GENERATED, + ERROR_LABEL_LOOKUP_FAILED, + ERROR_ALL_LABEL_LOOKUP_FAILED, + ERROR_NO_PACKAGES, + ) + ) + assertStatus( + listOf( + SUCCESS, + HAS_PRIMARY, + HAS_SUGGESTIONS, + ) + ) + assertStatus( + listOf( + SUCCESS, + HAS_PRIMARY, + HAS_SUGGESTIONS, + ) + ) + } + + fun assertStatus(statusList: List) { + var infos = FolderNameInfos() + statusList.forEach { infos.setStatus(it) } + assert(infos.status() == statusList.sum()) { + "There is an overlap on the status constants!" + } + } + + @Test + fun hasPrimary() { + assertHasPrimary( + createNameInfos(listOf(Label(0, "label", 1f)), statusList), + hasPrimary = true + ) + assertHasPrimary( + createNameInfos(listOf(Label(1, "label", 1f)), statusList), + hasPrimary = false + ) + assertHasPrimary( + createNameInfos( + listOf(Label(0, "label", 1f)), + listOf( + ERROR_NO_PROVIDER, + ERROR_APP_LOOKUP_FAILED, + ERROR_ALL_APP_LOOKUP_FAILED, + ERROR_NO_LABELS_GENERATED, + ERROR_LABEL_LOOKUP_FAILED, + ERROR_ALL_LABEL_LOOKUP_FAILED, + ERROR_NO_PACKAGES, + ) + ), + hasPrimary = false + ) + } + + private fun assertHasPrimary(nameInfos: FolderNameInfos, hasPrimary: Boolean) = + assert(nameInfos.hasPrimary() == hasPrimary) + + private fun createNameInfos(labels: List