am 4a76cbeb: (-s ours) DO NOT MERGE - Updated TelephoneService launcher icons
diff --git a/res/drawable-hdpi/ic_launcher_phone.png b/res/drawable-hdpi/ic_launcher_phone.png
index 7739546..0943ce5 100755
--- a/res/drawable-hdpi/ic_launcher_phone.png
+++ b/res/drawable-hdpi/ic_launcher_phone.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_launcher_phone.png b/res/drawable-mdpi/ic_launcher_phone.png
index aa4f3c5..88336a3 100644
--- a/res/drawable-mdpi/ic_launcher_phone.png
+++ b/res/drawable-mdpi/ic_launcher_phone.png
Binary files differ
diff --git a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
index c26e855..ece8b0e 100644
--- a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
+++ b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
@@ -1196,10 +1196,9 @@
                 null);
         ArrayList<String> filesToDelete = new ArrayList<String>();
         try {
+            db.beginTransaction();
             if (textRows != null) {
-                int partIdColumn = textRows.getColumnIndex(Part._ID);
                 int partDataColumn = textRows.getColumnIndex(Part._DATA);
-                int partTextColumn = textRows.getColumnIndex(Part.TEXT);
 
                 // This code is imperfect in that we can't guarantee that all the
                 // backing files get deleted.  For example if the system aborts after
@@ -1213,8 +1212,8 @@
                             byte [] data = new byte[is.available()];
                             is.read(data);
                             EncodedStringValue v = new EncodedStringValue(data);
-                            textRows.updateString(partTextColumn, v.getString());
-                            textRows.updateToNull(partDataColumn);
+                            db.execSQL("UPDATE part SET " + Part._DATA + " = NULL, " +
+                                    Part.TEXT + " = ?", new String[] { v.getString() });
                             is.close();
                             filesToDelete.add(path);
                         } catch (IOException e) {
@@ -1224,8 +1223,9 @@
                     }
                 }
             }
+            db.setTransactionSuccessful();
         } finally {
-            textRows.commitUpdates();
+            db.endTransaction();
             for (String pathToDelete : filesToDelete) {
                 try {
                     (new File(pathToDelete)).delete();
diff --git a/src/com/android/providers/telephony/MmsSmsProvider.java b/src/com/android/providers/telephony/MmsSmsProvider.java
index 31f5062..07c22f1 100644
--- a/src/com/android/providers/telephony/MmsSmsProvider.java
+++ b/src/com/android/providers/telephony/MmsSmsProvider.java
@@ -94,6 +94,7 @@
     private static final int URI_SEARCH_SUGGEST                    = 15;
     private static final int URI_FIRST_LOCKED_MESSAGE_ALL          = 16;
     private static final int URI_FIRST_LOCKED_MESSAGE_BY_THREAD_ID = 17;
+    private static final int URI_MESSAGE_ID_TO_THREAD              = 18;
 
     /**
      * the name of the table that is used to store the queue of
@@ -237,6 +238,7 @@
 
         URI_MATCHER.addURI(AUTHORITY, "locked/#", URI_FIRST_LOCKED_MESSAGE_BY_THREAD_ID);
 
+        URI_MATCHER.addURI(AUTHORITY, "messageIdToThread", URI_MESSAGE_ID_TO_THREAD);
         initializeColumnSets();
     }
 
@@ -258,7 +260,6 @@
             String selection, String[] selectionArgs, String sortOrder) {
         SQLiteDatabase db = mOpenHelper.getReadableDatabase();
         Cursor cursor = null;
-
         switch(URI_MATCHER.match(uri)) {
             case URI_COMPLETE_CONVERSATIONS:
                 cursor = getCompleteConversations(
@@ -339,6 +340,34 @@
                 cursor = db.rawQuery(query, null);
                 break;
             }
+            case URI_MESSAGE_ID_TO_THREAD: {
+                // Given a message ID and an indicator for SMS vs. MMS return
+                // the thread id of the corresponding thread.
+                try {
+                    long id = Long.parseLong(uri.getQueryParameter("row_id"));
+                    switch (Integer.parseInt(uri.getQueryParameter("table_to_use"))) {
+                        case 1:  // sms
+                            cursor = db.query(
+                                "sms",
+                                new String[] { "thread_id" },
+                                "_id=?",
+                                new String[] { String.valueOf(id) },
+                                null,
+                                null,
+                                null);
+                            break;
+                        case 2:  // mms
+                            String mmsQuery =
+                                "SELECT thread_id FROM pdu,part WHERE ((part.mid=pdu._id) AND " +
+                                "(part._id=?))";
+                            cursor = db.rawQuery(mmsQuery, new String[] { String.valueOf(id) });
+                            break;
+                    }
+                } catch (NumberFormatException ex) {
+                    // ignore... return empty cursor
+                }
+                break;
+            }
             case URI_SEARCH: {
                 if (       sortOrder != null
                         || selection != null
@@ -351,7 +380,7 @@
 
                 // This code queries the sms and mms tables and returns a unified result set
                 // of text matches.  We query the sms table which is pretty simple.  We also
-                // query the pdu, part and addr table to get the mms result.  Note that we're
+                // query the pdu, part and addr table to get the mms result.  Notet we're
                 // using a UNION so we have to have the same number of result columns from
                 // both queries.
 
@@ -617,7 +646,7 @@
             db = mOpenHelper.getReadableDatabase();  // In case insertThread closed it
             cursor = db.rawQuery(THREAD_QUERY, selectionArgs);
         }
-        
+
         if (cursor.getCount() > 1) {
             Log.w(LOG_TAG, "getThreadId: why is cursorCount=" + cursor.getCount());
         }