Bug 1494748 - Stop stumbler service when Fennec is killed. r=snorp
authorDylan Roeh <droeh@mozilla.com>
Wed, 12 Dec 2018 11:53:49 -0600
changeset 510419 f3260513492738dd6f9dc779b396baad9347e719
parent 510418 099ba012de2795e21945b1d671113f456178db75
child 510420 e19e818041e3a0345880216bde3059d2a6577c8e
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1494748
milestone66.0a1
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 1494748 - Stop stumbler service when Fennec is killed. r=snorp
mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/StumblerService.java
--- a/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/StumblerService.java
+++ b/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/StumblerService.java
@@ -51,16 +51,18 @@ public class StumblerService extends Per
     private static final int DELAY_IN_SEC_BEFORE_STARTING_UPLOAD_IN_PASSIVE_MODE = 2;
 
     // This is the frequency of the repeating upload alarm in active scanning mode.
     private static final int FREQUENCY_IN_SEC_OF_UPLOAD_IN_ACTIVE_MODE = 5 * 60;
 
     // Used to guard against attempting to upload too frequently in passive mode.
     private static final long PASSIVE_UPLOAD_FREQ_GUARD_MSEC = 5 * 60 * 1000;
 
+    private static final String BROWSERAPP = "org.mozilla.gecko.BrowserApp";
+
     public StumblerService() {
         this("StumblerService");
     }
 
     public StumblerService(String name) {
         super(name);
     }
 
@@ -279,9 +281,17 @@ public class StumblerService extends Per
     private boolean hasLocationPermission() {
         return ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
     }
 
     private PendingIntent createContentIntent() {
         Intent intent = IntentHelper.getPrivacySettingsIntent();
         return PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
     }
+
+    @Override
+    public void onTaskRemoved(Intent rootIntent) {
+        if (rootIntent != null && rootIntent.getComponent() != null &&
+                BROWSERAPP.equals(rootIntent.getComponent().getClassName())) {
+            stopSelf();
+        }
+    }
 }