am a595fcc5: Fix crash in Bluetooth when sharing MMS video.
* commit 'a595fcc57e7f0be9cf57913cd665dc99e4001b16':
Fix crash in Bluetooth when sharing MMS video.
diff --git a/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java b/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
index 81c3c92..c269ad7 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
@@ -36,6 +36,7 @@
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
+import android.database.sqlite.SQLiteException;
import android.net.Uri;
import android.provider.OpenableColumns;
import android.util.Log;
@@ -108,9 +109,15 @@
// bluetooth
if ("content".equals(scheme)) {
contentType = contentResolver.getType(uri);
- Cursor metadataCursor = contentResolver.query(uri, new String[] {
- OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE
- }, null, null, null);
+ Cursor metadataCursor;
+ try {
+ metadataCursor = contentResolver.query(uri, new String[] {
+ OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE
+ }, null, null, null);
+ } catch (SQLiteException e) {
+ // some content providers don't support the DISPLAY_NAME or SIZE columns
+ metadataCursor = null;
+ }
if (metadataCursor != null) {
try {
if (metadataCursor.moveToFirst()) {
@@ -122,6 +129,10 @@
metadataCursor.close();
}
}
+ if (fileName == null) {
+ // use last segment of URI if DISPLAY_NAME query fails
+ fileName = uri.getLastPathSegment();
+ }
} else if ("file".equals(scheme)) {
fileName = uri.getLastPathSegment();
contentType = type;