Bug 1540573 - P2. Have GeckoRuntime listen for network link changes when in the foreground. r=snorp
authorChris Pearce <cpearce@mozilla.com>
Fri, 03 May 2019 02:43:22 +0000
changeset 531229 1bde5042e507bbc2a96809c6a35f1b69e2e016bc
parent 531228 4ff116b9d729055b866bb9fadf35065bba8f1c63
child 531230 fe196b2dfc6247bd8f9ec102aeb9927fffc1af87
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1540573
milestone68.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 1540573 - P2. Have GeckoRuntime listen for network link changes when in the foreground. r=snorp This allows Gecko to react to network link/status changes events as needed. Differential Revision: https://phabricator.services.mozilla.com/D28942
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java
@@ -26,16 +26,17 @@ import android.os.Process;
 import android.support.annotation.AnyThread;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
 import android.support.annotation.UiThread;
 import android.util.Log;
 
 import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.GeckoAppShell;
+import org.mozilla.gecko.GeckoNetworkManager;
 import org.mozilla.gecko.GeckoScreenOrientation;
 import org.mozilla.gecko.GeckoSystemStateListener;
 import org.mozilla.gecko.GeckoThread;
 import org.mozilla.gecko.PrefsHelper;
 import org.mozilla.gecko.util.BundleEventListener;
 import org.mozilla.gecko.util.DebugConfig;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.GeckoBundle;
@@ -110,21 +111,26 @@ public final class GeckoRuntime implemen
         @OnLifecycleEvent(Lifecycle.Event.ON_START)
         void onStart() {
             Log.d(LOGTAG, "Lifecycle: onStart");
         }
 
         @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
         void onResume() {
             Log.d(LOGTAG, "Lifecycle: onResume");
+            // Monitor network status and send change notifications to Gecko
+            // while active.
+            GeckoNetworkManager.getInstance().start(GeckoAppShell.getApplicationContext());
         }
 
         @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
         void onPause() {
             Log.d(LOGTAG, "Lifecycle: onPause");
+            // Stop monitoring network status while inactive.
+            GeckoNetworkManager.getInstance().stop();
         }
     }
 
     private static GeckoRuntime sDefaultRuntime;
 
     /**
      * Get the default runtime for the given context.
      * This will create and initialize the runtime with the default settings.