Bug 922694 - Part 5: grab distribution ID in FHR. r=mcomella
--- 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) {