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

Commit 3f87ea22 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Move file lookup to its own thread for beaming"

parents cdff8a32 87dbfa5d
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -43,31 +43,31 @@ public class BluetoothOppHandoverReceiver extends BroadcastReceiver {
                if (D) Log.d(TAG, "No device attached to handover intent.");
                return;
            }

            String mimeType = intent.getType();
            ArrayList<Uri> uris = new ArrayList<Uri>();
            if (action.equals(Constants.ACTION_HANDOVER_SEND)) {
                String type = intent.getType();
                Uri stream = (Uri)intent.getParcelableExtra(Intent.EXTRA_STREAM);
                if (stream != null && type != null) {
                    // Save type/stream, will be used when adding transfer
                    // session to DB.
                    BluetoothOppManager.getInstance(context).saveSendingFileInfo(type,
                            stream.toString(), true);
                } else {
                    if (D) Log.d(TAG, "No mimeType or stream attached to handover request");
                }
                if (stream != null) uris.add(stream);
            } else if (action.equals(Constants.ACTION_HANDOVER_SEND_MULTIPLE)) {
                ArrayList<Uri> uris = new ArrayList<Uri>();
                String mimeType = intent.getType();
                uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
                if (mimeType != null && uris != null) {
                    BluetoothOppManager.getInstance(context).saveSendingFileInfo(mimeType,
                            uris, true);
            }

            if (mimeType != null && uris != null && !uris.isEmpty()) {
                final String finalType = mimeType;
                final ArrayList<Uri> finalUris = uris;
                Thread t = new Thread(new Runnable() {
                    public void run() {
                        BluetoothOppManager.getInstance(context).saveSendingFileInfo(finalType,
                            finalUris, true);
                        BluetoothOppManager.getInstance(context).startTransfer(device);
                    }
                });
                t.start();
            } else {
                if (D) Log.d(TAG, "No mimeType or stream attached to handover request");
                return;
            }
            }
            // we already know where to send to
            BluetoothOppManager.getInstance(context).startTransfer(device);
        } else if (action.equals(Constants.ACTION_WHITELIST_DEVICE)) {
            BluetoothDevice device =
                    (BluetoothDevice)intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);