Adds option to launch Gesture Sandbox from dev settings.

This is set to have the same task affinity as Launcher
so that it inherits the ability to ignore system gestures.

Bug: 148542211
Change-Id: I29bc5599dea61c44be721dcc0bec7bc494c415c4
diff --git a/quickstep/AndroidManifest-launcher.xml b/quickstep/AndroidManifest-launcher.xml
index 60afddb..527bfc3 100644
--- a/quickstep/AndroidManifest-launcher.xml
+++ b/quickstep/AndroidManifest-launcher.xml
@@ -52,7 +52,7 @@
             android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
             android:resizeableActivity="true"
             android:resumeWhilePausing="true"
-            android:taskAffinity=""
+            android:taskAffinity="${packageName}.launcher"
             android:enabled="true">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml
index a06a2dd..d360613 100644
--- a/quickstep/AndroidManifest.xml
+++ b/quickstep/AndroidManifest.xml
@@ -93,6 +93,7 @@
             android:name="com.android.quickstep.interaction.GestureSandboxActivity"
             android:autoRemoveFromRecents="true"
             android:excludeFromRecents="true"
+            android:taskAffinity="${packageName}.launcher"
             android:screenOrientation="portrait">
             <intent-filter>
                 <action android:name="com.android.quickstep.action.GESTURE_SANDBOX" />
diff --git a/src/com/android/launcher3/settings/DeveloperOptionsFragment.java b/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
index 049fda9..8dc2e61 100644
--- a/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
+++ b/src/com/android/launcher3/settings/DeveloperOptionsFragment.java
@@ -96,6 +96,7 @@
 
         initFlags();
         loadPluginPrefs();
+        maybeAddSandboxCategory();
     }
 
     @Override
@@ -203,6 +204,31 @@
         });
     }
 
+    private void maybeAddSandboxCategory() {
+        Context context = getContext();
+        if (context == null) {
+            return;
+        }
+        Intent launchSandboxIntent =
+                new Intent("com.android.quickstep.action.GESTURE_SANDBOX")
+                        .setPackage(context.getPackageName())
+                        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        if (launchSandboxIntent.resolveActivity(context.getPackageManager()) == null) {
+            return;
+        }
+        PreferenceCategory sandboxCategory = newCategory("Sandbox");
+        Preference launchSandboxPreference = new Preference(context);
+        launchSandboxPreference.setKey("launchSandbox");
+        launchSandboxPreference.setTitle("Launch Gesture Navigation Sandbox");
+        launchSandboxPreference.setSummary(
+                "This provides tutorials and a place to practice navigation gestures.");
+        launchSandboxPreference.setOnPreferenceClickListener(preference -> {
+            startActivity(launchSandboxIntent);
+            return true;
+        });
+        sandboxCategory.addPreference(launchSandboxPreference);
+    }
+
     private String toName(String action) {
         String str = action.replace("com.android.systemui.action.PLUGIN_", "")
                 .replace("com.android.launcher3.action.PLUGIN_", "");