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

Commit 72a68a4d authored by Ajay Panicker's avatar Ajay Panicker
Browse files

Move file lookup to its own thread for beaming

Bug: 28973021
Change-Id: I40f6d32ffadd58e60dbd1e44802a629b9fab64e4
parent 81ee1c72
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);