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

Commit e2c39a4c authored by Sravan voleti's avatar Sravan voleti Committed by sravan voleti
Browse files

OPP: Fix ANR during retry failed transfer

Use Case:
1. Open Video from G photos App
2. Select large (above 50 MB )  video and share via Bluetooth.
3. while transfer is in progress, stop sending the video.
4. The video will come under "outbound transfers" in the DUT .
5. Select the video again from the "outbound transfers" & tap on "try again" , Observe

Failure:
Observed ANR in OPP profile.

Root Cause:
BluetoothOppSendFileInfo::generateFileInfo() takes long time to process
when sharing file from G photos app.

Fix:
When tap the "try again" button on the send failed dialog, the
method "BluetoothOppSendFileInfo::generateFileInfo()" will be
call, this method would be very time consuming , thereby causing ANR.
Changed this method into the child thread execution to avoid ANR in BT context.

Fixes: 141833952
Test: Perfomed above use case issue not seen.
Change-Id: Ie50771d7b5cdd1e0dd47834996135f2ea8e03a5c
parent 16b4eea9
Loading
Loading
Loading
Loading
+20 −12
Original line number Diff line number Diff line
@@ -375,24 +375,13 @@ public class BluetoothOppTransferActivity extends AlertActivity
                            mTransInfo.mID);
                } else if (mWhichDialog == DIALOG_SEND_COMPLETE_FAIL) {
                    // "try again"

                    // make current transfer "hidden"
                    BluetoothOppUtility.updateVisibilityToHidden(this, mUri);

                    // clear correspondent notification item
                    ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)).cancel(
                            mTransInfo.mID);

                    // retry the failed transfer
                    Uri uri = BluetoothOppUtility.originalUri(Uri.parse(mTransInfo.mFileUri));
                    BluetoothOppSendFileInfo sendFileInfo =
                            BluetoothOppSendFileInfo.generateFileInfo(BluetoothOppTransferActivity
                            .this, uri, mTransInfo.mFileType, false);
                    uri = BluetoothOppUtility.generateUri(uri, sendFileInfo);
                    BluetoothOppUtility.putSendFileInfo(uri, sendFileInfo);
                    mTransInfo.mFileUri = uri.toString();
                    BluetoothOppUtility.retryTransfer(this, mTransInfo);

                    retryFailedTrasfer();
                    BluetoothDevice remoteDevice = mAdapter.getRemoteDevice(mTransInfo.mDestAddr);

                    // Display toast message
@@ -502,4 +491,23 @@ public class BluetoothOppTransferActivity extends AlertActivity
                    .setText(getString(R.string.upload_fail_cancel));
        }
    }

   /*
    * Retry the failed transfer in background thread
    */
   private void retryFailedTrasfer() {
        new Thread() {
            @Override
            public void run() {
                Uri uri = BluetoothOppUtility.originalUri(Uri.parse(mTransInfo.mFileUri));
                BluetoothOppSendFileInfo sendFileInfo =
                        BluetoothOppSendFileInfo.generateFileInfo(BluetoothOppTransferActivity
                        .this, uri, mTransInfo.mFileType, false);
                uri = BluetoothOppUtility.generateUri(uri, sendFileInfo);
                BluetoothOppUtility.putSendFileInfo(uri, sendFileInfo);
                mTransInfo.mFileUri = uri.toString();
                BluetoothOppUtility.retryTransfer(BluetoothOppTransferActivity.this, mTransInfo);
            }
        }.start();
    }
}