Bug 1405192 - Return when onResume is already called and add Telemetry ping for future investigationr. ?maliu draft
authorNevin Chen <cnevinchen@gmail.com>
Thu, 11 Jan 2018 15:39:23 +0800
changeset 718972 b00d731f253c3f887f432d40f7772d3af535e335
parent 702568 4bdad977319a5d9be6c534aa0e968a1c81040bd9
child 745664 2aebf859f31c7b9b72774f5c96fbdd3eb8c7d28a
push id95117
push userbmo:cnevinchen@gmail.com
push dateThu, 11 Jan 2018 08:14:28 +0000
bugs1405192, 1317191
milestone59.0a1
Bug 1405192 - Return when onResume is already called and add Telemetry ping for future investigationr. ?maliu The fix will be similar to bug 1317191. MozReview-Commit-ID: HzeLYKDLVAm
mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
@@ -35,16 +35,18 @@ import java.io.IOException;
 /**
  * An activity-lifecycle delegate for uploading the core ping.
  */
 public class TelemetryCorePingDelegate extends BrowserAppDelegateWithReference
         implements SearchEngineManager.SearchEngineCallback, AttributionHelperListener {
     private static final String LOGTAG = StringUtils.safeSubstring(
             "Gecko" + TelemetryCorePingDelegate.class.getSimpleName(), 0, 23);
 
+    private static final String TELEMETRY_EXTRA_ONRESUME_ALREADY_CALLED = "onResumeAlreadyCalled";
+
     private boolean isOnResumeCalled = false;
     private TelemetryDispatcher telemetryDispatcher; // lazy
     private final SessionMeasurements sessionMeasurements = new SessionMeasurements();
 
     @Override
     public void onStart(final BrowserApp browserApp) {
         TelemetryPreferences.initPreferenceObserver(browserApp, GeckoThread.getActiveProfile().getName());
 
@@ -81,16 +83,20 @@ public class TelemetryCorePingDelegate e
 
     private void uploadPing(final BrowserApp browserApp) {
         final SearchEngineManager searchEngineManager = browserApp.getSearchEngineManager();
         searchEngineManager.getEngine(this);
     }
 
     @Override
     public void onResume(BrowserApp browserApp) {
+        if (isOnResumeCalled) {
+            Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.SYSTEM, TELEMETRY_EXTRA_ONRESUME_ALREADY_CALLED);
+            return;
+        }
         isOnResumeCalled = true;
         sessionMeasurements.recordSessionStart();
     }
 
     @Override
     public void onPause(BrowserApp browserApp) {
         if (!isOnResumeCalled) {
             Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.SYSTEM, "onPauseCalledBeforeOnResume");