Merge "Handle exception upgrading to db version 65 gracefully."
am: a615f3daa0
Change-Id: Ifcd68df9f73515f9dc3a61ed037ce1d92e388bc2
diff --git a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
index 118eaeb..45d4f01 100644
--- a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
+++ b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
@@ -23,6 +23,7 @@
import android.content.IntentFilter;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.storage.StorageManager;
import android.provider.BaseColumns;
@@ -1734,7 +1735,17 @@
}
private void upgradeDatabaseToVersion65(SQLiteDatabase db) {
- db.execSQL("ALTER TABLE " + SmsProvider.TABLE_RAW +" ADD COLUMN message_body TEXT");
+ // aosp and internal code diverged at version 63. Aosp did createThreadIdDateIndex() on
+ // upgrading to 63, whereas internal (nyc) added column 'deleted'. A device upgrading from
+ // nyc will have columns deleted and message_body in raw table with version 64, but not
+ // createThreadIdDateIndex()
+ try {
+ db.execSQL("ALTER TABLE " + SmsProvider.TABLE_RAW + " ADD COLUMN message_body TEXT");
+ } catch (SQLiteException e) {
+ Log.w(TAG, "[upgradeDatabaseToVersion65] Exception adding column message_body; " +
+ "trying createThreadIdDateIndex() instead: " + e);
+ createThreadIdDateIndex(db);
+ }
}
@Override