SettingsProvider: Fix botched merge from donut to eclair.

donut and eclair had different ideas of what it means to upgrade from verion 34 to 35.

Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 6a1f6f8..8f4061e 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -64,7 +64,7 @@
 
     private static final String TAG = "SettingsProvider";
     private static final String DATABASE_NAME = "settings.db";
-    private static final int DATABASE_VERSION = 38;
+    private static final int DATABASE_VERSION = 39;
 
     private Context mContext;
 
@@ -389,21 +389,6 @@
         if (upgradeVersion == 34) {
             db.beginTransaction();
             try {
-                String value =
-                        mContext.getResources().getBoolean(R.bool.assisted_gps_enabled) ? "1" : "0";
-                db.execSQL("INSERT OR IGNORE INTO secure(name,value) values('" +
-                        Settings.Secure.ASSISTED_GPS_ENABLED + "','" + value + "');");
-                db.setTransactionSuccessful();
-            } finally {
-                db.endTransaction();
-            }
-
-            upgradeVersion = 35;
-        }
-
-        if (upgradeVersion == 35) {
-            db.beginTransaction();
-            try {
                 SQLiteStatement stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
                         + " VALUES(?,?);");
                 loadSecure35Settings(stmt);
@@ -412,8 +397,15 @@
             } finally {
                 db.endTransaction();
             }
+        }
+            // due to a botched merge from donut to eclair, the initialization of ASSISTED_GPS_ENABLED
+            // was accidentally done out of order here.
+            // to fix this, ASSISTED_GPS_ENABLED is now initialized while upgrading from 38 to 39,
+            // and we intentionally do nothing from 35 to 36 now.
+        if (upgradeVersion == 35) {
             upgradeVersion = 36;
         }
+
         if (upgradeVersion == 36) {
            // This upgrade adds the STREAM_SYSTEM_ENFORCED type to the list of
             // types affected by ringer modes (silent, vibrate, etc.)
@@ -450,6 +442,21 @@
             upgradeVersion = 38;
         }
 
+        if (upgradeVersion == 38) {
+            db.beginTransaction();
+            try {
+                String value =
+                        mContext.getResources().getBoolean(R.bool.assisted_gps_enabled) ? "1" : "0";
+                db.execSQL("INSERT OR IGNORE INTO secure(name,value) values('" +
+                        Settings.Secure.ASSISTED_GPS_ENABLED + "','" + value + "');");
+                db.setTransactionSuccessful();
+            } finally {
+                db.endTransaction();
+            }
+
+            upgradeVersion = 39;
+        }
+
         if (upgradeVersion != currentVersion) {
             Log.w(TAG, "Got stuck trying to upgrade from version " + upgradeVersion
                     + ", must wipe the settings provider");