Bug 1360699 - Finish CustomTabsActivities when leaving. r=walkingice
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 29 Apr 2017 15:03:41 +0200
changeset 355976 daaac7877e432a0daff8f1e920736e5682100676
parent 355975 2aaa56ceee09ca3abb950d9e214d76eed9cb4db7
child 355977 8c6b6d197f52360f0c3d9a8277b8e727856ad1ac
push id31754
push userkwierso@gmail.com
push dateWed, 03 May 2017 00:28:51 +0000
treeherdermozilla-central@5eaf2d70eded [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1360699 - Finish CustomTabsActivities when leaving. r=walkingice Looking again, the original motivation for *not* calling finish(), i.e. avoiding Gecko being unloaded from memory, doesn't quite seem to apply and in any case for custom tabs we *have* to finish() the activity, since we're most probably running within another activity's task. There's also no point in overriding onDone() in SingleTabActivity any more if - we just do the same thing as GeckoApp's default behaviour, and - custom tabs now require a different behaviour anyway. MozReview-Commit-ID: BsP1tMj5DEe
--- a/mobile/android/base/java/org/mozilla/gecko/SingleTabActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/SingleTabActivity.java
@@ -131,26 +131,16 @@ public abstract class SingleTabActivity 
             return true;
         // If we end up here, this means that there's no suitable tab we can take over.
         // Instead, we'll just open a new tab from the data specified in the intent.
         return false;
-    @Override
-    protected void onDone() {
-        // Our startup logic should be robust enough to cope with it's tab having been closed even
-        // though the activity might survive, so we don't have to call finish() just to make sure
-        // that a new tab is opened in that case. This also has the advantage that we'll remain in
-        // memory as long as the low-memory killer permits, so we can potentially avoid a costly
-        // re-startup of Gecko if the user returns to us soon.
-        moveTaskToBack(true);
-    }
      * For us here, mLastSelectedTabId/Hash will hold the tab that will be selected when the
      * activity is resumed/recreated, unless
      * - it has been explicitly overridden through an intent
      * - the tab cannot be found, in which case the URI passed as intent data will instead be
      *   opened in a new tab.
      * Therefore, we only update the stored tab data from those two locations.
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
@@ -160,16 +160,23 @@ public class CustomTabsActivity extends 
             // Use its package name to retrieve animation resource
             return IntentUtil.getAnimationPackageName(new SafeIntent(getIntent()));
         } else {
             return super.getPackageName();
+    public void onDone() {
+        // We're most probably running within a foreign app's task, so we have no choice what to
+        // call here if we want to allow the user to return to that task's previous activity.
+        finish();
+    }
+    @Override
     public void finish() {
         final SafeIntent intent = new SafeIntent(getIntent());
         // When 3rd party app launch this Activity, it could also specify custom exit-animation.
         if (IntentUtil.hasExitAnimation(intent)) {
             usingCustomAnimation = true;