diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 951a9b61dc..cdf7d3af35 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -559,6 +559,9 @@ public class QuickstepLauncher extends Launcher { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + if (Utilities.ATLEAST_U && FeatureFlags.ENABLE_BACK_SWIPE_LAUNCHER_ANIMATION.get()) { + getApplicationInfo().setEnableOnBackInvokedCallback(true); + } if (savedInstanceState != null) { mPendingSplitSelectInfo = ObjectWrapper.unwrap( savedInstanceState.getIBinder(PENDING_SPLIT_SELECT_INFO)); diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index 1714610ace..9a65b4f213 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -27,12 +27,14 @@ import static org.junit.Assume.assumeTrue; import android.content.Intent; import androidx.test.filters.LargeTest; +import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.runner.AndroidJUnit4; import androidx.test.uiautomator.By; import androidx.test.uiautomator.Until; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.tapl.LaunchedAppState; import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel; import com.android.launcher3.tapl.Overview; @@ -57,6 +59,8 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { private static final String APP_NAME = "LauncherTestApp"; private static final String CALCULATOR_APP_PACKAGE = resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR); + private static final String READ_DEVICE_CONFIG_PERMISSION = + "android.permission.READ_DEVICE_CONFIG"; @Before public void setUp() throws Exception { @@ -370,6 +374,9 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @PortraitLandscape @NavigationModeSwitch public void testPressBack() throws Exception { + InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity( + READ_DEVICE_CONFIG_PERMISSION); + assumeFalse(FeatureFlags.ENABLE_BACK_SWIPE_LAUNCHER_ANIMATION.get()); mLauncher.getWorkspace().switchToAllApps(); mLauncher.pressBack(); mLauncher.getWorkspace(); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 184059785d..0a09c1ee17 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -204,6 +204,10 @@ public final class FeatureFlags { "ENABLE_BACK_SWIPE_HOME_ANIMATION", true, "Enables home animation to icon when user swipes back."); + public static final BooleanFlag ENABLE_BACK_SWIPE_LAUNCHER_ANIMATION = getDebugFlag(270614790, + "ENABLE_BACK_SWIPE_LAUNCHER_ANIMATION", false, + "Enables predictive back aniamtion from all apps and widgets to home"); + public static final BooleanFlag ENABLE_ICON_LABEL_AUTO_SCALING = getDebugFlag(270393294, "ENABLE_ICON_LABEL_AUTO_SCALING", true, "Enables scaling/spacing for icon labels to make more characters visible"); diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index 66187659db..0b694788d8 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -25,6 +25,7 @@ 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.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; import android.content.Intent; @@ -33,10 +34,12 @@ import android.platform.test.annotations.IwTest; import androidx.test.filters.FlakyTest; import androidx.test.filters.LargeTest; +import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.runner.AndroidJUnit4; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.popup.ArrowPopup; import com.android.launcher3.tapl.AllApps; import com.android.launcher3.tapl.AppIcon; @@ -73,6 +76,8 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { private static final String MAPS_APP_NAME = "Maps"; private static final String STORE_APP_NAME = "Play Store"; private static final String GMAIL_APP_NAME = "Gmail"; + private static final String READ_DEVICE_CONFIG_PERMISSION = + "android.permission.READ_DEVICE_CONFIG"; @Rule public TISBindRule mTISBindRule = new TISBindRule(); @@ -440,11 +445,13 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { @Test @PortraitLandscape public void testPressBack() throws Exception { + InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity( + READ_DEVICE_CONFIG_PERMISSION); + assumeFalse(FeatureFlags.ENABLE_BACK_SWIPE_LAUNCHER_ANIMATION.get()); mLauncher.getWorkspace().switchToAllApps(); mLauncher.pressBack(); mLauncher.getWorkspace(); waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); - startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)); mLauncher.pressBack(); mLauncher.getWorkspace();