Bug 1570383 - Call GeckoThread.onPause() and onResume() on GeckoRuntime lifecycle events. r=snorp,rbarker

Call GeckoThread.onPause() and onResume() on GeckoRuntime lifecycle events.

Differential Revision: https://phabricator.services.mozilla.com/D40078

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Imanol Fernandez 2019-08-01 16:02:56 +00:00
parent 0b4a5a5bc8
commit 613d14e352

View File

@ -100,6 +100,7 @@ public final class GeckoRuntime implements Parcelable {
public static final String EXTRA_CRASH_FATAL = "fatal";
private final class LifecycleListener implements LifecycleObserver {
private boolean mPaused = false;
public LifecycleListener() {
}
@ -116,6 +117,11 @@ public final class GeckoRuntime implements Parcelable {
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
void onResume() {
Log.d(LOGTAG, "Lifecycle: onResume");
if (mPaused) {
// Do not trigger the first onResume event because it breaks nsAppShell::sPauseCount counter thresholds.
GeckoThread.onResume();
}
mPaused = false;
// Monitor network status and send change notifications to Gecko
// while active.
GeckoNetworkManager.getInstance().start(GeckoAppShell.getApplicationContext());
@ -124,8 +130,10 @@ public final class GeckoRuntime implements Parcelable {
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
void onPause() {
Log.d(LOGTAG, "Lifecycle: onPause");
mPaused = true;
// Stop monitoring network status while inactive.
GeckoNetworkManager.getInstance().stop();
GeckoThread.onPause();
}
}