Bug 1360699 - Finish CustomTabsActivities when leaving. r?walkingice draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 29 Apr 2017 15:03:41 +0200
changeset 570617 27077114ba90cc4e2d9231e20552a34f4875bc6b
parent 570616 5cfca8183302a751c50741a94c88dc9530b75e52
child 570618 d7840cb262f36073cdd518b0ebd22caf28a548b4
push id56531
push usermozilla@buttercookie.de
push dateSat, 29 Apr 2017 14:37:47 +0000
reviewerswalkingice
bugs1360699
milestone55.0a1
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
mobile/android/base/java/org/mozilla/gecko/SingleTabActivity.java
mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
--- 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();
         }
     }
 
     @Override
+    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() {
         super.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;
             overridePendingTransition(IntentUtil.getEnterAnimationRes(intent),