Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 826d86c3 authored by Hemant Gupta's avatar Hemant Gupta
Browse files

OPP: Handle abnormal behaviour while sharing file from Snapchat

Use case:
1. Take a pic in Snapchat
2. share this picture via BT

Expected Result:
Photo can be shared successfully via BT to remote device

Root Cause:
Android Content Resolver not able to find name column from
received URI of external app.

Fix:
Add extra check while fetching name value from provider,
to prevent cursor exception and make file transfer successful.

Test: No crash observed while sharing file from Snapchat

Fixes: 77167222
Change-Id: I26c6543a4276fd18496ec5479a99eda52dd403b5
parent 4cb75999
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -127,10 +127,14 @@ public class BluetoothOppSendFileInfo {
            if (metadataCursor != null) {
                try {
                    if (metadataCursor.moveToFirst()) {
                        fileName = metadataCursor.getString(
                                metadataCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
                        length = metadataCursor.getLong(
                                metadataCursor.getColumnIndex(OpenableColumns.SIZE));
                        int indexName = metadataCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
                        int indexSize = metadataCursor.getColumnIndex(OpenableColumns.SIZE);
                        if (indexName != -1) {
                            fileName = metadataCursor.getString(indexName);
                        }
                        if (indexSize != -1) {
                            length = metadataCursor.getLong(indexSize);
                        }
                        if (D) {
                            Log.d(TAG, "fileName = " + fileName + " length = " + length);
                        }
@@ -142,6 +146,7 @@ public class BluetoothOppSendFileInfo {
            if (fileName == null) {
                // use last segment of URI if DISPLAY_NAME query fails
                fileName = uri.getLastPathSegment();
                if (D) Log.d(TAG, "fileName from URI :" + fileName);
            }
        } else if ("file".equals(scheme)) {
            if (uri.getPath() == null) {