Bug 732572: Restart the entire application on locale change. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Wed, 16 May 2012 15:28:28 -0700
changeset 94172 c462ef73a65fa17fb49d7bbccaa9294698fe7b68
parent 94171 1c2c14d8be7821842208ce8d959c9f5cd21aa1a0
child 94173 25995acb6675472d2d6bfb9b3f8d363f563c8d1c
push id22701
push useremorley@mozilla.com
push dateThu, 17 May 2012 10:00:02 +0000
treeherdermozilla-central@f2b2b99108a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs732572
milestone15.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 732572: Restart the entire application on locale change. [r=mfinkle]
mobile/android/base/GeckoApp.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1520,16 +1520,24 @@ abstract public class GeckoApp
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState)
     {
         GeckoAppShell.registerGlobalExceptionHandler();
 
         mAppContext = this;
 
+        // Check to see if the activity is restarted after configuration change.
+        if (getLastNonConfigurationInstance() != null) {
+            // Restart the application as a safe way to handle the configuration change.
+            doRestart();
+            System.exit(0);
+            return;
+        }
+
         // StrictMode is set by defaults resource flag |enableStrictMode|.
         if (getResources().getBoolean(R.bool.enableStrictMode)) {
             enableStrictMode();
         }
 
         GeckoAppShell.loadMozGlue();
         mMainHandler = new Handler();
         Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
@@ -2132,16 +2140,23 @@ abstract public class GeckoApp
             GeckoAppShell.sendEventToGecko(GeckoEvent.createResumeEvent(true));
 
         if (mConnectivityReceiver != null)
             mConnectivityReceiver.registerFor(mAppContext);
         GeckoNetworkManager.getInstance().start();
         GeckoScreenOrientationListener.getInstance().start();
     }
 
+    @Override
+    public Object onRetainNonConfigurationInstance() {
+        // Send a non-null value so that we can restart the application, 
+        // when activity restarts due to configuration change.
+        return new Boolean(true);
+    } 
+
     abstract public String getPackageName();
     abstract public String getContentProcessName();
 
     public void addEnvToIntent(Intent intent) {
         Map<String,String> envMap = System.getenv();
         Set<Map.Entry<String,String>> envSet = envMap.entrySet();
         Iterator<Map.Entry<String,String>> envIter = envSet.iterator();
         int c = 0;