Merge "Pass bubble flyout from wm shell to launcher" into main
diff --git a/aconfig/launcher_overview.aconfig b/aconfig/launcher_overview.aconfig
index 853faf8..c59978f 100644
--- a/aconfig/launcher_overview.aconfig
+++ b/aconfig/launcher_overview.aconfig
@@ -36,7 +36,7 @@
name: "enable_large_desktop_windowing_tile"
namespace: "launcher_overview"
description: "Makes the desktop tiles larger and moves them to the front of the list in Overview."
- bug: "353947137"
+ bug: "357860832"
}
flag {
diff --git a/go/quickstep/src/com/android/launcher3/AppSharing.java b/go/quickstep/src/com/android/launcher3/AppSharing.java
index e15b132..a97fecc 100644
--- a/go/quickstep/src/com/android/launcher3/AppSharing.java
+++ b/go/quickstep/src/com/android/launcher3/AppSharing.java
@@ -37,12 +37,13 @@
import androidx.core.content.FileProvider;
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.AppShareabilityChecker;
import com.android.launcher3.model.AppShareabilityJobService;
import com.android.launcher3.model.AppShareabilityManager;
import com.android.launcher3.model.AppShareabilityManager.ShareabilityStatus;
import com.android.launcher3.model.data.ItemInfo;
-import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.views.ActivityContext;
@@ -114,17 +115,17 @@
* The Share App system shortcut, used to initiate p2p sharing of a given app
*/
public final class Share extends SystemShortcut<Launcher> {
- private final PopupDataProvider mPopupDataProvider;
private final boolean mSharingEnabledForUser;
private final Set<View> mBoundViews = Collections.newSetFromMap(new WeakHashMap<>());
private boolean mIsEnabled = true;
+ private StatsLogManager mStatsLogManager;
public Share(Launcher target, ItemInfo itemInfo, View originalView) {
super(R.drawable.ic_share, R.string.app_share_drop_target_label, target, itemInfo,
originalView);
- mPopupDataProvider = target.getPopupDataProvider();
-
+ mStatsLogManager = ActivityContext.lookupContext(originalView.getContext())
+ .getStatsLogManager();
mSharingEnabledForUser = bluetoothSharingEnabled(target);
if (!mSharingEnabledForUser) {
setEnabled(false);
@@ -150,8 +151,7 @@
@Override
public void onClick(View view) {
- ActivityContext.lookupContext(view.getContext())
- .getStatsLogManager().logger().log(LAUNCHER_SYSTEM_SHORTCUT_APP_SHARE_TAP);
+ mStatsLogManager.logger().log(LAUNCHER_SYSTEM_SHORTCUT_APP_SHARE_TAP);
if (!mIsEnabled) {
showCannotShareToast(view.getContext());
return;
@@ -240,6 +240,11 @@
public boolean isEnabled() {
return mIsEnabled;
}
+
+ @VisibleForTesting
+ void setStatsLogManager(StatsLogManager statsLogManager) {
+ mStatsLogManager = statsLogManager;
+ }
}
/**
diff --git a/quickstep/res/values-en-rGB/strings.xml b/quickstep/res/values-en-rGB/strings.xml
index a74a17b..04b04dd 100644
--- a/quickstep/res/values-en-rGB/strings.xml
+++ b/quickstep/res/values-en-rGB/strings.xml
@@ -139,8 +139,7 @@
<string name="always_show_taskbar" msgid="3608801276107751229">"Always show Taskbar"</string>
<string name="change_navigation_mode" msgid="9088393078736808968">"Change navigation mode"</string>
<string name="taskbar_divider_a11y_title" msgid="6608690309720242080">"Taskbar divider"</string>
- <!-- no translation found for taskbar_overflow_a11y_title (7960342079198820179) -->
- <skip />
+ <string name="taskbar_overflow_a11y_title" msgid="7960342079198820179">"Taskbar overflow"</string>
<string name="move_drop_target_top_or_left" msgid="2988702185049595807">"Move to top/left"</string>
<string name="move_drop_target_bottom_or_right" msgid="5431393418797620162">"Move to bottom/right"</string>
<string name="quick_switch_overflow" msgid="3679780650881041632">"{count,plural, =1{more app}other{more apps}}"</string>
diff --git a/quickstep/src/com/android/launcher3/desktop/DesktopRecentsTransitionController.kt b/quickstep/src/com/android/launcher3/desktop/DesktopRecentsTransitionController.kt
index f7da34a..8b3a032 100644
--- a/quickstep/src/com/android/launcher3/desktop/DesktopRecentsTransitionController.kt
+++ b/quickstep/src/com/android/launcher3/desktop/DesktopRecentsTransitionController.kt
@@ -20,6 +20,7 @@
import android.os.RemoteException
import android.util.Log
import android.view.SurfaceControl
+import android.view.WindowManager.TRANSIT_TO_FRONT
import android.window.IRemoteTransitionFinishedCallback
import android.window.RemoteTransition
import android.window.RemoteTransitionStub
@@ -30,6 +31,7 @@
import com.android.quickstep.SystemUiProxy
import com.android.quickstep.TaskViewUtils
import com.android.quickstep.views.DesktopTaskView
+import com.android.window.flags.Flags
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource
import java.util.function.Consumer
@@ -38,14 +40,14 @@
private val stateManager: StateManager<*, *>,
private val systemUiProxy: SystemUiProxy,
private val appThread: IApplicationThread,
- private val depthController: DepthController?
+ private val depthController: DepthController?,
) {
/** Launch desktop tasks from recents view */
fun launchDesktopFromRecents(
desktopTaskView: DesktopTaskView,
animated: Boolean,
- callback: Consumer<Boolean>? = null
+ callback: Consumer<Boolean>? = null,
) {
val animRunner =
RemoteDesktopLaunchTransitionRunner(
@@ -53,7 +55,7 @@
animated,
stateManager,
depthController,
- callback
+ callback,
)
val transition = RemoteTransition(animRunner, appThread, "RecentsToDesktop")
systemUiProxy.showDesktopApps(desktopTaskView.display.displayId, transition)
@@ -69,14 +71,14 @@
private val animated: Boolean,
private val stateManager: StateManager<*, *>,
private val depthController: DepthController?,
- private val successCallback: Consumer<Boolean>?
+ private val successCallback: Consumer<Boolean>?,
) : RemoteTransitionStub() {
override fun startAnimation(
token: IBinder,
info: TransitionInfo,
t: SurfaceControl.Transaction,
- finishCallback: IRemoteTransitionFinishedCallback
+ finishCallback: IRemoteTransitionFinishedCallback,
) {
val errorHandlingFinishCallback = Runnable {
try {
@@ -86,6 +88,9 @@
}
}
+ if (Flags.enableDesktopWindowingPersistence()) {
+ handleAnimationAfterReboot(info)
+ }
MAIN_EXECUTOR.execute {
val animator =
TaskViewUtils.composeRecentsDesktopLaunchAnimator(
@@ -93,7 +98,7 @@
stateManager,
depthController,
info,
- t
+ t,
) {
errorHandlingFinishCallback.run()
successCallback?.accept(true)
@@ -104,6 +109,26 @@
animator.start()
}
}
+
+ /**
+ * Upon reboot the start bounds of a task is set to fullscreen with the recents transition.
+ * Check this case and set the start bounds to the end bounds so that the window doesn't
+ * jump from start bounds to end bounds during the animation. Tasks in desktop cannot
+ * normally have top bound as 0 due to status bar so this is a good indicator to identify
+ * reboot case.
+ */
+ private fun handleAnimationAfterReboot(info: TransitionInfo) {
+ info.changes.forEach { change ->
+ if (
+ change.mode == TRANSIT_TO_FRONT &&
+ change.taskInfo?.isFreeform == true &&
+ change.startAbsBounds.top == 0 &&
+ change.startAbsBounds.left == 0
+ ) {
+ change.setStartAbsBounds(change.endAbsBounds)
+ }
+ }
+ }
}
companion object {
diff --git a/quickstep/src/com/android/launcher3/proxy/ProxyActivityStarter.java b/quickstep/src/com/android/launcher3/proxy/ProxyActivityStarter.java
index 212a5ff..4293ccd 100644
--- a/quickstep/src/com/android/launcher3/proxy/ProxyActivityStarter.java
+++ b/quickstep/src/com/android/launcher3/proxy/ProxyActivityStarter.java
@@ -61,6 +61,7 @@
}
} catch (NullPointerException | ActivityNotFoundException | SecurityException
| SendIntentException e) {
+ Log.w(TAG, "Proxy activity starter could not start activity: ", e);
mParams.deliverResult(this, RESULT_CANCELED, null);
}
finishAndRemoveTask();
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index 895535e..d1725bc 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -406,6 +406,12 @@
}
};
mSeparateWindowParent.recreateControllers();
+ if (BubbleBarController.isBubbleBarEnabled()) {
+ mNavButtonsView.addOnLayoutChangeListener(
+ (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
+ onLayoutsUpdated()
+ );
+ }
}
private void initButtons(ViewGroup navContainer, ViewGroup endContainer,
@@ -1180,15 +1186,20 @@
/** Adjusts navigation buttons layout accordingly to the bubble bar position. */
@Override
public void onBubbleBarLocationUpdated(BubbleBarLocation location) {
- cancelExistingNavBarAnimation();
- mBubbleBarTargetLocation = location;
+ boolean locationUpdated = location != mBubbleBarTargetLocation;
+ if (locationUpdated) {
+ cancelExistingNavBarAnimation();
+ } else {
+ endExistingAnimation();
+ }
mNavButtonContainer.setTranslationX(getNavBarTranslationX(location));
- mNavButtonContainer.setAlpha(1);
+ mBubbleBarTargetLocation = location;
}
/** Animates navigation buttons accordingly to the bubble bar position. */
@Override
public void onBubbleBarLocationAnimated(BubbleBarLocation location) {
+ if (location == mBubbleBarTargetLocation) return;
cancelExistingNavBarAnimation();
mBubbleBarTargetLocation = location;
int finalX = getNavBarTranslationX(location);
@@ -1199,6 +1210,13 @@
mNavBarLocationAnimator.start();
}
+ private void endExistingAnimation() {
+ if (mNavBarLocationAnimator != null) {
+ mNavBarLocationAnimator.end();
+ mNavBarLocationAnimator = null;
+ }
+ }
+
private void cancelExistingNavBarAnimation() {
if (mNavBarLocationAnimator != null) {
mNavBarLocationAnimator.cancel();
@@ -1240,12 +1258,18 @@
}
/** Adjusts the navigation buttons layout position according to the bubble bar location. */
- public void onTaskbarLayoutChanged() {
- if (mControllers.taskbarViewController.getIconLayoutBounds().isEmpty()) return;
+ public void onLayoutsUpdated() {
+ // no need to do anything if on phone, or if taskbar or navbar views were not placed on
+ // screen.
+ if (mContext.getDeviceProfile().isPhone
+ || mControllers.taskbarViewController.getIconLayoutBounds().isEmpty()
+ || mNavButtonsView.getWidth() == 0) {
+ return;
+ }
if (enableBubbleBarInPersistentTaskBar()
&& mControllers.bubbleControllers.isPresent()) {
if (mBubbleBarTargetLocation == null) {
- // only set bubble bar location if it was not set before, e.g. at device boot
+ // only set bubble bar location if it was not set before
mBubbleBarTargetLocation = mControllers.bubbleControllers.get()
.bubbleBarViewController.getBubbleBarLocation();
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index a59445b..46d063b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -278,7 +278,10 @@
// If Bubble bar is present, TaskbarControllers depends on it so build it first.
Optional<BubbleControllers> bubbleControllersOptional = Optional.empty();
BubbleBarController.onTaskbarRecreated();
- if (BubbleBarController.isBubbleBarEnabled() && bubbleBarView != null) {
+ if (BubbleBarController.isBubbleBarEnabled()
+ && !mDeviceProfile.isPhone
+ && bubbleBarView != null
+ ) {
Optional<BubbleStashedHandleViewController> bubbleHandleController = Optional.empty();
Optional<BubbleBarSwipeController> bubbleBarSwipeController = Optional.empty();
if (isTransientTaskbar) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
index 5974675..219a24a 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
@@ -220,11 +220,12 @@
uiController = newUiController;
uiController.init(this);
uiController.updateStateForSysuiFlags(mSharedState.sysuiStateFlags);
- bubbleControllers.ifPresent(bubbleControllers -> {
+ // if bubble controllers are present take bubble bar location, else set it to null
+ bubbleControllers.ifPresentOrElse(bubbleControllers -> {
BubbleBarLocation location =
bubbleControllers.bubbleBarViewController.getBubbleBarLocation();
uiController.onBubbleBarLocationUpdated(location);
- });
+ }, () -> uiController.onBubbleBarLocationUpdated(null));
// Notify that the ui controller has changed
navbarButtonsViewController.onUiControllerChanged();
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 065646a..8a1d71a 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -24,6 +24,7 @@
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_OVERVIEW;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_FOR_BUBBLES;
+import static com.android.launcher3.taskbar.TaskbarStashController.UNLOCK_TRANSITION_MEMOIZATION_MS;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
import static com.android.launcher3.taskbar.bubbles.BubbleBarView.FADE_IN_ANIM_ALPHA_DURATION_MS;
import static com.android.launcher3.taskbar.bubbles.BubbleBarView.FADE_OUT_ANIM_POSITION_DURATION_MS;
@@ -57,6 +58,7 @@
import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.statemanager.StateManager;
+import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.BubbleLauncherState;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
@@ -167,7 +169,12 @@
private boolean mSkipNextRecentsAnimEnd;
// Time when FLAG_TASKBAR_HIDDEN was last cleared, SystemClock.elapsedRealtime (milliseconds).
- private long mLastUnlockTimeMs = 0;
+ private long mLastRemoveTaskbarHiddenTimeMs = 0;
+ /**
+ * Time when FLAG_DEVICE_LOCKED was last cleared, plus
+ * {@link TaskbarStashController#UNLOCK_TRANSITION_MEMOIZATION_MS}
+ */
+ private long mLastUnlockTransitionTimeout;
private @Nullable TaskBarRecentsAnimationListener mTaskBarRecentsAnimationListener;
@@ -473,8 +480,12 @@
boolean onOverview = mLauncherState == LauncherState.OVERVIEW;
boolean hotseatIconsVisible = isInLauncher && mLauncherState.areElementsVisible(
mLauncher, HOTSEAT_ICONS);
- controllers.bubbleStashController.setBubblesShowingOnHome(hotseatIconsVisible);
- controllers.bubbleStashController.setBubblesShowingOnOverview(onOverview);
+ BubbleLauncherState state = onOverview
+ ? BubbleLauncherState.OVERVIEW
+ : hotseatIconsVisible
+ ? BubbleLauncherState.HOME
+ : BubbleLauncherState.IN_APP;
+ controllers.bubbleStashController.setLauncherState(state);
});
TaskbarStashController stashController = mControllers.taskbarStashController;
@@ -535,7 +546,7 @@
if (hasAnyFlag(changedFlags, FLAG_TASKBAR_HIDDEN) && !hasAnyFlag(FLAG_TASKBAR_HIDDEN)) {
// Take note of the current time, as the taskbar is made visible again.
- mLastUnlockTimeMs = SystemClock.elapsedRealtime();
+ mLastRemoveTaskbarHiddenTimeMs = SystemClock.elapsedRealtime();
}
boolean isHidden = hasAnyFlag(FLAG_TASKBAR_HIDDEN);
@@ -561,7 +572,8 @@
// with a fingerprint reader. This should only be done when the device was woken
// up via fingerprint reader, however since this information is currently not
// available, opting to always delay the fade-in a bit.
- long durationSinceLastUnlockMs = SystemClock.elapsedRealtime() - mLastUnlockTimeMs;
+ long durationSinceLastUnlockMs = SystemClock.elapsedRealtime()
+ - mLastRemoveTaskbarHiddenTimeMs;
taskbarVisibility.setStartDelay(
Math.max(0, TASKBAR_SHOW_DELAY_MS - durationSinceLastUnlockMs));
}
@@ -631,6 +643,15 @@
boolean isUnlockTransition =
hasAnyFlag(changedFlags, FLAG_DEVICE_LOCKED) && !hasAnyFlag(FLAG_DEVICE_LOCKED);
if (isUnlockTransition) {
+ // the launcher might not be resumed at the time the device is considered
+ // unlocked (when the keyguard goes away), but possibly shortly afterwards.
+ // To play the unlock transition at the time the unstash animation actually happens,
+ // this memoizes the state transition for UNLOCK_TRANSITION_MEMOIZATION_MS.
+ mLastUnlockTransitionTimeout =
+ SystemClock.elapsedRealtime() + UNLOCK_TRANSITION_MEMOIZATION_MS;
+ }
+ boolean isInUnlockTimeout = SystemClock.elapsedRealtime() < mLastUnlockTransitionTimeout;
+ if (isUnlockTransition || isInUnlockTimeout) {
// When transitioning to unlocked, ensure the hotseat is fully visible from the
// beginning. The hotseat itself is animated by LauncherUnlockAnimationController.
mIconAlignment.cancelAnimation();
@@ -845,43 +866,49 @@
}
/** Updates launcher home screen appearance accordingly to the bubble bar location. */
- public void onBubbleBarLocationChanged(BubbleBarLocation location, boolean animate) {
- DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
- if (mBubbleBarLocation == location) return;
+ public void onBubbleBarLocationChanged(@Nullable BubbleBarLocation location, boolean animate) {
mBubbleBarLocation = location;
+ if (location == null) {
+ // bubble bar is not present, hence no location, resetting the hotseat
+ updateHotseatAndQsbTranslationX(0, animate);
+ mBubbleBarLocation = null;
+ return;
+ }
+ DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
if (!deviceProfile.shouldAdjustHotseatOnBubblesLocationUpdate(
mControllers.taskbarActivityContext)) {
return;
}
- int targetX = 0;
- if (mBubbleBarLocation != null) {
- boolean isBubblesOnLeft = location.isOnLeft(isRtl(mLauncher.getResources()));
- targetX = deviceProfile.getHotseatTranslationXForBubbleBar(/* isNavbarOnRight= */
- isBubblesOnLeft);
- }
+ boolean isBubblesOnLeft = location.isOnLeft(isRtl(mLauncher.getResources()));
+ int targetX = deviceProfile
+ .getHotseatTranslationXForBubbleBar(/* isNavbarOnRight= */ isBubblesOnLeft);
updateHotseatAndQsbTranslationX(targetX, animate);
}
+ /** Used to translate hotseat and QSB to make room for bubbles. */
private void updateHotseatAndQsbTranslationX(float targetValue, boolean animate) {
// cancel existing animation
if (mHotseatTranslationXAnimation != null) {
mHotseatTranslationXAnimation.cancel();
+ mHotseatTranslationXAnimation = null;
}
- Runnable alignTaskbar = new Runnable() {
+ Runnable postAnimationAction = new Runnable() {
@Override
public void run() {
+ mHotseatTranslationXAnimation = null;
// We only need to align the task bar when on launcher home screen
if (mControllers.taskbarStashController.isOnHome()) {
- DeviceProfile dp = mLauncher.getDeviceProfile();
- mControllers.taskbarViewController
- .setLauncherIconAlignment(/* alignmentRatio = */ 1, dp);
+ mControllers.taskbarViewController.setLauncherIconAlignment(
+ /* alignmentRatio = */ 1,
+ mLauncher.getDeviceProfile()
+ );
}
}
};
Hotseat hotseat = mLauncher.getHotseat();
AnimatorSet translationXAnimation = new AnimatorSet();
- MultiProperty iconsTranslationX = hotseat.getIconsTranslationX(
- Hotseat.ICONS_TRANSLATION_X_NAV_BAR_ALIGNMENT);
+ MultiProperty iconsTranslationX = mLauncher.getHotseat()
+ .getIconsTranslationX(Hotseat.ICONS_TRANSLATION_X_NAV_BAR_ALIGNMENT);
if (animate) {
translationXAnimation.playTogether(iconsTranslationX.animateToValue(targetValue));
} else {
@@ -900,18 +927,17 @@
}
}
if (!animate) {
- alignTaskbar.run();
+ postAnimationAction.run();
return;
}
mHotseatTranslationXAnimation = translationXAnimation;
translationXAnimation.setStartDelay(FADE_OUT_ANIM_POSITION_DURATION_MS);
translationXAnimation.setDuration(FADE_IN_ANIM_ALPHA_DURATION_MS);
translationXAnimation.setInterpolator(Interpolators.EMPHASIZED);
- translationXAnimation.addListener(AnimatorListeners.forEndCallback(alignTaskbar));
+ translationXAnimation.addListener(AnimatorListeners.forEndCallback(postAnimationAction));
translationXAnimation.start();
}
-
private final class TaskBarRecentsAnimationListener implements
RecentsAnimationCallbacks.RecentsAnimationListener {
private final RecentsAnimationCallbacks mCallbacks;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index 6222e53..8991965 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -191,7 +191,7 @@
// Duration for which an unlock event is considered "current", as other events are received
// asynchronously.
- private static final long UNLOCK_TRANSITION_MEMOIZATION_MS = 200;
+ public static final long UNLOCK_TRANSITION_MEMOIZATION_MS = 200;
/**
* The default stash animation, morphing the taskbar into the navbar.
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index b495e7d..21d0cda 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -159,7 +159,9 @@
private final View.OnLayoutChangeListener mTaskbarViewLayoutChangeListener =
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
updateTaskbarIconTranslationXForPinning();
- mControllers.navbarButtonsViewController.onTaskbarLayoutChanged();
+ if (BubbleBarController.isBubbleBarEnabled()) {
+ mControllers.navbarButtonsViewController.onLayoutsUpdated();
+ }
};
// Animation to align icons with Launcher, created lazily. This allows the controller to be
@@ -329,7 +331,8 @@
*/
public void setRecentsButtonDisabled(boolean isDisabled) {
// TODO: check TaskbarStashController#supportsStashing(), to stash instead of setting alpha.
- mTaskbarIconAlpha.get(ALPHA_INDEX_RECENTS_DISABLED).setValue(isDisabled ? 0 : 1);
+ mTaskbarIconAlpha.get(ALPHA_INDEX_RECENTS_DISABLED).animateToValue(isDisabled ? 0 : 1)
+ .start();
}
/**
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt
index f08318e..249773d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarBackground.kt
@@ -43,9 +43,10 @@
private val arrowTipRadius: Float
private val arrowVisibleHeight: Float
- private val shadowAlpha: Float
- private var shadowBlur = 0f
- private var keyShadowDistance = 0f
+ private val strokeAlpha: Int
+ private val shadowAlpha: Int
+ private val shadowBlur: Float
+ private val keyShadowDistance: Float
private var arrowHeightFraction = 1f
var arrowPositionX: Float = 0f
@@ -105,13 +106,13 @@
strokePaint.strokeWidth = res.getDimension(R.dimen.transient_taskbar_stroke_width)
// apply theme alpha attributes
if (Utilities.isDarkTheme(context)) {
- strokePaint.alpha = DARK_THEME_STROKE_ALPHA
+ strokeAlpha = DARK_THEME_STROKE_ALPHA
shadowAlpha = DARK_THEME_SHADOW_ALPHA
} else {
- strokePaint.alpha = LIGHT_THEME_STROKE_ALPHA
+ strokeAlpha = LIGHT_THEME_STROKE_ALPHA
shadowAlpha = LIGHT_THEME_SHADOW_ALPHA
}
-
+ strokePaint.alpha = strokeAlpha
shadowBlur = res.getDimension(R.dimen.transient_taskbar_shadow_blur)
keyShadowDistance = res.getDimension(R.dimen.transient_taskbar_key_shadow_distance)
arrowWidth = res.getDimension(R.dimen.bubblebar_pointer_width)
@@ -132,15 +133,14 @@
override fun draw(canvas: Canvas) {
canvas.save()
- // TODO (b/277359345): Should animate the alpha similar to taskbar (see TaskbarDragLayer)
// Draw shadows.
val newShadowAlpha =
- mapToRange(fillPaint.alpha.toFloat(), 0f, 255f, 0f, shadowAlpha, Interpolators.LINEAR)
+ mapToRange(fillPaint.alpha, 0, 255, 0, shadowAlpha, Interpolators.LINEAR)
fillPaint.setShadowLayer(
shadowBlur,
0f,
keyShadowDistance,
- setColorAlphaBound(Color.BLACK, Math.round(newShadowAlpha))
+ setColorAlphaBound(Color.BLACK, newShadowAlpha),
)
// Create background path
val backgroundPath = Path()
@@ -172,7 +172,7 @@
arrowWidth,
scaledHeight,
arrowTipRadius,
- arrowPath
+ arrowPath,
)
// flip it horizontally
val pathTransform = Matrix()
@@ -196,6 +196,7 @@
override fun setAlpha(alpha: Int) {
fillPaint.alpha = alpha
+ strokePaint.alpha = mapToRange(alpha, 0, 255, 0, strokeAlpha, Interpolators.LINEAR)
invalidateSelf()
}
@@ -237,7 +238,7 @@
companion object {
private const val DARK_THEME_STROKE_ALPHA = 51
private const val LIGHT_THEME_STROKE_ALPHA = 41
- private const val DARK_THEME_SHADOW_ALPHA = 51f
- private const val LIGHT_THEME_SHADOW_ALPHA = 25f
+ private const val DARK_THEME_SHADOW_ALPHA = 51
+ private const val LIGHT_THEME_SHADOW_ALPHA = 25
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
index 025c038..ba180a6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
@@ -675,7 +675,8 @@
// if the animation is suppressed, immediately stash or show the bubble bar to
// ensure they've been initialized.
if (mTaskbarStashController.isInApp()
- && mBubbleStashController.isTransientTaskBar()) {
+ && mBubbleStashController.isTransientTaskBar()
+ && mTaskbarStashController.isStashed()) {
mBubbleStashController.stashBubbleBarImmediate();
} else {
mBubbleStashController.showBubbleBarImmediate();
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutPositioner.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutPositioner.kt
index b8c1c7f..aa2555e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutPositioner.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutPositioner.kt
@@ -39,4 +39,13 @@
/** The color of the flyout when collapsed. */
val collapsedColor: Int
+
+ /** The elevation of the flyout when collapsed. */
+ val collapsedElevation: Float
+
+ /**
+ * The distance the flyout must pass from its collapsed position until it can start revealing
+ * the triangle.
+ */
+ val distanceToRevealTriangle: Float
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutView.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutView.kt
index 6723f57..8d84ddf 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutView.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutView.kt
@@ -40,8 +40,6 @@
ConstraintLayout(context) {
private companion object {
- // the minimum progress of the expansion animation before the triangle is made visible.
- const val MIN_EXPANSION_PROGRESS_FOR_TRIANGLE = 0.1f
// the minimum progress of the expansion animation before the content starts fading in.
const val MIN_EXPANSION_PROGRESS_FOR_CONTENT_ALPHA = 0.75f
}
@@ -92,6 +90,11 @@
context.resources.getDimensionPixelSize(R.dimen.bubblebar_flyout_max_width)
}
+ private val flyoutElevation by
+ lazy(LazyThreadSafetyMode.NONE) {
+ context.resources.getDimensionPixelSize(R.dimen.bubblebar_flyout_elevation).toFloat()
+ }
+
/** The bounds of the background rect. */
private val backgroundRect = RectF()
private val cornerRadius: Float
@@ -108,6 +111,10 @@
private var collapsedCornerRadius = 0f
/** The color of the flyout when collapsed. */
private var collapsedColor = 0
+ /** The elevation of the flyout when collapsed. */
+ private var collapsedElevation = 0f
+ /** The minimum progress of the expansion animation before the triangle is made visible. */
+ private var minExpansionProgressForTriangle = 0f
/** The corner radius of the background according to the progress of the animation. */
private val currentCornerRadius
@@ -141,8 +148,7 @@
val padding = context.resources.getDimensionPixelSize(R.dimen.bubblebar_flyout_padding)
// add extra padding to the bottom of the view to include the triangle
setPadding(padding, padding, padding, padding + triangleHeight - triangleOverlap)
- translationZ =
- context.resources.getDimensionPixelSize(R.dimen.bubblebar_flyout_elevation).toFloat()
+ translationZ = flyoutElevation
RoundedArrowDrawable.addDownPointingRoundedTriangleToPath(
triangleWidth.toFloat(),
@@ -182,6 +188,12 @@
collapsedSize = positioner.collapsedSize
collapsedCornerRadius = collapsedSize / 2
collapsedColor = positioner.collapsedColor
+ collapsedElevation = positioner.collapsedElevation
+
+ // calculate the expansion progress required before we start showing the triangle as part of
+ // the expansion animation
+ minExpansionProgressForTriangle =
+ positioner.distanceToRevealTriangle / tyToCollapsedPosition
// post the request to start the expand animation to the looper so the view can measure
// itself
@@ -240,6 +252,9 @@
message.alpha = alpha
avatar.alpha = alpha
+ translationZ =
+ collapsedElevation + (flyoutElevation - collapsedElevation) * expansionProgress
+
invalidate()
}
@@ -275,7 +290,7 @@
currentCornerRadius,
backgroundPaint,
)
- if (expansionProgress >= MIN_EXPANSION_PROGRESS_FOR_TRIANGLE) {
+ if (expansionProgress >= minExpansionProgressForTriangle) {
drawTriangle(canvas)
}
canvas.restore()
@@ -291,9 +306,20 @@
} else {
width - currentCornerRadius - triangleWidth
}
- // instead of scaling the triangle, increasingly reveal it from the background, starting
- // with half the size. this has the effect of the triangle scaling.
- val triangleY = height - triangleHeight - 0.5f * triangleHeight * (1 - expansionProgress)
+ // instead of scaling the triangle, increasingly reveal it from the background. this has the
+ // effect of the triangle scaling.
+
+ // the translation y of the triangle before we start revealing it. align its bottom with the
+ // bottom of the rect
+ val triangleYCollapsed = height - triangleHeight - (triangleHeight - triangleOverlap)
+ // the translation y of the triangle when it's fully revealed
+ val triangleYExpanded = height - triangleHeight
+ val interpolatedExpansion =
+ ((expansionProgress - minExpansionProgressForTriangle) /
+ (1 - minExpansionProgressForTriangle))
+ .coerceIn(0f, 1f)
+ val triangleY =
+ triangleYCollapsed + (triangleYExpanded - triangleYCollapsed) * interpolatedExpansion
canvas.translate(triangleX, triangleY)
canvas.drawPath(triangle, backgroundPaint)
triangleOutline.setPath(triangle)
@@ -309,7 +335,7 @@
currentCornerRadius,
Path.Direction.CW,
)
- if (expansionProgress >= MIN_EXPANSION_PROGRESS_FOR_TRIANGLE) {
+ if (expansionProgress >= minExpansionProgressForTriangle) {
path.addPath(triangleOutline.mPath)
}
outline.setPath(path)
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt
index 9721792..a78890b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/BubbleStashController.kt
@@ -56,14 +56,29 @@
fun runAfterInit(action: Runnable)
}
+ /** Launcher states bubbles cares about */
+ enum class BubbleLauncherState {
+ /* When launcher is in overview */
+ OVERVIEW,
+ /* When launcher is on home */
+ HOME,
+ /* We're in an app */
+ IN_APP,
+ }
+
+ /** The current launcher state */
+ var launcherState: BubbleLauncherState
+
/** Whether bubble bar is currently stashed */
val isStashed: Boolean
/** Whether launcher enters or exits the home page. */
- var isBubblesShowingOnHome: Boolean
+ val isBubblesShowingOnHome: Boolean
+ get() = launcherState == BubbleLauncherState.HOME
/** Whether launcher enters or exits the overview page. */
- var isBubblesShowingOnOverview: Boolean
+ val isBubblesShowingOnOverview: Boolean
+ get() = launcherState == BubbleLauncherState.OVERVIEW
/** Updated when sysui locked state changes, when locked, bubble bar is not shown. */
var isSysuiLocked: Boolean
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt
index 7d6f7ad..722dfe7 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashController.kt
@@ -26,6 +26,7 @@
import com.android.launcher3.taskbar.TaskbarInsetsController
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
import com.android.launcher3.taskbar.bubbles.BubbleStashedHandleViewController
+import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.BubbleLauncherState
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.Companion.BAR_STASH_DURATION
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.Companion.BAR_TRANSLATION_DURATION
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.ControllersAfterInitAction
@@ -45,29 +46,21 @@
private lateinit var bubbleBarScaleAnimator: AnimatedFloat
private lateinit var controllersAfterInitAction: ControllersAfterInitAction
- override var isBubblesShowingOnHome: Boolean = false
- set(onHome) {
- if (field == onHome) return
- field = onHome
+ override var launcherState: BubbleLauncherState = BubbleLauncherState.IN_APP
+ set(state) {
+ if (field == state) return
+ val transitionFromHome = field == BubbleLauncherState.HOME
+ field = state
if (!bubbleBarViewController.hasBubbles()) {
// if there are no bubbles, there's nothing to show, so just return.
return
}
- if (onHome) {
- // When transition to home we should show collapse the bubble bar
- updateExpandedState(expand = false)
- }
- animateBubbleBarY()
- bubbleBarViewController.onBubbleBarConfigurationChanged(/* animate= */ true)
- }
-
- override var isBubblesShowingOnOverview: Boolean = false
- set(onOverview) {
- if (field == onOverview) return
- field = onOverview
- if (!onOverview) {
- // When transition from overview we should show collapse the bubble bar
- updateExpandedState(expand = false)
+ // If we're transitioning anywhere, bubble bar should be collapsed
+ updateExpandedState(expand = false)
+ if (transitionFromHome || field == BubbleLauncherState.HOME) {
+ // If we're transitioning to or from home, animate the Y because we're in hotseat
+ // on home but in persistent taskbar elsewhere so the position is different.
+ animateBubbleBarY()
}
bubbleBarViewController.onBubbleBarConfigurationChanged(/* animate= */ true)
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt
index 74e3c00..fe3db30 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashController.kt
@@ -36,6 +36,7 @@
import com.android.launcher3.taskbar.TaskbarStashController.TRANSIENT_TASKBAR_STASH_ALPHA_DURATION
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
import com.android.launcher3.taskbar.bubbles.BubbleStashedHandleViewController
+import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.BubbleLauncherState
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.Companion.BAR_STASH_DURATION
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.Companion.BAR_TRANSLATION_DURATION
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.ControllersAfterInitAction
@@ -81,36 +82,26 @@
override var isStashed: Boolean = false
@VisibleForTesting set
- override var isBubblesShowingOnHome: Boolean = false
- set(onHome) {
- if (field == onHome) return
- field = onHome
+ override var launcherState: BubbleLauncherState = BubbleLauncherState.IN_APP
+ set(state) {
+ if (field == state) return
+ field = state
if (!bubbleBarViewController.hasBubbles()) {
// if there are no bubbles, there's nothing to show, so just return.
return
}
- if (onHome) {
- updateStashedAndExpandedState(stash = false, expand = false)
- // When transitioning from app to home we need to animate the bubble bar
+ if (field == BubbleLauncherState.HOME) {
+ // When to home we need to animate the bubble bar
// here to align with hotseat center.
animateBubbleBarYToHotseat()
- } else if (!bubbleBarViewController.isExpanded) {
- updateStashedAndExpandedState(stash = true, expand = false)
- }
- bubbleBarViewController.onBubbleBarConfigurationChanged(/* animate= */ true)
- }
-
- override var isBubblesShowingOnOverview: Boolean = false
- set(onOverview) {
- if (field == onOverview) return
- field = onOverview
- if (onOverview) {
+ } else if (field == BubbleLauncherState.OVERVIEW) {
// When transitioning to overview we need to animate the bubble bar to align with
// the taskbar bottom.
animateBubbleBarYToTaskbar()
- } else {
- updateStashedAndExpandedState(stash = true, expand = false)
}
+ // Only stash if we're in an app, otherwise we're in home or overview where we should
+ // be un-stashed
+ updateStashedAndExpandedState(field == BubbleLauncherState.IN_APP, expand = false)
bubbleBarViewController.onBubbleBarConfigurationChanged(/* animate= */ true)
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
index 235ec7b..111069f 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -155,6 +155,9 @@
0,
timings.getGridSlideSecondaryInterpolator());
+ mRecentsView.handleDesktopTaskInSplitSelectState(builder,
+ timings.getDesktopTaskFadeInterpolator());
+
if (!animate) {
AnimatorSet as = builder.buildAnim();
as.start();
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 9ad6b303..dc7ed24 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -1149,12 +1149,18 @@
if (endTarget != NEW_TASK) {
InteractionJankMonitorWrapper.cancel(Cuj.CUJ_LAUNCHER_QUICK_SWITCH);
+ } else {
+ InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_QUICK_SWITCH);
}
if (endTarget != HOME) {
InteractionJankMonitorWrapper.cancel(Cuj.CUJ_LAUNCHER_APP_CLOSE_TO_HOME);
+ } else {
+ InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_APP_CLOSE_TO_HOME);
}
if (endTarget != RECENTS) {
InteractionJankMonitorWrapper.cancel(Cuj.CUJ_LAUNCHER_APP_SWIPE_TO_RECENTS);
+ } else {
+ InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_APP_SWIPE_TO_RECENTS);
}
switch (endTarget) {
diff --git a/quickstep/src/com/android/quickstep/FocusState.kt b/quickstep/src/com/android/quickstep/FocusState.kt
new file mode 100644
index 0000000..ba3991f
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/FocusState.kt
@@ -0,0 +1,63 @@
+/*
+ * 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.os.RemoteException
+import android.util.Log
+import android.view.Display.DEFAULT_DISPLAY
+import com.android.launcher3.util.Executors
+import com.android.wm.shell.shared.IFocusTransitionListener.Stub
+import com.android.wm.shell.shared.IShellTransitions
+
+/** Class to track focus state of displays and windows */
+class FocusState {
+
+ var focusedDisplayId = DEFAULT_DISPLAY
+ private set
+
+ private var listeners = mutableSetOf<FocusChangeListener>()
+
+ fun addListener(l: FocusChangeListener) = listeners.add(l)
+
+ fun removeListener(l: FocusChangeListener) = listeners.remove(l)
+
+ fun init(transitions: IShellTransitions?) {
+ try {
+ transitions?.setFocusTransitionListener(
+ object : Stub() {
+ override fun onFocusedDisplayChanged(displayId: Int) {
+ Executors.MAIN_EXECUTOR.execute {
+ listeners.forEach { it.onFocusedDisplayChanged(displayId) }
+ }
+ }
+ }
+ )
+ } catch (e: RemoteException) {
+ Log.w(TAG, "Failed call setFocusTransitionListener", e)
+ }
+ }
+
+ interface FocusChangeListener {
+ fun onFocusedDisplayChanged(displayId: Int)
+ }
+
+ override fun toString() = "{FocusState focusedDisplayId=$focusedDisplayId}"
+
+ companion object {
+ private const val TAG = "FocusState"
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt b/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
index a33e5c0..461f963 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
@@ -27,6 +27,7 @@
import androidx.annotation.UiThread
import androidx.annotation.VisibleForTesting
import com.android.internal.jank.Cuj
+import com.android.launcher3.Flags.enableLargeDesktopWindowingTile
import com.android.launcher3.Flags.enableOverviewCommandHelperTimeout
import com.android.launcher3.PagedView
import com.android.launcher3.logger.LauncherAtom
@@ -215,13 +216,12 @@
}
}
TOGGLE -> {
- val taskView =
- if (recentsView.runningTaskView == null) {
- recentsView.getTaskViewAt(0)
- } else {
- recentsView.nextTaskView ?: recentsView.runningTaskView
- }
- launchTask(recentsView, taskView, command, onCallbackResult)
+ launchTask(
+ recentsView,
+ getNextToggledTaskView(recentsView),
+ command,
+ onCallbackResult,
+ )
}
HOME -> {
recentsView.startHome()
@@ -229,6 +229,27 @@
}
}
+ private fun getNextToggledTaskView(recentsView: RecentsView<*, *>): TaskView? {
+ // When running task view is null we return last large taskView - typically focusView when
+ // grid only is not enabled else last desktop task view.
+ return if (recentsView.runningTaskView == null) {
+ recentsView.lastLargeTaskView ?: recentsView.getTaskViewAt(0)
+ } else {
+ if (
+ enableLargeDesktopWindowingTile() &&
+ recentsView.getTaskViewCount() == recentsView.largeTilesCount &&
+ recentsView.runningTaskView === recentsView.lastLargeTaskView
+ ) {
+ // Enables the toggle when only large tiles are in recents view.
+ // We return previous because unlike small tiles, large tiles are always
+ // on the right hand side.
+ recentsView.previousTaskView ?: recentsView.runningTaskView
+ } else {
+ recentsView.nextTaskView ?: recentsView.runningTaskView
+ }
+ }
+ }
+
private fun launchTask(
recents: RecentsView<*, *>,
taskView: TaskView?,
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index 34435d5..a55cf18 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -161,6 +161,7 @@
private IRemoteAnimationRunner mBackToLauncherRunner;
private IDragAndDrop mDragAndDrop;
private final HomeVisibilityState mHomeVisibilityState = new HomeVisibilityState();
+ private final FocusState mFocusState = new FocusState();
// Used to dedupe calls to SystemUI
private int mLastShelfHeight;
@@ -300,6 +301,7 @@
registerSplitScreenListener(mSplitScreenListener);
registerSplitSelectListener(mSplitSelectListener);
mHomeVisibilityState.init(mShellTransitions);
+ mFocusState.init(mShellTransitions);
setStartingWindowListener(mStartingWindowListener);
setLauncherUnlockAnimationController(
mLauncherActivityClass, mLauncherUnlockAnimationController);
@@ -1144,6 +1146,10 @@
return mHomeVisibilityState;
}
+ public FocusState getFocusState() {
+ return mFocusState;
+ }
+
/**
* Returns a surface which can be used to attach overlays to home task or null if
* the task doesn't exist or sysui is not connected
@@ -1592,6 +1598,7 @@
pw.println("\tmOneHanded=" + mOneHanded);
pw.println("\tmShellTransitions=" + mShellTransitions);
pw.println("\tmHomeVisibilityState=" + mHomeVisibilityState);
+ pw.println("\tmFocusState=" + mFocusState);
pw.println("\tmStartingWindow=" + mStartingWindow);
pw.println("\tmStartingWindowListener=" + mStartingWindowListener);
pw.println("\tmSysuiUnlockAnimationController=" + mSysuiUnlockAnimationController);
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java
index 5ad55ae..49bff8d 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java
@@ -228,10 +228,13 @@
}
float velocityYPxPerS = mVelocityTracker.getYVelocity();
+ float dY = Math.abs(mLastPos.y - mDownPos.y);
if (mCanPlayTaskbarBgAlphaAnimation
&& mMotionMoveCount >= NUM_MOTION_MOVE_THRESHOLD // Arbitrary value
&& velocityYPxPerS != 0 // Ignore these
- && velocityYPxPerS >= mTaskbarSlowVelocityYThreshold) {
+ && velocityYPxPerS >= mTaskbarSlowVelocityYThreshold
+ && dY != 0
+ && dY > mTouchSlop) {
mTaskbarActivityContext.playTaskbarBackgroundAlphaAnimation();
mCanPlayTaskbarBgAlphaAnimation = false;
}
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialController.java b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
index 5028da4..9510a05 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialController.java
@@ -52,7 +52,6 @@
import androidx.annotation.StringRes;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.AlertDialog;
-import androidx.appcompat.content.res.AppCompatResources;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
@@ -610,8 +609,8 @@
private void updateDrawables() {
if (mContext != null) {
- mTutorialFragment.getRootView().setBackground(AppCompatResources.getDrawable(
- mContext, getMockWallpaperResId()));
+ mTutorialFragment.getRootView()
+ .setBackground(mContext.getDrawable(getMockWallpaperResId()));
mTutorialFragment.updateFeedbackAnimation();
mFakeLauncherView.setBackgroundColor(getFakeLauncherColor());
updateFakeViewLayout(mFakeHotseatView, getMockHotseatResId());
@@ -619,9 +618,7 @@
mFakeTaskView.animate().alpha(1).setListener(
AnimatorListeners.forSuccessCallback(() -> mFakeTaskView.animate().cancel()));
mFakePreviousTaskView.setFakeTaskViewFillColor(getMockPreviousAppTaskThumbnailColor());
- mFakeIconView.setBackground(AppCompatResources.getDrawable(
- mContext, getMockAppIconResId()));
-
+ mFakeIconView.setBackground(mContext.getDrawable(getMockAppIconResId()));
mExitingAppView.setBackgroundColor(getExitingAppColor());
mFakeTaskView.setBackgroundColor(getFakeTaskViewColor());
updateHotseatChildViewColor(mHotseatIconView);
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialStepIndicator.java b/quickstep/src/com/android/quickstep/interaction/TutorialStepIndicator.java
index ae0e725..f1fc179 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialStepIndicator.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialStepIndicator.java
@@ -22,8 +22,6 @@
import android.widget.ImageView;
import android.widget.LinearLayout;
-import androidx.appcompat.content.res.AppCompatResources;
-
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.icons.GraphicsUtils;
@@ -91,9 +89,8 @@
int inactiveStepIndicatorColor = GraphicsUtils.getAttrColor(
getContext(), android.R.attr.textColorSecondaryInverse);
for (int i = 0; i < mTotalSteps; i++) {
- Drawable pageIndicatorPillDrawable = AppCompatResources.getDrawable(
- getContext(), R.drawable.tutorial_step_indicator_pill);
-
+ Drawable pageIndicatorPillDrawable =
+ getContext().getDrawable(R.drawable.tutorial_step_indicator_pill);
if (i >= getChildCount()) {
ImageView pageIndicatorPill = new ImageView(getContext());
pageIndicatorPill.setImageDrawable(pageIndicatorPillDrawable);
diff --git a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt
index aa0fd88..c3b072d 100644
--- a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt
+++ b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt
@@ -73,9 +73,21 @@
* Returns the first TaskView that should be displayed as a large tile.
*
* @param taskViews List of [TaskView]s
+ * @param splitSelectActive current split state
*/
- fun getFirstLargeTaskView(taskViews: Iterable<TaskView>): TaskView? =
- taskViews.firstOrNull { it.isLargeTile }
+ fun getFirstLargeTaskView(
+ taskViews: MutableIterable<TaskView>,
+ splitSelectActive: Boolean,
+ ): TaskView? =
+ taskViews.firstOrNull { it.isLargeTile && !(splitSelectActive && it is DesktopTaskView) }
+
+ /**
+ * Returns the first TaskView that is not large
+ *
+ * @param taskViews List of [TaskView]s
+ */
+ fun getFirstSmallTaskView(taskViews: MutableIterable<TaskView>): TaskView? =
+ taskViews.firstOrNull { !it.isLargeTile }
/** Returns the last TaskView that should be displayed as a large tile. */
fun getLastLargeTaskView(taskViews: Iterable<TaskView>): TaskView? =
@@ -101,6 +113,12 @@
it.isVisibleInCarousel(runningTaskView, nonRunningTaskCarouselHidden)
}
+ /** Returns if any small tasks are fully visible */
+ fun isAnySmallTaskFullyVisible(
+ taskViews: Iterable<TaskView>,
+ isTaskViewFullyVisible: (TaskView) -> Boolean,
+ ): Boolean = taskViews.any { !it.isLargeTile && isTaskViewFullyVisible(it) }
+
/** Returns the current list of [TaskView] children. */
fun getTaskViews(taskViewCount: Int, requireTaskViewAt: (Int) -> TaskView): Iterable<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 3449cf2..f708f4b 100644
--- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
+++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
@@ -238,7 +238,7 @@
taskViewHeight,
)
val snapshotViewSize =
- if (isPrimaryTaskSplitting) primarySnapshotViewSize else secondarySnapshotViewSize
+ if (isPrimaryTaskSplitting) secondarySnapshotViewSize else primarySnapshotViewSize
if (deviceProfile.isLeftRightSplit) {
// Center view first so scaling happens uniformly, alternatively we can move pivotX to 0
val centerThumbnailTranslationX: Float = (taskViewWidth - snapshotViewSize.x) / 2f
diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationTimings.java b/quickstep/src/com/android/quickstep/util/SplitAnimationTimings.java
index b618546..90569b4 100644
--- a/quickstep/src/com/android/quickstep/util/SplitAnimationTimings.java
+++ b/quickstep/src/com/android/quickstep/util/SplitAnimationTimings.java
@@ -105,6 +105,10 @@
default Interpolator getGridSlidePrimaryInterpolator() { return LINEAR; }
default Interpolator getGridSlideSecondaryInterpolator() { return LINEAR; }
+ default Interpolator getDesktopTaskFadeInterpolator() {
+ return LINEAR;
+ }
+
// Defaults for HomeToSplit
default float getScrimFadeInStartOffset() { return 0; }
default float getScrimFadeInEndOffset() { return 0; }
diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
index 60c6ade..511c989 100644
--- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
+++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
@@ -77,6 +77,7 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.statemanager.StateManager;
+import com.android.launcher3.taskbar.LauncherTaskbarUIController;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.uioverrides.QuickstepLauncher;
@@ -743,6 +744,7 @@
*/
public void resetState() {
mSplitSelectDataHolder.resetState();
+ mContainer.<RecentsView>getOverviewPanel().resetDesktopTaskFromSplitSelectState();
dispatchOnSplitSelectionExit();
mRecentsAnimationRunning = false;
mLaunchingTaskView = null;
@@ -942,7 +944,16 @@
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
- controller.finish(true /* toRecents */, null /* onFinishComplete */,
+ controller.finish(
+ true /* toRecents */,
+ () -> {
+ LauncherTaskbarUIController controller =
+ mLauncher.getTaskbarUIController();
+ if (controller != null) {
+ controller.updateTaskbarLauncherStateGoingHome();
+ }
+
+ },
false /* sendUserLeaveHint */);
}
@Override
@@ -950,7 +961,16 @@
SystemUiProxy.INSTANCE.get(mLauncher.getApplicationContext())
.onDesktopSplitSelectAnimComplete(mTaskInfo);
}
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ mLauncher.getDragLayer().removeView(floatingTaskView);
+ getSplitAnimationController()
+ .removeSplitInstructionsView(mLauncher);
+ resetState();
+ }
});
+ anim.add(getSplitAnimationController()
+ .getShowSplitInstructionsAnim(mLauncher).buildAnim());
anim.buildAnim().start();
}
}
diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
index c7777d8..f5be103 100644
--- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
+++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
@@ -305,6 +305,14 @@
}
/**
+ * Override the pivot used to apply scale changes.
+ */
+ public void setPivotOverride(PointF pivotOverride) {
+ mPivotOverride = pivotOverride;
+ getFullScreenScale();
+ }
+
+ /**
* Adds animation for all the components corresponding to transition from an app to overview.
*/
public void addAppToOverviewAnim(PendingAnimation pa, Interpolator interpolator) {
diff --git a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
index bdca596..b719ee5 100644
--- a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
+++ b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java
@@ -18,6 +18,7 @@
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.annotation.TargetApi;
+import android.app.TaskInfo;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.RectF;
@@ -333,11 +334,16 @@
* context's theme background color.
*/
public static int getDefaultBackgroundColor(
- Context context, RemoteAnimationTarget target) {
- return (target != null && target.taskInfo != null
- && target.taskInfo.taskDescription != null)
- ? target.taskInfo.taskDescription.getBackgroundColor()
- : Themes.getColorBackground(context);
+ Context context, @Nullable RemoteAnimationTarget target) {
+ final int fallbackColor = Themes.getColorBackground(context);
+ if (target == null) {
+ return fallbackColor;
+ }
+ final TaskInfo taskInfo = target.taskInfo;
+ if (taskInfo == null) {
+ return fallbackColor;
+ }
+ return taskInfo.taskDescription.getBackgroundColor();
}
private static void getRelativePosition(View descendant, View ancestor, RectF position) {
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index a075c58..c405080 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1706,10 +1706,11 @@
return;
}
TaskView taskView = getTaskViewAt(mNextPage);
- // Snap to fully visible focused task and clear all button.
boolean shouldSnapToLargeTask = taskView != null && taskView.isLargeTile()
- && isTaskViewFullyVisible(taskView);
+ && !mUtils.isAnySmallTaskFullyVisible(getTaskViews(),
+ this::isTaskViewFullyVisible);
boolean shouldSnapToClearAll = mNextPage == indexOfChild(mClearAllButton);
+ // Snap to large tile when grid tasks aren't fully visible or the clear all button.
if (!shouldSnapToLargeTask && !shouldSnapToClearAll) {
return;
}
@@ -3140,7 +3141,9 @@
// Horizontal grid translation for each task
float[] gridTranslations = new float[taskCount];
- int focusedTaskIndex = Integer.MAX_VALUE;
+ TaskView lastLargeTaskView = mUtils.getLastLargeTaskView(getTaskViews());
+ int lastLargeTaskIndex =
+ (lastLargeTaskView == null) ? Integer.MAX_VALUE : indexOfChild(lastLargeTaskView);
Set<Integer> largeTasksIndices = new HashSet<>();
int focusedTaskShift = 0;
int largeTaskWidthAndSpacing = 0;
@@ -3163,8 +3166,12 @@
boolean isLargeTile = taskView.isLargeTile();
if (isLargeTile) {
- topRowWidth += taskWidthAndSpacing;
- bottomRowWidth += taskWidthAndSpacing;
+ // DesktopTaskView`s are hidden during split select state, so we shouldn't count
+ // them when calculating row width.
+ if (!(taskView instanceof DesktopTaskView && isSplitSelectionActive())) {
+ topRowWidth += taskWidthAndSpacing;
+ bottomRowWidth += taskWidthAndSpacing;
+ }
gridTranslations[i] += focusedTaskShift;
gridTranslations[i] += mIsRtl ? taskWidthAndSpacing : -taskWidthAndSpacing;
@@ -3172,9 +3179,6 @@
taskView.setGridTranslationY((mLastComputedTaskSize.height() + taskTopMargin
- taskView.getLayoutParams().height) / 2f);
- if (taskView.getTaskViewId() == mFocusedTaskViewId) {
- focusedTaskIndex = i;
- }
largeTasksIndices.add(i);
largeTaskWidthAndSpacing = taskWidthAndSpacing;
@@ -3183,8 +3187,8 @@
snappedTaskRowWidth = taskWidthAndSpacing;
}
} else {
- if (i > focusedTaskIndex) {
- // For tasks after the focused task, shift by focused task's width and spacing.
+ if (i > lastLargeTaskIndex) {
+ // For tasks after the last large task, shift by large task's width and spacing.
gridTranslations[i] +=
mIsRtl ? largeTaskWidthAndSpacing : -largeTaskWidthAndSpacing;
} else {
@@ -3609,10 +3613,10 @@
float dismissedTaskWidth = 0;
float nextFocusedTaskWidth = 0;
- // Non-grid specific properties.
int[] oldScroll = new int[count];
int[] newScroll = new int[count];
int scrollDiffPerPage = 0;
+ // Non-grid specific properties.
boolean needsCurveUpdates = false;
if (showAsGrid) {
@@ -3642,13 +3646,13 @@
}
}
}
- } else {
- getPageScrolls(oldScroll, false, SIMPLE_SCROLL_LOGIC);
- getPageScrolls(newScroll, false,
- v -> v.getVisibility() != GONE && v != dismissedTaskView);
- if (count > 1) {
- scrollDiffPerPage = Math.abs(oldScroll[1] - oldScroll[0]);
- }
+ }
+
+ getPageScrolls(oldScroll, false, SIMPLE_SCROLL_LOGIC);
+ getPageScrolls(newScroll, false,
+ v -> v.getVisibility() != GONE && v != dismissedTaskView);
+ if (count > 1) {
+ scrollDiffPerPage = Math.abs(oldScroll[1] - oldScroll[0]);
}
float dismissTranslationInterpolationEnd = 1;
@@ -3800,7 +3804,9 @@
addDismissedTaskAnimations(dismissedTaskView, duration, anim);
}
}
- } else if (!showAsGrid) {
+ } else if (!showAsGrid || (enableLargeDesktopWindowingTile()
+ && dismissedTaskView.isLargeTile()
+ && nextFocusedTaskView == null)) {
int offset = getOffsetToDismissedTask(scrollDiffPerPage, dismissedIndex, taskCount);
int scrollDiff = newScroll[i] - oldScroll[i] + offset;
if (scrollDiff != 0) {
@@ -3812,18 +3818,16 @@
splitTimings);
needsCurveUpdates = true;
}
- } else if (child instanceof TaskView) {
- TaskView taskView = (TaskView) child;
+ } else if (child instanceof TaskView taskView) {
if (isFocusedTaskDismissed) {
if (nextFocusedTaskView != null &&
!isSameGridRow(taskView, nextFocusedTaskView)) {
continue;
}
- } else {
- if (i < dismissedIndex || !isSameGridRow(taskView, dismissedTaskView)) {
- continue;
- }
+ } else if (i < dismissedIndex || !isSameGridRow(taskView, dismissedTaskView)) {
+ continue;
}
+
// Animate task with index >= dismissed index and in the same row as the
// dismissed index or next focused index. Offset successive task dismissal
// durations for a staggered effect.
@@ -4134,15 +4138,18 @@
* - Dragging an adjacent page on the left side (right side for RTL)
*/
private int getOffsetToDismissedTask(int scrollDiffPerPage, int dismissedIndex, int taskCount) {
+ // When mCurrentPage is ClearAllButton, use the last TaskView instead to calculate
+ // offset.
+ int currentPage = mCurrentPage == taskCount ? taskCount - 1 : mCurrentPage;
int offset = mIsRtl ? scrollDiffPerPage : 0;
- if (mCurrentPage == dismissedIndex) {
+ if (currentPage == dismissedIndex) {
int lastPage = taskCount - 1;
- if (mCurrentPage == lastPage) {
+ if (currentPage == lastPage) {
offset += mIsRtl ? -scrollDiffPerPage : scrollDiffPerPage;
}
} else {
// Dismissing an adjacent page.
- int negativeAdjacent = mCurrentPage - 1; // (Right in RTL, left in LTR)
+ int negativeAdjacent = currentPage - 1; // (Right in RTL, left in LTR)
if (dismissedIndex == negativeAdjacent) {
offset += mIsRtl ? -scrollDiffPerPage : scrollDiffPerPage;
}
@@ -4566,6 +4573,20 @@
}
@Nullable
+ public TaskView getPreviousTaskView() {
+ return getTaskViewAt(getRunningTaskIndex() - 1);
+ }
+
+ @Nullable
+ public TaskView getLastLargeTaskView() {
+ return mUtils.getLastLargeTaskView(getTaskViews());
+ }
+
+ public int getLargeTilesCount() {
+ return mUtils.getLargeTileCount(getTaskViews());
+ }
+
+ @Nullable
public TaskView getCurrentPageTaskView() {
return getTaskViewAt(getCurrentPage());
}
@@ -5024,6 +5045,35 @@
}
/**
+ * Animate DesktopTaskView(s) to hide in split select
+ */
+ public void handleDesktopTaskInSplitSelectState(PendingAnimation builder,
+ Interpolator deskTopFadeInterPolator) {
+ if (enableLargeDesktopWindowingTile()) {
+ for (TaskView taskView : getTaskViews()) {
+ if (taskView instanceof DesktopTaskView) {
+ builder.addFloat(taskView.getSplitAlphaProperty(),
+ MULTI_PROPERTY_VALUE, 1f, 0f,
+ deskTopFadeInterPolator);
+ }
+ }
+ }
+ }
+
+ /**
+ * While exiting from split mode, show all existing DesktopTaskViews.
+ */
+ public void resetDesktopTaskFromSplitSelectState() {
+ if (enableLargeDesktopWindowingTile()) {
+ for (TaskView taskView : getTaskViews()) {
+ if (taskView instanceof DesktopTaskView) {
+ taskView.setSplitAlpha(1f);
+ }
+ }
+ }
+ }
+
+ /**
* Modifies a PendingAnimation with the animations for entering split staging
*/
public void createSplitSelectInitAnimation(PendingAnimation builder, int duration) {
@@ -5369,6 +5419,7 @@
int taskIndex = indexOfChild(taskView);
int centerTaskIndex = getCurrentPage();
+ boolean isRunningTask = taskView.isRunningTask();
float toScale = getMaxScaleForFullScreen();
boolean showAsGrid = showAsGrid();
@@ -5387,6 +5438,16 @@
mTempPointF);
setPivotX(mTempPointF.x);
setPivotY(mTempPointF.y);
+
+ if (!isRunningTask) {
+ runActionOnRemoteHandles(
+ remoteTargetHandle -> {
+ remoteTargetHandle.getTaskViewSimulator().setPivotOverride(
+ mTempPointF);
+ remoteTargetHandle.getTaskViewSimulator().setDrawsBelowRecents(
+ false);
+ });
+ }
}
});
} else if (!showAsGrid) {
@@ -5857,11 +5918,12 @@
if (mShowAsGridLastOnLayout) {
// For grid Overview, it always start if a large tile (focused task or desktop task) if
// they exist, otherwise it start with the first task.
- TaskView firstLargeTaskView = mUtils.getFirstLargeTaskView(getTaskViews());
+ TaskView firstLargeTaskView = mUtils.getFirstLargeTaskView(getTaskViews(),
+ isSplitSelectionActive());
if (firstLargeTaskView != null) {
firstView = firstLargeTaskView;
} else {
- firstView = getTaskViewAt(0);
+ firstView = mUtils.getFirstSmallTaskView(getTaskViews());
}
} else {
firstView = mUtils.getFirstTaskViewInCarousel(
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt
index f513a82..cc64dba 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskView.kt
@@ -402,6 +402,15 @@
}
get() = taskViewAlpha.get(ALPHA_INDEX_ATTACH).value
+ var splitAlpha
+ set(value) {
+ splitAlphaProperty.value = value
+ }
+ get() = splitAlphaProperty.value
+
+ val splitAlphaProperty: MultiPropertyFactory<View>.MultiProperty
+ get() = taskViewAlpha.get(ALPHA_INDEX_SPLIT)
+
protected var shouldShowScreenshot = false
get() = !isRunningTask || field
private set
@@ -606,6 +615,7 @@
override fun onRecycle() {
resetPersistentViewTransforms()
attachAlpha = 1f
+ splitAlpha = 1f
// Clear any references to the thumbnail (it will be re-read either from the cache or the
// system on next bind)
if (!enableRefactorTaskThumbnail()) {
@@ -1687,8 +1697,9 @@
private const val ALPHA_INDEX_STABLE = 0
private const val ALPHA_INDEX_ATTACH = 1
+ private const val ALPHA_INDEX_SPLIT = 2
- private const val NUM_ALPHA_CHANNELS = 2
+ private const val NUM_ALPHA_CHANNELS = 3
/** The maximum amount that a task view can be scrimmed, dimmed or tinted. */
const val MAX_PAGE_SCRIM_ALPHA = 0.4f
diff --git a/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutViewScreenshotTest.kt b/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutViewScreenshotTest.kt
index 50e2dcf..6aba6a3 100644
--- a/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutViewScreenshotTest.kt
+++ b/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutViewScreenshotTest.kt
@@ -224,7 +224,7 @@
BubbleBarFlyoutMessage(
senderAvatar = ColorDrawable(Color.RED),
senderName = "sender",
- message = "collapsed 90% on left",
+ message = "expanded 90% on left",
isGroupChat = true,
)
) {}
@@ -249,7 +249,7 @@
BubbleBarFlyoutMessage(
senderAvatar = ColorDrawable(Color.RED),
senderName = "sender",
- message = "collapsed 80% on right",
+ message = "expanded 80% on right",
isGroupChat = true,
)
) {}
@@ -265,5 +265,7 @@
override val targetTy = 0f
override val collapsedSize = 30f
override val collapsedColor = Color.BLUE
+ override val collapsedElevation = 1f
+ override val distanceToRevealTriangle = 10f
}
}
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarStashControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarStashControllerTest.kt
index e736446..d7ce4ed 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarStashControllerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarStashControllerTest.kt
@@ -35,7 +35,8 @@
import com.android.launcher3.taskbar.TaskbarStashController.TRANSIENT_TASKBAR_STASH_ALPHA_DURATION
import com.android.launcher3.taskbar.TaskbarStashController.TRANSIENT_TASKBAR_STASH_DURATION
import com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_STASH
-import com.android.launcher3.taskbar.bubbles.BubbleControllers
+import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
+import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController
import com.android.launcher3.taskbar.rules.TaskbarModeRule
import com.android.launcher3.taskbar.rules.TaskbarModeRule.Mode.PINNED
import com.android.launcher3.taskbar.rules.TaskbarModeRule.Mode.THREE_BUTTONS
@@ -52,7 +53,6 @@
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SHOWING
import com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_BAR
import com.google.common.truth.Truth.assertThat
-import java.util.Optional
import org.junit.After
import org.junit.Before
import org.junit.Rule
@@ -60,6 +60,7 @@
import org.junit.runner.RunWith
@RunWith(LauncherMultivalentJUnit::class)
+@EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
@EmulatedDevices(["pixelTablet2023"])
class TaskbarStashControllerTest {
private val context = TaskbarWindowSandboxContext.create(getInstrumentation().targetContext)
@@ -74,7 +75,8 @@
@InjectController lateinit var stashedHandleViewController: StashedHandleViewController
@InjectController lateinit var dragLayerController: TaskbarDragLayerController
@InjectController lateinit var autohideSuspendController: TaskbarAutohideSuspendController
- @InjectController lateinit var bubbleControllers: Optional<BubbleControllers>
+ @InjectController lateinit var bubbleBarViewController: BubbleBarViewController
+ @InjectController lateinit var bubbleStashController: BubbleStashController
private val activityContext by taskbarUnitTestRule::activityContext
@@ -420,60 +422,55 @@
}
@Test
- @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
@TaskbarMode(TRANSIENT)
fun testUpdateAndAnimateTransientTaskbar_unstashTaskbarWithBubbles_bubbleBarUnstashes() {
getInstrumentation().runOnMainSync {
- bubbleControllers.get().bubbleBarViewController.setHiddenForBubbles(false)
- bubbleControllers.get().bubbleStashController.stashBubbleBarImmediate()
+ bubbleBarViewController.setHiddenForBubbles(false)
+ bubbleStashController.stashBubbleBarImmediate()
stashController.updateAndAnimateTransientTaskbar(false, true)
}
- assertThat(bubbleControllers.get().bubbleStashController.isStashed).isFalse()
+ assertThat(bubbleStashController.isStashed).isFalse()
}
@Test
- @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
@TaskbarMode(TRANSIENT)
fun testUpdateAndAnimateTransientTaskbar_unstashTaskbarWithoutBubbles_bubbleBarStashed() {
getInstrumentation().runOnMainSync {
- bubbleControllers.get().bubbleBarViewController.setHiddenForBubbles(false)
- bubbleControllers.get().bubbleStashController.stashBubbleBarImmediate()
+ bubbleBarViewController.setHiddenForBubbles(false)
+ bubbleStashController.stashBubbleBarImmediate()
stashController.updateAndAnimateTransientTaskbar(false, false)
}
- assertThat(bubbleControllers.get().bubbleStashController.isStashed).isTrue()
+ assertThat(bubbleStashController.isStashed).isTrue()
}
@Test
- @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
@TaskbarMode(TRANSIENT)
fun testUpdateAndAnimateTransientTaskbar_stashTaskbarWithBubbles_bubbleBarStashes() {
getInstrumentation().runOnMainSync {
- bubbleControllers.get().bubbleBarViewController.setHiddenForBubbles(false)
- bubbleControllers.get().bubbleStashController.showBubbleBarImmediate()
+ bubbleBarViewController.setHiddenForBubbles(false)
+ bubbleStashController.showBubbleBarImmediate()
stashController.updateAndAnimateTransientTaskbar(true, true)
}
- assertThat(bubbleControllers.get().bubbleStashController.isStashed).isTrue()
+ assertThat(bubbleStashController.isStashed).isTrue()
}
@Test
- @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
@TaskbarMode(TRANSIENT)
fun testUpdateAndAnimateTransientTaskbar_stashTaskbarWithoutBubbles_bubbleBarUnstashed() {
getInstrumentation().runOnMainSync {
- bubbleControllers.get().bubbleBarViewController.setHiddenForBubbles(false)
- bubbleControllers.get().bubbleStashController.showBubbleBarImmediate()
+ bubbleBarViewController.setHiddenForBubbles(false)
+ bubbleStashController.showBubbleBarImmediate()
stashController.updateAndAnimateTransientTaskbar(true, false)
}
- assertThat(bubbleControllers.get().bubbleStashController.isStashed).isFalse()
+ assertThat(bubbleStashController.isStashed).isFalse()
}
@Test
- @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
@TaskbarMode(TRANSIENT)
fun testUpdateAndAnimateTransientTaskbar_bubbleBarExpandedBeforeTimeout_expandedAfterwards() {
getInstrumentation().runOnMainSync {
- bubbleControllers.get().bubbleBarViewController.setHiddenForBubbles(false)
- bubbleControllers.get().bubbleBarViewController.isExpanded = true
+ bubbleBarViewController.setHiddenForBubbles(false)
+ bubbleBarViewController.isExpanded = true
stashController.updateAndAnimateTransientTaskbar(false)
animatorTestRule.advanceTimeBy(stashController.stashDuration)
}
@@ -483,7 +480,7 @@
stashController.timeoutAlarm.finishAlarm()
animatorTestRule.advanceTimeBy(stashController.stashDuration)
}
- assertThat(bubbleControllers.get().bubbleBarViewController.isExpanded).isTrue()
+ assertThat(bubbleBarViewController.isExpanded).isTrue()
}
@Test
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutControllerTest.kt
index 0f02444..d857ae5 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutControllerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutControllerTest.kt
@@ -55,6 +55,8 @@
override val distanceToCollapsedPosition = PointF(100f, 200f)
override val collapsedSize = 30f
override val collapsedColor = Color.BLUE
+ override val collapsedElevation = 1f
+ override val distanceToRevealTriangle = 50f
}
flyoutController = BubbleBarFlyoutController(flyoutContainer, positioner)
}
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt
index 4106a2c..5dc78a9 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt
@@ -27,6 +27,7 @@
import com.android.launcher3.taskbar.TaskbarInsetsController
import com.android.launcher3.taskbar.bubbles.BubbleBarView
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
+import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.BubbleLauncherState
import com.android.launcher3.util.MultiValueAlpha
import com.google.common.truth.Truth.assertThat
import org.junit.Before
@@ -85,12 +86,12 @@
fun setBubblesShowingOnHomeUpdatedToFalse_barPositionYUpdated_controllersNotified() {
// Given bubble bar is on home and has bubbles
whenever(bubbleBarViewController.hasBubbles()).thenReturn(false)
- persistentTaskBarStashController.isBubblesShowingOnHome = true
+ persistentTaskBarStashController.launcherState = BubbleLauncherState.HOME
whenever(bubbleBarViewController.hasBubbles()).thenReturn(true)
// When switch out of the home screen
getInstrumentation().runOnMainSync {
- persistentTaskBarStashController.isBubblesShowingOnHome = false
+ persistentTaskBarStashController.launcherState = BubbleLauncherState.IN_APP
}
// Then translation Y is animating and the bubble bar controller is notified
@@ -110,7 +111,7 @@
// When switch to home screen
getInstrumentation().runOnMainSync {
- persistentTaskBarStashController.isBubblesShowingOnHome = true
+ persistentTaskBarStashController.launcherState = BubbleLauncherState.HOME
}
// Then translation Y is animating and the bubble bar controller is notified
@@ -127,11 +128,11 @@
@Test
fun setBubblesShowingOnOverviewUpdatedToFalse_controllersNotified() {
// Given bubble bar is on overview
- persistentTaskBarStashController.isBubblesShowingOnOverview = true
+ persistentTaskBarStashController.launcherState = BubbleLauncherState.OVERVIEW
clearInvocations(bubbleBarViewController)
// When switch out of the overview screen
- persistentTaskBarStashController.isBubblesShowingOnOverview = false
+ persistentTaskBarStashController.launcherState = BubbleLauncherState.IN_APP
// Then bubble bar controller is notified
verify(bubbleBarViewController).onBubbleBarConfigurationChanged(/* animate= */ true)
@@ -140,7 +141,7 @@
@Test
fun setBubblesShowingOnOverviewUpdatedToTrue_controllersNotified() {
// When switch to the overview screen
- persistentTaskBarStashController.isBubblesShowingOnOverview = true
+ persistentTaskBarStashController.launcherState = BubbleLauncherState.OVERVIEW
// Then bubble bar controller is notified
verify(bubbleBarViewController).onBubbleBarConfigurationChanged(/* animate= */ true)
@@ -150,7 +151,7 @@
fun isSysuiLockedSwitchedToFalseForOverview_unlockAnimationIsShown() {
// Given screen is locked and bubble bar has bubbles
persistentTaskBarStashController.isSysuiLocked = true
- persistentTaskBarStashController.isBubblesShowingOnOverview = true
+ persistentTaskBarStashController.launcherState = BubbleLauncherState.OVERVIEW
whenever(bubbleBarViewController.hasBubbles()).thenReturn(true)
// When switch to the overview screen
@@ -211,14 +212,14 @@
fun bubbleBarTranslationYForTaskbar() {
// Give bubble bar is on home
whenever(bubbleBarViewController.hasBubbles()).thenReturn(false)
- persistentTaskBarStashController.isBubblesShowingOnHome = true
+ persistentTaskBarStashController.launcherState = BubbleLauncherState.HOME
// Then bubbleBarTranslationY would be HOTSEAT_TRANSLATION_Y
assertThat(persistentTaskBarStashController.bubbleBarTranslationY)
.isEqualTo(HOTSEAT_TRANSLATION_Y)
// Give bubble bar is not on home
- persistentTaskBarStashController.isBubblesShowingOnHome = false
+ persistentTaskBarStashController.launcherState = BubbleLauncherState.IN_APP
// Then bubbleBarTranslationY would be TASK_BAR_TRANSLATION_Y
assertThat(persistentTaskBarStashController.bubbleBarTranslationY)
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt
index d4a3b3a..7973e2df 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt
@@ -29,13 +29,16 @@
import com.android.launcher3.anim.AnimatedFloat
import com.android.launcher3.taskbar.StashedHandleView
import com.android.launcher3.taskbar.TaskbarInsetsController
+import com.android.launcher3.taskbar.TaskbarStashController
import com.android.launcher3.taskbar.bubbles.BubbleBarView
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
import com.android.launcher3.taskbar.bubbles.BubbleStashedHandleViewController
import com.android.launcher3.taskbar.bubbles.BubbleView
+import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.BubbleLauncherState
import com.android.launcher3.util.MultiValueAlpha
import com.android.wm.shell.shared.animation.PhysicsAnimator
import com.android.wm.shell.shared.animation.PhysicsAnimatorTestUtils
+import com.google.common.collect.Range
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Rule
@@ -59,7 +62,7 @@
const val BUBBLE_BAR_WIDTH = 200
const val BUBBLE_BAR_HEIGHT = 100
const val HOTSEAT_TRANSLATION_Y = -45f
- const val TASK_BAR_TRANSLATION_Y = -TASKBAR_BOTTOM_SPACE
+ const val TASK_BAR_TRANSLATION_Y = -TASKBAR_BOTTOM_SPACE.toFloat()
const val HANDLE_VIEW_WIDTH = 150
const val HANDLE_VIEW_HEIGHT = 4
const val BUBBLE_BAR_STASHED_TRANSLATION_Y = -4.5f
@@ -119,7 +122,7 @@
// When switch out of the home screen
getInstrumentation().runOnMainSync {
- mTransientBubbleStashController.isBubblesShowingOnHome = true
+ mTransientBubbleStashController.launcherState = BubbleLauncherState.HOME
}
// Then BubbleBarView is animating, BubbleBarViewController controller is notified
@@ -137,12 +140,12 @@
@Test
fun setBubblesShowingOnOverviewUpdatedToTrue_barPositionYUpdated_controllersNotified() {
- // Given bubble bar is on home and has bubbles
+ // Given bubble bar is on overview and has bubbles
whenever(bubbleBarViewController.hasBubbles()).thenReturn(true)
// When switch out of the home screen
getInstrumentation().runOnMainSync {
- mTransientBubbleStashController.isBubblesShowingOnOverview = true
+ mTransientBubbleStashController.launcherState = BubbleLauncherState.OVERVIEW
}
// Then BubbleBarView is animating, BubbleBarViewController controller is notified
@@ -159,6 +162,27 @@
}
@Test
+ fun setBubblesShowingOnOverviewUpdatedToTrue_unstashes() {
+ // Given bubble bar is stashed with bubbles
+ whenever(bubbleBarViewController.hasBubbles()).thenReturn(true)
+
+ getInstrumentation().runOnMainSync {
+ mTransientBubbleStashController.updateStashedAndExpandedState(
+ stash = true,
+ expand = false,
+ )
+ }
+ assertThat(mTransientBubbleStashController.isStashed).isTrue()
+
+ // Move to overview
+ getInstrumentation().runOnMainSync {
+ mTransientBubbleStashController.launcherState = BubbleLauncherState.OVERVIEW
+ }
+ // No longer stashed in overview
+ assertThat(mTransientBubbleStashController.isStashed).isFalse()
+ }
+
+ @Test
fun updateStashedAndExpandedState_stashAndCollapse_bubbleBarHidden_stashedHandleShown() {
// Given bubble bar has bubbles and not stashed
mTransientBubbleStashController.isStashed = false
@@ -196,11 +220,98 @@
}
@Test
+ fun updateStashedAndExpandedState_unstash_bubbleBarShown_stashedHandleHidden() {
+ // Given bubble bar has bubbles and is stashed
+ mTransientBubbleStashController.isStashed = true
+ whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false)
+
+ val bubbleInitialTranslation = bubbleView.translationY
+
+ // When unstash
+ getInstrumentation().runOnMainSync {
+ mTransientBubbleStashController.updateStashedAndExpandedState(
+ stash = false,
+ expand = false,
+ )
+ }
+
+ // Wait until animations ends
+ advanceTimeBy(BubbleStashController.BAR_STASH_DURATION)
+ PhysicsAnimatorTestUtils.blockUntilAnimationsEnd(DynamicAnimation.TRANSLATION_Y)
+
+ // Then check BubbleBarController is notified
+ verify(bubbleBarViewController).onStashStateChanging()
+ // Bubble bar is unstashed
+ assertThat(mTransientBubbleStashController.isStashed).isFalse()
+ assertThat(bubbleBarView.translationY).isEqualTo(TASK_BAR_TRANSLATION_Y)
+ assertThat(bubbleBarView.alpha).isEqualTo(1f)
+ assertThat(bubbleBarView.scaleX).isEqualTo(1f)
+ assertThat(bubbleBarView.scaleY).isEqualTo(1f)
+ assertThat(bubbleBarView.background.alpha).isEqualTo(255)
+ // Handle view is hidden
+ assertThat(stashedHandleView.translationY).isEqualTo(0)
+ assertThat(stashedHandleView.alpha).isEqualTo(0)
+ // Bubble view is reset
+ assertThat(bubbleView.translationY).isEqualTo(bubbleInitialTranslation)
+ assertThat(bubbleView.alpha).isEqualTo(1f)
+ }
+
+ @Test
+ fun updateStashedAndExpandedState_stash_animatesAlphaForBubblesAndBackgroundSeparately() {
+ // Given bubble bar has bubbles and is unstashed
+ mTransientBubbleStashController.isStashed = false
+ whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false)
+
+ // When stash
+ getInstrumentation().runOnMainSync {
+ mTransientBubbleStashController.updateStashedAndExpandedState(
+ stash = true,
+ expand = false,
+ )
+ }
+
+ // Stop after alpha starts
+ advanceTimeBy(TaskbarStashController.TASKBAR_STASH_ALPHA_START_DELAY + 10)
+
+ // Bubble bar alpha is set to 1
+ assertThat(bubbleBarView.alpha).isEqualTo(1f)
+ // We animate alpha for background and children separately
+ assertThat(bubbleView.alpha).isIn(Range.open(0f, 1f))
+ assertThat(bubbleBarView.background.alpha).isIn(Range.open(0, 255))
+ assertThat(bubbleBarView.background.alpha).isNotEqualTo((bubbleView.alpha * 255f).toInt())
+ }
+
+ @Test
+ fun updateStashedAndExpandedState_unstash_animatesAlphaForBubblesAndBackgroundSeparately() {
+ // Given bubble bar has bubbles and is stashed
+ mTransientBubbleStashController.isStashed = true
+ whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false)
+
+ // When unstash
+ getInstrumentation().runOnMainSync {
+ mTransientBubbleStashController.updateStashedAndExpandedState(
+ stash = false,
+ expand = false,
+ )
+ }
+
+ // Stop after alpha starts
+ advanceTimeBy(TaskbarStashController.TASKBAR_STASH_ALPHA_START_DELAY + 10)
+
+ // Bubble bar alpha is set to 1
+ assertThat(bubbleBarView.alpha).isEqualTo(1f)
+ // We animate alpha for background and children separately
+ assertThat(bubbleView.alpha).isIn(Range.open(0f, 1f))
+ assertThat(bubbleBarView.background.alpha).isIn(Range.open(0, 255))
+ assertThat(bubbleBarView.background.alpha).isNotEqualTo((bubbleView.alpha * 255f).toInt())
+ }
+
+ @Test
fun isSysuiLockedSwitchedToFalseForOverview_unlockAnimationIsShown() {
// Given screen is locked and bubble bar has bubbles
getInstrumentation().runOnMainSync {
mTransientBubbleStashController.isSysuiLocked = true
- mTransientBubbleStashController.isBubblesShowingOnOverview = true
+ mTransientBubbleStashController.launcherState = BubbleLauncherState.OVERVIEW
whenever(bubbleBarViewController.hasBubbles()).thenReturn(true)
}
advanceTimeBy(BubbleStashController.BAR_TRANSLATION_DURATION)
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt
index cb5e464..b0d706f 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt
@@ -28,9 +28,11 @@
import com.android.launcher3.LauncherAppState
import com.android.launcher3.statehandlers.DesktopVisibilityController
import com.android.launcher3.taskbar.TaskbarActivityContext
+import com.android.launcher3.taskbar.TaskbarControllers
import com.android.launcher3.taskbar.TaskbarManager
import com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarNavButtonCallbacks
import com.android.launcher3.taskbar.TaskbarViewController
+import com.android.launcher3.taskbar.bubbles.BubbleControllers
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.InjectController
import com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR
import com.android.launcher3.util.LauncherMultivalentJUnit.Companion.isRunningInRobolectric
@@ -38,6 +40,9 @@
import com.android.quickstep.AllAppsActionManager
import com.android.quickstep.TouchInteractionService
import com.android.quickstep.TouchInteractionService.TISBinder
+import java.lang.reflect.Field
+import java.lang.reflect.ParameterizedType
+import java.util.Optional
import org.junit.Assume.assumeTrue
import org.junit.rules.RuleChain
import org.junit.rules.TestRule
@@ -180,19 +185,38 @@
fun recreateTaskbar() = instrumentation.runOnMainSync { taskbarManager.recreateTaskbar() }
private fun injectControllers() {
- val controllers = activityContext.controllers
- val controllerFieldsByType = controllers.javaClass.fields.associateBy { it.type }
+ val bubbleControllerTypes =
+ BubbleControllers::class.java.fields.map { f ->
+ if (f.type == Optional::class.java) {
+ (f.genericType as ParameterizedType).actualTypeArguments[0] as Class<*>
+ } else {
+ f.type
+ }
+ }
testInstance.javaClass.fields
.filter { it.isAnnotationPresent(InjectController::class.java) }
.forEach {
- it.set(
- testInstance,
- controllerFieldsByType[it.type]?.get(controllers)
- ?: throw NoSuchElementException("Failed to find controller for ${it.type}"),
- )
+ val controllers: Any =
+ if (it.type in bubbleControllerTypes) {
+ activityContext.controllers.bubbleControllers.orElseThrow {
+ NoSuchElementException("Bubble controllers are not initialized")
+ }
+ } else {
+ activityContext.controllers
+ }
+ injectController(it, testInstance, controllers)
}
}
+ private fun injectController(field: Field, testInstance: Any, controllers: Any) {
+ val controllerFieldsByType = controllers.javaClass.fields.associateBy { it.type }
+ field.set(
+ testInstance,
+ controllerFieldsByType[field.type]?.get(controllers)
+ ?: throw NoSuchElementException("Failed to find controller for ${field.type}"),
+ )
+ }
+
/**
* Annotates test controller fields to inject the corresponding controllers from the current
* [TaskbarControllers] instance.
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRuleTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRuleTest.kt
index 5d4fdc5..52ca78d 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRuleTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRuleTest.kt
@@ -16,18 +16,24 @@
package com.android.launcher3.taskbar.rules
+import android.platform.test.annotations.DisableFlags
+import android.platform.test.annotations.EnableFlags
+import android.platform.test.flag.junit.SetFlagsRule
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import com.android.launcher3.taskbar.TaskbarActivityContext
import com.android.launcher3.taskbar.TaskbarKeyguardController
import com.android.launcher3.taskbar.TaskbarManager
import com.android.launcher3.taskbar.TaskbarStashController
+import com.android.launcher3.taskbar.bubbles.BubbleBarController
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.InjectController
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.NavBarKidsMode
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.UserSetupMode
import com.android.launcher3.util.LauncherMultivalentJUnit
import com.android.launcher3.util.LauncherMultivalentJUnit.EmulatedDevices
+import com.android.wm.shell.Flags
import com.google.common.truth.Truth.assertThat
import org.junit.Assert.assertThrows
+import org.junit.Rule
import org.junit.Test
import org.junit.runner.Description
import org.junit.runner.RunWith
@@ -39,6 +45,8 @@
private val context = TaskbarWindowSandboxContext.create(getInstrumentation().targetContext)
+ @get:Rule(order = 0) val setFlagsRule = SetFlagsRule()
+
@Test
fun testSetup_taskbarInitialized() {
onSetup { assertThat(activityContext).isInstanceOf(TaskbarActivityContext::class.java) }
@@ -127,6 +135,44 @@
}
}
+ @EnableFlags(Flags.FLAG_ENABLE_BUBBLE_BAR)
+ @Test
+ fun testInjectBubbleController_bubbleFlagOn_isInjected() {
+ val testClass =
+ object {
+ @InjectController lateinit var controller: BubbleBarController
+ val isInjected: Boolean
+ get() = ::controller.isInitialized
+ }
+
+ TaskbarUnitTestRule(testClass, context).apply(EMPTY_STATEMENT, DESCRIPTION).evaluate()
+
+ onSetup(TaskbarUnitTestRule(testClass, context)) {
+ assertThat(testClass.isInjected).isTrue()
+ }
+ }
+
+ @DisableFlags(Flags.FLAG_ENABLE_BUBBLE_BAR)
+ @Test
+ fun testInjectBubbleController_bubbleFlagOff_exceptionThrown() {
+ val testClass =
+ object {
+ @InjectController lateinit var controller: BubbleBarController
+ }
+
+ // We cannot use #assertThrows because we also catch an assumption violated exception when
+ // running #evaluate on devices that do not support Taskbar.
+ val result =
+ try {
+ TaskbarUnitTestRule(testClass, context)
+ .apply(EMPTY_STATEMENT, DESCRIPTION)
+ .evaluate()
+ } catch (e: NoSuchElementException) {
+ e
+ }
+ assertThat(result).isInstanceOf(NoSuchElementException::class.java)
+ }
+
@Test
fun testUserSetupMode_default_isComplete() {
onSetup { assertThat(activityContext.isUserSetupComplete).isTrue() }
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java
index 87a7cda..3483723 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java
@@ -20,7 +20,6 @@
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -38,14 +37,13 @@
import android.view.ViewTreeObserver;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.test.platform.app.InstrumentationRegistry;
import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.Flags;
import com.android.launcher3.LauncherRootView;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.statemanager.BaseState;
-import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.statemanager.StatefulContainer;
import com.android.launcher3.util.SystemUiController;
import com.android.quickstep.fallback.window.RecentsWindowManager;
@@ -65,11 +63,11 @@
import java.util.HashMap;
public abstract class AbsSwipeUpHandlerTestCase<
- RECENTS_CONTAINER extends Context & RecentsViewContainer & StatefulContainer<STATE>,
- STATE extends BaseState<STATE>, RECENTS_VIEW extends RecentsView<RECENTS_CONTAINER, STATE>,
- ACTIVITY_TYPE extends StatefulActivity<STATE> & RecentsViewContainer,
- ACTIVITY_INTERFACE extends BaseActivityInterface<STATE, ACTIVITY_TYPE>,
- SWIPE_HANDLER extends AbsSwipeUpHandler<RECENTS_CONTAINER, RECENTS_VIEW, STATE>> {
+ STATE_TYPE extends BaseState<STATE_TYPE>,
+ RECENTS_CONTAINER extends Context & RecentsViewContainer & StatefulContainer<STATE_TYPE>,
+ RECENTS_VIEW extends RecentsView<RECENTS_CONTAINER, STATE_TYPE>,
+ SWIPE_HANDLER extends AbsSwipeUpHandler<RECENTS_CONTAINER, RECENTS_VIEW, STATE_TYPE>,
+ CONTAINER_INTERFACE extends BaseContainerInterface<STATE_TYPE, RECENTS_CONTAINER>> {
protected final Context mContext =
InstrumentationRegistry.getInstrumentation().getTargetContext();
@@ -106,13 +104,12 @@
/* minimizedHomeBounds= */ null,
new Bundle());
- protected RecentsWindowManager mRecentsWindowManager;
protected TaskAnimationManager mTaskAnimationManager;
- @Mock protected ACTIVITY_INTERFACE mActivityInterface;
+ @Mock protected CONTAINER_INTERFACE mActivityInterface;
@Mock protected ActivityInitListener<?> mActivityInitListener;
@Mock protected RecentsAnimationController mRecentsAnimationController;
- @Mock protected STATE mState;
+ @Mock protected STATE_TYPE mState;
@Mock protected ViewTreeObserver mViewTreeObserver;
@Mock protected DragLayer mDragLayer;
@Mock protected LauncherRootView mRootView;
@@ -123,16 +120,6 @@
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@Before
- public void setUpTaskAnimationManager() {
- runOnMainSync(() -> {
- if(Flags.enableFallbackOverviewInWindow()){
- mRecentsWindowManager = new RecentsWindowManager(mContext);
- }
- mTaskAnimationManager = new TaskAnimationManager(mContext, mRecentsWindowManager);
- });
- }
-
- @Before
public void setUpRunningTaskInfo() {
mRunningTaskInfo.baseIntent = new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME)
@@ -162,6 +149,7 @@
@Before
public void setUpRecentsContainer() {
+ mTaskAnimationManager = new TaskAnimationManager(mContext, getRecentsWindowManager());
RecentsViewContainer recentsContainer = getRecentsContainer();
RECENTS_VIEW recentsView = getRecentsView();
@@ -263,13 +251,12 @@
private void onRecentsAnimationStart(SWIPE_HANDLER absSwipeUpHandler) {
when(mActivityInterface.getOverviewWindowBounds(any(), any())).thenReturn(new Rect());
- doNothing().when(mActivityInterface).setOnDeferredActivityLaunchCallback(any());
runOnMainSync(() -> absSwipeUpHandler.onRecentsAnimationStart(
mRecentsAnimationController, mRecentsAnimationTargets));
}
- private static void runOnMainSync(Runnable runnable) {
+ protected static void runOnMainSync(Runnable runnable) {
InstrumentationRegistry.getInstrumentation().runOnMainSync(runnable);
}
@@ -278,6 +265,11 @@
return createSwipeHandler(SystemClock.uptimeMillis(), false);
}
+ @Nullable
+ protected RecentsWindowManager getRecentsWindowManager() {
+ return null;
+ }
+
@NonNull
protected abstract SWIPE_HANDLER createSwipeHandler(
long touchTimeMs, boolean continuingLastGesture);
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/FallbackSwipeHandlerTestCase.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/FallbackSwipeHandlerTestCase.java
index 8d6906f..88197e5 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/FallbackSwipeHandlerTestCase.java
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/FallbackSwipeHandlerTestCase.java
@@ -16,6 +16,7 @@
package com.android.quickstep;
+import androidx.annotation.NonNull;
import androidx.test.filters.SmallTest;
import com.android.launcher3.util.LauncherMultivalentJUnit;
@@ -28,15 +29,14 @@
@SmallTest
@RunWith(LauncherMultivalentJUnit.class)
public class FallbackSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase<
- RecentsActivity,
RecentsState,
- FallbackRecentsView<RecentsActivity>,
RecentsActivity,
- FallbackActivityInterface,
- FallbackSwipeHandler> {
+ FallbackRecentsView<RecentsActivity>,
+ FallbackSwipeHandler,
+ FallbackActivityInterface> {
@Mock private RecentsActivity mRecentsActivity;
- @Mock private FallbackRecentsView mRecentsView;
+ @Mock private FallbackRecentsView<RecentsActivity> mRecentsView;
@Override
@@ -52,13 +52,15 @@
mInputConsumerController);
}
+ @NonNull
@Override
protected RecentsActivity getRecentsContainer() {
return mRecentsActivity;
}
+ @NonNull
@Override
- protected FallbackRecentsView getRecentsView() {
+ protected FallbackRecentsView<RecentsActivity> getRecentsView() {
return mRecentsView;
}
}
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/LauncherSwipeHandlerV2TestCase.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/LauncherSwipeHandlerV2TestCase.java
index 653dc01..ec1dc8b 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/LauncherSwipeHandlerV2TestCase.java
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/LauncherSwipeHandlerV2TestCase.java
@@ -19,6 +19,7 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
+import androidx.annotation.NonNull;
import androidx.test.filters.SmallTest;
import com.android.launcher3.Hotseat;
@@ -38,12 +39,11 @@
@SmallTest
@RunWith(LauncherMultivalentJUnit.class)
public class LauncherSwipeHandlerV2TestCase extends AbsSwipeUpHandlerTestCase<
- QuickstepLauncher,
LauncherState,
- RecentsView<QuickstepLauncher, LauncherState>,
QuickstepLauncher,
- LauncherActivityInterface,
- LauncherSwipeHandlerV2> {
+ RecentsView<QuickstepLauncher, LauncherState>,
+ LauncherSwipeHandlerV2,
+ LauncherActivityInterface> {
@Mock private QuickstepLauncher mQuickstepLauncher;
@Mock private RecentsView<QuickstepLauncher, LauncherState> mRecentsView;
@@ -67,6 +67,7 @@
when(mWorkspace.getStateTransitionAnimation()).thenReturn(mTransitionAnimation);
}
+ @NonNull
@Override
protected LauncherSwipeHandlerV2 createSwipeHandler(
long touchTimeMs, boolean continuingLastGesture) {
@@ -80,11 +81,13 @@
mInputConsumerController);
}
+ @NonNull
@Override
protected QuickstepLauncher getRecentsContainer() {
return mQuickstepLauncher;
}
+ @NonNull
@Override
protected RecentsView<QuickstepLauncher, LauncherState> getRecentsView() {
return mRecentsView;
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsWindowSwipeHandlerTestCase.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsWindowSwipeHandlerTestCase.java
new file mode 100644
index 0000000..1bdf273
--- /dev/null
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsWindowSwipeHandlerTestCase.java
@@ -0,0 +1,77 @@
+/*
+ * 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 androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.test.filters.SmallTest;
+
+import com.android.launcher3.util.LauncherMultivalentJUnit;
+import com.android.quickstep.fallback.FallbackRecentsView;
+import com.android.quickstep.fallback.RecentsState;
+import com.android.quickstep.fallback.window.RecentsWindowManager;
+import com.android.quickstep.fallback.window.RecentsWindowSwipeHandler;
+import com.android.quickstep.views.RecentsViewContainer;
+
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+
+@SmallTest
+@RunWith(LauncherMultivalentJUnit.class)
+public class RecentsWindowSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase<
+ RecentsState,
+ RecentsWindowManager,
+ FallbackRecentsView<RecentsWindowManager>,
+ RecentsWindowSwipeHandler,
+ FallbackWindowInterface> {
+
+ @Mock private RecentsWindowManager mRecentsWindowManager;
+ @Mock private FallbackRecentsView<RecentsWindowManager> mRecentsView;
+
+ @NonNull
+ @Override
+ protected RecentsWindowSwipeHandler createSwipeHandler(long touchTimeMs,
+ boolean continuingLastGesture) {
+ return new RecentsWindowSwipeHandler(
+ mContext,
+ mRecentsAnimationDeviceState,
+ mTaskAnimationManager,
+ mGestureState,
+ touchTimeMs,
+ continuingLastGesture,
+ mInputConsumerController,
+ mRecentsWindowManager);
+ }
+
+ @Nullable
+ @Override
+ protected RecentsWindowManager getRecentsWindowManager() {
+ return mRecentsWindowManager;
+ }
+
+ @NonNull
+ @Override
+ protected RecentsViewContainer getRecentsContainer() {
+ return mRecentsWindowManager;
+ }
+
+ @NonNull
+ @Override
+ protected FallbackRecentsView<RecentsWindowManager> getRecentsView() {
+ return mRecentsView;
+ }
+}
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt
index 9d0b2ab..cb70694 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt
@@ -36,6 +36,7 @@
import com.android.quickstep.RecentsModel
import com.android.quickstep.SystemUiProxy
import com.android.quickstep.util.SplitSelectStateController.SplitFromDesktopController
+import com.android.quickstep.views.RecentsView
import com.android.quickstep.views.RecentsViewContainer
import com.android.systemui.shared.recents.model.Task
import com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50
@@ -50,6 +51,7 @@
import org.mockito.Mockito.`when`
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.mock
+import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import java.util.function.Consumer
@@ -66,6 +68,7 @@
private val recentsModel: RecentsModel = mock()
private val pendingIntent: PendingIntent = mock()
private val splitFromDesktopController: SplitFromDesktopController = mock()
+ private val recentsView: RecentsView<*, *> = mock()
private lateinit var splitSelectStateController: SplitSelectStateController
@@ -73,6 +76,7 @@
private val nonPrimaryUserHandle = UserHandle(ActivityManager.RunningTaskInfo().userId + 10)
private var taskIdCounter = 0
+
private fun getUniqueId(): Int {
return ++taskIdCounter
}
@@ -90,7 +94,7 @@
statsLogManager,
systemUiProxy,
recentsModel,
- null /*activityBackCallback*/
+ null, /*activityBackCallback*/
)
}
@@ -100,12 +104,12 @@
val groupTask1 =
generateGroupTask(
ComponentName("pomegranate", "juice"),
- ComponentName("pumpkin", "pie")
+ ComponentName("pumpkin", "pie"),
)
val groupTask2 =
generateGroupTask(
ComponentName("hotdog", "juice"),
- ComponentName("personal", "computer")
+ ComponentName("personal", "computer"),
)
val tasks: ArrayList<GroupTask> = ArrayList()
tasks.add(groupTask1)
@@ -122,7 +126,7 @@
splitSelectStateController.findLastActiveTasksAndRunCallback(
listOf(nonMatchingComponent),
false /* findExactPairMatch */,
- taskConsumer
+ taskConsumer,
)
verify(recentsModel).getTasks(capture())
}
@@ -141,12 +145,12 @@
val groupTask1 =
generateGroupTask(
ComponentName(matchingPackage, matchingClass),
- ComponentName("pomegranate", "juice")
+ ComponentName("pomegranate", "juice"),
)
val groupTask2 =
generateGroupTask(
ComponentName("pumpkin", "pie"),
- ComponentName("personal", "computer")
+ ComponentName("personal", "computer"),
)
val tasks: ArrayList<GroupTask> = ArrayList()
tasks.add(groupTask1)
@@ -159,12 +163,12 @@
assertEquals(
"ComponentName package mismatched",
it[0].key.baseIntent.component?.packageName,
- matchingPackage
+ matchingPackage,
)
assertEquals(
"ComponentName class mismatched",
it[0].key.baseIntent.component?.className,
- matchingClass
+ matchingClass,
)
assertEquals(it[0], groupTask1.task1)
}
@@ -175,7 +179,7 @@
splitSelectStateController.findLastActiveTasksAndRunCallback(
listOf(matchingComponent),
false /* findExactPairMatch */,
- taskConsumer
+ taskConsumer,
)
verify(recentsModel).getTasks(capture())
}
@@ -194,12 +198,12 @@
val groupTask1 =
generateGroupTask(
ComponentName(matchingPackage, matchingClass),
- ComponentName("pomegranate", "juice")
+ ComponentName("pomegranate", "juice"),
)
val groupTask2 =
generateGroupTask(
ComponentName("pumpkin", "pie"),
- ComponentName("personal", "computer")
+ ComponentName("personal", "computer"),
)
val tasks: ArrayList<GroupTask> = ArrayList()
tasks.add(groupTask1)
@@ -216,7 +220,7 @@
splitSelectStateController.findLastActiveTasksAndRunCallback(
listOf(nonPrimaryUserComponent),
false /* findExactPairMatch */,
- taskConsumer
+ taskConsumer,
)
verify(recentsModel).getTasks(capture())
}
@@ -237,12 +241,12 @@
ComponentName(matchingPackage, matchingClass),
nonPrimaryUserHandle,
ComponentName("pomegranate", "juice"),
- nonPrimaryUserHandle
+ nonPrimaryUserHandle,
)
val groupTask2 =
generateGroupTask(
ComponentName("pumpkin", "pie"),
- ComponentName("personal", "computer")
+ ComponentName("personal", "computer"),
)
val tasks: ArrayList<GroupTask> = ArrayList()
tasks.add(groupTask1)
@@ -255,12 +259,12 @@
assertEquals(
"ComponentName package mismatched",
it[0].key.baseIntent.component?.packageName,
- matchingPackage
+ matchingPackage,
)
assertEquals(
"ComponentName class mismatched",
it[0].key.baseIntent.component?.className,
- matchingClass
+ matchingClass,
)
assertEquals("userId mismatched", it[0].key.userId, nonPrimaryUserHandle.identifier)
assertEquals(it[0], groupTask1.task1)
@@ -272,7 +276,7 @@
splitSelectStateController.findLastActiveTasksAndRunCallback(
listOf(nonPrimaryUserComponent),
false /* findExactPairMatch */,
- taskConsumer
+ taskConsumer,
)
verify(recentsModel).getTasks(capture())
}
@@ -291,12 +295,12 @@
val groupTask1 =
generateGroupTask(
ComponentName(matchingPackage, matchingClass),
- ComponentName("pumpkin", "pie")
+ ComponentName("pumpkin", "pie"),
)
val groupTask2 =
generateGroupTask(
ComponentName("pomegranate", "juice"),
- ComponentName(matchingPackage, matchingClass)
+ ComponentName(matchingPackage, matchingClass),
)
val tasks: ArrayList<GroupTask> = ArrayList()
tasks.add(groupTask2)
@@ -309,12 +313,12 @@
assertEquals(
"ComponentName package mismatched",
it[0].key.baseIntent.component?.packageName,
- matchingPackage
+ matchingPackage,
)
assertEquals(
"ComponentName class mismatched",
it[0].key.baseIntent.component?.className,
- matchingClass
+ matchingClass,
)
assertEquals(it[0], groupTask1.task1)
}
@@ -325,7 +329,7 @@
splitSelectStateController.findLastActiveTasksAndRunCallback(
listOf(matchingComponent),
false /* findExactPairMatch */,
- taskConsumer
+ taskConsumer,
)
verify(recentsModel).getTasks(capture())
}
@@ -348,7 +352,7 @@
val groupTask2 =
generateGroupTask(
ComponentName("pomegranate", "juice"),
- ComponentName(matchingPackage, matchingClass)
+ ComponentName(matchingPackage, matchingClass),
)
val tasks: ArrayList<GroupTask> = ArrayList()
tasks.add(groupTask2)
@@ -363,12 +367,12 @@
assertEquals(
"ComponentName package mismatched",
it[1].key.baseIntent.component?.packageName,
- matchingPackage
+ matchingPackage,
)
assertEquals(
"ComponentName class mismatched",
it[1].key.baseIntent.component?.className,
- matchingClass
+ matchingClass,
)
assertEquals(it[1], groupTask2.task2)
}
@@ -379,7 +383,7 @@
splitSelectStateController.findLastActiveTasksAndRunCallback(
listOf(nonMatchingComponent, matchingComponent),
false /* findExactPairMatch */,
- taskConsumer
+ taskConsumer,
)
verify(recentsModel).getTasks(capture())
}
@@ -401,7 +405,7 @@
val groupTask2 =
generateGroupTask(
ComponentName("pomegranate", "juice"),
- ComponentName(matchingPackage, matchingClass)
+ ComponentName(matchingPackage, matchingClass),
)
val tasks: ArrayList<GroupTask> = ArrayList()
tasks.add(groupTask2)
@@ -415,12 +419,12 @@
assertEquals(
"ComponentName package mismatched",
it[0].key.baseIntent.component?.packageName,
- matchingPackage
+ matchingPackage,
)
assertEquals(
"ComponentName class mismatched",
it[0].key.baseIntent.component?.className,
- matchingClass
+ matchingClass,
)
assertEquals(it[0], groupTask2.task2)
assertNull("No tasks should have matched", it[1] /*task*/)
@@ -432,7 +436,7 @@
splitSelectStateController.findLastActiveTasksAndRunCallback(
listOf(matchingComponent, matchingComponent),
false /* findExactPairMatch */,
- taskConsumer
+ taskConsumer,
)
verify(recentsModel).getTasks(capture())
}
@@ -452,12 +456,12 @@
val groupTask1 =
generateGroupTask(
ComponentName(matchingPackage, matchingClass),
- ComponentName("pumpkin", "pie")
+ ComponentName("pumpkin", "pie"),
)
val groupTask2 =
generateGroupTask(
ComponentName("pomegranate", "juice"),
- ComponentName(matchingPackage, matchingClass)
+ ComponentName(matchingPackage, matchingClass),
)
val tasks: ArrayList<GroupTask> = ArrayList()
tasks.add(groupTask2)
@@ -471,23 +475,23 @@
assertEquals(
"ComponentName package mismatched",
it[0].key.baseIntent.component?.packageName,
- matchingPackage
+ matchingPackage,
)
assertEquals(
"ComponentName class mismatched",
it[0].key.baseIntent.component?.className,
- matchingClass
+ matchingClass,
)
assertEquals(it[0], groupTask1.task1)
assertEquals(
"ComponentName package mismatched",
it[1].key.baseIntent.component?.packageName,
- matchingPackage
+ matchingPackage,
)
assertEquals(
"ComponentName class mismatched",
it[1].key.baseIntent.component?.className,
- matchingClass
+ matchingClass,
)
assertEquals(it[1], groupTask2.task2)
}
@@ -498,7 +502,7 @@
splitSelectStateController.findLastActiveTasksAndRunCallback(
listOf(matchingComponent, matchingComponent),
false /* findExactPairMatch */,
- taskConsumer
+ taskConsumer,
)
verify(recentsModel).getTasks(capture())
}
@@ -524,12 +528,12 @@
val groupTask2 =
generateGroupTask(
ComponentName(matchingPackage2, matchingClass2),
- ComponentName(matchingPackage, matchingClass)
+ ComponentName(matchingPackage, matchingClass),
)
val groupTask3 =
generateGroupTask(
ComponentName("hotdog", "pie"),
- ComponentName(matchingPackage, matchingClass)
+ ComponentName(matchingPackage, matchingClass),
)
val tasks: ArrayList<GroupTask> = ArrayList()
tasks.add(groupTask3)
@@ -550,7 +554,7 @@
splitSelectStateController.findLastActiveTasksAndRunCallback(
listOf(matchingComponent2, matchingComponent),
true /* findExactPairMatch */,
- taskConsumer
+ taskConsumer,
)
verify(recentsModel).getTasks(capture())
}
@@ -567,7 +571,7 @@
-1 /*stagePosition*/,
ItemInfo(),
null /*splitEvent*/,
- 10 /*alreadyRunningTask*/
+ 10, /*alreadyRunningTask*/
)
assertTrue(splitSelectStateController.isSplitSelectActive)
}
@@ -579,21 +583,23 @@
-1 /*stagePosition*/,
ItemInfo(),
null /*splitEvent*/,
- -1 /*alreadyRunningTask*/
+ -1, /*alreadyRunningTask*/
)
assertTrue(splitSelectStateController.isSplitSelectActive)
}
@Test
fun resetAfterInitial() {
+ whenever(context.getOverviewPanel<RecentsView<*, *>>()).thenReturn(recentsView)
splitSelectStateController.setInitialTaskSelect(
Intent() /*intent*/,
-1 /*stagePosition*/,
ItemInfo(),
null /*splitEvent*/,
- -1
+ -1,
)
splitSelectStateController.resetState()
+ verify(recentsView, times(1)).resetDesktopTaskFromSplitSelectState()
assertFalse(splitSelectStateController.isSplitSelectActive)
}
@@ -622,7 +628,7 @@
// Generate GroupTask with default userId.
private fun generateGroupTask(
task1ComponentName: ComponentName,
- task2ComponentName: ComponentName
+ task2ComponentName: ComponentName,
): GroupTask {
val task1 = Task()
var taskInfo = ActivityManager.RunningTaskInfo()
@@ -642,7 +648,7 @@
return GroupTask(
task1,
task2,
- SplitConfigurationOptions.SplitBounds(Rect(), Rect(), -1, -1, SNAP_TO_2_50_50)
+ SplitConfigurationOptions.SplitBounds(Rect(), Rect(), -1, -1, SNAP_TO_2_50_50),
)
}
@@ -651,7 +657,7 @@
task1ComponentName: ComponentName,
userHandle1: UserHandle,
task2ComponentName: ComponentName,
- userHandle2: UserHandle
+ userHandle2: UserHandle,
): GroupTask {
val task1 = Task()
var taskInfo = ActivityManager.RunningTaskInfo()
@@ -674,7 +680,7 @@
return GroupTask(
task1,
task2,
- SplitConfigurationOptions.SplitBounds(Rect(), Rect(), -1, -1, SNAP_TO_2_50_50)
+ SplitConfigurationOptions.SplitBounds(Rect(), Rect(), -1, -1, SNAP_TO_2_50_50),
)
}
}
diff --git a/res/drawable/all_apps_tabs_background.xml b/res/drawable/all_apps_tabs_background.xml
index 62927af..d200b9f 100644
--- a/res/drawable/all_apps_tabs_background.xml
+++ b/res/drawable/all_apps_tabs_background.xml
@@ -13,36 +13,25 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="@color/accent_ripple_color">
-
- <item android:id="@android:id/mask">
- <shape android:shape="rectangle">
- <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
- <solid android:color="@color/accent_ripple_color" />
- </shape>
- </item>
-
- <item>
- <selector android:enterFadeDuration="100">
- <item
- android:id="@+id/unselected"
- android:state_selected="false">
- <shape android:shape="rectangle">
- <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
- <solid android:color="?attr/materialColorSurfaceBright" />
- </shape>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@drawable/all_apps_tabs_background_unselected_focused" android:state_focused="true" android:state_selected="false" />
+ <item android:drawable="@drawable/all_apps_tabs_background_selected_focused" android:state_focused="true" android:state_selected="true" />
+ <item android:id="@+id/unselected" android:state_focused="false" android:state_selected="false">
+ <ripple android:color="@color/accent_ripple_color">
+ <item>
+ <selector android:enterFadeDuration="100">
+ <item android:drawable="@drawable/all_apps_tabs_background_unselected" />
+ </selector>
</item>
-
- <item
- android:id="@+id/selected"
- android:state_selected="true">
- <shape android:shape="rectangle">
- <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
- <solid android:color="?attr/materialColorPrimary" />
- </shape>
- </item>
- </selector>
+ </ripple>
</item>
-
-</ripple>
\ No newline at end of file
+ <item android:id="@+id/selected" android:state_focused="false" android:state_selected="true">
+ <ripple android:color="@color/accent_ripple_color">
+ <item>
+ <selector android:enterFadeDuration="100">
+ <item android:drawable="@drawable/all_apps_tabs_background_selected" />
+ </selector>
+ </item>
+ </ripple>
+ </item>
+</selector>
\ No newline at end of file
diff --git a/res/drawable/all_apps_tabs_background_selected.xml b/res/drawable/all_apps_tabs_background_selected.xml
new file mode 100644
index 0000000..47f95dd
--- /dev/null
+++ b/res/drawable/all_apps_tabs_background_selected.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ 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.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item
+ android:bottom="@dimen/all_apps_tabs_focus_width"
+ android:end="@dimen/all_apps_tabs_focus_width"
+ android:start="@dimen/all_apps_tabs_focus_width"
+ android:top="@dimen/all_apps_tabs_focus_width">
+ <shape android:shape="rectangle">
+ <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
+ <solid android:color="?attr/materialColorPrimary" />
+ </shape>
+ </item>
+</layer-list>
\ No newline at end of file
diff --git a/res/drawable/all_apps_tabs_background_selected_focused.xml b/res/drawable/all_apps_tabs_background_selected_focused.xml
new file mode 100644
index 0000000..e3d86c0
--- /dev/null
+++ b/res/drawable/all_apps_tabs_background_selected_focused.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ 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.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item>
+ <shape>
+ <corners android:radius="16dp" />
+ <solid android:color="?attr/materialColorPrimary" />
+ </shape>
+ </item>
+
+ <item
+ android:bottom="@dimen/all_apps_tabs_focus_border"
+ android:end="@dimen/all_apps_tabs_focus_border"
+ android:start="@dimen/all_apps_tabs_focus_border"
+ android:top="@dimen/all_apps_tabs_focus_border">
+ <shape android:shape="rectangle">
+ <corners android:radius="13dp" />
+ <solid android:color="?attr/materialColorPrimary" />
+ <stroke
+ android:width="@dimen/all_apps_tabs_focus_padding"
+ android:color="?attr/materialColorSurfaceDim" />
+ </shape>
+ </item>
+</layer-list>
\ No newline at end of file
diff --git a/res/drawable/all_apps_tabs_background_unselected.xml b/res/drawable/all_apps_tabs_background_unselected.xml
new file mode 100644
index 0000000..ab592a8
--- /dev/null
+++ b/res/drawable/all_apps_tabs_background_unselected.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ 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.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item
+ android:bottom="@dimen/all_apps_tabs_focus_width"
+ android:end="@dimen/all_apps_tabs_focus_width"
+ android:start="@dimen/all_apps_tabs_focus_width"
+ android:top="@dimen/all_apps_tabs_focus_width">
+ <shape android:shape="rectangle">
+ <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
+ <solid android:color="?attr/materialColorSurfaceBright" />
+ </shape>
+ </item>
+</layer-list>
\ No newline at end of file
diff --git a/res/drawable/all_apps_tabs_background_unselected_focused.xml b/res/drawable/all_apps_tabs_background_unselected_focused.xml
new file mode 100644
index 0000000..0016102
--- /dev/null
+++ b/res/drawable/all_apps_tabs_background_unselected_focused.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ 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.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item>
+ <shape>
+ <corners android:radius="16dp" />
+ <solid android:color="?attr/materialColorPrimary" />
+ </shape>
+ </item>
+
+ <item
+ android:bottom="@dimen/all_apps_tabs_focus_border"
+ android:end="@dimen/all_apps_tabs_focus_border"
+ android:start="@dimen/all_apps_tabs_focus_border"
+ android:top="@dimen/all_apps_tabs_focus_border">
+ <shape android:shape="rectangle">
+ <corners android:radius="13dp" />
+ <solid android:color="?attr/materialColorSurfaceBright" />
+ <stroke
+ android:width="@dimen/all_apps_tabs_focus_padding"
+ android:color="?attr/materialColorSurfaceDim" />
+ </shape>
+ </item>
+</layer-list>
\ No newline at end of file
diff --git a/res/layout/all_apps_personal_work_tabs.xml b/res/layout/all_apps_personal_work_tabs.xml
index e04b207..ecc5a14 100644
--- a/res/layout/all_apps_personal_work_tabs.xml
+++ b/res/layout/all_apps_personal_work_tabs.xml
@@ -21,8 +21,8 @@
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_header_pill_height"
android:layout_gravity="center_horizontal"
- android:paddingTop="@dimen/all_apps_tabs_vertical_padding"
- android:paddingBottom="@dimen/all_apps_tabs_vertical_padding"
+ android:paddingTop="@dimen/all_apps_tabs_vertical_padding_focus"
+ android:paddingBottom="@dimen/all_apps_tabs_vertical_padding_focus"
android:layout_marginTop="@dimen/all_apps_tabs_margin_top"
android:orientation="horizontal"
style="@style/TextHeadline"
diff --git a/res/layout/widgets_two_pane_sheet_paged_view.xml b/res/layout/widgets_two_pane_sheet_paged_view.xml
index 1cbd2ba..71c77b5 100644
--- a/res/layout/widgets_two_pane_sheet_paged_view.xml
+++ b/res/layout/widgets_two_pane_sheet_paged_view.xml
@@ -20,16 +20,19 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="start"
- android:paddingHorizontal="@dimen/widget_list_horizontal_margin_two_pane"
android:layout_gravity="start"
android:clipChildren="false"
android:clipToPadding="false"
android:layout_alignParentStart="true">
+ <!-- Note: the paddingHorizontal has to be on WidgetPagedView level so that talkback
+ correctly orders the lists to be after the search and suggestions header. See b/209579563.
+ -->
<com.android.launcher3.widget.picker.WidgetPagedView
android:id="@+id/widgets_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
+ android:paddingHorizontal="@dimen/widget_list_horizontal_margin_two_pane"
android:descendantFocusability="afterDescendants"
launcher:pageIndicator="@+id/tabs" >
@@ -48,11 +51,13 @@
</com.android.launcher3.widget.picker.WidgetPagedView>
<!-- SearchAndRecommendationsView without the tab layout as well -->
+ <!-- Note: the horizontal padding matches with the WidgetPagedView -->
<com.android.launcher3.views.StickyHeaderLayout
android:id="@+id/search_and_recommendations_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToOutline="true"
+ android:paddingHorizontal="@dimen/widget_list_horizontal_margin_two_pane"
android:orientation="vertical">
<LinearLayout
diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml
index aee49be..f7b04a3 100644
--- a/res/values-en-rGB/strings.xml
+++ b/res/values-en-rGB/strings.xml
@@ -31,8 +31,7 @@
<string name="recent_task_option_split_screen" msgid="6690461455618725183">"Split screen"</string>
<string name="split_app_info_accessibility" msgid="5475288491241414932">"App info for %1$s"</string>
<string name="split_app_usage_settings" msgid="7214375263347964093">"Usage settings for %1$s"</string>
- <!-- no translation found for new_window_option_taskbar (6448780542727767211) -->
- <skip />
+ <string name="new_window_option_taskbar" msgid="6448780542727767211">"New window"</string>
<string name="save_app_pair" msgid="5647523853662686243">"Save app pair"</string>
<string name="app_pair_default_title" msgid="4045241727446873529">"<xliff:g id="APP1">%1$s</xliff:g> | <xliff:g id="APP2">%2$s</xliff:g>"</string>
<string name="app_pair_unlaunchable_at_screen_size" msgid="3446551575502685376">"This app pair isn\'t supported on this device"</string>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index f8c075f..d1e905d 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -126,6 +126,10 @@
<dimen name="all_apps_work_profile_tab_footer_bottom_padding">20dp</dimen>
<dimen name="all_apps_tabs_button_horizontal_padding">4dp</dimen>
<dimen name="all_apps_tabs_vertical_padding">6dp</dimen>
+ <dimen name="all_apps_tabs_vertical_padding_focus">1dp</dimen>
+ <dimen name="all_apps_tabs_focus_width">5dp</dimen>
+ <dimen name="all_apps_tabs_focus_border">3dp</dimen>
+ <dimen name="all_apps_tabs_focus_padding">2dp</dimen>
<dimen name="all_apps_tabs_margin_top">8dp</dimen>
<dimen name="all_apps_divider_height">2dp</dimen>
<dimen name="all_apps_divider_width">128dp</dimen>
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 572274e..9192e13 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -420,6 +420,25 @@
return mapRange(interpolator.getInterpolation(progress), toMin, toMax);
}
+ /**
+ * Maps t from one range to another range.
+ * @param t The value to map.
+ * @param fromMin The lower bound of the range that t is being mapped from.
+ * @param fromMax The upper bound of the range that t is being mapped from.
+ * @param toMin The lower bound of the range that t is being mapped to.
+ * @param toMax The upper bound of the range that t is being mapped to.
+ * @return The mapped value of t.
+ */
+ public static int mapToRange(int t, int fromMin, int fromMax, int toMin, int toMax,
+ Interpolator interpolator) {
+ if (fromMin == fromMax || toMin == toMax) {
+ Log.e(TAG, "mapToRange: range has 0 length");
+ return toMin;
+ }
+ float progress = getProgress(t, fromMin, fromMax);
+ return (int) mapRange(interpolator.getInterpolation(progress), toMin, toMax);
+ }
+
/** Bounds t between a lower and upper bound and maps the result to a range. */
public static float mapBoundToRange(float t, float lowerBound, float upperBound,
float toMin, float toMax, Interpolator interpolator) {
diff --git a/src/com/android/launcher3/allapps/PrivateProfileManager.java b/src/com/android/launcher3/allapps/PrivateProfileManager.java
index e215cab..6a40121 100644
--- a/src/com/android/launcher3/allapps/PrivateProfileManager.java
+++ b/src/com/android/launcher3/allapps/PrivateProfileManager.java
@@ -66,6 +66,7 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Flags;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatedPropertySetter;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.icons.BitmapInfo;
@@ -699,7 +700,9 @@
mAllApps.mAH.get(MAIN).mRecyclerView.removeItemDecoration(
mPrivateAppsSectionDecorator);
// Call onAppsUpdated() because it may be canceled when this animation occurs.
- mAllApps.getPersonalAppList().onAppsUpdated();
+ if (!Utilities.isRunningInTestHarness()) {
+ mAllApps.getPersonalAppList().onAppsUpdated();
+ }
if (isPrivateSpaceHidden()) {
// TODO (b/325455879): Figure out if we can avoid this.
getMainRecyclerView().getAdapter().notifyDataSetChanged();
diff --git a/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java b/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java
index 0a50e8b..9f6b40b 100644
--- a/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java
+++ b/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java
@@ -18,6 +18,7 @@
import android.content.Context;
+import com.android.launcher3.pm.InstallSessionHelper;
import com.android.launcher3.util.DaggerSingletonTracker;
import dagger.BindsInstance;
@@ -32,6 +33,8 @@
*/
public interface LauncherBaseAppComponent {
DaggerSingletonTracker getDaggerSingletonTracker();
+ InstallSessionHelper getInstallSessionHelper();
+
/** Builder for LauncherBaseAppComponent. */
interface Builder {
@BindsInstance Builder appContext(@ApplicationContext Context context);
diff --git a/src/com/android/launcher3/icons/CacheableShortcutInfo.kt b/src/com/android/launcher3/icons/CacheableShortcutInfo.kt
index c121340..c673bb3 100644
--- a/src/com/android/launcher3/icons/CacheableShortcutInfo.kt
+++ b/src/com/android/launcher3/icons/CacheableShortcutInfo.kt
@@ -110,8 +110,6 @@
info?.let { max(info.shortcutInfo.lastChangedTimestamp, packageInfo.lastUpdateTime) }
?: packageInfo.lastUpdateTime
- override fun addToMemCache() = false
-
override fun getApplicationInfo(info: CacheableShortcutInfo) = info.appInfo.getInfo()
override fun loadIcon(context: Context, cache: BaseIconCache, info: CacheableShortcutInfo) =
diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java
index 5396597..ffed1e8 100644
--- a/src/com/android/launcher3/icons/IconCache.java
+++ b/src/com/android/launcher3/icons/IconCache.java
@@ -110,8 +110,7 @@
IconProvider iconProvider) {
super(context, dbFileName, MODEL_EXECUTOR.getLooper(),
idp.fillResIconDpi, idp.iconBitmapSize, true /* inMemoryCache */, iconProvider);
- mComponentWithLabelCachingLogic = new CachedObjectCachingLogic(
- context, false /* loadIcons */, false /* addToMemCache */);
+ mComponentWithLabelCachingLogic = new CachedObjectCachingLogic(context);
mLauncherActivityInfoCachingLogic = LauncherActivityCachingLogic.INSTANCE;
mLauncherApps = mContext.getSystemService(LauncherApps.class);
mUserManager = UserCache.INSTANCE.get(mContext);
@@ -149,8 +148,7 @@
PackageManager.GET_UNINSTALLED_PACKAGES);
long userSerial = mUserManager.getSerialNumberForUser(user);
for (LauncherActivityInfo app : mLauncherApps.getActivityList(packageName, user)) {
- addIconToDBAndMemCache(app, mLauncherActivityInfoCachingLogic, info, userSerial,
- false /*replace existing*/);
+ addIconToDBAndMemCache(app, mLauncherActivityInfoCachingLogic, info, userSerial);
}
} catch (NameNotFoundException e) {
Log.d(TAG, "Package not found", e);
@@ -205,7 +203,7 @@
CancellableTask<ItemInfoWithIcon> request = new CancellableTask<>(
task, MAIN_EXECUTOR, caller::reapplyItemInfo, endRunnable);
- Utilities.postAsyncCallback(mWorkerHandler, request);
+ Utilities.postAsyncCallback(workerHandler, request);
return request;
}
@@ -257,6 +255,7 @@
/**
* Fill in {@code info} with the icon and label for {@code si}. If the icon is not
* available, and fallback check returns true, it keeps the old icon.
+ * Shortcut entries are not kept in memory since they are not frequently used
*/
public <T extends ItemInfoWithIcon> void getShortcutIcon(T info, CacheableShortcutInfo si,
@NonNull Predicate<T> fallbackIconCheck) {
@@ -266,7 +265,7 @@
user,
() -> si,
CacheableShortcutCachingLogic.INSTANCE,
- LookupFlag.DEFAULT).bitmap;
+ LookupFlag.SKIP_ADD_TO_MEM_CACHE).bitmap;
if (bitmapInfo.isNullOrLowRes()) {
bitmapInfo = getDefaultIcon(user);
}
@@ -337,7 +336,8 @@
*/
public synchronized String getTitleNoCache(ComponentWithLabel info) {
CacheEntry entry = cacheLocked(info.getComponent(), info.getUser(), () -> info,
- mComponentWithLabelCachingLogic, LookupFlag.USE_LOW_RES);
+ mComponentWithLabelCachingLogic,
+ LookupFlag.USE_LOW_RES | LookupFlag.SKIP_ADD_TO_MEM_CACHE);
return Utilities.trim(entry.title);
}
diff --git a/src/com/android/launcher3/pm/InstallSessionHelper.java b/src/com/android/launcher3/pm/InstallSessionHelper.java
index 124907f..f36f595 100644
--- a/src/com/android/launcher3/pm/InstallSessionHelper.java
+++ b/src/com/android/launcher3/pm/InstallSessionHelper.java
@@ -31,12 +31,17 @@
import com.android.launcher3.Flags;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.SessionCommitReceiver;
+import com.android.launcher3.dagger.ApplicationContext;
+import com.android.launcher3.dagger.LauncherAppSingleton;
+import com.android.launcher3.dagger.LauncherBaseAppComponent;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.model.ItemInstallQueue;
import com.android.launcher3.util.ApplicationInfoWrapper;
+import com.android.launcher3.util.DaggerSingletonObject;
+import com.android.launcher3.util.DaggerSingletonTracker;
+import com.android.launcher3.util.ExecutorUtil;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.IntSet;
-import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.SafeCloseable;
@@ -47,10 +52,13 @@
import java.util.List;
import java.util.Objects;
+import javax.inject.Inject;
+
/**
* Utility class to tracking install sessions
*/
@SuppressWarnings("NewApi")
+@LauncherAppSingleton
public class InstallSessionHelper implements SafeCloseable {
@NonNull
@@ -64,8 +72,8 @@
private static final boolean DEBUG = false;
@NonNull
- public static final MainThreadInitializedObject<InstallSessionHelper> INSTANCE =
- new MainThreadInitializedObject<>(InstallSessionHelper::new);
+ public static final DaggerSingletonObject<InstallSessionHelper> INSTANCE =
+ new DaggerSingletonObject<>(LauncherBaseAppComponent::getInstallSessionHelper);
@Nullable
private final LauncherApps mLauncherApps;
@@ -82,10 +90,13 @@
@Nullable
private IntSet mPromiseIconIds;
- public InstallSessionHelper(@NonNull final Context context) {
+ @Inject
+ public InstallSessionHelper(@NonNull @ApplicationContext final Context context,
+ DaggerSingletonTracker tracker) {
mInstaller = context.getPackageManager().getPackageInstaller();
mAppContext = context.getApplicationContext();
mLauncherApps = context.getSystemService(LauncherApps.class);
+ ExecutorUtil.executeSyncOnMainOrFail(() -> tracker.addCloseable(this));
}
@Override
diff --git a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java
index b5932d5..4e9143e 100644
--- a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java
+++ b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java
@@ -167,7 +167,6 @@
public static final String PERMANENT_DIAG_TAG = "TaplTarget";
public static final String ICON_MISSING = "b/282963545";
- public static final String UIOBJECT_STALE_ELEMENT = "b/319501259";
public static final String WIDGET_CONFIG_NULL_EXTRA_INTENT = "b/324419890";
public static final String REQUEST_FLAG_ENABLE_GRID_ONLY_OVERVIEW = "enable-grid-only-overview";
public static final String REQUEST_FLAG_ENABLE_APP_PAIRS = "enable-app-pairs";
diff --git a/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheTest.java b/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheTest.java
index 495d583..1f0e750 100644
--- a/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheTest.java
+++ b/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheTest.java
@@ -15,21 +15,39 @@
*/
package com.android.launcher3.icons;
+import static android.os.Process.myUserHandle;
+
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static com.android.launcher3.icons.IconCache.EXTRA_SHORTCUT_BADGE_OVERRIDE_PACKAGE;
+import static com.android.launcher3.icons.IconCacheUpdateHandlerTestKt.waitForUpdateHandlerToFinish;
+import static com.android.launcher3.model.data.AppInfo.makeLaunchIntent;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
+import static com.android.launcher3.util.LauncherModelHelper.TEST_ACTIVITY;
+import static com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE;
+import static com.android.launcher3.util.TestUtil.runOnExecutorSync;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
import android.content.ComponentName;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
+import android.content.pm.LauncherActivityInfo;
+import android.content.pm.LauncherApps;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutInfo.Builder;
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
+import android.graphics.drawable.Icon;
import android.os.PersistableBundle;
+import android.os.UserHandle;
import android.text.TextUtils;
import androidx.annotation.Nullable;
@@ -37,15 +55,30 @@
import androidx.test.filters.SmallTest;
import com.android.launcher3.InvariantDeviceProfile;
+import com.android.launcher3.icons.cache.CachingLogic;
+import com.android.launcher3.icons.cache.IconCacheUpdateHandler;
+import com.android.launcher3.icons.cache.LauncherActivityCachingLogic;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.PackageItemInfo;
+import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.settings.SettingsActivity;
+import com.android.launcher3.shortcuts.ShortcutKey;
+import com.android.launcher3.util.ApplicationInfoWrapper;
+import com.android.launcher3.util.ComponentKey;
+import com.android.launcher3.util.PackageUserKey;
+import com.android.launcher3.util.RoboApiWrapper;
+
+import com.google.common.truth.Truth;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
@SmallTest
@RunWith(AndroidJUnit4.class)
public class IconCacheTest {
@@ -112,6 +145,102 @@
assertEquals(((PackageItemInfo) item).packageName, otherPackage);
}
+ @Test
+ public void launcherActivityInfo_cached_in_memory() {
+ RoboApiWrapper.INSTANCE.initialize();
+ ComponentName cn = new ComponentName(TEST_PACKAGE, TEST_ACTIVITY);
+ UserHandle user = myUserHandle();
+ ComponentKey cacheKey = new ComponentKey(cn, user);
+
+ LauncherActivityInfo lai = mContext.getSystemService(LauncherApps.class)
+ .resolveActivity(makeLaunchIntent(cn), user);
+ assertNotNull(lai);
+
+ WorkspaceItemInfo info = new WorkspaceItemInfo();
+ info.intent = makeLaunchIntent(cn);
+ runOnExecutorSync(MODEL_EXECUTOR,
+ () -> mIconCache.getTitleAndIcon(info, lai, false));
+ assertNotNull(info.bitmap);
+ assertFalse(info.bitmap.isLowRes());
+
+ // Verify that icon is in memory cache
+ runOnExecutorSync(MODEL_EXECUTOR,
+ () -> assertNotNull(mIconCache.getInMemoryEntryLocked(cacheKey)));
+
+ // Schedule async update and wait for it to complete
+ Set<PackageUserKey> updates =
+ executeIconUpdate(lai, LauncherActivityCachingLogic.INSTANCE);
+
+ // Verify that the icon was not updated and is still in memory cache
+ Truth.assertThat(updates).isEmpty();
+ runOnExecutorSync(MODEL_EXECUTOR,
+ () -> assertNotNull(mIconCache.getInMemoryEntryLocked(cacheKey)));
+ }
+
+ @Test
+ public void shortcutInfo_not_cached_in_memory() {
+ CacheableShortcutInfo si = mockShortcutInfo(0);
+ ShortcutKey cacheKey = ShortcutKey.fromInfo(si.getShortcutInfo());
+
+ WorkspaceItemInfo info = new WorkspaceItemInfo();
+ runOnExecutorSync(MODEL_EXECUTOR, () -> mIconCache.getShortcutIcon(info, si));
+ assertNotNull(info.bitmap);
+ assertFalse(info.bitmap.isLowRes());
+
+ // Verify that icon is in memory cache
+ runOnExecutorSync(MODEL_EXECUTOR,
+ () -> assertNull(mIconCache.getInMemoryEntryLocked(cacheKey)));
+
+ Set<PackageUserKey> updates =
+ executeIconUpdate(si, CacheableShortcutCachingLogic.INSTANCE);
+ // Verify that the icon was not updated and is still in memory cache
+ Truth.assertThat(updates).isEmpty();
+ runOnExecutorSync(MODEL_EXECUTOR,
+ () -> assertNull(mIconCache.getInMemoryEntryLocked(cacheKey)));
+
+ // Now update the shortcut with a newer version
+ updates = executeIconUpdate(
+ mockShortcutInfo(System.currentTimeMillis() + 2000),
+ CacheableShortcutCachingLogic.INSTANCE);
+
+ // Verify that icon was updated but it is still not in mem-cache
+ Truth.assertThat(updates).containsExactly(
+ new PackageUserKey(cacheKey.getPackageName(), cacheKey.user));
+ runOnExecutorSync(MODEL_EXECUTOR,
+ () -> assertNull(mIconCache.getInMemoryEntryLocked(cacheKey)));
+ }
+
+ /**
+ * Executes the icon update for the provided entry and returns the updated packages
+ */
+ private <T> Set<PackageUserKey> executeIconUpdate(T object, CachingLogic<T> cachingLogic) {
+ HashSet<PackageUserKey> updates = new HashSet<>();
+
+ runOnExecutorSync(MODEL_EXECUTOR, () -> {
+ IconCacheUpdateHandler updateHandler = mIconCache.getUpdateHandler();
+ updateHandler.updateIcons(
+ Collections.singletonList(object),
+ cachingLogic,
+ (a, b) -> a.forEach(p -> updates.add(new PackageUserKey(p, b))));
+ updateHandler.finish();
+ });
+ waitForUpdateHandlerToFinish(mIconCache);
+ return updates;
+ }
+
+ private CacheableShortcutInfo mockShortcutInfo(long updateTime) {
+ ShortcutInfo info = new ShortcutInfo.Builder(
+ getInstrumentation().getContext(), "test-shortcut")
+ .setIntent(new Intent(Intent.ACTION_VIEW))
+ .setShortLabel("Test")
+ .setIcon(Icon.createWithBitmap(Bitmap.createBitmap(200, 200, Config.ARGB_8888)))
+ .build();
+ ShortcutInfo spied = spy(info);
+ doReturn(updateTime).when(spied).getLastChangedTimestamp();
+ return new CacheableShortcutInfo(spied,
+ new ApplicationInfoWrapper(getInstrumentation().getContext().getApplicationInfo()));
+ }
+
private ItemInfoWithIcon getBadgingInfo(Context context,
@Nullable ComponentName cn, @Nullable String badgeOverride) throws Exception {
Builder builder = new Builder(context, "test-shortcut")
diff --git a/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheUpdateHandlerTest.kt b/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheUpdateHandlerTest.kt
index e27926f..b54636c 100644
--- a/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheUpdateHandlerTest.kt
+++ b/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheUpdateHandlerTest.kt
@@ -25,6 +25,8 @@
import com.android.launcher3.icons.cache.BaseIconCache
import com.android.launcher3.icons.cache.CachingLogic
import com.android.launcher3.icons.cache.IconCacheUpdateHandler
+import com.android.launcher3.util.RoboApiWrapper
+import java.util.concurrent.FutureTask
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -51,7 +53,7 @@
System.currentTimeMillis(),
1,
1.0.toLong(),
- "stateOfConfusion"
+ "stateOfConfusion",
)
@Before
@@ -81,17 +83,32 @@
componentMap,
ignorePackages,
user,
- cachingLogic
+ cachingLogic,
)
assert(result == null)
}
}
+/** Utility method to wait for the icon update handler to finish */
+fun IconCache.waitForUpdateHandlerToFinish() {
+ var cacheUpdateInProgress = true
+ while (cacheUpdateInProgress) {
+ val cacheCheck = FutureTask {
+ // Check for pending message on the worker thread itself as some task may be
+ // running currently
+ workerHandler.hasMessages(0, iconUpdateToken)
+ }
+ workerHandler.postDelayed(cacheCheck, 10)
+ RoboApiWrapper.waitForLooperSync(workerHandler.looper)
+ cacheUpdateInProgress = cacheCheck.get()
+ }
+}
+
data class IconCacheRowData(
val component: String,
val lastUpdated: Long,
val version: Int,
val row: Long,
- val systemState: String
+ val systemState: String,
)
diff --git a/tests/multivalentTests/src/com/android/launcher3/model/FolderIconLoadTest.kt b/tests/multivalentTests/src/com/android/launcher3/model/FolderIconLoadTest.kt
index 371bac2..4ca47e3 100644
--- a/tests/multivalentTests/src/com/android/launcher3/model/FolderIconLoadTest.kt
+++ b/tests/multivalentTests/src/com/android/launcher3/model/FolderIconLoadTest.kt
@@ -19,16 +19,15 @@
import androidx.test.filters.SmallTest
import com.android.launcher3.LauncherAppState
import com.android.launcher3.icons.BitmapInfo
+import com.android.launcher3.icons.waitForUpdateHandlerToFinish
import com.android.launcher3.model.data.WorkspaceItemInfo
import com.android.launcher3.util.Executors
import com.android.launcher3.util.LauncherLayoutBuilder
import com.android.launcher3.util.LauncherModelHelper
import com.android.launcher3.util.LauncherModelHelper.*
-import com.android.launcher3.util.RoboApiWrapper
import com.android.launcher3.util.TestUtil
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
-import java.util.concurrent.CountDownLatch
import org.junit.After
import org.junit.Before
import org.junit.Rule
@@ -147,14 +146,9 @@
// The first load initializes the DB, load again so that icons are now used from the DB
// Wait for the icon cache to be updated and then reload
val app = LauncherAppState.getInstance(modelHelper.sandboxContext)
- val cache = app.iconCache
- while (cache.isIconUpdateInProgress) {
- val wait = CountDownLatch(1)
- Executors.MODEL_EXECUTOR.handler.postDelayed({ wait.countDown() }, 10)
- RoboApiWrapper.waitForLooperSync(Executors.MODEL_EXECUTOR.handler.looper)
- wait.await()
- }
- TestUtil.runOnExecutorSync(Executors.MODEL_EXECUTOR) { cache.clearMemoryCache() }
+ app.iconCache.waitForUpdateHandlerToFinish()
+
+ TestUtil.runOnExecutorSync(Executors.MODEL_EXECUTOR) { app.iconCache.clearMemoryCache() }
// Reload again with correct icon state
app.model.forceReload()
modelHelper.loadModelSync()
diff --git a/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java b/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java
index 7c87c65..44b8ff8 100644
--- a/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java
+++ b/tests/src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java
@@ -16,14 +16,11 @@
package com.android.launcher3.dragging;
import static com.android.launcher3.testing.shared.TestProtocol.ICON_MISSING;
-import static com.android.launcher3.testing.shared.TestProtocol.UIOBJECT_STALE_ELEMENT;
import static com.android.launcher3.util.TestConstants.AppNames.DUMMY_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.GMAIL_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.MAPS_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.STORE_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
-import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
-import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
import static com.google.common.truth.Truth.assertThat;
@@ -40,7 +37,6 @@
import com.android.launcher3.util.TestUtil;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.rule.ScreenRecordRule;
-import com.android.launcher3.util.rule.TestStabilityRule;
import org.junit.Test;
@@ -150,7 +146,6 @@
0, Math.min(gridPositions.length, appNameCandidates.length));
for (int i = 0; i < appNames.length; ++i) {
- Log.d(UIOBJECT_STALE_ELEMENT, "creatingShortcut for: " + appNames[i]);
createShortcutIfNotExist(appNames[i], gridPositions[i]);
}
diff --git a/tests/src/com/android/launcher3/pm/InstallSessionHelperTest.kt b/tests/src/com/android/launcher3/pm/InstallSessionHelperTest.kt
index ca2ef42..a991981 100644
--- a/tests/src/com/android/launcher3/pm/InstallSessionHelperTest.kt
+++ b/tests/src/com/android/launcher3/pm/InstallSessionHelperTest.kt
@@ -28,6 +28,7 @@
import androidx.test.filters.SmallTest
import com.android.launcher3.LauncherPrefs
import com.android.launcher3.LauncherPrefs.Companion.PROMISE_ICON_IDS
+import com.android.launcher3.util.DaggerSingletonTracker
import com.android.launcher3.util.Executors.MODEL_EXECUTOR
import com.android.launcher3.util.IntArray
import com.android.launcher3.util.LauncherModelHelper
@@ -53,6 +54,7 @@
private val expectedAppPackage = "expectedAppPackage"
private val expectedInstallerPackage = "expectedInstallerPackage"
private val mockPackageInstaller: PackageInstaller = mock()
+ private val mTracker: DaggerSingletonTracker = mock()
private lateinit var installSessionHelper: InstallSessionHelper
private lateinit var launcherApps: LauncherApps
@@ -62,7 +64,7 @@
whenever(packageManager.packageInstaller).thenReturn(mockPackageInstaller)
whenever(sandboxContext.packageName).thenReturn(expectedInstallerPackage)
launcherApps = sandboxContext.spyService(LauncherApps::class.java)
- installSessionHelper = InstallSessionHelper(sandboxContext)
+ installSessionHelper = InstallSessionHelper(sandboxContext, mTracker)
}
@Test
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 68004bb..cee88ac 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -26,6 +26,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -103,6 +104,8 @@
public static final long DEFAULT_UI_TIMEOUT = TestUtil.DEFAULT_UI_TIMEOUT;
private static final String TAG = "AbstractLauncherUiTest";
+ private static final long BYTES_PER_MEGABYTE = 1 << 20;
+
private static boolean sDumpWasGenerated = false;
private static boolean sActivityLeakReported = false;
private static boolean sSeenKeyguard = false;
@@ -124,6 +127,10 @@
protected String mTargetPackage;
private int mLauncherPid;
+ private final ActivityManager.MemoryInfo mMemoryInfo = new ActivityManager.MemoryInfo();
+ private final ActivityManager mActivityManager;
+ private long mMemoryBefore;
+
/** Detects activity leaks and throws an exception if a leak is found. */
public static void checkDetectedLeaks(LauncherInstrumentation launcher) {
checkDetectedLeaks(launcher, false);
@@ -192,6 +199,8 @@
}
protected AbstractLauncherUiTest() {
+ mActivityManager = InstrumentationRegistry.getContext()
+ .getSystemService(ActivityManager.class);
mLauncher.enableCheckEventsForSuccessfulGestures();
mLauncher.setAnomalyChecker(AbstractLauncherUiTest::verifyKeyguardInvisible);
try {
@@ -311,6 +320,26 @@
initialize(this);
}
+ private long getAvailableMemory() {
+ mActivityManager.getMemoryInfo(mMemoryInfo);
+
+ return Math.divideExact(mMemoryInfo.availMem, BYTES_PER_MEGABYTE);
+ }
+
+ @Before
+ public void saveMemoryBefore() {
+ mMemoryBefore = getAvailableMemory();
+ }
+
+ @After
+ public void logMemoryAfter() {
+ long memoryAfter = getAvailableMemory();
+
+ Log.d(TAG, "Available memory: before=" + mMemoryBefore
+ + "MB, after=" + memoryAfter
+ + "MB, delta=" + (memoryAfter - mMemoryBefore) + "MB");
+ }
+
/** Method that should be called when a test starts. */
public static void onTestStart() {
waitForSetupWizardDismissal();
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index c8c5384..a29362f 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -25,7 +25,6 @@
import static com.android.launcher3.testing.shared.TestProtocol.ALL_APPS_STATE_ORDINAL;
import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
import static com.android.launcher3.testing.shared.TestProtocol.OVERVIEW_STATE_ORDINAL;
-import static com.android.launcher3.testing.shared.TestProtocol.UIOBJECT_STALE_ELEMENT;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;
@@ -33,7 +32,6 @@
import android.graphics.Point;
import android.graphics.Rect;
import android.os.SystemClock;
-import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -370,14 +368,9 @@
.collect(
Collectors.toMap(
/* keyMapper= */ uiObject21 -> {
- Log.d(UIOBJECT_STALE_ELEMENT, "keyText: "
- + uiObject21.getText());
return uiObject21.getText();
},
/* valueMapper= */ uiObject2 -> {
- Log.d(UIOBJECT_STALE_ELEMENT, uiObject2.getText() +
- " dispId" + uiObject2.getDisplayId() +
- " parent" + uiObject2.getParent());
return uiObject2.getVisibleCenter();
},
/* mergeFunction= */ (p1, p2) -> p1.x < p2.x ? p1 : p2));