Bug 945832 - java.lang.IllegalStateException: No ContextGetter; cannot fetch prefs. on rotation or system locale change. r=wesj
authorRichard Newman <rnewman@mozilla.com>
Tue, 03 Dec 2013 15:05:43 -0800
changeset 158753 942827d00677d37458d75e75d5eacf485eff2674
parent 158752 cd918aef9e641d5fc74a5da2d398784e29f93548
child 158754 14b3b255b2c834848966a9d2c19878e873fd3f24
push id37085
push userryanvm@gmail.com
push dateWed, 04 Dec 2013 22:39:20 +0000
treeherdermozilla-inbound@1426ffa9caf2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs945832
milestone28.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 945832 - java.lang.IllegalStateException: No ContextGetter; cannot fetch prefs. on rotation or system locale change. r=wesj
mobile/android/base/GeckoApplication.java
mobile/android/base/LocaleManager.java
--- a/mobile/android/base/GeckoApplication.java
+++ b/mobile/android/base/GeckoApplication.java
@@ -11,42 +11,49 @@ import org.mozilla.gecko.util.Clipboard;
 import org.mozilla.gecko.util.HardwareUtils;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.app.Application;
 import android.content.res.Configuration;
 import android.util.Log;
 
 public class GeckoApplication extends Application {
+    private static final String LOG_TAG = "GeckoApplication";
 
     private boolean mInited;
     private boolean mInBackground;
     private boolean mPausedGecko;
 
     private LightweightTheme mLightweightTheme;
 
     /**
      * We need to do locale work here, because we need to intercept
      * each hit to onConfigurationChanged.
      */
     @Override
     public void onConfigurationChanged(Configuration config) {
-        Log.d("GeckoApplication", "onConfigurationChanged: " + config.locale +
-                                  ", background: " + mInBackground);
+        Log.d(LOG_TAG, "onConfigurationChanged: " + config.locale +
+                       ", background: " + mInBackground);
 
         // Do nothing if we're in the background. It'll simply cause a loop
         // (Bug 936756 Comment 11), and it's not necessary.
         if (mInBackground) {
             super.onConfigurationChanged(config);
             return;
         }
 
         // Otherwise, correct the locale. This catches some cases that GeckoApp
         // doesn't get a chance to.
-        LocaleManager.correctLocale(getResources(), config);
+        try {
+            LocaleManager.correctLocale(getResources(), config);
+        } catch (IllegalStateException ex) {
+            // GeckoApp hasn't started, so we have no ContextGetter in LocaleManager.
+            Log.w(LOG_TAG, "Couldn't correct locale.", ex);
+        }
+
         super.onConfigurationChanged(config);
     }
 
     protected void initialize() {
         if (mInited)
             return;
 
         // workaround for http://code.google.com/p/android/issues/detail?id=20915
--- a/mobile/android/base/LocaleManager.java
+++ b/mobile/android/base/LocaleManager.java
@@ -39,16 +39,17 @@ public class LocaleManager {
     private static volatile ContextGetter getter = null;
     private static volatile Locale currentLocale = null;
 
     private static volatile boolean inited = false;
     private static boolean systemLocaleDidChange = false;
     private static BroadcastReceiver receiver;
 
     public static void setContextGetter(ContextGetter getter) {
+        Log.d(LOG_TAG, "Calling setContextGetter: " + getter);
         LocaleManager.getter = getter;
     }
 
     public static void initialize() {
         if (inited) {
             return;
         }