Bug 1289140 - LauncherActivity: Exclude from recents and filter flags. r?ahunt
MozReview-Commit-ID: 2brjUGbl7hx
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -41,17 +41,20 @@
#ifdef MOZ_NATIVE_DEVICES
<!-- This resources comes from Google Play Services. Required for casting support. -->
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
#endif
<!-- This activity handles all incoming Intents and dispatches them to other activities. -->
<activity android:name="org.mozilla.gecko.LauncherActivity"
- android:theme="@android:style/Theme.Translucent.NoTitleBar" />
+ android:theme="@android:style/Theme.Translucent.NoTitleBar"
+ android:relinquishTaskIdentity="true"
+ android:taskAffinity=""
+ android:excludeFromRecents="true" />
<!-- Fennec is shipped as the Android package named
org.mozilla.{fennec,firefox,firefox_beta}. The internal Java
package hierarchy inside the Android package used to have an
org.mozilla.{fennec,firefox,firefox_beta} subtree *and* an
org.mozilla.gecko subtree; it now only has org.mozilla.gecko. -->
<activity android:name="@MOZ_ANDROID_BROWSER_INTENT_CLASS@"
android:label="@string/moz_app_displayname"
--- a/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
@@ -64,30 +64,41 @@ public class LauncherActivity extends Ac
/**
* Launch the browser activity.
*/
private void dispatchNormalIntent() {
Intent intent = new Intent(getIntent());
intent.setClassName(getApplicationContext(), AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);
- // Explicitly remove the new task and clear task flags (Our browser activity is a single
- // task activity and we never want to start a second task here). See bug 1280112.
- intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ filterFlags(intent);
startActivity(intent);
}
private void dispatchCustomTabsIntent() {
Intent intent = new Intent(getIntent());
intent.setClassName(getApplicationContext(), CustomTabsActivity.class.getName());
+
+ filterFlags(intent);
+
startActivity(intent);
}
+ private static void filterFlags(Intent intent) {
+ // Explicitly remove the new task and clear task flags (Our browser activity is a single
+ // task activity and we never want to start a second task here). See bug 1280112.
+ intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_CLEAR_TASK);
+
+ // LauncherActivity is started with the "exclude from recents" flag (set in manifest). We do
+ // not want to propagate this flag from the launcher activity to the browser.
+ intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ }
+
private static boolean isViewIntentWithURL(@NonNull final SafeIntent safeIntent) {
return Intent.ACTION_VIEW.equals(safeIntent.getAction())
&& safeIntent.getDataString() != null;
}
private static boolean isCustomTabsIntent(@NonNull final SafeIntent safeIntent) {
return isViewIntentWithURL(safeIntent)
&& safeIntent.hasExtra(CustomTabsIntent.EXTRA_SESSION);