MmsProvider throws an exception on unknown column
If the vcard importer is handed a uri to an MMS part, it will crash.
The MmsProvider will throw an exception when it queries for a column
name not in the schema. With this change, the MmsProvider will simply
return a null cursor when queried for an unkonwn column.
Change-Id: I967f4a631d24eb5a43a70d563c2008f555d0aa3c
diff --git a/src/com/android/providers/telephony/MmsProvider.java b/src/com/android/providers/telephony/MmsProvider.java
index ac7c1f9..424ea0e 100644
--- a/src/com/android/providers/telephony/MmsProvider.java
+++ b/src/com/android/providers/telephony/MmsProvider.java
@@ -18,13 +18,13 @@
import android.app.AppOpsManager;
import android.content.ContentProvider;
-import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
@@ -205,9 +205,15 @@
finalSortOrder = sortOrder;
}
- SQLiteDatabase db = mOpenHelper.getReadableDatabase();
- Cursor ret = qb.query(db, projection, selection,
- selectionArgs, null, null, finalSortOrder);
+ Cursor ret;
+ try {
+ SQLiteDatabase db = mOpenHelper.getReadableDatabase();
+ ret = qb.query(db, projection, selection,
+ selectionArgs, null, null, finalSortOrder);
+ } catch (SQLiteException e) {
+ Log.e(TAG, "returning NULL cursor, query: " + uri, e);
+ return null;
+ }
// TODO: Does this need to be a URI for this provider.
ret.setNotificationUri(getContext().getContentResolver(), uri);