Android M sytle upgrade : P3 feature
1. Support separate notification msg
2. Add MMS attachment type flag/icon in conversation list
Change-Id: I6f21ca0d4e7a3743c88ae8ec2c40ed4fecbfa235
CRs-Fixed: 999204
diff --git a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
index 4f89900..7cb8b74 100644
--- a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
+++ b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
@@ -500,6 +500,16 @@
createSmsTables(db);
}
}
+ try {
+ // Try to access the table and create it if "no such table"
+ db.query(MmsSmsProvider.TABLE_THREADS, null, null, null, null, null, null);
+ checkAndUpdateThreadsTable(db);
+ } catch (SQLiteException e) {
+ Log.e(TAG, "onOpen: ex. ", e);
+ if (e.getMessage().startsWith(NO_SUCH_TABLE_EXCEPTION_MESSAGE)) {
+ createCommonTables(db);
+ }
+ }
// Improve the performance of deleting Mms.
dropMmsTriggers(db);
@@ -979,7 +989,9 @@
Threads.ARCHIVED + " INTEGER DEFAULT 0," +
Threads.TYPE + " INTEGER DEFAULT 0," +
Threads.ERROR + " INTEGER DEFAULT 0," +
- Threads.HAS_ATTACHMENT + " INTEGER DEFAULT 0);");
+ Threads.HAS_ATTACHMENT + " INTEGER DEFAULT 0," +
+ Threads.ATTACHMENT_INFO + " TEXT," +
+ Threads.NOTIFICATION + " INTEGER DEFAULT 0);");
/**
* This table stores the queue of messages to be sent/downloaded.
@@ -1757,6 +1769,30 @@
}
}
+ private void checkAndUpdateThreadsTable(SQLiteDatabase db) {
+ try {
+ db.query(MmsSmsProvider.TABLE_THREADS, new String[] {Threads.ATTACHMENT_INFO},
+ null, null, null, null, null);
+ } catch (SQLiteException e) {
+ Log.e(TAG, "checkAndUpdateThreadsTable: ex. ", e);
+ if (e.getMessage().startsWith(NO_SUCH_COLUMN_EXCEPTION_MESSAGE)) {
+ db.execSQL("ALTER TABLE " + MmsSmsProvider.TABLE_THREADS + " ADD COLUMN "
+ + Threads.ATTACHMENT_INFO + " TEXT");
+ }
+ }
+
+ try {
+ db.query(MmsSmsProvider.TABLE_THREADS, new String[] {Threads.NOTIFICATION},
+ null, null, null, null, null);
+ } catch (SQLiteException e) {
+ Log.e(TAG, "checkAndUpdateThreadsTable: ex. ", e);
+ if (e.getMessage().startsWith(NO_SUCH_COLUMN_EXCEPTION_MESSAGE)) {
+ db.execSQL("ALTER TABLE " + MmsSmsProvider.TABLE_THREADS + " ADD COLUMN "
+ + Threads.NOTIFICATION + " INTEGER DEFAULT 0");
+ }
+ }
+ }
+
@Override
public synchronized SQLiteDatabase getWritableDatabase() {
SQLiteDatabase db = super.getWritableDatabase();
@@ -1921,7 +1957,9 @@
Threads.READ + " INTEGER DEFAULT 1," +
Threads.TYPE + " INTEGER DEFAULT 0," +
Threads.ERROR + " INTEGER DEFAULT 0," +
- Threads.HAS_ATTACHMENT + " INTEGER DEFAULT 0);");
+ Threads.HAS_ATTACHMENT + " INTEGER DEFAULT 0," +
+ Threads.ATTACHMENT_INFO + " TEXT," +
+ Threads.NOTIFICATION + " INTEGER DEFAULT 0);");
db.execSQL("INSERT INTO threads_temp SELECT * from threads;");
db.execSQL("DROP TABLE threads;");
diff --git a/src/com/android/providers/telephony/MmsSmsProvider.java b/src/com/android/providers/telephony/MmsSmsProvider.java
index 23229db..64ba181 100644
--- a/src/com/android/providers/telephony/MmsSmsProvider.java
+++ b/src/com/android/providers/telephony/MmsSmsProvider.java
@@ -1306,8 +1306,14 @@
switch(URI_MATCHER.match(uri)) {
case URI_CONVERSATIONS_MESSAGES:
String threadIdString = uri.getPathSegments().get(1);
- affectedRows = updateConversation(threadIdString, values,
- selection, selectionArgs, callerUid, callerPkg);
+ if (values.containsKey(Threads.NOTIFICATION) ||
+ values.containsKey(Threads.ATTACHMENT_INFO)) {
+ String finalSelection = concatSelections(selection, "_id=" + threadIdString);
+ affectedRows = db.update(TABLE_THREADS, values, finalSelection, null);
+ } else {
+ affectedRows = updateConversation(threadIdString, values,
+ selection, selectionArgs, callerUid, callerPkg);
+ }
break;
case URI_PENDING_MSG: