Bug 1540573 - P2. Have GeckoRuntime listen for network link changes when in the foreground. r=snorp
authorChris Pearce <cpearce@mozilla.com>
Mon, 06 May 2019 22:41:10 +0000
changeset 472827 d029091d7fd831b30cbc4a660c03f962b20fa44e
parent 472826 6a17951bc4b981f455e3b8f54db29b5ed28fa122
child 472828 b78948e4f480ea6b99f2c689fe048256590b8769
push id84853
push usercpearce@mozilla.com
push dateTue, 07 May 2019 01:30:16 +0000
treeherderautoland@90ebd256a92b [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.