diff options
author | Amit Mahajan <amitmahajan@google.com> | 2015-10-29 01:56:00 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-10-29 01:56:00 +0000 |
commit | 9b0e36e7a2bad6951d984f853cf96e59657006cd (patch) | |
tree | 4b405a8a531ed531c643a295392d083e5fec8b7e | |
parent | 6296936ec0fe08b862d3011bd1394a78d76f4fc2 (diff) | |
parent | 962e1be7e9733d75e15dc85fd29184870b05381a (diff) | |
download | android_packages_providers_TelephonyProvider-9b0e36e7a2bad6951d984f853cf96e59657006cd.tar.gz android_packages_providers_TelephonyProvider-9b0e36e7a2bad6951d984f853cf96e59657006cd.tar.bz2 android_packages_providers_TelephonyProvider-9b0e36e7a2bad6951d984f853cf96e59657006cd.zip |
Upgrade telephony db (carriers table) only if needed. am: d4091e0fbb
am: 962e1be7e9
* commit '962e1be7e9733d75e15dc85fd29184870b05381a':
Upgrade telephony db (carriers table) only if needed.
-rw-r--r-- | src/com/android/providers/telephony/TelephonyProvider.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java index 75cddee..bf7dc74 100644 --- a/src/com/android/providers/telephony/TelephonyProvider.java +++ b/src/com/android/providers/telephony/TelephonyProvider.java @@ -533,6 +533,12 @@ public class TelephonyProvider extends ContentProvider // copyPreservedApnsToNewTable() // The only exception if upgrading from version 14 is that EDITED field is already // present (but is called USER_EDITED) + /********************************************************************************* + * IMPORTANT NOTE: SINCE CARRIERS TABLE IS RECREATED HERE, IT WILL BE THE LATEST + * VERSION AFTER THIS. AS A RESULT ANY SUBSEQUENT UPDATES TO THE TABLE WILL FAIL + * (DUE TO COLUMN-ALREADY-EXISTS KIND OF EXCEPTION). ALL SUBSEQUENT UPDATES SHOULD + * HANDLE THAT GRACEFULLY. + *********************************************************************************/ Cursor c; String[] proj = {"_id"}; if (VDBG) { @@ -617,8 +623,24 @@ public class TelephonyProvider extends ContentProvider oldVersion = 16 << 16 | 6; } if (oldVersion < (17 << 16 | 6)) { - db.execSQL("ALTER TABLE " + CARRIERS_TABLE + " ADD COLUMN " + - Telephony.Carriers.USER_VISIBLE + " BOOLEAN DEFAULT 1;"); + Cursor c = null; + try { + c = db.query(CARRIERS_TABLE, null, null, null, null, null, null, + String.valueOf(1)); + if (c == null || c.getColumnIndex(Telephony.Carriers.USER_VISIBLE) == -1) { + db.execSQL("ALTER TABLE " + CARRIERS_TABLE + " ADD COLUMN " + + Telephony.Carriers.USER_VISIBLE + " BOOLEAN DEFAULT 1;"); + } else { + if (DBG) { + log("onUpgrade skipping " + CARRIERS_TABLE + " upgrade. Column " + + Telephony.Carriers.USER_VISIBLE + " already exists."); + } + } + } finally { + if (c != null) { + c.close(); + } + } oldVersion = 17 << 16 | 6; } if (DBG) { |