Bug 792212 - Don't attempt to migrate profiles if using a custom profile;r=gbrown
authorWilliam Lachance <wlachance@mozilla.com>
Fri, 28 Sep 2012 22:52:11 -0400
changeset 108702 4a4733ddb26e28f88011ffbe61bacdf38b70ac5f
parent 108701 e88f05f326185447e13bf00b00f0214e2f8550b9
child 108703 bed646e2b0f5b298b93a9477cf48a62ebe1c93d9
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersgbrown
bugs792212
milestone18.0a1
Bug 792212 - Don't attempt to migrate profiles if using a custom profile;r=gbrown It seems that doing so triggers a race condition which can result in the fennec reftests failing, if the shared preferences associated with profile migration or the gecko application is not correctly initialized. This is more or less a band aid solution, but it addresses the problem until we can find the root cause.
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoProfile.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -151,16 +151,17 @@ abstract public class GeckoApp
     protected Menu mMenu;
     private static GeckoThread sGeckoThread;
     public Handler mMainHandler;
     private GeckoProfile mProfile;
     public static boolean sIsGeckoReady = false;
     public static int mOrientation;
     private boolean mIsRestoringActivity;
     private String mCurrentResponse = "";
+    public static boolean sIsUsingCustomProfile = false;
 
     private PromptService mPromptService;
     private Favicons mFavicons;
     private TextSelection mTextSelection;
 
     protected DoorHangerPopup mDoorHangerPopup;
     protected FormAssistPopup mFormAssistPopup;
     protected TabsPanel mTabsPanel;
@@ -1549,16 +1550,17 @@ abstract public class GeckoApp
                 if (m.find()) {
                     profilePath =  m.group(1);
                 }
                 if (profileName == null) {
                     profileName = getDefaultProfileName();
                     if (profileName == null)
                         profileName = "default";
                 }
+                GeckoApp.sIsUsingCustomProfile = true;
             }
             if (profileName != null || profilePath != null) {
                 mProfile = GeckoProfile.get(this, profileName, profilePath);
             }
         }
 
         BrowserDB.initialize(getProfile().getName());
 
@@ -2247,17 +2249,18 @@ abstract public class GeckoApp
 
             GeckoAppShell.getHandler().post(new Runnable() {
                 public void run() {
                     Log.i(LOGTAG, "Checking profile migration in: " + profileDir.getAbsolutePath());
 
                     ProfileMigrator profileMigrator = new ProfileMigrator(app);
 
                     // Do a migration run on the first start after an upgrade.
-                    if (!profileMigrator.hasMigrationRun()) {
+                    if (!GeckoApp.sIsUsingCustomProfile &&
+                        !profileMigrator.hasMigrationRun()) {
                         // Show the "Setting up Fennec" screen if this takes
                         // a while.
                         final SetupScreen setupScreen = new SetupScreen(app);
 
                         final Runnable startCallback = new Runnable() {
                             public void run() {
                                 GeckoApp.mAppContext.runOnUiThread(new Runnable() {
                                     public void run() {
@@ -2291,17 +2294,17 @@ abstract public class GeckoApp
         }
     }
 
     protected void finishProfileMigration() {
     }
 
     private void checkMigrateSync() {
         final File profileDir = getProfile().getDir();
-        if (profileDir != null) {
+        if (!GeckoApp.sIsUsingCustomProfile && profileDir != null) {
             final GeckoApp app = GeckoApp.mAppContext;
             ProfileMigrator profileMigrator = new ProfileMigrator(app);
             if (!profileMigrator.hasSyncMigrated()) {
                 Log.i(LOGTAG, "Checking Sync settings in: " + profileDir.getAbsolutePath());
                 profileMigrator.launchSyncPrefs();
             }
         }
     }
--- a/mobile/android/base/GeckoProfile.java
+++ b/mobile/android/base/GeckoProfile.java
@@ -143,17 +143,18 @@ public final class GeckoProfile {
     public synchronized File getDir() {
         if (mDir != null) {
             return mDir;
         }
 
         try {
             // Check for old profiles that may need migration.
             ProfileMigrator profileMigrator = new ProfileMigrator(mContext);
-            if (!profileMigrator.isProfileMoved()) {
+            if (!GeckoApp.sIsUsingCustomProfile &&
+                !profileMigrator.isProfileMoved()) {
                 Log.i(LOGTAG, "New installation or update, checking for old profiles.");
                 profileMigrator.launchMoveProfile();
             }
 
             // now check if a profile with this name that already exists
             File mozillaDir = ensureMozillaDirectory(mContext);
             mDir = findProfileDir(mozillaDir);
             if (mDir == null) {