Auto-Stashing Functionality for Pinned Taskbar

This cl includes :
- Refactor to remove unpinning/pinning in desktop mode with refactor of DisplayController, TaksbarPinningController, and its tests.
- Combined the auto stashing conditions under one method shouldAllowTaskbarToAutoStash() which takes in consideration isTransientTaskbar, isInDesktop, and Always Show Taskbar option is turned on/off in desktop mode.
- enabled taksbar divider popup support in desktop mode.
- Intorduced animation for pinned taksbar when autostadhing is enabled.
- Enable to onSwipeToUnstashTaskbar for TaskbarInputStashController for pinned taksbar in desktop mode.

Test: Presubmit, Unit, Manual
Bug: 381535785
Flag: com.android.window.flags.enable_desktop_windowing_mode
Change-Id: Ie5ecf3a3c72bf8dfadf2d0c908269305fe5bad0b
This commit is contained in:
Jagrut Desai
2025-04-25 09:46:12 -07:00
parent dd367a2218
commit f52ffc1232
14 changed files with 171 additions and 119 deletions
@@ -1924,8 +1924,12 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mControllers.uiController.onSwipeToUnstashTaskbar();
boolean wasStashed = mControllers.taskbarStashController.isStashed();
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(/* stash= */ false,
SHOULD_BUBBLES_FOLLOW_DEFAULT_VALUE, delayTaskbarBackground);
if (isTransientTaskbar()) {
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(/* stash= */ false,
SHOULD_BUBBLES_FOLLOW_DEFAULT_VALUE, delayTaskbarBackground);
} else if (shouldAllowTaskbarToAutoStash()) {
mControllers.taskbarStashController.updateAndAnimatePinnedTaskbar(false);
}
boolean isStashed = mControllers.taskbarStashController.isStashed();
if (isStashed != wasStashed) {
VibratorWrapper.INSTANCE.get(this).vibrateForTaskbarUnstash();
@@ -1980,6 +1984,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mControllers.taskbarStashController.startUnstashHint(animateForward);
}
/**
* @return if we should allow taskbar to auto stash
*/
public boolean shouldAllowTaskbarToAutoStash() {
return mControllers.taskbarStashController.shouldAllowTaskbarToAutoStash();
}
/**
* Enables the auto timeout for taskbar stashing. This method should only be used for taskbar
* testing.
@@ -33,6 +33,7 @@ import androidx.core.content.res.ResourcesCompat
import androidx.core.view.postDelayed
import com.android.app.animation.Interpolators.EMPHASIZED_ACCELERATE
import com.android.launcher3.Flags
import com.android.launcher3.LauncherPrefs
import com.android.launcher3.R
import com.android.launcher3.popup.ArrowPopup
import com.android.launcher3.popup.RoundedArrowDrawable
@@ -81,8 +82,13 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
private val minPaddingFromScreenEdge =
resources.getDimension(R.dimen.taskbar_pinning_popup_menu_min_padding_from_screen_edge)
// TODO: add test for isTransientTaskbar & long presses divider and ensures the popup shows up.
private var alwaysShowTaskbarOn = !taskbarActivityContext.isTransientTaskbar
private var alwaysShowTaskbarOn =
if (taskbarActivityContext.isInDesktopMode) {
LauncherPrefs.TASKBAR_PINNING_IN_DESKTOP_MODE.get(context)
} else {
!taskbarActivityContext.isTransientTaskbar
}
private var didPreferenceChange = false
private var verticalOffsetForPopupView =
resources.getDimensionPixelSize(R.dimen.taskbar_pinning_popup_menu_vertical_margin)
@@ -629,7 +629,7 @@ public class TaskbarLauncherStateController {
AnimatedFloat taskbarBgOffset =
mControllers.taskbarDragLayerController.getTaskbarBackgroundOffset();
boolean showTaskbar = shouldShowTaskbar(mControllers.taskbarActivityContext, isInLauncher,
isInOverview) && !mControllers.taskbarStashController.isInStashedLauncherState();
isInOverview) && !mControllers.taskbarStashController.isStashed();
float taskbarBgOffsetEnd = showTaskbar ? 0f : 1f;
float taskbarBgOffsetStart = showTaskbar ? 1f : 0f;
@@ -24,6 +24,8 @@ import com.android.app.animation.Interpolators
import com.android.launcher3.LauncherPrefs
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING_IN_DESKTOP_MODE
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DESKTOP_MODE_TASKBAR_PINNED
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DESKTOP_MODE_TASKBAR_UNPINNED
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_DIVIDER_MENU_CLOSE
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_DIVIDER_MENU_OPEN
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_PINNED
@@ -56,16 +58,26 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) :
if (!didPreferenceChange) {
return
}
val shouldPinTaskbar =
if (
controllers.taskbarDesktopModeController.isInDesktopModeAndNotInOverview(
context.displayId
)
) {
if (
controllers.taskbarDesktopModeController.isInDesktopModeAndNotInOverview(
context.displayId
)
) {
val shouldPinDesktopTaskbar =
!launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)
} else {
!launcherPrefs.get(TASKBAR_PINNING)
}
val logEvent =
if (shouldPinDesktopTaskbar) {
LAUNCHER_DESKTOP_MODE_TASKBAR_PINNED
} else {
LAUNCHER_DESKTOP_MODE_TASKBAR_UNPINNED
}
statsLogManager.logger().log(logEvent)
launcherPrefs.put(TASKBAR_PINNING_IN_DESKTOP_MODE, shouldPinDesktopTaskbar)
return
}
val shouldPinTaskbar = !launcherPrefs.get(TASKBAR_PINNING)
val animateToValue =
if (shouldPinTaskbar) {
@@ -62,6 +62,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.launcher3.Alarm;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.anim.AnimationSuccessListener;
@@ -374,8 +375,8 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
mTaskbarBackgroundAlphaForStash.setValue(shouldHideTaskbarBackground ? 0 : 1);
if (mTaskbarSharedState.getTaskbarWasPinned()
|| !mTaskbarSharedState.taskbarWasStashedAuto) {
// if taskbar should auto stash attempt to start timeout.
if (shouldAllowTaskbarToAutoStash()) {
tryStartTaskbarTimeout();
}
notifyStashChange(/* visible */ false, /* stashed */ isStashedInApp());
@@ -647,10 +648,48 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
/* shouldBubblesFollow= */ !bubbleBarExpanded);
}
/**
* @return if we should allow taskbar to auto stash
*/
public boolean shouldAllowTaskbarToAutoStash() {
boolean isTransientTaskbar = mActivity.isTransientTaskbar();
boolean isInDesktop = mActivity.isInDesktopMode();
boolean isTaskbarPinningOnInDesktopMode = LauncherPrefs.TASKBAR_PINNING_IN_DESKTOP_MODE.get(
mActivity);
return isTransientTaskbar || (isInDesktop && !isTaskbarPinningOnInDesktopMode);
}
/**
* Stashes pinned taskbar after it has timed out.
*/
public void updateAndAnimatePinnedTaskbarForTimeout() {
updateAndAnimatePinnedTaskbar(true);
}
/**
* Handles stashing/un-stashing taskbar in desktop mode.
*/
public void updateAndAnimatePinnedTaskbar(boolean isStashed) {
boolean shouldApplyState = false;
if (hasAnyFlag(FLAG_STASHED_IN_APP_AUTO) != isStashed) {
updateStateForFlag(FLAG_STASHED_IN_APP_AUTO, isStashed);
shouldApplyState = true;
}
if (shouldApplyState) {
applyState();
}
}
/** Toggles the Taskbar's stash state. */
public void toggleTaskbarStash() {
if (!mActivity.isTransientTaskbar() || !hasAnyFlag(FLAGS_IN_APP)) return;
updateAndAnimateTransientTaskbar(!hasAnyFlag(FLAG_STASHED_IN_APP_AUTO));
if (!shouldAllowTaskbarToAutoStash() || !hasAnyFlag(FLAGS_IN_APP)) {
return;
}
if (mActivity.isTransientTaskbar()) {
updateAndAnimateTransientTaskbar(!hasAnyFlag(FLAG_STASHED_IN_APP_AUTO));
} else if (mActivity.isInDesktopMode()) {
updateAndAnimatePinnedTaskbar(!hasAnyFlag(FLAG_STASHED_IN_APP_AUTO));
}
}
/**
@@ -727,6 +766,8 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
if (mActivity.isTransientTaskbar()) {
createTransientAnimToIsStashed(mAnimator, isStashed, duration,
shouldDelayBackground, animationType);
} else if (shouldAllowTaskbarToAutoStash()) {
createAnimToIsStashedPinnedTaskbar(mAnimator, isStashed, duration);
} else {
createAnimToIsStashed(mAnimator, isStashed, duration, stashTranslation, animationType);
}
@@ -756,6 +797,16 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
});
}
private void createAnimToIsStashedPinnedTaskbar(AnimatorSet as, boolean isStashed,
long duration) {
int stashTranslation = !isStashed ? 0 : mUnstashedHeight;
as.play(mIconTranslationYForStash.animateToValue(stashTranslation));
as.play(mTaskbarBackgroundOffset.animateToValue(isStashed ? 1 : 0));
as.play(mIconAlphaForStash.animateToValue(isStashed ? 0 : 1));
as.play(mIconScaleForStash.animateToValue(1));
as.setDuration(duration);
}
private void createAnimToIsStashed(AnimatorSet as, boolean isStashed, long duration,
float stashTranslation, @StashAnimation int animationType) {
AnimatorSet fullLengthAnimatorSet = new AnimatorSet();
@@ -1152,6 +1203,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
&& mActivity.isTransientTaskbar();
updateStateForFlag(FLAG_STASHED_SYSUI,
hasAnyFlag(systemUiStateFlags, SYSUI_STATE_SCREEN_PINNING) || stashForBubbles);
updateStateForFlag(FLAG_STASHED_DEVICE_LOCKED,
SystemUiFlagUtils.isLocked(systemUiStateFlags));
@@ -1326,7 +1378,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
* If false, attempts to re/start the timeout
*/
public void updateTaskbarTimeout(boolean isAutohideSuspended) {
if (!mActivity.isTransientTaskbar()) {
if (!shouldAllowTaskbarToAutoStash()) {
return;
}
if (isAutohideSuspended) {
@@ -1340,7 +1392,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
* Attempts to start timer to auto hide the taskbar based on time.
*/
private void tryStartTaskbarTimeout() {
if (!mActivity.isTransientTaskbar() || mIsStashed || mEnableBlockingTimeoutDuringTests) {
if (!shouldAllowTaskbarToAutoStash() || mIsStashed || mEnableBlockingTimeoutDuringTests) {
return;
}
@@ -1362,7 +1414,11 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
if (mControllers.taskbarAutohideSuspendController.isTransientTaskbarStashingSuspended()) {
return;
}
updateAndAnimateTransientTaskbarForTimeout();
if (mActivity.isTransientTaskbar()) {
updateAndAnimateTransientTaskbarForTimeout();
} else if (shouldAllowTaskbarToAutoStash()) {
updateAndAnimatePinnedTaskbarForTimeout();
}
}
@VisibleForTesting
@@ -162,6 +162,13 @@ public class TaskbarUIController implements BubbleBarController.BubbleBarLocatio
mControllers.taskbarActivityContext.startTranslationSpring();
}
/**
* @return if we should allow taskbar to auto stash
*/
public boolean shouldAllowTaskbarToAutoStash() {
return mControllers.taskbarActivityContext.shouldAllowTaskbarToAutoStash();
}
/**
* @param ev MotionEvent in screen coordinates.
* @return Whether any Taskbar item could handle the given MotionEvent if given the chance.
@@ -43,7 +43,7 @@ private constructor(private val taskbarActivityContext: TaskbarActivityContext)
val supportsPinningPopup: Boolean
// TODO(b/381535785): Allow pinning for desktop taskbar when desktop mode transient behavior
// gets updated to retain pinned UI, but translate the taskbar offscreen.
get() = !hasNavButtons && !taskbarActivityContext.isTaskbarShowingDesktopTasks
get() = !hasNavButtons
fun onDestroy() {
taskbarFeatureEvaluator = null
@@ -2781,7 +2781,11 @@ public abstract class AbsSwipeUpHandler<
*/
@Override
protected float overrideDisplacementForTransientTaskbar(float displacement) {
if (!mIsTransientTaskbar) {
boolean shouldReturnDisplacement = mContainerInterface.getTaskbarController() == null
? !mIsTransientTaskbar
: !mContainerInterface.getTaskbarController().shouldAllowTaskbarToAutoStash();
if (shouldReturnDisplacement) {
return displacement;
}
@@ -98,18 +98,24 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
GestureState gestureState) {
super(gestureState.getDisplayId(), delegate, inputMonitor);
mTaskbarActivityContext = taskbarActivityContext;
mIsTransientTaskbar = DisplayController.isTransientTaskbar(context);
mOverviewCommandHelper = overviewCommandHelper;
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
Resources res = context.getResources();
mUnstashArea = res.getDimensionPixelSize(R.dimen.taskbar_unstash_input_area);
mTaskbarNavThreshold = TaskbarThresholdUtils.getFromNavThreshold(res,
taskbarActivityContext.getDeviceProfile());
boolean pinnedTaskbarWithAutoStashing =
mTaskbarActivityContext.shouldAllowTaskbarToAutoStash() && !mIsTransientTaskbar;
mTaskbarNavThreshold =
pinnedTaskbarWithAutoStashing ? 0 : TaskbarThresholdUtils.getFromNavThreshold(res,
taskbarActivityContext.getDeviceProfile());
mTaskbarNavThresholdY = taskbarActivityContext.getDeviceProfile().heightPx
- mTaskbarNavThreshold;
mIsTaskbarAllAppsOpen = mTaskbarActivityContext.isTaskbarAllAppsOpen();
mIsTransientTaskbar = DisplayController.isTransientTaskbar(context);
mTaskbarSlowVelocityYThreshold =
res.getDimensionPixelSize(R.dimen.taskbar_slow_velocity_y_threshold);
@@ -181,16 +187,16 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
float dX = mLastPos.x - mDownPos.x;
float dY = mLastPos.y - mDownPos.y;
if (mIsTransientTaskbar) {
if (mTaskbarActivityContext.shouldAllowTaskbarToAutoStash()) {
boolean passedTaskbarNavThreshold = dY < 0
&& Math.abs(dY) >= mTaskbarNavThreshold;
// we only care about nav thresholds when we are transient taskbar
if (!mHasPassedTaskbarNavThreshold && passedTaskbarNavThreshold
&& !mGestureState.isInExtendedSlopRegion()) {
mHasPassedTaskbarNavThreshold = true;
mTaskbarActivityContext.onSwipeToUnstashTaskbar(true);
}
if (dY < 0) {
dY = -OverScroll.dampedScroll(-dY, mTaskbarNavThresholdY);
if (mTransitionCallback != null && !mIsTaskbarAllAppsOpen) {
@@ -20,9 +20,12 @@ import android.animation.AnimatorTestRule
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import com.android.launcher3.LauncherPrefs
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING_IN_DESKTOP_MODE
import com.android.launcher3.QuickstepTransitionManager.PINNED_TASKBAR_TRANSITION_DURATION
import com.android.launcher3.R
import com.android.launcher3.statehandlers.DesktopVisibilityController
import com.android.launcher3.taskbar.StashedHandleViewController.ALPHA_INDEX_STASHED
import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_EDU_OPEN
import com.android.launcher3.taskbar.TaskbarControllerTestUtil.asProperty
@@ -61,6 +64,7 @@ import org.junit.After
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.whenever
@RunWith(LauncherMultivalentJUnit::class)
@EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
@@ -80,6 +84,9 @@ class TaskbarStashControllerTest {
@InjectController lateinit var bubbleBarViewController: BubbleBarViewController
@InjectController lateinit var bubbleStashController: BubbleStashController
private val desktopVisibilityController: DesktopVisibilityController
get() = DesktopVisibilityController.INSTANCE[context]
private val activityContext by taskbarUnitTestRule::activityContext
@After fun cancelTimeoutIfExists() = stashController.cancelTimeoutIfExists()
@@ -387,6 +394,24 @@ class TaskbarStashControllerTest {
assertThat(stashController.timeoutAlarm.alarmPending()).isTrue()
}
@Test
@TaskbarMode(PINNED)
fun testUpdateTaskbarTimeout_unPinnedTaskbarInDesktopMode_startsTaskbarTimeout() {
LauncherPrefs.get(context).put(TASKBAR_PINNING_IN_DESKTOP_MODE, false)
whenever(desktopVisibilityController.isInDesktopMode(context.displayId)).thenReturn(true)
stashController.updateTaskbarTimeout(false)
assertThat(stashController.timeoutAlarm.alarmPending()).isTrue()
}
@Test
@TaskbarMode(PINNED)
fun testUpdateTaskbarTimeout_pinnedTaskbarInDesktopMode_shouldNotStartsTaskbarTimeout() {
LauncherPrefs.get(context).put(TASKBAR_PINNING_IN_DESKTOP_MODE, true)
whenever(desktopVisibilityController.isInDesktopMode(context.displayId)).thenReturn(true)
stashController.updateTaskbarTimeout(false)
assertThat(stashController.timeoutAlarm.alarmPending()).isFalse()
}
@Test
@TaskbarMode(TRANSIENT)
fun testUpdateAndAnimateTransientTaskbar_finishTaskbarTimeout_taskbarStashes() {
@@ -117,6 +117,14 @@ class TaskbarPinningControllerTest : TaskbarBaseTestCase() {
verify(pinningController, times(1)).animateTaskbarPinning(PINNING_PERSISTENT)
}
@Test
fun testOnCloseCallback_whenLauncherPreferenceChanged_shouldNotAnimateToTaskbarInDesktopMode() {
isInDesktopMode = true
whenever(launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)).thenReturn(false)
pinningController.onCloseCallback(true)
verify(pinningController, never()).animateTaskbarPinning(any())
}
@Test
fun testOnCloseCallback_whenLauncherPreferenceChanged_shouldAnimateToTransientTaskbar() {
whenever(launcherPrefs.get(TASKBAR_PINNING)).thenReturn(true)
@@ -211,13 +219,4 @@ class TaskbarPinningControllerTest : TaskbarBaseTestCase() {
assertThat(pinningController.isAnimatingTaskbarPinning).isFalse()
verify(launcherPrefs, times(1)).put(TASKBAR_PINNING, true)
}
@Test
fun testRecreateTaskbarAndUpdatePinningValue_whenAnimationEnds_shouldUpdateTaskbarPinningDesktopModePref() {
isInDesktopMode = true
pinningController.recreateTaskbarAndUpdatePinningValue()
verify(taskbarDragLayer, times(1)).setAnimatingTaskbarPinning(false)
assertThat(pinningController.isAnimatingTaskbarPinning).isFalse()
verify(launcherPrefs, times(1)).put(TASKBAR_PINNING_IN_DESKTOP_MODE, true)
}
}
@@ -933,6 +933,12 @@ public class StatsLogManager {
@UiEvent(doc = "Do row shift migration when upgrading to one grid")
LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION(2206),
@UiEvent(doc = "User has pinned taskbar in desktop mode using taskbar divider menu")
LAUNCHER_DESKTOP_MODE_TASKBAR_PINNED(2241),
@UiEvent(doc = "User has unpinned taskbar in desktop mode using taskbar divider menu")
LAUNCHER_DESKTOP_MODE_TASKBAR_UNPINNED(2242),
// ADD MORE
;
@@ -23,7 +23,6 @@ import static com.android.launcher3.InvariantDeviceProfile.TYPE_MULTI_DISPLAY;
import static com.android.launcher3.InvariantDeviceProfile.TYPE_PHONE;
import static com.android.launcher3.InvariantDeviceProfile.TYPE_TABLET;
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING;
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING_DESKTOP_MODE_KEY;
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING_IN_DESKTOP_MODE;
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING_KEY;
import static com.android.launcher3.Utilities.dpiFromPx;
@@ -141,11 +140,7 @@ public class DisplayController implements DesktopVisibilityListener {
Info info = getInfo();
boolean isTaskbarPinningChanged = TASKBAR_PINNING_KEY.equals(key)
&& info.mIsTaskbarPinned != prefs.get(TASKBAR_PINNING);
boolean isTaskbarPinningDesktopModeChanged =
TASKBAR_PINNING_DESKTOP_MODE_KEY.equals(key)
&& info.mIsTaskbarPinnedInDesktopMode != prefs.get(
TASKBAR_PINNING_IN_DESKTOP_MODE);
if (isTaskbarPinningChanged || isTaskbarPinningDesktopModeChanged) {
if (isTaskbarPinningChanged) {
notifyConfigChange(DEFAULT_DISPLAY);
}
};
@@ -407,8 +402,6 @@ public class DisplayController implements DesktopVisibilityListener {
"(CHANGE_SUPPORTED_BOUNDS) perDisplayBounds: " + newInfo.mPerDisplayBounds);
}
if ((newInfo.mIsTaskbarPinned != oldInfo.mIsTaskbarPinned)
|| (newInfo.mIsTaskbarPinnedInDesktopMode
!= oldInfo.mIsTaskbarPinnedInDesktopMode)
|| newInfo.isPinnedTaskbar() != oldInfo.isPinnedTaskbar()) {
change |= CHANGE_TASKBAR_PINNING;
}
@@ -507,7 +500,6 @@ public class DisplayController implements DesktopVisibilityListener {
new ArrayMap<>();
private final boolean mIsTaskbarPinned;
private final boolean mIsTaskbarPinnedInDesktopMode;
private final boolean mIsInDesktopMode;
@@ -574,8 +566,6 @@ public class DisplayController implements DesktopVisibilityListener {
}
mIsTaskbarPinned = LauncherPrefs.get(displayInfoContext).get(TASKBAR_PINNING);
mIsTaskbarPinnedInDesktopMode = LauncherPrefs.get(displayInfoContext).get(
TASKBAR_PINNING_IN_DESKTOP_MODE);
mIsInDesktopMode = wmProxy.isInDesktopMode(DEFAULT_DISPLAY);
mShowLockedTaskbarOnHome = wmProxy.showLockedTaskbarOnHome(displayInfoContext);
mShowDesktopTaskbarForFreeformDisplay = wmProxy.showDesktopTaskbarForFreeformDisplay(
@@ -607,7 +597,7 @@ public class DisplayController implements DesktopVisibilityListener {
return false;
}
if (mIsInDesktopMode) {
return !mIsTaskbarPinnedInDesktopMode;
return false;
}
return !mIsTaskbarPinned;
}
@@ -733,7 +723,6 @@ public class DisplayController implements DesktopVisibilityListener {
pw.println(" densityDpi=" + info.densityDpi);
pw.println(" navigationMode=" + info.getNavigationMode().name());
pw.println(" isTaskbarPinned=" + info.mIsTaskbarPinned);
pw.println(" isTaskbarPinnedInDesktopMode=" + info.mIsTaskbarPinnedInDesktopMode);
pw.println(" isInDesktopMode=" + info.mIsInDesktopMode);
pw.println(" showLockedTaskbarOnHome=" + info.showLockedTaskbarOnHome());
pw.println(" currentSize=" + info.currentSize);
@@ -28,11 +28,9 @@ import androidx.test.annotation.UiThreadTest
import androidx.test.filters.SmallTest
import com.android.launcher3.LauncherPrefs
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING_IN_DESKTOP_MODE
import com.android.launcher3.dagger.LauncherAppComponent
import com.android.launcher3.dagger.LauncherAppSingleton
import com.android.launcher3.util.DisplayController.CHANGE_DENSITY
import com.android.launcher3.util.DisplayController.CHANGE_DESKTOP_MODE
import com.android.launcher3.util.DisplayController.CHANGE_ROTATION
import com.android.launcher3.util.DisplayController.CHANGE_SHOW_LOCKED_TASKBAR
import com.android.launcher3.util.DisplayController.CHANGE_TASKBAR_PINNING
@@ -105,7 +103,6 @@ class DisplayControllerTest {
displayManager = context.spyService(DisplayManager::class.java)
whenever(launcherPrefs.get(TASKBAR_PINNING)).thenReturn(false)
whenever(launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)).thenReturn(true)
// Mock WindowManagerProxy
val displayInfo = CachedDisplayInfo(Point(width, height), Surface.ROTATION_0)
@@ -189,15 +186,6 @@ class DisplayControllerTest {
.onDisplayInfoChanged(any(), any(), eq(CHANGE_TASKBAR_PINNING))
}
@Test
@UiThreadTest
fun testTaskbarPinningChangeInDesktopMode() {
whenever(launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)).thenReturn(false)
displayController.notifyConfigChange()
verify(displayInfoChangeListener)
.onDisplayInfoChanged(any(), any(), eq(CHANGE_TASKBAR_PINNING))
}
@Test
@UiThreadTest
fun testTaskbarPinningChangeInLockedTaskbarChange() {
@@ -239,63 +227,6 @@ class DisplayControllerTest {
)
assertFalse(displayController.getInfo().isTransientTaskbar())
}
@Test
@UiThreadTest
fun testTaskbarPinnedForDesktopTaskbar_inDesktopMode() {
whenever(windowManagerProxy.showDesktopTaskbarForFreeformDisplay(any())).thenReturn(true)
whenever(launcherPrefs.get(TASKBAR_PINNING)).thenReturn(false)
whenever(launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)).thenReturn(false)
whenever(windowManagerProxy.isInDesktopMode(any())).thenReturn(true)
whenever(windowManagerProxy.isHomeVisible()).thenReturn(false)
DisplayController.enableTaskbarModePreferenceForTests(true)
assertTrue(displayController.getInfo().isTransientTaskbar())
displayController.onConfigurationChanged(configuration)
verify(displayInfoChangeListener)
.onDisplayInfoChanged(any(), any(), eq(CHANGE_TASKBAR_PINNING or CHANGE_DESKTOP_MODE))
assertFalse(displayController.getInfo().isTransientTaskbar())
}
@Test
@UiThreadTest
fun testTaskbarPinnedForDesktopTaskbar_notInDesktopMode() {
whenever(windowManagerProxy.showDesktopTaskbarForFreeformDisplay(any())).thenReturn(true)
whenever(launcherPrefs.get(TASKBAR_PINNING)).thenReturn(false)
whenever(launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)).thenReturn(false)
whenever(windowManagerProxy.isInDesktopMode(any())).thenReturn(false)
whenever(windowManagerProxy.isHomeVisible()).thenReturn(false)
DisplayController.enableTaskbarModePreferenceForTests(true)
assertTrue(displayController.getInfo().isTransientTaskbar())
displayController.onConfigurationChanged(configuration)
verify(displayInfoChangeListener)
.onDisplayInfoChanged(any(), any(), eq(CHANGE_TASKBAR_PINNING))
assertFalse(displayController.getInfo().isTransientTaskbar())
}
@Test
@UiThreadTest
fun testTaskbarPinnedForDesktopTaskbar_onHome() {
whenever(windowManagerProxy.showDesktopTaskbarForFreeformDisplay(any())).thenReturn(true)
whenever(launcherPrefs.get(TASKBAR_PINNING)).thenReturn(false)
whenever(launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)).thenReturn(false)
whenever(windowManagerProxy.isInDesktopMode(any())).thenReturn(false)
whenever(windowManagerProxy.isHomeVisible()).thenReturn(true)
DisplayController.enableTaskbarModePreferenceForTests(true)
assertTrue(displayController.getInfo().isTransientTaskbar())
displayController.onConfigurationChanged(configuration)
verify(displayInfoChangeListener)
.onDisplayInfoChanged(any(), any(), eq(CHANGE_TASKBAR_PINNING))
assertFalse(displayController.getInfo().isTransientTaskbar())
}
}
class MyWmProxy : WindowManagerProxy()