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

Commit b1f8481a authored by Juffin Alex Varghese's avatar Juffin Alex Varghese Committed by Linux Build Service Account
Browse files

Bluetooth-OPP:ANR fix while sending 250 files

ANR is observed in OppLauncherActivity while sending 250 files
because OppLauncherActivity thread start DevicePickerActivity,
but in this case user clicked back key before PickerActivity starts
and then user tries to send 250 files again. At this point one of
the DevicePickerActivity got blocked.

CRs-Fixed: 710599
Change-Id: I3df3bc8559e91df6360fbc55d8e33d567184fe51
parent 38befc68
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -157,13 +157,15 @@ public class BluetoothOppLauncherActivity extends Activity {
                        public void run() {
                            BluetoothOppManager.getInstance(BluetoothOppLauncherActivity.this)
                                .saveSendingFileInfo(mimeType,uris, false);
                            //Done getting file info..Launch device picker
                            //and finish this activity
                            launchDevicePicker();
                            finish();
                            //Done getting file info
                        }
                    });
                    t.start();
                    //Launch device picker after thread is started to avoid delay
                    //caused by saving file information during multiple file share scenarios
                    //which may cause ANR.
                    launchDevicePicker();
                    finish();
                    return;
                } else {
                    Log.e(TAG, "type is null; or sending files URIs are null");
+18 −8
Original line number Diff line number Diff line
@@ -280,21 +280,31 @@ public class BluetoothOppManager {

    public void cleanUpSendingFileInfo() {
        synchronized (BluetoothOppManager.this) {
            Uri uri;
            if (V) Log.v(TAG, "cleanUpSendingFileInfo: mMultipleFlag = " +
                mMultipleFlag);
            if (!mMultipleFlag) {
                uri = Uri.parse(mUriOfSendingFile);
                final Uri uri = Uri.parse(mUriOfSendingFile);
                if (V) Log.v(TAG, "cleanUpSendingFileInfo: " +
                        "closeSendFileInfo for uri = " + uri);
                //Call closeSendFileInfo in a thread to avoid memory leak
                Thread t = new Thread(new Runnable() {
                    public void run () {
                        BluetoothOppUtility.closeSendFileInfo(uri);
                    }
                });
                t.start();
            } else {
                for (int i = 0, count = mUrisOfSendingFiles.size(); i < count; i++) {
                    uri = mUrisOfSendingFiles.get(i);
                for (final Uri uri : mUrisOfSendingFiles) {
                    if (V) Log.v(TAG, "cleanUpSendingFileInfo: " +
                            "closeSendFileInfo for uri = " + uri);
                    //Call closeSendFileInfo in a thread to avoid memory leak
                    Thread t = new Thread(new Runnable() {
                        public void run () {
                            BluetoothOppUtility.closeSendFileInfo(uri);
                        }
                    });
                    t.start();
                }
            }
        }
    }