Add column for eventual thread topic

Change-Id: I23a66d3ddf2fbdce516c161017713809af458d3d
diff --git a/CleanSpec.mk b/CleanSpec.mk
index d974023..b5064f0 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -71,6 +71,8 @@
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Email2_intermediates)
 $(call add-clean-step, rm -rf $(OUT_DIR)/out/target/common/obj/JAVA_LIBRARIES/com.android.emailcommon*)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Email*)
+$(call add-clean-step, rm -rf $(OUT_DIR)/out/target/common/obj/JAVA_LIBRARIES/com.android.emailcommon*)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Email*)
 
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java b/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java
index d253f94..9265de7 100755
--- a/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java
+++ b/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java
@@ -517,6 +517,8 @@
         // and the sync adapter might, for example, need more information about the original source
         // of the message)
         public static final String PROTOCOL_SEARCH_INFO = "protocolSearchInfo";
+        // Simple thread topic
+        public static final String THREAD_TOPIC = "threadTopic";
     }
 
     public static final class Message extends EmailContent implements SyncColumns, MessageColumns {
@@ -562,6 +564,7 @@
         public static final int CONTENT_MEETING_INFO_COLUMN = 20;
         public static final int CONTENT_SNIPPET_COLUMN = 21;
         public static final int CONTENT_PROTOCOL_SEARCH_INFO_COLUMN = 22;
+        public static final int CONTENT_THREAD_TOPIC_COLUMN = 23;
 
         public static final String[] CONTENT_PROJECTION = new String[] {
             RECORD_ID,
@@ -575,7 +578,8 @@
             MessageColumns.TO_LIST, MessageColumns.CC_LIST,
             MessageColumns.BCC_LIST, MessageColumns.REPLY_TO_LIST,
             SyncColumns.SERVER_TIMESTAMP, MessageColumns.MEETING_INFO,
-            MessageColumns.SNIPPET, MessageColumns.PROTOCOL_SEARCH_INFO
+            MessageColumns.SNIPPET, MessageColumns.PROTOCOL_SEARCH_INFO,
+            MessageColumns.THREAD_TOPIC
         };
 
         public static final int LIST_ID_COLUMN = 0;
@@ -710,6 +714,8 @@
 
         public String mProtocolSearchInfo;
 
+        public String mThreadTopic;
+
         /**
          * Base64-encoded representation of the byte array provided by servers for identifying
          * messages belonging to the same conversation thread. Currently unsupported and not
@@ -817,6 +823,8 @@
             values.put(MessageColumns.SNIPPET, mSnippet);
 
             values.put(MessageColumns.PROTOCOL_SEARCH_INFO, mProtocolSearchInfo);
+
+            values.put(MessageColumns.THREAD_TOPIC, mThreadTopic);
             return values;
         }
 
@@ -851,6 +859,7 @@
             mMeetingInfo = cursor.getString(CONTENT_MEETING_INFO_COLUMN);
             mSnippet = cursor.getString(CONTENT_SNIPPET_COLUMN);
             mProtocolSearchInfo = cursor.getString(CONTENT_PROTOCOL_SEARCH_INFO_COLUMN);
+            mThreadTopic = cursor.getString(CONTENT_THREAD_TOPIC_COLUMN);
         }
 
         public boolean update() {
diff --git a/email2/src/com/android/email/provider/DBHelper.java b/email2/src/com/android/email/provider/DBHelper.java
index bc783ab..796086b 100644
--- a/email2/src/com/android/email/provider/DBHelper.java
+++ b/email2/src/com/android/email/provider/DBHelper.java
@@ -24,7 +24,6 @@
 import android.database.SQLException;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteOpenHelper;
-import android.os.Debug;
 import android.provider.ContactsContract;
 import android.util.Log;
 
@@ -122,8 +121,9 @@
     // Version 35: Set up defaults for lastTouchedCount for drafts and sent
     // Version 36: mblank intentionally left this space
     // Version 37: Add flag for settings support in folders
+    // Version 38&39: Add threadTopic to message (for future support)
 
-    public static final int DATABASE_VERSION = 37;
+    public static final int DATABASE_VERSION = 39;
 
     // Any changes to the database format *must* include update-in-place code.
     // Original version: 2
@@ -165,7 +165,8 @@
             + MessageColumns.REPLY_TO_LIST + " text, "
             + MessageColumns.MEETING_INFO + " text, "
             + MessageColumns.SNIPPET + " text, "
-            + MessageColumns.PROTOCOL_SEARCH_INFO + " text"
+            + MessageColumns.PROTOCOL_SEARCH_INFO + " text, "
+            + MessageColumns.THREAD_TOPIC + " text"
             + ");";
 
         // This String and the following String MUST have the same columns, except for the type
@@ -903,6 +904,28 @@
                 }
                 oldVersion = 37;
             }
+            if (oldVersion == 37) {
+                try {
+                    db.execSQL("alter table " + Message.TABLE_NAME
+                            + " add column " + MessageColumns.THREAD_TOPIC + " text;");
+                } catch (SQLException e) {
+                    // Shouldn't be needed unless we're debugging and interrupt the process
+                    Log.w(TAG, "Exception upgrading EmailProvider.db from 37 to 38 " + e);
+                }
+                oldVersion = 38;
+            }
+            if (oldVersion == 38) {
+                try {
+                    db.execSQL("alter table " + Message.DELETED_TABLE_NAME
+                            + " add column " + MessageColumns.THREAD_TOPIC + " text;");
+                    db.execSQL("alter table " + Message.UPDATED_TABLE_NAME
+                            + " add column " + MessageColumns.THREAD_TOPIC + " text;");
+                } catch (SQLException e) {
+                    // Shouldn't be needed unless we're debugging and interrupt the process
+                    Log.w(TAG, "Exception upgrading EmailProvider.db from 38 to 39 " + e);
+                }
+                oldVersion = 39;
+            }
         }
 
         @Override