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 94146 c462ef73a65fa17fb49d7bbccaa9294698fe7b68
parent 94145 1c2c14d8be7821842208ce8d959c9f5cd21aa1a0
child 94147 25995acb6675472d2d6bfb9b3f8d363f563c8d1c
push id9494
push usersramasubramanian@mozilla.com
push dateWed, 16 May 2012 22:29:44 +0000
treeherdermozilla-inbound@c462ef73a65f [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;