From 1e8b45f8f12a23ac4caa6b4c325304e372b58d0c Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Thu, 25 Aug 2022 11:50:59 -0400 Subject: [PATCH 1/8] Extract cell horizontal space to a method Fixes: 229100375 Test: DeviceProfileTest Change-Id: Ia2e560b37f4e9fbff9b5c2e7c0ef3fe710e55c29 --- src/com/android/launcher3/DeviceProfile.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 14a467ad65..a330fb3c7e 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -513,7 +513,7 @@ public class DeviceProfile { private int getIconToIconWidthForColumns(int columns) { return columns * getCellSize().x + (columns - 1) * cellLayoutBorderSpacePx.x - - (getCellSize().x - iconSizePx); // left and right cell space + - getCellHorizontalSpace(); } private int getHorizontalMarginPx(InvariantDeviceProfile idp, Resources res) { @@ -984,6 +984,13 @@ public class DeviceProfile { return result; } + /** + * Returns the left and right space on the cell, which is the cell width - icon size + */ + public int getCellHorizontalSpace() { + return getCellSize().x - iconSizePx; + } + /** * Gets the number of panels within the workspace. */ From edea2575e6ba134192a125284ca83d3b19f0cb9a Mon Sep 17 00:00:00 2001 From: Becky Qiu Date: Fri, 26 Aug 2022 12:42:05 -0700 Subject: [PATCH 2/8] [Toast] Add a feature flag for using app search for web zero-state. Bug: 241001264 Test: local Change-Id: Id4af1664253182217014a43d8f8025f1a00da291 --- src/com/android/launcher3/config/FeatureFlags.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 49466adb38..e109b4754b 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -269,6 +269,10 @@ public final class FeatureFlags { "USE_SEARCH_REQUEST_TIMEOUT_OVERRIDES", false, "Use local overrides for search request timeout"); + public static final BooleanFlag USE_APP_SEARCH_FOR_WEB = getDebugFlag( + "USE_APP_SEARCH_FOR_WEB", false, + "Use app search to request zero state web suggestions"); + public static final BooleanFlag CONTINUOUS_VIEW_TREE_CAPTURE = getDebugFlag( "CONTINUOUS_VIEW_TREE_CAPTURE", false, "Capture View tree every frame"); From b6f593042db5a61089adfaae9a994b0d53b3d41f Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Fri, 26 Aug 2022 20:43:51 -0700 Subject: [PATCH 3/8] Don't rely on QuickstepLauncher instance for tests Instead, bind to TouchInteractionService and use that binder to call into taskbar. Test: TaplTestsTaskbar Bug: 235986838 Change-Id: I222522bc53c9d1698542fbae52c37889f14abf41 --- .../DebugQuickstepTestInformationHandler.java | 53 ++++++++++--------- .../taskbar/LauncherTaskbarUIController.java | 19 ------- .../taskbar/TaskbarActivityContext.java | 18 +++++++ 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java b/quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java index 2ffb28e8fb..7fa62c1ca5 100644 --- a/quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java +++ b/quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java @@ -25,12 +25,14 @@ import androidx.annotation.Nullable; import com.android.launcher3.Launcher; import com.android.launcher3.R; -import com.android.launcher3.taskbar.LauncherTaskbarUIController; import com.android.launcher3.testing.DebugTestInformationHandler; import com.android.launcher3.testing.shared.TestProtocol; -import com.android.launcher3.uioverrides.QuickstepLauncher; +import com.android.quickstep.TouchInteractionService.TISBinder; +import com.android.quickstep.util.TISBindHelper; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; +import java.util.function.Consumer; /** * Class to handle requests from tests, including debug ones, to Quickstep Launcher builds. @@ -49,29 +51,26 @@ public abstract class DebugQuickstepTestInformationHandler extends QuickstepTest Bundle response = new Bundle(); switch (method) { case TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING: - runOnUIThread(l -> { - enableManualTaskbarStashing(l, true); + runOnTISBinder(tisBinder -> { + enableManualTaskbarStashing(tisBinder, true); }); return response; case TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING: - runOnUIThread(l -> { - enableManualTaskbarStashing(l, false); + runOnTISBinder(tisBinder -> { + enableManualTaskbarStashing(tisBinder, false); }); return response; case TestProtocol.REQUEST_UNSTASH_TASKBAR_IF_STASHED: - runOnUIThread(l -> { - enableManualTaskbarStashing(l, true); - - QuickstepLauncher quickstepLauncher = (QuickstepLauncher) l; - LauncherTaskbarUIController taskbarUIController = - quickstepLauncher.getTaskbarUIController(); + runOnTISBinder(tisBinder -> { + enableManualTaskbarStashing(tisBinder, true); // Allow null-pointer to catch illegal states. - taskbarUIController.unstashTaskbarIfStashed(); + tisBinder.getTaskbarManager().getCurrentActivityContext() + .unstashTaskbarIfStashed(); - enableManualTaskbarStashing(l, false); + enableManualTaskbarStashing(tisBinder, false); }); return response; @@ -89,24 +88,26 @@ public abstract class DebugQuickstepTestInformationHandler extends QuickstepTest } } - private void enableManualTaskbarStashing(Launcher launcher, boolean enable) { - QuickstepLauncher quickstepLauncher = (QuickstepLauncher) launcher; - LauncherTaskbarUIController taskbarUIController = - quickstepLauncher.getTaskbarUIController(); - + private void enableManualTaskbarStashing(TISBinder tisBinder, boolean enable) { // Allow null-pointer to catch illegal states. - taskbarUIController.enableManualStashingForTests(enable); + tisBinder.getTaskbarManager().getCurrentActivityContext().enableManualStashingForTests( + enable); } /** - * Runs the given command on the UI thread. + * Runs the given command on the UI thread, after ensuring we are connected to + * TouchInteractionService. */ - private static void runOnUIThread(UIThreadCommand command) { + private void runOnTISBinder(Consumer connectionCallback) { try { - MAIN_EXECUTOR.submit(() -> { - command.execute(Launcher.ACTIVITY_TRACKER.getCreatedActivity()); - return null; - }).get(); + CountDownLatch countDownLatch = new CountDownLatch(1); + TISBindHelper helper = MAIN_EXECUTOR.submit(() -> + new TISBindHelper(mContext, tisBinder -> { + connectionCallback.accept(tisBinder); + countDownLatch.countDown(); + })).get(); + countDownLatch.await(); + MAIN_EXECUTOR.submit(helper::onDestroy); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index 6c740bac50..6e0b71dca0 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -30,7 +30,6 @@ import android.view.WindowManagerGlobal; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.annotation.VisibleForTesting; import com.android.launcher3.DeviceProfile; import com.android.launcher3.LauncherState; @@ -123,24 +122,6 @@ public class LauncherTaskbarUIController extends TaskbarUIController { shouldDelayLauncherStateAnim); } - /** - * Enables manual taskbar stashing. This method should only be used for tests that need to - * stash/unstash the taskbar. - */ - @VisibleForTesting - public void enableManualStashingForTests(boolean enableManualStashing) { - mControllers.taskbarStashController.enableManualStashingForTests(enableManualStashing); - } - - /** - * Unstashes the Taskbar if it is stashed. This method should only be used to unstash the - * taskbar at the end of a test. - */ - @VisibleForTesting - public void unstashTaskbarIfStashed() { - mControllers.taskbarStashController.onLongPressToUnstashTaskbar(); - } - /** * Adds the Launcher resume animator to the given animator set. * diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index e1bcbe23bf..3b1e6774b4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -773,6 +773,24 @@ public class TaskbarActivityContext extends BaseTaskbarContext { mControllers.taskbarStashController.startUnstashHint(animateForward); } + /** + * Enables manual taskbar stashing. This method should only be used for tests that need to + * stash/unstash the taskbar. + */ + @VisibleForTesting + public void enableManualStashingForTests(boolean enableManualStashing) { + mControllers.taskbarStashController.enableManualStashingForTests(enableManualStashing); + } + + /** + * Unstashes the Taskbar if it is stashed. This method should only be used to unstash the + * taskbar at the end of a test. + */ + @VisibleForTesting + public void unstashTaskbarIfStashed() { + mControllers.taskbarStashController.onLongPressToUnstashTaskbar(); + } + protected boolean isUserSetupComplete() { return mIsUserSetupComplete; } From c8e824dbdb6783e8cdd0a5cacf1206c849ca2fde Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 2 Aug 2022 13:42:10 -0700 Subject: [PATCH 4/8] Add support to Tapl to recreateTaskbar Also moved references of "tasbkar_view" to share TASKBAR_RES_ID constant Test: compiles; see follow up CLs Bug: 235986838 Change-Id: I69bcfa975550e567f3daa35af8a810546297d79c --- .../DebugQuickstepTestInformationHandler.java | 5 +++++ .../launcher3/taskbar/TaskbarManager.java | 4 +++- .../launcher3/testing/shared/TestProtocol.java | 1 + .../launcher3/tapl/LaunchedAppState.java | 17 ++++++++++++++--- .../launcher3/tapl/LauncherInstrumentation.java | 11 ++++++++++- .../com/android/launcher3/tapl/Taskbar.java | 9 +++++---- 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java b/quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java index 7fa62c1ca5..0c1f05f923 100644 --- a/quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java +++ b/quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java @@ -81,6 +81,11 @@ public abstract class DebugQuickstepTestInformationHandler extends QuickstepTest return response; } + case TestProtocol.REQUEST_RECREATE_TASKBAR: + // Allow null-pointer to catch illegal states. + runOnTISBinder(tisBinder -> tisBinder.getTaskbarManager().recreateTaskbar()); + return response; + default: response = super.call(method, arg, extras); if (response != null) return response; diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java index 35c5b96b9a..80b3c1d095 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java @@ -36,6 +36,7 @@ import android.view.Display; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import com.android.launcher3.DeviceProfile; import com.android.launcher3.LauncherAppState; @@ -277,7 +278,8 @@ public class TaskbarManager { * we fully want to destroy an existing taskbar and create a new one. * In other case (folding/unfolding) we don't need to remove and add window. */ - private void recreateTaskbar() { + @VisibleForTesting + public void recreateTaskbar() { DeviceProfile dp = mUserUnlocked ? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null; diff --git a/src/com/android/launcher3/testing/shared/TestProtocol.java b/src/com/android/launcher3/testing/shared/TestProtocol.java index 67efb58848..5116b01ba5 100644 --- a/src/com/android/launcher3/testing/shared/TestProtocol.java +++ b/src/com/android/launcher3/testing/shared/TestProtocol.java @@ -86,6 +86,7 @@ public final class TestProtocol { public static final String REQUEST_DISABLE_MANUAL_TASKBAR_STASHING = "disable-taskbar-stashing"; public static final String REQUEST_UNSTASH_TASKBAR_IF_STASHED = "unstash-taskbar-if-stashed"; public static final String REQUEST_STASHED_TASKBAR_HEIGHT = "stashed-taskbar-height"; + public static final String REQUEST_RECREATE_TASKBAR = "recreate-taskbar"; public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags"; public static final String REQUEST_APPS_LIST_SCROLL_Y = "apps-list-scroll-y"; public static final String REQUEST_WIDGETS_SCROLL_Y = "widgets-scroll-y"; diff --git a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java index 0416783998..a17651b640 100644 --- a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java +++ b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java @@ -16,6 +16,7 @@ package com.android.launcher3.tapl; +import static com.android.launcher3.tapl.LauncherInstrumentation.TASKBAR_RES_ID; import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING; import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING; import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_STASHED_TASKBAR_HEIGHT; @@ -54,12 +55,22 @@ public final class LaunchedAppState extends Background { public Taskbar getTaskbar() { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to get the taskbar")) { - mLauncher.waitForLauncherObject("taskbar_view"); + mLauncher.waitForLauncherObject(TASKBAR_RES_ID); return new Taskbar(mLauncher); } } + /** + * Waits for the taskbar to be hidden, or fails. + */ + public void assertTaskbarHidden() { + try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( + "waiting for taskbar to be hidden")) { + mLauncher.waitUntilLauncherObjectGone(TASKBAR_RES_ID); + } + } + /** * Returns the Taskbar in a visible state. * @@ -71,7 +82,7 @@ public final class LaunchedAppState extends Background { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "want to show the taskbar")) { - mLauncher.waitUntilLauncherObjectGone("taskbar_view"); + mLauncher.waitUntilLauncherObjectGone(TASKBAR_RES_ID); final long downTime = SystemClock.uptimeMillis(); final int unstashTargetY = mLauncher.getRealDisplaySize().y @@ -85,7 +96,7 @@ public final class LaunchedAppState extends Background { LauncherInstrumentation.log("showTaskbar: sent down"); try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("pressed down")) { - mLauncher.waitForLauncherObject("taskbar_view"); + mLauncher.waitForLauncherObject(TASKBAR_RES_ID); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_UP, unstashTarget, LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER); diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index fa7e8e93bb..1fb8cc7df8 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -168,7 +168,7 @@ public final class LauncherInstrumentation { private static final String OVERVIEW_RES_ID = "overview_panel"; private static final String WIDGETS_RES_ID = "primary_widgets_list_view"; private static final String CONTEXT_MENU_RES_ID = "popup_container"; - private static final String TASKBAR_RES_ID = "taskbar_view"; + static final String TASKBAR_RES_ID = "taskbar_view"; private static final String SPLIT_PLACEHOLDER_RES_ID = "split_placeholder"; public static final int WAIT_TIME_MS = 30000; private static final String SYSTEMUI_PACKAGE = "com.android.systemui"; @@ -1755,6 +1755,15 @@ public final class LauncherInstrumentation { getTestInfo(TestProtocol.REQUEST_UNSTASH_TASKBAR_IF_STASHED); } + /** + * Recreates the taskbar (outside of tests this is done for certain configuration changes). + * The expected behavior is that the taskbar retains its current state after being recreated. + * For example, if taskbar is currently stashed, it should still be stashed after recreating. + */ + public void recreateTaskbar() { + getTestInfo(TestProtocol.REQUEST_RECREATE_TASKBAR); + } + public List getHotseatIconNames() { return getTestInfo(TestProtocol.REQUEST_HOTSEAT_ICON_NAMES) .getStringArrayList(TestProtocol.TEST_INFO_RESPONSE_FIELD); diff --git a/tests/tapl/com/android/launcher3/tapl/Taskbar.java b/tests/tapl/com/android/launcher3/tapl/Taskbar.java index 5d9be3604d..0f9d5f52c7 100644 --- a/tests/tapl/com/android/launcher3/tapl/Taskbar.java +++ b/tests/tapl/com/android/launcher3/tapl/Taskbar.java @@ -15,6 +15,7 @@ */ package com.android.launcher3.tapl; +import static com.android.launcher3.tapl.LauncherInstrumentation.TASKBAR_RES_ID; import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING; import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING; @@ -51,7 +52,7 @@ public final class Taskbar { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to get a taskbar icon")) { return new TaskbarAppIcon(mLauncher, mLauncher.waitForObjectInContainer( - mLauncher.waitForLauncherObject("taskbar_view"), + mLauncher.waitForLauncherObject(TASKBAR_RES_ID), AppIcon.getAppIconSelector(appName, mLauncher))); } } @@ -67,7 +68,7 @@ public final class Taskbar { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to hide the taskbar"); LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { - mLauncher.waitForLauncherObject("taskbar_view"); + mLauncher.waitForLauncherObject(TASKBAR_RES_ID); final long downTime = SystemClock.uptimeMillis(); Point stashTarget = new Point( @@ -96,7 +97,7 @@ public final class Taskbar { LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { mLauncher.clickLauncherObject(mLauncher.waitForObjectInContainer( - mLauncher.waitForLauncherObject("taskbar_view"), getAllAppsButtonSelector())); + mLauncher.waitForLauncherObject(TASKBAR_RES_ID), getAllAppsButtonSelector())); return new AllAppsFromTaskbar(mLauncher); } @@ -107,7 +108,7 @@ public final class Taskbar { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "want to get all taskbar icons")) { return mLauncher.waitForObjectsInContainer( - mLauncher.waitForLauncherObject("taskbar_view"), + mLauncher.waitForLauncherObject(TASKBAR_RES_ID), AppIcon.getAnyAppIconSelector()) .stream() .map(UiObject2::getText) From e74569e935ebee5d01e9144b8a8c5145fea7fcfb Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Fri, 29 Jul 2022 16:55:18 -0700 Subject: [PATCH 5/8] Fix taskbar stash state not persisting properly across recreate Because we check supportsVisualStashing() in TaskbarStashController#init(), we need to avoid using TaskbarUIController to provide that value since TaskbarUIController isn't initialized until a bit later than the other controllers. So I moved the logic from supportsVisualStashing() back to TaskbarStashController, but still allow TaskbarUIController to override it (e.g. for DesktopTaskbarUIController). After that fix, I noticed that force stopping launcher (to test the fix) would briefly show the taskbar background before resetting the stashed state. This is also due to LauncherTaskbarUIController not being ready immediately, since that's what sets FLAG_IN_APP due to launcher being paused. To work around this, I set FLAG_IN_APP to true by default in TaskbarStashController#init(), since that is the most common case, and taskbar background/stashed handle isn't shown on home anyway. Test: Force stop launcher while taskbar is stashed, verify it recreates as stashed without background flicker; same when changing wallpaper color on home or in app; also tested when taskbar isn't stashed and in 3 button mode for good measure Test: testHideTaskbarPersistsOnRecreate Fixes: 235986838 Change-Id: Ie55bd70e8288d5ad7433dde970f18c176831d747 --- .../taskbar/DesktopTaskbarUIController.java | 2 +- .../launcher3/taskbar/TaskbarStashController.java | 13 +++++++++---- .../launcher3/taskbar/TaskbarUIController.java | 8 ++++++-- .../src/com/android/quickstep/TaplTestsTaskbar.java | 7 +++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java index d69b8d291c..9393b0f7ab 100644 --- a/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java @@ -43,8 +43,8 @@ public class DesktopTaskbarUIController extends TaskbarUIController { mLauncher.getHotseat().setIconsAlpha(1f); } - @Override /** Disable taskbar stashing in desktop environment. */ + @Override public boolean supportsVisualStashing() { return false; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 3ea917334c..d9d55e765f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -210,7 +210,10 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba StashedHandleViewController.ALPHA_INDEX_STASHED); mTaskbarStashedHandleHintScale = stashedHandleController.getStashedHandleHintScale(); - boolean isManuallyStashedInApp = supportsManualStashing() + // We use supportsVisualStashing() here instead of supportsManualStashing() because we want + // it to work properly for tests that recreate taskbar. This check is here just to ensure + // that taskbar unstashes when going to 3 button mode (supportsVisualStashing() false). + boolean isManuallyStashedInApp = supportsVisualStashing() && mPrefs.getBoolean(SHARED_PREFS_STASHED_KEY, DEFAULT_STASHED_PREF); boolean isInSetup = !mActivity.isUserSetupComplete() || setupUIVisible; updateStateForFlag(FLAG_STASHED_IN_APP_MANUAL, isManuallyStashedInApp); @@ -218,7 +221,10 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba updateStateForFlag(FLAG_IN_SETUP, isInSetup); updateStateForFlag(FLAG_STASHED_SMALL_SCREEN, isPhoneMode() && !mActivity.isThreeButtonNav()); - applyState(); + // For now, assume we're in an app, since LauncherTaskbarUIController won't be able to tell + // us that we're paused until a bit later. This avoids flickering upon recreating taskbar. + updateStateForFlag(FLAG_IN_APP, true); + applyState(/* duration = */ 0); notifyStashChange(/* visible */ false, /* stashed */ isStashedInApp()); } @@ -228,8 +234,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba * state. */ public boolean supportsVisualStashing() { - return mControllers.uiController.supportsVisualStashing() || - (isPhoneMode() && !mActivity.isThreeButtonNav()); + return !mActivity.isThreeButtonNav() && mControllers.uiController.supportsVisualStashing(); } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java index fcc34c6d99..114bfecb6e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java @@ -49,9 +49,13 @@ public class TaskbarUIController { return true; } + /** + * This should only be called by TaskbarStashController so that a TaskbarUIController can + * disable stashing. All other controllers should use + * {@link TaskbarStashController#supportsVisualStashing()} as the source of truth. + */ public boolean supportsVisualStashing() { - if (mControllers == null) return false; - return !mControllers.taskbarActivityContext.isThreeButtonNav(); + return true; } protected void onStashedInAppChanged() { } diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java index 1df9c02ee8..9337cb55bc 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java @@ -67,6 +67,13 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest { mLauncher.getLaunchedAppState().showTaskbar(); } + @Test + public void testHideTaskbarPersistsOnRecreate() { + getTaskbar().hide(); + mLauncher.recreateTaskbar(); + mLauncher.getLaunchedAppState().assertTaskbarHidden(); + } + @Test public void testLaunchApp() throws Exception { getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE); From 038e112e9dfacfaf4c25221a0b25304b8c4dd30d Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Wed, 31 Aug 2022 17:55:22 +0100 Subject: [PATCH 6/8] Update grouped task view thumbnail splash interpolation to match regular task. Follow-up to ag/19730966 Fix: 244433374 Test: follow up after b/238405972 Change-Id: I5c3c05dd51234b568e8f99c075e0f3384bca4741 --- .../src/com/android/quickstep/views/GroupedTaskView.java | 4 +--- quickstep/src/com/android/quickstep/views/TaskView.java | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java index f718be884c..a870f9cc8f 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java @@ -1,6 +1,5 @@ package com.android.quickstep.views; -import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.util.SplitConfigurationOptions.DEFAULT_SPLIT_RATIO; import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT; import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT; @@ -318,7 +317,6 @@ public class GroupedTaskView extends TaskView { @Override protected void applyThumbnailSplashAlpha() { super.applyThumbnailSplashAlpha(); - mSnapshotView2.setSplashAlpha( - Utilities.mapToRange(mTaskThumbnailSplashAlpha, 0f, 1f, 1f, 0f, LINEAR)); + mSnapshotView2.setSplashAlpha(mTaskThumbnailSplashAlpha); } } diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 1e783777b7..34c2021d0b 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -1064,7 +1064,7 @@ public class TaskView extends FrameLayout implements Reusable { } protected void applyThumbnailSplashAlpha() { - mSnapshotView.setSplashAlpha(Utilities.boundToRange(mTaskThumbnailSplashAlpha, 0f, 1f)); + mSnapshotView.setSplashAlpha(mTaskThumbnailSplashAlpha); } private void setSplitSelectTranslationX(float x) { From 91ca748819c9164aba53f12df1d90cad64819da8 Mon Sep 17 00:00:00 2001 From: hyunyoungs Date: Wed, 31 Aug 2022 22:05:45 -0700 Subject: [PATCH 7/8] Fix blurry wallpaper when user locks on all apps surface Bug: 242746421 Test: manual TL;DR;; setState toState= NORMAL called when locking screen on ALLAPPS screen but mSurface==null hence depth is not reset to NORMAL state Change-Id: I26a37f7de8b0ecd481b36eebf07e1b79f8b0035c --- .../com/android/launcher3/statehandlers/DepthController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java index 1311b1d629..4b8b5f7d7c 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java @@ -141,7 +141,7 @@ public class DepthController extends BaseDepthController implements StateHandler @Override public void setState(LauncherState toState) { - if (mSurface == null || mIgnoreStateChangesDuringMultiWindowAnimation) { + if (mIgnoreStateChangesDuringMultiWindowAnimation) { return; } From 401f6bb0d46f812d2dc278bc6b5745bd48bd6de9 Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Wed, 17 Aug 2022 19:29:55 +0100 Subject: [PATCH 8/8] Undim kids nav icons on a11y focus and click. Fix: 241298057 Test: manual Change-Id: I9a330bde4641a01b4d19dc83c8f25f56a69328c8 --- .../taskbar/NavbarButtonsViewController.java | 21 ++++++++++++++ ...askbarForceVisibleImmersiveController.java | 28 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index f1f18c1756..4fda50efd1 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -15,6 +15,7 @@ */ package com.android.launcher3.taskbar; +import static android.view.View.AccessibilityDelegate; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X; @@ -582,6 +583,26 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT return mHomeButtonAlpha; } + /** + * Sets the AccessibilityDelegate for the home button. + */ + public void setHomeButtonAccessibilityDelegate(AccessibilityDelegate accessibilityDelegate) { + if (mHomeButton == null) { + return; + } + mHomeButton.setAccessibilityDelegate(accessibilityDelegate); + } + + /** + * Sets the AccessibilityDelegate for the back button. + */ + public void setBackButtonAccessibilityDelegate(AccessibilityDelegate accessibilityDelegate) { + if (mBackButton == null) { + return; + } + mBackButton.setAccessibilityDelegate(accessibilityDelegate); + } + /** Use to set the translationY for the all nav+contextual buttons */ public AnimatedFloat getTaskbarNavButtonTranslationY() { return mTaskbarNavButtonTranslationY; diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarForceVisibleImmersiveController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarForceVisibleImmersiveController.java index c99cebb1a7..6c793a6119 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarForceVisibleImmersiveController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarForceVisibleImmersiveController.java @@ -18,13 +18,17 @@ package com.android.launcher3.taskbar; import static android.view.accessibility.AccessibilityManager.FLAG_CONTENT_CONTROLS; import static android.view.accessibility.AccessibilityManager.FLAG_CONTENT_ICONS; +import static android.view.accessibility.AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS; +import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK; import static com.android.launcher3.taskbar.NavbarButtonsViewController.ALPHA_INDEX_IMMERSIVE_MODE; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IMMERSIVE_MODE; +import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.MotionEvent; +import android.view.View; import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.util.MultiValueAlpha; @@ -52,6 +56,21 @@ public class TaskbarForceVisibleImmersiveController implements TouchController { this::updateIconDimmingAlpha); private final Consumer mImmersiveModeAlphaUpdater = alpha -> alpha.getProperty( ALPHA_INDEX_IMMERSIVE_MODE).setValue(mIconAlphaForDimming.value); + private final View.AccessibilityDelegate mKidsModeAccessibilityDelegate = + new View.AccessibilityDelegate() { + @Override + public boolean performAccessibilityAction(View host, int action, Bundle args) { + if (action == ACTION_ACCESSIBILITY_FOCUS || action == ACTION_CLICK) { + // Animate undimming of icons on an a11y event, followed by starting the + // dimming animation (after its timeout has expired). Both can be called in + // succession, as the playing of the two animations in a row is managed by + // mHandler's message queue. + startIconUndimming(); + startIconDimming(); + } + return super.performAccessibilityAction(host, action, args); + } + }; // Initialized in init. private TaskbarControllers mControllers; @@ -77,12 +96,21 @@ public class TaskbarForceVisibleImmersiveController implements TouchController { } else { startIconUndimming(); } + mControllers.navbarButtonsViewController.setHomeButtonAccessibilityDelegate( + mKidsModeAccessibilityDelegate); + mControllers.navbarButtonsViewController.setBackButtonAccessibilityDelegate( + mKidsModeAccessibilityDelegate); + } else { + mControllers.navbarButtonsViewController.setHomeButtonAccessibilityDelegate(null); + mControllers.navbarButtonsViewController.setBackButtonAccessibilityDelegate(null); } } /** Clean up animations. */ public void onDestroy() { startIconUndimming(); + mControllers.navbarButtonsViewController.setHomeButtonAccessibilityDelegate(null); + mControllers.navbarButtonsViewController.setBackButtonAccessibilityDelegate(null); } private void startIconUndimming() {