OPP: Updated NFC failed status during the turn of BT
Use case:
1) NFC beam transfer files
2) Manually turn off Bluetooth to make transfer fail
Expected result:
BT on should successful after turn on Bluetooth.
Observed Result:
After turn on BT NFC initiated BT off event.
Root cause:
During Bluetooth off Event Handler not getting enough time
or priority to process all messages, with this reason current
batch transfer status not updated from PENDING to
CONNECTION_ERROR. So, in next BT on profile trying to
resend because of status PENDING in DB.
Fix:
Update NFC records status PENDING to CONNECTION_ERROR during BT off.
to avoid resend after next BT on to fix this abnormal behaviour.
CRs-Fixed: 2699183
Change-Id: Ib85d570c22cd97d9324044b20db69e3fd00b7e12
diff --git a/src/com/android/bluetooth/opp/BluetoothOppService.java b/src/com/android/bluetooth/opp/BluetoothOppService.java
old mode 100755
new mode 100644
index 4d529f7..ad23c5f
--- a/src/com/android/bluetooth/opp/BluetoothOppService.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppService.java
@@ -371,6 +371,7 @@
if (mNotifier != null) {
mNotifier.cancelNotifications();
}
+ updatePendingNfcState();
break;
case START_LISTENER:
if (mAdapter.isEnabled()) {
@@ -1240,4 +1241,25 @@
void acceptNewConnections() {
mAcceptNewConnections = true;
}
+
+ private void updatePendingNfcState() {
+ new Thread("updateState") {
+ @Override
+ public void run() {
+ String where_nfc_pending = BluetoothShare.STATUS
+ + "=" + BluetoothShare.STATUS_PENDING + " AND "
+ + BluetoothShare.USER_CONFIRMATION + "="
+ + BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED
+ +" AND ( " + BluetoothShare.DIRECTION
+ + "=" + BluetoothShare.DIRECTION_OUTBOUND + " OR "
+ + BluetoothShare.DIRECTION + "="
+ + BluetoothShare.DIRECTION_INBOUND + ")";
+ ContentValues cv = new ContentValues();
+ cv.put(BluetoothShare.STATUS, BluetoothShare.STATUS_CONNECTION_ERROR);
+ int updatedCount = getContentResolver().update(BluetoothShare.CONTENT_URI,
+ cv, where_nfc_pending, null);
+ if (V) Log.v(TAG, "updatePendingNfcState " + updatedCount);
+ }
+ }.start();
+ }
}