diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index 4032a0276a3..ca459dd0859 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -2594,7 +2594,7 @@ abstract public class BrowserApp extends GeckoApp final EventDispatcher dispatcher, final String osLocale, final String appLocale, - SessionInformation previousSession) { + final SessionInformation previousSession) { return new BrowserHealthRecorder(context, profilePath, dispatcher, diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index f3a767d2070..ef250459891 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -2117,7 +2117,7 @@ public abstract class GeckoApp final HealthRecorder rec = mHealthRecorder; mHealthRecorder = null; - if (rec != null) { + if (rec != null && rec.isEnabled()) { // Closing a BrowserHealthRecorder could incur a write. ThreadUtils.postToBackgroundThread(new Runnable() { @Override @@ -2834,7 +2834,7 @@ public abstract class GeckoApp final EventDispatcher dispatcher, final String osLocale, final String appLocale, - SessionInformation previousSession) { + final SessionInformation previousSession) { // GeckoApp does not need to record any health information - return a stub. return new StubbedHealthRecorder(); } diff --git a/mobile/android/base/health/BrowserHealthRecorder.java b/mobile/android/base/health/BrowserHealthRecorder.java index b2b4890bd14..d41f45810ec 100644 --- a/mobile/android/base/health/BrowserHealthRecorder.java +++ b/mobile/android/base/health/BrowserHealthRecorder.java @@ -168,6 +168,10 @@ public class BrowserHealthRecorder implements HealthRecorder, GeckoEventListener } } + public boolean isEnabled() { + return true; + } + /** * Shut down database connections, unregister event listeners, and perform * provider-specific uninitialization. diff --git a/mobile/android/base/health/HealthRecorder.java b/mobile/android/base/health/HealthRecorder.java index 95a80422932..7e95767db5b 100644 --- a/mobile/android/base/health/HealthRecorder.java +++ b/mobile/android/base/health/HealthRecorder.java @@ -13,6 +13,11 @@ import org.json.JSONObject; * HealthRecorder is an interface into the Firefox Health Report storage system. */ public interface HealthRecorder { + /** + * Returns whether the Health Recorder is actively recording events. + */ + public boolean isEnabled(); + public void setCurrentSession(SessionInformation session); public void checkForOrphanSessions(); diff --git a/mobile/android/base/health/StubbedHealthRecorder.java b/mobile/android/base/health/StubbedHealthRecorder.java index 9fca77cd4a4..38962a1e7b5 100644 --- a/mobile/android/base/health/StubbedHealthRecorder.java +++ b/mobile/android/base/health/StubbedHealthRecorder.java @@ -14,6 +14,8 @@ import org.json.JSONObject; * nothing. */ public class StubbedHealthRecorder implements HealthRecorder { + public boolean isEnabled() { return false; } + public void setCurrentSession(SessionInformation session) { } public void checkForOrphanSessions() { }