From 21d8230b9095c435f9baf1509993216da710c60c Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Thu, 20 Oct 2022 16:58:11 -0700 Subject: [PATCH 1/7] Prevent rotating TaskMenuViewWithArrow for large screen * Only attempt to rotate TaskMenuView on fake rotation Fixes: 254198019 Test: Rotation on large screen w/ TaskMenu open doesn't crash Change-Id: If8ae8c018e9cc8cb80a2ec3313f5e8d0fda2e148 --- quickstep/src/com/android/quickstep/views/RecentsView.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index ce96b7168e..b28e048bb9 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -122,6 +122,7 @@ import androidx.annotation.Nullable; import androidx.annotation.UiThread; import androidx.core.graphics.ColorUtils; +import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseActivity; import com.android.launcher3.BaseActivity.MultiWindowModeChangedListener; import com.android.launcher3.DeviceProfile; @@ -2241,8 +2242,14 @@ public abstract class RecentsView Date: Sun, 6 Nov 2022 15:03:54 -0800 Subject: [PATCH 2/7] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I123cbe1bc412bda54efaf9699faa03bd0fc21dd5 --- res/values-eu/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml index 9e2d9a47d1..8b944fe509 100644 --- a/res/values-eu/strings.xml +++ b/res/values-eu/strings.xml @@ -124,7 +124,7 @@ "%1$s instalatzen, %2$s osatuta" "%1$s deskargatzen, %2$s osatuta" "%1$s instalatzeko zain" - "Aplikazioa eguneratu behar da" + "Aplikazioa eguneratu egin behar da" "Ikonoaren aplikazioa ez dago eguneratuta. Lasterbidea berriro gaitzeko, eskuz egunera dezakezu aplikazioa. Bestela, kendu ikonoa." "Eguneratu" "Kendu" From 2370406efb94129fa4ba873d79903878400c8501 Mon Sep 17 00:00:00 2001 From: Nicolo' Mazzucato Date: Tue, 1 Nov 2022 14:40:37 +0000 Subject: [PATCH 3/7] Add CUJ_LAUNCHER_APP_SWIPE_TO_RECENTS Bug: 231130484 Bug: 228969045 Test: recorded prefetto trace while going to recents Change-Id: If33daaa22f904c928f5d4a561a7ac1a03d82b7eb --- quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java | 6 ++++++ .../com/android/quickstep/RecentsAnimationController.java | 2 ++ 2 files changed, 8 insertions(+) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index ff7c668991..bd270f9a14 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -939,6 +939,8 @@ public abstract class AbsSwipeUpHandler, InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH, 2000 /* ms timeout */); InteractionJankMonitorWrapper.begin(mRecentsView, InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); + InteractionJankMonitorWrapper.begin(mRecentsView, + InteractionJankMonitorWrapper.CUJ_APP_SWIPE_TO_RECENTS); rv.post(() -> rv.getViewTreeObserver().removeOnDrawListener(this)); } @@ -1044,6 +1046,10 @@ public abstract class AbsSwipeUpHandler, InteractionJankMonitorWrapper.cancel( InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); } + if (endTarget != RECENTS) { + InteractionJankMonitorWrapper.cancel( + InteractionJankMonitorWrapper.CUJ_APP_SWIPE_TO_RECENTS); + } switch (endTarget) { case HOME: diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationController.java b/quickstep/src/com/android/quickstep/RecentsAnimationController.java index 81e3782142..6088a36fdc 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationController.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationController.java @@ -165,6 +165,8 @@ public class RecentsAnimationController { mController.finish(toRecents, sendUserLeaveHint); InteractionJankMonitorWrapper.end(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH); InteractionJankMonitorWrapper.end(InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); + InteractionJankMonitorWrapper.end( + InteractionJankMonitorWrapper.CUJ_APP_SWIPE_TO_RECENTS); MAIN_EXECUTOR.execute(mPendingFinishCallbacks::executeAllAndDestroy); }); } From 81f5cee2cb457fd14f24474be788127c0a16d559 Mon Sep 17 00:00:00 2001 From: Luca Zuccarini Date: Tue, 11 Oct 2022 13:02:09 +0000 Subject: [PATCH 4/7] Fix IME sync flicker with 3-button navigation. With keyboard sync, the dismissal is handled by the animator. Calling hideKeyboard() on top of that causes the two signals to conflict with each other, resulting in the visible flicker and extra delayed hiding animation. Fixes: 251185052 Test: manual, see videos in the bug Change-Id: Ic12ad304ef9e4b6a51279ce18d6c09ba93bd59be --- src/com/android/launcher3/Launcher.java | 7 +++---- .../allapps/AllAppsTransitionController.java | 13 ++++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index c73e07794f..ab7f6226c9 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -482,6 +482,9 @@ public class Launcher extends StatefulActivity mOnboardingPrefs = createOnboardingPrefs(mSharedPrefs); + // TODO: move the SearchConfig to SearchState when new LauncherState is created. + mBaseSearchConfig = new BaseSearchConfig(); + mAppWidgetManager = new WidgetManagerHelper(this); mAppWidgetHolder = createAppWidgetHolder(); mAppWidgetHolder.startListening(); @@ -548,9 +551,6 @@ public class Launcher extends StatefulActivity getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_ADJUST_NOTHING); } setTitle(R.string.home_screen); - - // TODO: move the SearchConfig to SearchState when new LauncherState is created. - mBaseSearchConfig = new BaseSearchConfig(); } protected LauncherOverlayManager getDefaultOverlay() { @@ -1598,7 +1598,6 @@ public class Launcher extends StatefulActivity && AbstractFloatingView.getTopOpenView(this) == null; boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction()); boolean internalStateHandled = ACTIVITY_TRACKER.handleNewIntent(this); - hideKeyboard(); if (isActionMain) { if (!internalStateHandled) { diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index fa2c6e93c0..9930abeb12 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -141,6 +141,9 @@ public class AllAppsTransitionController private final Launcher mLauncher; private boolean mIsVerticalLayout; + // Whether this class should take care of closing the keyboard. + private boolean mShouldControlKeyboard; + // Animation in this class is controlled by a single variable {@link mProgress}. // Visually, it represents top y coordinate of the all apps container if multiplied with // {@link mShiftRange}. @@ -238,7 +241,7 @@ public class AllAppsTransitionController StateAnimationConfig config, PendingAnimation builder) { if (mLauncher.isInState(ALL_APPS) && !ALL_APPS.equals(toState)) { // For atomic animations, we close the keyboard immediately. - if (!config.userControlled && !mLauncher.getSearchConfig().isKeyboardSyncEnabled()) { + if (!config.userControlled && mShouldControlKeyboard) { mLauncher.getAppsView().getSearchUiManager().getEditText().hideKeyboard(); } @@ -252,7 +255,7 @@ public class AllAppsTransitionController // the keyboard open and then changes their mind and swipes back up, we want the // keyboard to remain open. However an onCancel signal is sent to the listeners // (success = false), so we need to check for that. - if (config.userControlled && success) { + if (config.userControlled && success && mShouldControlKeyboard) { mLauncher.getAppsView().getSearchUiManager().getEditText().hideKeyboard(); } }); @@ -317,6 +320,8 @@ public class AllAppsTransitionController mAppsViewAlpha.setUpdateVisibility(true); mAppsViewTranslationY = new MultiPropertyFactory<>( mAppsView, VIEW_TRANSLATE_Y, APPS_VIEW_INDEX_COUNT, Float::sum); + + mShouldControlKeyboard = !mLauncher.getSearchConfig().isKeyboardSyncEnabled(); } /** @@ -333,7 +338,9 @@ public class AllAppsTransitionController private void onProgressAnimationEnd() { if (Float.compare(mProgress, 1f) == 0) { mAppsView.reset(false /* animate */); - mLauncher.getAppsView().getSearchUiManager().getEditText().hideKeyboard(); + if (mShouldControlKeyboard) { + mLauncher.getAppsView().getSearchUiManager().getEditText().hideKeyboard(); + } } } } From 4f56f0a10b051eb0414512b3f1301980678b6b8e Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 8 Nov 2022 11:19:05 -0800 Subject: [PATCH 5/7] Add dark theme bg for transient taskbar. Bug: 256052691 Test: enable dark theme, view dark taskbar disable dark theme, view light taskbar Change-Id: Icf8b946fd68804a904493336063704a6584d5f0e --- .../transient_taskbar_background.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 res/color-night-v31/transient_taskbar_background.xml diff --git a/res/color-night-v31/transient_taskbar_background.xml b/res/color-night-v31/transient_taskbar_background.xml new file mode 100644 index 0000000000..40f6494933 --- /dev/null +++ b/res/color-night-v31/transient_taskbar_background.xml @@ -0,0 +1,19 @@ + + + + + + From 3153cd9b971fba459ec952962cbcfa0209905d23 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 8 Nov 2022 11:42:28 -0800 Subject: [PATCH 6/7] Proposal to move Developer Options to top of Home settings if studio build. - Increases developer efficiency by avoiding the need to scroll Bug: 258263867 Test: manual Change-Id: I6cb46fdd12b51f8c45017f823dd4b2458e21fc72 --- src/com/android/launcher3/settings/SettingsActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java index 49d27b7ed4..70956a35ac 100644 --- a/src/com/android/launcher3/settings/SettingsActivity.java +++ b/src/com/android/launcher3/settings/SettingsActivity.java @@ -18,6 +18,7 @@ package com.android.launcher3.settings; import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS; +import static com.android.launcher3.config.FeatureFlags.IS_STUDIO_BUILD; import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY; import android.content.Intent; @@ -207,7 +208,11 @@ public class SettingsActivity extends FragmentActivity PreferenceScreen screen = getPreferenceScreen(); for (int i = screen.getPreferenceCount() - 1; i >= 0; i--) { Preference preference = screen.getPreference(i); - if (!initPreference(preference)) { + if (initPreference(preference)) { + if (IS_STUDIO_BUILD && preference == mDeveloperOptionPref) { + preference.setOrder(0); + } + } else { screen.removePreference(preference); } } From e7011d2b876770dcefde509e8775bb65b6d1d8e1 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 8 Nov 2022 21:56:52 +0000 Subject: [PATCH 7/7] Revert "Add TaskbarModeSwitchRule to test both transient/persistent taskbar." This reverts commit d5a6b5f688f45f3f98cb22170f574495214d3f4f. Reason for revert: Breaks tests due to "SharedPreferences in credential encrypted storage are not available until after user is unlocked" Bug: 258256906 Change-Id: I1de69249685f9d2e71183357cf3eda8d443c7d97 --- quickstep/Android.bp | 1 - .../taskbar/TaskbarActivityContext.java | 19 +- .../taskbar/TaskbarStashController.java | 20 +-- .../QuickstepTestInformationHandler.java | 19 -- .../quickstep/AbstractQuickStepTest.java | 1 - .../quickstep/NavigationModeSwitchRule.java | 2 +- .../android/quickstep/TaplTestsTaskbar.java | 17 -- .../quickstep/TaskbarModeSwitchRule.java | 162 ------------------ .../testing/shared/TestProtocol.java | 2 - .../launcher3/tapl/LaunchedAppState.java | 4 - .../tapl/LauncherInstrumentation.java | 7 - 11 files changed, 7 insertions(+), 247 deletions(-) delete mode 100644 quickstep/tests/src/com/android/quickstep/TaskbarModeSwitchRule.java diff --git a/quickstep/Android.bp b/quickstep/Android.bp index f5a8253563..7292c4495b 100644 --- a/quickstep/Android.bp +++ b/quickstep/Android.bp @@ -38,7 +38,6 @@ filegroup { name: "launcher3-quickstep-oop-tests-src", path: "tests", srcs: [ - "tests/src/com/android/quickstep/TaskbarModeSwitchRule.java", "tests/src/com/android/quickstep/NavigationModeSwitchRule.java", "tests/src/com/android/quickstep/AbstractQuickStepTest.java", "tests/src/com/android/quickstep/TaplTestsQuickstep.java", diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index d0256c5caf..fad9ff490c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -23,7 +23,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; import static com.android.launcher3.AbstractFloatingView.TYPE_ALL; import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE; -import static com.android.launcher3.Utilities.IS_RUNNING_IN_TEST_HARNESS; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN; import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING; import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_FULLSCREEN; @@ -305,8 +304,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { int windowFlags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_SLIPPERY | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH; - if (DisplayController.isTransientTaskbar(this) - && !IS_RUNNING_IN_TEST_HARNESS) { + if (DisplayController.isTransientTaskbar(this)) { windowFlags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; } @@ -859,26 +857,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext { mControllers.taskbarStashController.enableManualStashingDuringTests(enableManualStashing); } - /** - * Enables the auto timeout for taskbar stashing. This method should only be used for taskbar - * testing. - */ - @VisibleForTesting - public void enableBlockingTimeoutDuringTests(boolean enableBlockingTimeout) { - mControllers.taskbarStashController.enableBlockingTimeoutDuringTests(enableBlockingTimeout); - } - /** * 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() { - if (DisplayController.isTransientTaskbar(this)) { - mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(false); - } else { - mControllers.taskbarStashController.onLongPressToUnstashTaskbar(); - } + mControllers.taskbarStashController.onLongPressToUnstashTaskbar(); } protected boolean isUserSetupComplete() { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index b53e9c56cd..72ae1d1c31 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -37,7 +37,6 @@ import android.view.View; import android.view.ViewConfiguration; import androidx.annotation.NonNull; -import androidx.annotation.VisibleForTesting; import com.android.internal.jank.InteractionJankMonitor; import com.android.launcher3.Alarm; @@ -170,7 +169,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba private boolean mEnableManualStashingDuringTests = false; private final Alarm mTimeoutAlarm = new Alarm(); - private boolean mEnableBlockingTimeoutDuringTests = false; // Evaluate whether the handle should be stashed private final StatePropertyHolder mStatePropertyHolder = new StatePropertyHolder( @@ -269,20 +267,10 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba * Enables support for manual stashing. This should only be used to add this functionality * to Launcher specific tests. */ - @VisibleForTesting public void enableManualStashingDuringTests(boolean enableManualStashing) { mEnableManualStashingDuringTests = enableManualStashing; } - /** - * Enables the auto timeout for taskbar stashing. This method should only be used for taskbar - * testing. - */ - @VisibleForTesting - public void enableBlockingTimeoutDuringTests(boolean enableBlockingTimeout) { - mEnableBlockingTimeoutDuringTests = enableBlockingTimeout; - } - /** * Sets the flag indicating setup UI is visible */ @@ -858,12 +846,12 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba * Attempts to start timer to auto hide the taskbar based on time. */ public void tryStartTaskbarTimeout() { - if (!DisplayController.isTransientTaskbar(mActivity) - || mIsStashed - || mEnableBlockingTimeoutDuringTests) { + if (!DisplayController.isTransientTaskbar(mActivity)) { + return; + } + if (mIsStashed) { return; } - cancelTimeoutIfExists(); mTimeoutAlarm.setOnAlarmListener(this::onTaskbarTimeout); diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index 177ecf54a5..9621ce6eba 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -120,18 +120,6 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { .getCurrentActivityContext() .getTaskbarAllAppsTopPadding()); } - - case TestProtocol.REQUEST_ENABLE_BLOCK_TIMEOUT: - runOnTISBinder(tisBinder -> { - enableBlockingTimeout(tisBinder, true); - }); - return response; - - case TestProtocol.REQUEST_DISABLE_BLOCK_TIMEOUT: - runOnTISBinder(tisBinder -> { - enableBlockingTimeout(tisBinder, false); - }); - return response; } return super.call(method, arg, extras); @@ -161,13 +149,6 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { enable); } - private void enableBlockingTimeout( - TouchInteractionService.TISBinder tisBinder, boolean enable) { - // Allow null-pointer to catch illegal states. - tisBinder.getTaskbarManager().getCurrentActivityContext().enableBlockingTimeoutDuringTests( - enable); - } - /** * Runs the given command on the UI thread, after ensuring we are connected to * TouchInteractionService. diff --git a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java index 2c5825fd0b..e2774c003d 100644 --- a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java +++ b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java @@ -39,7 +39,6 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest { protected TestRule getRulesInsideActivityMonitor() { return RuleChain. outerRule(new NavigationModeSwitchRule(mLauncher)). - around(new TaskbarModeSwitchRule(mLauncher)). around(super.getRulesInsideActivityMonitor()); } diff --git a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java index eded1c961f..e5e2cf3337 100644 --- a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java +++ b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java @@ -51,7 +51,7 @@ import java.util.concurrent.TimeUnit; /** * Test rule that allows executing a test with Quickstep on and then Quickstep off. - * The test should be annotated with @NavigationModeSwitch. + * The test should be annotated with @QuickstepOnOff. */ public class NavigationModeSwitchRule implements TestRule { diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java index 0b8bc10fec..9337cb55bc 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java @@ -17,8 +17,6 @@ package com.android.quickstep; import static androidx.test.InstrumentationRegistry.getInstrumentation; -import static com.android.quickstep.TaskbarModeSwitchRule.Mode.PERSISTENT; - import static junit.framework.TestCase.assertEquals; import android.content.Intent; @@ -29,7 +27,6 @@ import androidx.test.runner.AndroidJUnit4; import com.android.launcher3.tapl.Taskbar; import com.android.launcher3.ui.TaplTestsLauncher3; import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord; -import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch; import org.junit.After; import org.junit.Assume; @@ -56,25 +53,21 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest { TaplTestsLauncher3.initialize(this); startAppFast(CALCULATOR_APP_PACKAGE); - mLauncher.enableBlockTimeout(true); mLauncher.showTaskbarIfHidden(); } @After public void tearDown() { mLauncher.useDefaultWorkspaceLayoutOnReload(); - mLauncher.enableBlockTimeout(false); } @Test - @TaskbarModeSwitch(mode = PERSISTENT) public void testHideShowTaskbar() { getTaskbar().hide(); mLauncher.getLaunchedAppState().showTaskbar(); } @Test - @TaskbarModeSwitch(mode = PERSISTENT) public void testHideTaskbarPersistsOnRecreate() { getTaskbar().hide(); mLauncher.recreateTaskbar(); @@ -82,19 +75,16 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest { } @Test - @TaskbarModeSwitch public void testLaunchApp() throws Exception { getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE); } @Test - @TaskbarModeSwitch public void testOpenMenu() throws Exception { getTaskbar().getAppIcon(TEST_APP_NAME).openMenu(); } @Test - @TaskbarModeSwitch public void testLaunchShortcut() throws Exception { getTaskbar().getAppIcon(TEST_APP_NAME) .openDeepShortcutMenu() @@ -105,7 +95,6 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest { @Test @ScreenRecord // b/231615831 @PortraitLandscape - @TaskbarModeSwitch public void testLaunchAppInSplitscreen() throws Exception { getTaskbar().getAppIcon(TEST_APP_NAME).dragToSplitscreen( TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE); @@ -114,7 +103,6 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest { @Test @ScreenRecord // b/231615831 @PortraitLandscape - @TaskbarModeSwitch public void testLaunchShortcutInSplitscreen() throws Exception { getTaskbar().getAppIcon(TEST_APP_NAME) .openDeepShortcutMenu() @@ -123,19 +111,16 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest { } @Test - @TaskbarModeSwitch public void testLaunchApp_FromTaskbarAllApps() throws Exception { getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE); } @Test - @TaskbarModeSwitch public void testOpenMenu_FromTaskbarAllApps() throws Exception { getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).openMenu(); } @Test - @TaskbarModeSwitch public void testLaunchShortcut_FromTaskbarAllApps() throws Exception { getTaskbar().openAllApps() .getAppIcon(TEST_APP_NAME) @@ -147,7 +132,6 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest { @Test @ScreenRecord // b/231615831 @PortraitLandscape - @TaskbarModeSwitch public void testLaunchAppInSplitscreen_FromTaskbarAllApps() throws Exception { getTaskbar().openAllApps() .getAppIcon(TEST_APP_NAME) @@ -157,7 +141,6 @@ public class TaplTestsTaskbar extends AbstractQuickStepTest { @Test @ScreenRecord // b/231615831 @PortraitLandscape - @TaskbarModeSwitch public void testLaunchShortcutInSplitscreen_FromTaskbarAllApps() throws Exception { getTaskbar().openAllApps() .getAppIcon(TEST_APP_NAME) diff --git a/quickstep/tests/src/com/android/quickstep/TaskbarModeSwitchRule.java b/quickstep/tests/src/com/android/quickstep/TaskbarModeSwitchRule.java deleted file mode 100644 index 8cc812bbb7..0000000000 --- a/quickstep/tests/src/com/android/quickstep/TaskbarModeSwitchRule.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (C) 2022 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 static androidx.test.InstrumentationRegistry.getInstrumentation; - -import static com.android.quickstep.TaskbarModeSwitchRule.Mode.ALL; -import static com.android.quickstep.TaskbarModeSwitchRule.Mode.PERSISTENT; -import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT; - -import android.content.Context; -import android.util.Log; - -import com.android.launcher3.config.FeatureFlags; -import com.android.launcher3.tapl.LauncherInstrumentation; -import com.android.launcher3.tapl.TestHelpers; -import com.android.launcher3.ui.AbstractLauncherUiTest; -import com.android.launcher3.util.rule.FailureWatcher; - -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Test rule that allows executing a test multiple times with different conditions - * ie. with transient taskbar enabled and disabled. - * The test should be annotated with @TaskbarModeSwitch. - */ -public class TaskbarModeSwitchRule implements TestRule { - - static final String TAG = "TaskbarModeSwitchRule"; - - public static final int WAIT_TIME_MS = 10000; - - public enum Mode { - TRANSIENT, PERSISTENT, ALL - } - - // Annotation for tests that need to be run with quickstep enabled and disabled. - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface TaskbarModeSwitch { - Mode mode() default ALL; - } - - private final LauncherInstrumentation mLauncher; - - public TaskbarModeSwitchRule(LauncherInstrumentation launcher) { - mLauncher = launcher; - } - - @Override - public Statement apply(Statement base, Description description) { - if (TestHelpers.isInLauncherProcess() - && description.getAnnotation(TaskbarModeSwitch.class) != null) { - Mode mode = description.getAnnotation(TaskbarModeSwitch.class).mode(); - return new Statement() { - @Override - public void evaluate() throws Throwable { - mLauncher.enableDebugTracing(); - final boolean wasTransientTaskbarMode = isTaskbarTransientMode(); - try { - if (mode == TRANSIENT || mode == ALL) { - evaluateWithTransientTaskbar(); - } - if (mode == PERSISTENT || mode == ALL) { - evaluateWithPersistentTaskbar(); - } - } catch (Throwable e) { - Log.e(TAG, "Error", e); - throw e; - } finally { - Log.d(TAG, "In Finally block"); - setTaskbarMode(mLauncher, wasTransientTaskbarMode, description); - } - } - - private void evaluateWithPersistentTaskbar() throws Throwable { - setTaskbarMode(mLauncher, false, description); - base.evaluate(); - } - - private void evaluateWithTransientTaskbar() throws Throwable { - setTaskbarMode(mLauncher, true, description); - base.evaluate(); - } - }; - } else { - return base; - } - } - - private static void enableTransientTaskbar(LauncherInstrumentation launcher, Context c, - boolean enable, Description description) { - boolean success = c.getSharedPreferences(FeatureFlags.FLAGS_PREF_NAME, Context.MODE_PRIVATE) - .edit() - .putBoolean(FeatureFlags.ENABLE_TRANSIENT_TASKBAR.key, enable) - .commit(); - - if (!success) { - final AssertionError assertionError = new AssertionError( - "Unable to save state to SharedPrefs transientTaskbar=" + enable); - if (description != null) { - FailureWatcher.onError(launcher, description, assertionError); - } - throw assertionError; - } - - FeatureFlags.initialize(c); - } - - private static boolean isTaskbarTransientMode() { - return FeatureFlags.ENABLE_TRANSIENT_TASKBAR.get(); - } - - public static void setTaskbarMode(LauncherInstrumentation launcher, - boolean expectTransientTaskbar, Description description) throws Exception { - - Log.d(TAG, "setTaskbarMode: isTransientTaskbar=" + expectTransientTaskbar + "..."); - - enableTransientTaskbar(launcher, getInstrumentation().getTargetContext(), - expectTransientTaskbar, description); - - launcher.recreateTaskbar(); - - assertTrue(launcher, "Couldn't set taskbar=" + expectTransientTaskbar, - isTaskbarTransientMode() == expectTransientTaskbar, description); - - AbstractLauncherUiTest.checkDetectedLeaks(launcher); - } - - private static void assertTrue(LauncherInstrumentation launcher, String message, - boolean condition, Description description) { - launcher.checkForAnomaly(true, true); - if (!condition) { - final AssertionError assertionError = new AssertionError(message); - if (description != null) { - FailureWatcher.onError(launcher, description, assertionError); - } - throw assertionError; - } - } -} diff --git a/src/com/android/launcher3/testing/shared/TestProtocol.java b/src/com/android/launcher3/testing/shared/TestProtocol.java index 90b8bfa50d..3fbce888f1 100644 --- a/src/com/android/launcher3/testing/shared/TestProtocol.java +++ b/src/com/android/launcher3/testing/shared/TestProtocol.java @@ -84,8 +84,6 @@ public final class TestProtocol { public static final String REQUEST_UNFREEZE_APP_LIST = "unfreeze-app-list"; public static final String REQUEST_ENABLE_MANUAL_TASKBAR_STASHING = "enable-taskbar-stashing"; public static final String REQUEST_DISABLE_MANUAL_TASKBAR_STASHING = "disable-taskbar-stashing"; - public static final String REQUEST_ENABLE_BLOCK_TIMEOUT = "enable-block-timeout"; - public static final String REQUEST_DISABLE_BLOCK_TIMEOUT = "disable-block-timeout"; 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"; diff --git a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java index 0a00480a84..4b02ecc1f2 100644 --- a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java +++ b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java @@ -17,9 +17,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_BLOCK_TIMEOUT; import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING; -import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_BLOCK_TIMEOUT; 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; @@ -90,7 +88,6 @@ public final class LaunchedAppState extends Background { */ public Taskbar showTaskbar() { mLauncher.getTestInfo(REQUEST_ENABLE_MANUAL_TASKBAR_STASHING); - mLauncher.getTestInfo(REQUEST_ENABLE_BLOCK_TIMEOUT); try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( @@ -117,7 +114,6 @@ public final class LaunchedAppState extends Background { } } finally { mLauncher.getTestInfo(REQUEST_DISABLE_MANUAL_TASKBAR_STASHING); - mLauncher.getTestInfo(REQUEST_DISABLE_BLOCK_TIMEOUT); } } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 477d5ad46f..fe060a1609 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -1824,13 +1824,6 @@ public final class LauncherInstrumentation { getTestInfo(TestProtocol.REQUEST_UNSTASH_TASKBAR_IF_STASHED); } - /** Blocks the taskbar from automatically stashing based on time. */ - public void enableBlockTimeout(boolean enable) { - getTestInfo(enable - ? TestProtocol.REQUEST_ENABLE_BLOCK_TIMEOUT - : TestProtocol.REQUEST_DISABLE_BLOCK_TIMEOUT); - } - /** * 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.