OPP: Fix ANR during retry failed transfer

Use Case:

1. Send a video from another device to DUT.
2. while sending , stop sending the video .
3. The video will come under "outbound transfers" in the DUT .
4. 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.

CRs-Fixed: 2531986
Change-Id: Ie50771d7b5cdd1e0dd47834996135f2ea8e03a5c
diff --git a/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java b/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java
index 74fd872..7d0cfcc 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java
@@ -372,24 +372,13 @@
                             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
@@ -499,4 +488,22 @@
                     .setText(getString(R.string.upload_fail_cancel));
         }
     }
+
+ // Retry the failed transfer in background thread
+   private void retryFailedTrasfer() {
+        new Thread() {
+            @Override
+            public void run() {
+                super.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();
+    }
 }