Bug 960709 - Part 5: Allow locale change even if HealthRecorder is not yet initialized. r=rnewman
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 04 Feb 2014 19:41:30 -0800
changeset 166825 50c164585e255921e0f28f4e4dd929e7d94cb717
parent 166824 229735e9e5ab855c2a941ce7f449fea9fd80d49d
child 166826 e78a7c6d9601b8c669b520d9aae02abfa5652e23
push id4842
push usermichael.l.comella@gmail.com
push dateWed, 05 Feb 2014 03:41:25 +0000
treeherderfx-team@50c164585e25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs960709
milestone30.0a1
Bug 960709 - Part 5: Allow locale change even if HealthRecorder is not yet initialized. r=rnewman
mobile/android/base/GeckoApp.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -2780,25 +2780,27 @@ public abstract class GeckoApp
         if (locale == null) {
             return;
         }
         final String resultant = LocaleManager.setSelectedLocale(locale);
         if (resultant == null) {
             return;
         }
 
-        final HealthRecorder rec = mHealthRecorder;
-        if (rec == null) {
-            return;
-        }
-
         final boolean startNewSession = true;
         final boolean shouldRestart = false;
-        rec.onAppLocaleChanged(resultant);
-        rec.onEnvironmentChanged(startNewSession, SESSION_END_LOCALE_CHANGED);
+
+        // If the HealthRecorder is not yet initialized (unlikely), the locale change won't
+        // trigger a session transition and subsequent events will be recorded in an environment
+        // with the wrong locale.
+        final HealthRecorder rec = mHealthRecorder;
+        if (rec != null) {
+            rec.onAppLocaleChanged(resultant);
+            rec.onEnvironmentChanged(startNewSession, SESSION_END_LOCALE_CHANGED);
+        }
 
         if (!shouldRestart) {
             ThreadUtils.postToUiThread(new Runnable() {
                 @Override
                 public void run() {
                     GeckoApp.this.onLocaleReady(resultant);
                 }
             });