Bug 922694 - Part 5: grab distribution ID in FHR. r=mcomella
authorRichard Newman <rnewman@mozilla.com>
Wed, 16 Oct 2013 18:56:27 -0700
changeset 165823 6d403b11bd6270c4fde317cc88d3919850568a4e
parent 165822 74b504d3e20a3488589a65492b9b3d8ceb7c5faa
child 165824 05ebffcae22e45e3b683d8e463af60f4b9ee1325
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs922694
milestone27.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 922694 - Part 5: grab distribution ID in FHR. r=mcomella
mobile/android/base/health/BrowserHealthRecorder.java
--- a/mobile/android/base/health/BrowserHealthRecorder.java
+++ b/mobile/android/base/health/BrowserHealthRecorder.java
@@ -8,16 +8,18 @@ package org.mozilla.gecko.health;
 import java.util.ArrayList;
 
 import android.content.Context;
 import android.content.ContentProviderClient;
 import android.content.SharedPreferences;
 import android.util.Log;
 
 import org.mozilla.gecko.AppConstants;
+import org.mozilla.gecko.Distribution;
+import org.mozilla.gecko.Distribution.DistributionDescriptor;
 import org.mozilla.gecko.GeckoApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 
 import org.mozilla.gecko.background.healthreport.EnvironmentBuilder;
 import org.mozilla.gecko.background.healthreport.HealthReportDatabaseStorage;
 import org.mozilla.gecko.background.healthreport.HealthReportStorage.Field;
 import org.mozilla.gecko.background.healthreport.HealthReportStorage.MeasurementFields;
@@ -615,19 +617,31 @@ public class BrowserHealthRecorder imple
         }
 
         // Otherwise, let's initialize it from scratch.
         this.profileCache.beginInitialization();
         this.profileCache.setProfileCreationTime(getAndPersistProfileInitTime(context, profilePath));
         this.profileCache.setOSLocale(osLocale);
         this.profileCache.setAppLocale(appLocale);
 
-        Log.d(LOG_TAG, "Requesting all add-ons and FHR prefs from Gecko.");
-        dispatcher.registerEventListener(EVENT_SNAPSHOT, this);
-        GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("HealthReport:RequestSnapshot", null));
+        // Because the distribution lookup can take some time, do it at the end of
+        // our background startup work, along with the Gecko snapshot fetch.
+        final GeckoEventListener self = this;
+        ThreadUtils.postToBackgroundThread(new Runnable() {
+            @Override
+            public void run() {
+                final DistributionDescriptor desc = new Distribution(context).getDescriptor();
+                if (desc != null && desc.valid) {
+                    profileCache.setDistributionString(desc.id, desc.version);
+                }
+                Log.d(LOG_TAG, "Requesting all add-ons and FHR prefs from Gecko.");
+                dispatcher.registerEventListener(EVENT_SNAPSHOT, self);
+                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("HealthReport:RequestSnapshot", null));
+            }
+        });
     }
 
     /**
      * Invoked in the background whenever the environment transitions between
      * two valid values.
      */
     protected void onEnvironmentTransition(int prev, int env) {
         if (this.state != State.INITIALIZED) {