am 575b04b0: am fb73583e: am fe3315b5: Merge from gingerbread

* commit '575b04b0805398f1caf8edb536764eb75bc2a840':
diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml
new file mode 100644
index 0000000..f6c6f02
--- /dev/null
+++ b/res/values-af/strings.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--  Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- outdated translation 4846406803456361049 -->     <string name="app_label" product="tablet" msgid="9194799012395299737">"Bellerberging"</string>
+    <!-- outdated translation 4846406803456361049 -->     <string name="app_label" product="default" msgid="4282451239358791628">"Bellerberging"</string>
+</resources>
diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml
new file mode 100644
index 0000000..eca8109
--- /dev/null
+++ b/res/values-am/strings.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--  Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- outdated translation 4846406803456361049 -->     <string name="app_label" product="tablet" msgid="9194799012395299737">"የደዋይ ማከማቻ"</string>
+    <!-- outdated translation 4846406803456361049 -->     <string name="app_label" product="default" msgid="4282451239358791628">"የደዋይ ማከማቻ"</string>
+</resources>
diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml
new file mode 100644
index 0000000..0cee647
--- /dev/null
+++ b/res/values-ms/strings.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--  Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- outdated translation 4846406803456361049 -->     <string name="app_label" product="tablet" msgid="9194799012395299737">"Storan Pendail"</string>
+    <!-- outdated translation 4846406803456361049 -->     <string name="app_label" product="default" msgid="4282451239358791628">"Storan Pendail"</string>
+</resources>
diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml
new file mode 100644
index 0000000..dd1b430
--- /dev/null
+++ b/res/values-sw/strings.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--  Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- outdated translation 4846406803456361049 -->     <string name="app_label" product="tablet" msgid="9194799012395299737">"Hifadhi ya Kipigaji"</string>
+    <!-- outdated translation 4846406803456361049 -->     <string name="app_label" product="default" msgid="4282451239358791628">"Hifadhi ya Kipigaji"</string>
+</resources>
diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml
new file mode 100644
index 0000000..e2d5490
--- /dev/null
+++ b/res/values-zu/strings.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--  Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- outdated translation 4846406803456361049 -->     <string name="app_label" product="tablet" msgid="9194799012395299737">"Ukugcina Isidayeli"</string>
+    <!-- outdated translation 4846406803456361049 -->     <string name="app_label" product="default" msgid="4282451239358791628">"Ukugcina Isidayeli"</string>
+</resources>
diff --git a/src/com/android/providers/telephony/MmsProvider.java b/src/com/android/providers/telephony/MmsProvider.java
index a4e6919..5df3fdf 100644
--- a/src/com/android/providers/telephony/MmsProvider.java
+++ b/src/com/android/providers/telephony/MmsProvider.java
@@ -36,7 +36,6 @@
 import android.provider.Telephony.Mms.Part;
 import android.provider.Telephony.Mms.Rate;
 import android.text.TextUtils;
-import android.util.Config;
 import android.util.Log;
 
 import com.google.android.mms.pdu.PduHeaders;
@@ -823,7 +822,7 @@
     private final static String VND_ANDROID_MMS = "vnd.android/mms";
     private final static String VND_ANDROID_DIR_MMS = "vnd.android-dir/mms";
     private final static boolean DEBUG = false;
-    private final static boolean LOCAL_LOGV = DEBUG ? Config.LOGD : Config.LOGV;
+    private final static boolean LOCAL_LOGV = false;
 
     private static final int MMS_ALL                      = 0;
     private static final int MMS_ALL_ID                   = 1;
diff --git a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
index ece8b0e..619ba83 100644
--- a/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
+++ b/src/com/android/providers/telephony/MmsSmsDatabaseHelper.java
@@ -22,8 +22,11 @@
 import java.io.File;
 import java.util.ArrayList;
 
+import android.content.BroadcastReceiver;
 import android.content.ContentValues;
 import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteOpenHelper;
@@ -205,13 +208,20 @@
                         "     AND part.mid = pdu._id);" +
                         " END";
 
-    private static MmsSmsDatabaseHelper mInstance = null;
+    private static MmsSmsDatabaseHelper sInstance = null;
+    private static boolean sTriedAutoIncrement = false;
+    private static boolean sFakeLowStorageTest = false;     // for testing only
 
     static final String DATABASE_NAME = "mmssms.db";
-    static final int DATABASE_VERSION = 53;
+    static final int DATABASE_VERSION = 54;
+    private final Context mContext;
+    private LowStorageMonitor mLowStorageMonitor;
+
 
     private MmsSmsDatabaseHelper(Context context) {
         super(context, DATABASE_NAME, null, DATABASE_VERSION);
+
+        mContext = context;
     }
 
     /**
@@ -219,10 +229,10 @@
      * database.
      */
     /* package */ static synchronized MmsSmsDatabaseHelper getInstance(Context context) {
-        if (mInstance == null) {
-            mInstance = new MmsSmsDatabaseHelper(context);
+        if (sInstance == null) {
+            sInstance = new MmsSmsDatabaseHelper(context);
         }
-        return mInstance;
+        return sInstance;
     }
 
     public static void updateThread(SQLiteDatabase db, long thread_id) {
@@ -491,6 +501,7 @@
                    Mms._ID + " INTEGER PRIMARY KEY," +
                    Mms.THREAD_ID + " INTEGER," +
                    Mms.DATE + " INTEGER," +
+                   Mms.DATE_SENT + " INTEGER DEFAULT 0," +
                    Mms.MESSAGE_BOX + " INTEGER," +
                    Mms.READ + " INTEGER DEFAULT 0," +
                    Mms.MESSAGE_ID + " TEXT," +
@@ -598,6 +609,7 @@
                    "address TEXT," +
                    "person INTEGER," +
                    "date INTEGER," +
+                   "date_sent INTEGER DEFAULT 0," +
                    "protocol INTEGER," +
                    "read INTEGER DEFAULT 0," +
                    "status INTEGER DEFAULT -1," + // a TP-Status value
@@ -668,7 +680,7 @@
          * and the same set of recipients.
          */
         db.execSQL("CREATE TABLE threads (" +
-                   Threads._ID + " INTEGER PRIMARY KEY," +
+                   Threads._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
                    Threads.DATE + " INTEGER DEFAULT 0," +
                    Threads.MESSAGE_COUNT + " INTEGER DEFAULT 0," +
                    Threads.RECIPIENT_IDS + " TEXT," +
@@ -1095,6 +1107,22 @@
             } finally {
                 db.endTransaction();
             }
+            // fall through
+        case 53:
+            if (currentVersion <= 53) {
+                return;
+            }
+
+            db.beginTransaction();
+            try {
+                upgradeDatabaseToVersion54(db);
+                db.setTransactionSuccessful();
+            } catch (Throwable ex) {
+                Log.e(TAG, ex.getMessage(), ex);
+                break;
+            } finally {
+                db.endTransaction();
+            }
             return;
         }
 
@@ -1168,19 +1196,6 @@
         db.execSQL("ALTER TABLE pdu ADD COLUMN " + Mms.LOCKED + " INTEGER DEFAULT 0");
     }
 
-    private void upgradeDatabaseToVersion53(SQLiteDatabase db) {
-        db.execSQL("DROP TRIGGER IF EXISTS pdu_update_thread_read_on_update");
-
-        // Updates threads table whenever a message in pdu is updated.
-        db.execSQL("CREATE TRIGGER pdu_update_thread_read_on_update AFTER" +
-                   "  UPDATE OF " + Mms.READ +
-                   "  ON " + MmsProvider.TABLE_PDU + " " +
-                   PDU_UPDATE_THREAD_CONSTRAINTS +
-                   "BEGIN " +
-                   PDU_UPDATE_THREAD_READ_BODY +
-                   "END;");
-    }
-
     private void upgradeDatabaseToVersion46(SQLiteDatabase db) {
         // add the "text" column for caching inline text (e.g. strings) instead of
         // putting them in an external file
@@ -1271,6 +1286,142 @@
         }
     }
 
+    private void upgradeDatabaseToVersion53(SQLiteDatabase db) {
+        db.execSQL("DROP TRIGGER IF EXISTS pdu_update_thread_read_on_update");
+
+        // Updates threads table whenever a message in pdu is updated.
+        db.execSQL("CREATE TRIGGER pdu_update_thread_read_on_update AFTER" +
+                   "  UPDATE OF " + Mms.READ +
+                   "  ON " + MmsProvider.TABLE_PDU + " " +
+                   PDU_UPDATE_THREAD_CONSTRAINTS +
+                   "BEGIN " +
+                   PDU_UPDATE_THREAD_READ_BODY +
+                   "END;");
+    }
+
+    private void upgradeDatabaseToVersion54(SQLiteDatabase db) {
+        // Add 'date_sent' column to sms table.
+        db.execSQL("ALTER TABLE sms ADD COLUMN " + Sms.DATE_SENT + " INTEGER DEFAULT 0");
+
+        // Add 'date_sent' column to pdu table.
+        db.execSQL("ALTER TABLE pdu ADD COLUMN " + Mms.DATE_SENT + " INTEGER DEFAULT 0");
+    }
+
+    @Override
+    public synchronized SQLiteDatabase getWritableDatabase() {
+        SQLiteDatabase db = super.getWritableDatabase();
+
+        if (!sTriedAutoIncrement) {
+            sTriedAutoIncrement = true;
+            boolean hasAutoIncrement = hasAutoIncrement(db);
+            Log.d(TAG, "[getWritableDatabase] hasAutoIncrement: " + hasAutoIncrement);
+            if (!hasAutoIncrement) {
+                db.beginTransaction();
+                try {
+                    if (false && sFakeLowStorageTest) {
+                        Log.d(TAG, "[getWritableDatabase] mFakeLowStorageTest is true " +
+                                " - fake exception");
+                        throw new Exception("FakeLowStorageTest");
+                    }
+                    upgradeThreadsTableToAutoIncrement(db);
+                    db.setTransactionSuccessful();
+
+                    if (mLowStorageMonitor != null) {
+                        // We've already updated the database. This receiver is no longer necessary.
+                        Log.d(TAG, "Unregistering mLowStorageMonitor - we've upgraded");
+                        mContext.unregisterReceiver(mLowStorageMonitor);
+                        mLowStorageMonitor = null;
+                    }
+                } catch (Throwable ex) {
+                    Log.e(TAG, "Failed to add autoIncrement: " + ex.getMessage(), ex);
+
+                    if (sFakeLowStorageTest) {
+                        sFakeLowStorageTest = false;
+                    }
+
+                    // We failed, perhaps because of low storage. Turn on a receiver to watch for
+                    // storage space.
+                    if (mLowStorageMonitor == null) {
+                        Log.d(TAG, "[getWritableDatabase] turning on storage monitor");
+                        mLowStorageMonitor = new LowStorageMonitor();
+                        IntentFilter intentFilter = new IntentFilter();
+                        intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);
+                        intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK);
+                        mContext.registerReceiver(mLowStorageMonitor, intentFilter);
+                    }
+                } finally {
+                    db.endTransaction();
+                }
+            }
+        }
+        return db;
+    }
+
+    private boolean hasAutoIncrement(SQLiteDatabase db) {
+        boolean result = false;
+        String query = "SELECT sql FROM sqlite_master WHERE type='table' AND name='threads'";
+        Cursor c = db.rawQuery(query, null);
+        if (c != null) {
+            try {
+                if (c.moveToFirst()) {
+                    String schema = c.getString(0);
+                    result = schema != null ? schema.contains("AUTOINCREMENT") : false;
+                    Log.d(TAG, "[MmsSmsDb] hasAutoIncrement: " + schema + " result: " + result);
+                }
+            } finally {
+                c.close();
+            }
+        }
+        return result;
+    }
+
+    // upgradeThreadsTableToAutoIncrement() is called to add the AUTOINCREMENT keyword to
+    // the threads table. This could fail if the user has a lot of conversations and not enough
+    // storage to make a copy of the threads table. That's ok. This upgrade is optional. It'll
+    // be called again next time the device is rebooted.
+    private void upgradeThreadsTableToAutoIncrement(SQLiteDatabase db) {
+        if (hasAutoIncrement(db)) {
+            Log.d(TAG, "[MmsSmsDb] upgradeThreadsTableToAutoIncrement: already upgraded");
+            return;
+        }
+        Log.d(TAG, "[MmsSmsDb] upgradeThreadsTableToAutoIncrement: upgrading");
+
+        // Make the _id of the threads table autoincrement so we never re-use thread ids
+        // Have to create a new temp threads table. Copy all the info from the old table.
+        // Drop the old table and rename the new table to that of the old.
+        db.execSQL("CREATE TABLE threads_temp (" +
+                Threads._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
+                Threads.DATE + " INTEGER DEFAULT 0," +
+                Threads.MESSAGE_COUNT + " INTEGER DEFAULT 0," +
+                Threads.RECIPIENT_IDS + " TEXT," +
+                Threads.SNIPPET + " TEXT," +
+                Threads.SNIPPET_CHARSET + " INTEGER DEFAULT 0," +
+                Threads.READ + " INTEGER DEFAULT 1," +
+                Threads.TYPE + " INTEGER DEFAULT 0," +
+                Threads.ERROR + " INTEGER DEFAULT 0," +
+                Threads.HAS_ATTACHMENT + " INTEGER DEFAULT 0);");
+
+        db.execSQL("INSERT INTO threads_temp SELECT * from threads;");
+        db.execSQL("DROP TABLE threads;");
+        db.execSQL("ALTER TABLE threads_temp RENAME TO threads;");
+    }
+
+    private class LowStorageMonitor extends BroadcastReceiver {
+
+        public LowStorageMonitor() {
+        }
+
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+
+            Log.d(TAG, "[LowStorageMonitor] onReceive intent " + action);
+
+            if (Intent.ACTION_DEVICE_STORAGE_OK.equals(action)) {
+                sTriedAutoIncrement = false;    // try to upgrade on the next getWriteableDatabase
+            }
+        }
+    }
+
     private void updateThreadsAttachmentColumn(SQLiteDatabase db) {
         // Set the values of that column correctly based on the current
         // contents of the database.
diff --git a/src/com/android/providers/telephony/MmsSmsProvider.java b/src/com/android/providers/telephony/MmsSmsProvider.java
index bc4bc18..f2c7e9c 100644
--- a/src/com/android/providers/telephony/MmsSmsProvider.java
+++ b/src/com/android/providers/telephony/MmsSmsProvider.java
@@ -16,13 +16,11 @@
 
 package com.android.providers.telephony;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import android.app.SearchManager;
 import android.content.ContentProvider;
 import android.content.ContentValues;
 import android.content.Context;
@@ -113,7 +111,7 @@
     // These are the columns that appear in both the MMS ("pdu") and
     // SMS ("sms") message tables.
     private static final String[] MMS_SMS_COLUMNS =
-            { BaseColumns._ID, Mms.DATE, Mms.READ, Mms.THREAD_ID, Mms.LOCKED };
+            { BaseColumns._ID, Mms.DATE, Mms.DATE_SENT, Mms.READ, Mms.THREAD_ID, Mms.LOCKED };
 
     // These are the columns that appear only in the MMS message
     // table.
@@ -178,14 +176,14 @@
 
     // Search on the words table but return the rows from the corresponding sms table
     private static final String SMS_QUERY =
-            "SELECT sms._id AS _id,thread_id,address,body,date,index_text,words._id " +
+            "SELECT sms._id AS _id,thread_id,address,body,date,date_sent,index_text,words._id " +
             "FROM sms,words WHERE (words MATCH ? " +
             "AND sms._id=words.source_id AND words.table_to_use=1)";
 
     // Search on the words table but return the rows from the corresponding parts table
     private static final String MMS_QUERY =
             "SELECT pdu._id,thread_id,addr.address,part.text " +
-            "AS body,pdu.date,index_text,words._id " +
+            "AS body,pdu.date,pdu.date_sent,index_text,words._id " +
             "FROM pdu,part,addr,words WHERE ((part.mid=pdu._id) AND " +
             "(addr.msg_id=pdu._id) AND " +
             "(addr.type=" + PduHeaders.TO + ") AND " +
@@ -289,8 +287,7 @@
         Cursor cursor = null;
         switch(URI_MATCHER.match(uri)) {
             case URI_COMPLETE_CONVERSATIONS:
-                cursor = getCompleteConversations(
-                        projection, selection, selectionArgs, sortOrder);
+                cursor = getCompleteConversations(projection, selection, sortOrder);
                 break;
             case URI_CONVERSATIONS:
                 String simple = uri.getQueryParameter("simple");
@@ -304,13 +301,12 @@
                             projection, selection, selectionArgs, sortOrder);
                 } else {
                     cursor = getConversations(
-                            projection, selection, selectionArgs, sortOrder);
+                            projection, selection, sortOrder);
                 }
                 break;
             case URI_CONVERSATIONS_MESSAGES:
-                cursor = getConversationMessages(
-                        uri.getPathSegments().get(1), projection, selection,
-                        selectionArgs, sortOrder);
+                cursor = getConversationMessages(uri.getPathSegments().get(1), projection,
+                        selection, sortOrder);
                 break;
             case URI_CONVERSATIONS_RECIPIENTS:
                 cursor = getConversationById(
@@ -324,8 +320,7 @@
                 break;
             case URI_MESSAGES_BY_PHONE:
                 cursor = getMessagesByPhoneNumber(
-                        uri.getPathSegments().get(2), projection, selection,
-                        selectionArgs, sortOrder);
+                        uri.getPathSegments().get(2), projection, selection, sortOrder);
                 break;
             case URI_THREAD_ID:
                 List<String> recipients = uri.getQueryParameters("recipient");
@@ -440,7 +435,7 @@
                 break;
             }
             case URI_DRAFT: {
-                cursor = getDraftThread(projection, selection, selectionArgs, sortOrder);
+                cursor = getDraftThread(projection, selection, sortOrder);
                 break;
             }
             case URI_FIRST_LOCKED_MESSAGE_BY_THREAD_ID: {
@@ -452,12 +447,11 @@
                     break;
                 }
                 cursor = getFirstLockedMessage(projection, "thread_id=" + Long.toString(threadId),
-                        null, sortOrder);
+                        sortOrder);
                 break;
             }
             case URI_FIRST_LOCKED_MESSAGE_ALL: {
-                cursor = getFirstLockedMessage(projection, selection,
-                        selectionArgs, sortOrder);
+                cursor = getFirstLockedMessage(projection, selection, sortOrder);
                 break;
             }
             default:
@@ -714,7 +708,7 @@
      *   ;
      */
     private Cursor getDraftThread(String[] projection, String selection,
-            String[] selectionArgs, String sortOrder) {
+            String sortOrder) {
         String[] innerProjection = new String[] {BaseColumns._ID, Conversations.THREAD_ID};
         SQLiteQueryBuilder mmsQueryBuilder = new SQLiteQueryBuilder();
         SQLiteQueryBuilder smsQueryBuilder = new SQLiteQueryBuilder();
@@ -726,12 +720,12 @@
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, innerProjection,
                 MMS_COLUMNS, 1, "mms",
                 concatSelections(selection, Mms.MESSAGE_BOX + "=" + Mms.MESSAGE_BOX_DRAFTS),
-                selectionArgs, null, null);
+                null, null);
         String smsSubQuery = smsQueryBuilder.buildUnionSubQuery(
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, innerProjection,
                 SMS_COLUMNS, 1, "sms",
                 concatSelections(selection, Sms.TYPE + "=" + Sms.MESSAGE_TYPE_DRAFT),
-                selectionArgs, null, null);
+                null, null);
         SQLiteQueryBuilder unionQueryBuilder = new SQLiteQueryBuilder();
 
         unionQueryBuilder.setDistinct(true);
@@ -744,7 +738,7 @@
         outerQueryBuilder.setTables("(" + unionQuery + ")");
 
         String outerQuery = outerQueryBuilder.buildQuery(
-                projection, null, null, null, null, sortOrder, null);
+                projection, null, null, null, sortOrder, null);
 
         return mOpenHelper.getReadableDatabase().rawQuery(outerQuery, EMPTY_STRING_ARRAY);
     }
@@ -774,7 +768,7 @@
      * messages.
      */
     private Cursor getConversations(String[] projection, String selection,
-            String[] selectionArgs, String sortOrder) {
+            String sortOrder) {
         SQLiteQueryBuilder mmsQueryBuilder = new SQLiteQueryBuilder();
         SQLiteQueryBuilder smsQueryBuilder = new SQLiteQueryBuilder();
 
@@ -789,12 +783,12 @@
         String mmsSubQuery = mmsQueryBuilder.buildUnionSubQuery(
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, innerMmsProjection,
                 MMS_COLUMNS, 1, "mms",
-                concatSelections(selection, MMS_CONVERSATION_CONSTRAINT), selectionArgs,
+                concatSelections(selection, MMS_CONVERSATION_CONSTRAINT),
                 "thread_id", "date = MAX(date)");
         String smsSubQuery = smsQueryBuilder.buildUnionSubQuery(
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, innerSmsProjection,
                 SMS_COLUMNS, 1, "sms",
-                concatSelections(selection, SMS_CONVERSATION_CONSTRAINT), selectionArgs,
+                concatSelections(selection, SMS_CONVERSATION_CONSTRAINT),
                 "thread_id", "date = MAX(date)");
         SQLiteQueryBuilder unionQueryBuilder = new SQLiteQueryBuilder();
 
@@ -808,7 +802,7 @@
         outerQueryBuilder.setTables("(" + unionQuery + ")");
 
         String outerQuery = outerQueryBuilder.buildQuery(
-                columns, null, null, "tid",
+                columns, null, "tid",
                 "normalized_date = MAX(normalized_date)", sortOrder, null);
 
         return mOpenHelper.getReadableDatabase().rawQuery(outerQuery, EMPTY_STRING_ARRAY);
@@ -827,7 +821,7 @@
      * there is *any* locked message, not the actual messages themselves.
      */
     private Cursor getFirstLockedMessage(String[] projection, String selection,
-            String[] selectionArgs, String sortOrder) {
+            String sortOrder) {
         SQLiteQueryBuilder mmsQueryBuilder = new SQLiteQueryBuilder();
         SQLiteQueryBuilder smsQueryBuilder = new SQLiteQueryBuilder();
 
@@ -836,16 +830,17 @@
 
         String[] idColumn = new String[] { BaseColumns._ID };
 
+        // NOTE: buildUnionSubQuery *ignores* selectionArgs
         String mmsSubQuery = mmsQueryBuilder.buildUnionSubQuery(
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, idColumn,
                 null, 1, "mms",
-                selection, selectionArgs,
+                selection,
                 BaseColumns._ID, "locked=1");
 
         String smsSubQuery = smsQueryBuilder.buildUnionSubQuery(
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, idColumn,
                 null, 1, "sms",
-                selection, selectionArgs,
+                selection,
                 BaseColumns._ID, "locked=1");
 
         SQLiteQueryBuilder unionQueryBuilder = new SQLiteQueryBuilder();
@@ -869,9 +864,8 @@
      * and SMS.
      */
     private Cursor getCompleteConversations(String[] projection,
-            String selection, String[] selectionArgs, String sortOrder) {
-        String unionQuery = buildConversationQuery(
-                projection, selection, selectionArgs, sortOrder);
+            String selection, String sortOrder) {
+        String unionQuery = buildConversationQuery(projection, selection, sortOrder);
 
         return mOpenHelper.getReadableDatabase().rawQuery(unionQuery, EMPTY_STRING_ARRAY);
     }
@@ -900,7 +894,7 @@
      */
     private Cursor getConversationMessages(
             String threadIdString, String[] projection, String selection,
-            String[] selectionArgs, String sortOrder) {
+            String sortOrder) {
         try {
             Long.parseLong(threadIdString);
         } catch (NumberFormatException exception) {
@@ -910,8 +904,7 @@
 
         String finalSelection = concatSelections(
                 selection, "thread_id = " + threadIdString);
-        String unionQuery = buildConversationQuery(
-                projection, finalSelection, selectionArgs, sortOrder);
+        String unionQuery = buildConversationQuery(projection, finalSelection, sortOrder);
 
         return mOpenHelper.getReadableDatabase().rawQuery(unionQuery, EMPTY_STRING_ARRAY);
     }
@@ -936,7 +929,7 @@
      */
     private Cursor getMessagesByPhoneNumber(
             String phoneNumber, String[] projection, String selection,
-            String[] selectionArgs, String sortOrder) {
+            String sortOrder) {
         String escapedPhoneNumber = DatabaseUtils.sqlEscapeString(phoneNumber);
         String finalMmsSelection =
                 concatSelections(
@@ -966,10 +959,10 @@
         String[] columns = handleNullMessageProjection(projection);
         String mmsSubQuery = mmsQueryBuilder.buildUnionSubQuery(
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, columns, MMS_COLUMNS,
-                0, "mms", finalMmsSelection, selectionArgs, null, null);
+                0, "mms", finalMmsSelection, null, null);
         String smsSubQuery = smsQueryBuilder.buildUnionSubQuery(
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, columns, SMS_COLUMNS,
-                0, "sms", finalSmsSelection, selectionArgs, null, null);
+                0, "sms", finalSmsSelection, null, null);
         SQLiteQueryBuilder unionQueryBuilder = new SQLiteQueryBuilder();
 
         unionQueryBuilder.setDistinct(true);
@@ -1052,11 +1045,11 @@
         columnsPresentInTable.add(PendingMessages.ERROR_TYPE);
         String mmsSubQuery = mmsQueryBuilder.buildUnionSubQuery(
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, innerMmsProjection,
-                columnsPresentInTable, 1, "mms", finalMmsSelection, selectionArgs,
+                columnsPresentInTable, 1, "mms", finalMmsSelection,
                 null, null);
         String smsSubQuery = smsQueryBuilder.buildUnionSubQuery(
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, innerSmsProjection,
-                SMS_COLUMNS, 1, "sms", finalSmsSelection, selectionArgs,
+                SMS_COLUMNS, 1, "sms", finalSmsSelection,
                 null, null);
         SQLiteQueryBuilder unionQueryBuilder = new SQLiteQueryBuilder();
 
@@ -1070,7 +1063,7 @@
         outerQueryBuilder.setTables("(" + unionQuery + ")");
 
         String outerQuery = outerQueryBuilder.buildQuery(
-                smsColumns, null, null, null, null, sortOrder, null);
+                smsColumns, null, null, null, sortOrder, null);
 
         return mOpenHelper.getReadableDatabase().rawQuery(outerQuery, EMPTY_STRING_ARRAY);
     }
@@ -1090,7 +1083,7 @@
     }
 
     private static String buildConversationQuery(String[] projection,
-            String selection, String[] selectionArgs, String sortOrder) {
+            String selection, String sortOrder) {
         String[] mmsProjection = createMmsProjection(projection);
 
         SQLiteQueryBuilder mmsQueryBuilder = new SQLiteQueryBuilder();
@@ -1116,11 +1109,11 @@
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, innerMmsProjection,
                 columnsPresentInTable, 0, "mms",
                 concatSelections(mmsSelection, MMS_CONVERSATION_CONSTRAINT),
-                selectionArgs, null, null);
+                null, null);
         String smsSubQuery = smsQueryBuilder.buildUnionSubQuery(
                 MmsSms.TYPE_DISCRIMINATOR_COLUMN, innerSmsProjection, SMS_COLUMNS,
                 0, "sms", concatSelections(selection, SMS_CONVERSATION_CONSTRAINT),
-                selectionArgs, null, null);
+                null, null);
         SQLiteQueryBuilder unionQueryBuilder = new SQLiteQueryBuilder();
 
         unionQueryBuilder.setDistinct(true);
@@ -1134,7 +1127,7 @@
         outerQueryBuilder.setTables("(" + unionQuery + ")");
 
         return outerQueryBuilder.buildQuery(
-                smsColumns, null, null, null, null, sortOrder, null);
+                smsColumns, null, null, null, sortOrder, null);
     }
 
     @Override
diff --git a/src/com/android/providers/telephony/SmsProvider.java b/src/com/android/providers/telephony/SmsProvider.java
index 57ac256..89300b6 100644
--- a/src/com/android/providers/telephony/SmsProvider.java
+++ b/src/com/android/providers/telephony/SmsProvider.java
@@ -37,7 +37,6 @@
 import android.telephony.SmsManager;
 import android.telephony.SmsMessage;
 import android.text.TextUtils;
-import android.util.Config;
 import android.util.Log;
 
 import com.android.common.ArrayListCursor;
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 35c884d..5f136e9 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -33,7 +33,6 @@
 import android.os.Environment;
 import android.os.FileUtils;
 import android.provider.Telephony;
-import android.util.Config;
 import android.util.Log;
 import android.util.Xml;
 
@@ -522,7 +521,7 @@
                     notify = true;
                 }
 
-                if (Config.LOGD) Log.d(TAG, "inserted " + values.toString() + " rowID = " + rowID);
+                if (false) Log.d(TAG, "inserted " + values.toString() + " rowID = " + rowID);
                 break;
             }
 
@@ -537,7 +536,7 @@
 
                 if (updated > 0)
                 {
-                    if (Config.LOGD) {
+                    if (false) {
                         Log.d(TAG, "Setting numeric '" + numeric + "' to be the current operator");
                     }
                 }