Bug 1485178 - Only migrate sharedprefs when in Fennec. r=snorp a=ritu GECKOVIEW_62_RELBRANCH
authorDylan Roeh <droeh@mozilla.com>
Tue, 28 Aug 2018 11:35:46 -0500
branchGECKOVIEW_62_RELBRANCH
changeset 481113 31683bdf39d7
parent 481112 99aa10a241f6
child 481123 494b2c115bc1
push id1772
push usernchen@mozilla.com
push date2018-08-31 22:52 +0000
treeherdermozilla-release@31683bdf39d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, ritu
bugs1485178
milestone62.0
Bug 1485178 - Only migrate sharedprefs when in Fennec. r=snorp a=ritu
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoSharedPrefs.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoSharedPrefs.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoSharedPrefs.java
@@ -168,16 +168,20 @@ public final class GeckoSharedPrefs {
     }
 
     /**
      * Performs all prefs migrations in the background thread to avoid StrictMode
      * exceptions from reading/writing in the UI thread. This method will block
      * the current thread until the migration is finished.
      */
     private static synchronized void migrateIfNecessary(final Context context) {
+        if (!GeckoAppShell.isFennec()) {
+            return;
+        }
+
         if (migrationDone) {
             return;
         }
 
         // We deliberately perform the migration in the current thread (which
         // is likely the UI thread) as this is actually cheaper than enforcing a
         // context switch to another thread (see bug 940575).
         // Avoid strict mode warnings when doing so.
@@ -250,17 +254,17 @@ public final class GeckoSharedPrefs {
         Log.d(LOGTAG, "All keys have been migrated");
     }
 
     /**
      * Moves all preferences stored in PreferenceManager's default prefs
      * to either app or profile scopes. The profile-scoped keys are defined
      * in given profileKeys list, all other keys are moved to the app scope.
      */
-    public static Editor migrateFromPreferenceManager(Context context, Editor appEditor,
+    private static Editor migrateFromPreferenceManager(Context context, Editor appEditor,
             Editor profileEditor, List<String> profileKeys) {
         Log.d(LOGTAG, "Migrating from PreferenceManager");
 
         final SharedPreferences pmPrefs =
                 PreferenceManager.getDefaultSharedPreferences(context);
 
         for (Map.Entry<String, ?> entry : pmPrefs.getAll().entrySet()) {
             final String key = entry.getKey();
@@ -279,17 +283,17 @@ public final class GeckoSharedPrefs {
         // and return the Editor to be committed.
         return pmPrefs.edit().clear();
     }
 
     /**
      * Moves the crash reporter's preferences from the app-wide prefs
      * into its own shared prefs to avoid cross-process pref accesses.
      */
-    public static void migrateCrashReporterSettings(SharedPreferences appPrefs, Editor appEditor,
+    private static void migrateCrashReporterSettings(SharedPreferences appPrefs, Editor appEditor,
                                                     Editor crashEditor, List<String> profileKeys) {
         Log.d(LOGTAG, "Migrating crash reporter settings");
 
         for (Map.Entry<String, ?> entry : appPrefs.getAll().entrySet()) {
             final String key = entry.getKey();
 
             if (profileKeys.contains(key)) {
                 putEntry(crashEditor, key, entry.getValue());