Add message_body column to raw table.
Use this column in addition to other fields to compare if messages
are the same.
Bug: 27974596
Change-Id: Ibe3b556aaf8e7918acec493e9dac36fdf86a9728
diff --git a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
index 6ff0bff..5c9c426 100644
--- a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
+++ b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
@@ -235,7 +235,7 @@
private static boolean sFakeLowStorageTest = false; // for testing only
static final String DATABASE_NAME = "mmssms.db";
- static final int DATABASE_VERSION = 63;
+ static final int DATABASE_VERSION = 64;
private final Context mContext;
private LowStorageMonitor mLowStorageMonitor;
@@ -1430,6 +1430,22 @@
} finally {
db.endTransaction();
}
+ // fall through
+ case 63:
+ if (currentVersion <= 63) {
+ return;
+ }
+
+ db.beginTransaction();
+ try {
+ upgradeDatabaseToVersion64(db);
+ db.setTransactionSuccessful();
+ } catch (Throwable ex) {
+ Log.e(TAG, ex.getMessage(), ex);
+ break;
+ } finally {
+ db.endTransaction();
+ }
return;
}
@@ -1709,6 +1725,10 @@
db.execSQL("ALTER TABLE " + SmsProvider.TABLE_RAW +" ADD COLUMN deleted INTEGER DEFAULT 0");
}
+ private void upgradeDatabaseToVersion64(SQLiteDatabase db) {
+ db.execSQL("ALTER TABLE " + SmsProvider.TABLE_RAW +" ADD COLUMN message_body TEXT");
+ }
+
@Override
public synchronized SQLiteDatabase getWritableDatabase() {
SQLiteDatabase db = super.getWritableDatabase();
diff --git a/src/com/android/providers/telephony/SmsProvider.java b/src/com/android/providers/telephony/SmsProvider.java
index 61d0be9..d8b97c5 100644
--- a/src/com/android/providers/telephony/SmsProvider.java
+++ b/src/com/android/providers/telephony/SmsProvider.java
@@ -209,7 +209,7 @@
case SMS_RAW_MESSAGE:
// before querying purge old entries with deleted = 1
- // purgeDeletedMessagesInRawTable(db);
+ purgeDeletedMessagesInRawTable(db);
qb.setTables("raw");
break;
@@ -687,14 +687,14 @@
break;
case SMS_RAW_MESSAGE:
- /* ContentValues cv = new ContentValues();
+ ContentValues cv = new ContentValues();
cv.put("deleted", 1);
count = db.update(TABLE_RAW, cv, where, whereArgs);
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.d(TAG, "delete: num rows marked deleted in raw table: " + count);
}
notifyIfNotDefault = false;
- break;*/
+ break;
case SMS_RAW_MESSAGE_PERMANENT_DELETE:
count = db.delete(TABLE_RAW, where, whereArgs);