diff options
author | Matthew Xie <mattx@google.com> | 2014-11-17 09:50:54 -0800 |
---|---|---|
committer | Brint E. Kriebel <bekit@cyngn.com> | 2015-03-18 21:39:44 +0000 |
commit | 842e3fe083c3e6a244c40697c87654abfec6b531 (patch) | |
tree | 0bc72c67f1146ad8f7ffda5b4e53a6180bdc4789 | |
parent | caf1ca1c169eecafc9ff51d490350a7dad96ec8b (diff) | |
download | android_packages_apps_Bluetooth-842e3fe083c3e6a244c40697c87654abfec6b531.tar.gz android_packages_apps_Bluetooth-842e3fe083c3e6a244c40697c87654abfec6b531.tar.bz2 android_packages_apps_Bluetooth-842e3fe083c3e6a244c40697c87654abfec6b531.zip |
Check previous user confirmation before auto-confirm put request
Also correct a confirm status change check in updateShare.
Bug: 17770561, 18343032
Change-Id: I8e7d10e73604c0bf1c88801a1caef7d579fbd1eb
(cherry picked from commit 0cb71bf79ed4b70bc6b254950a1683d72b7e1ed5)
3 files changed, 13 insertions, 15 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java index d4885dc5b..2d86c9606 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java +++ b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java @@ -416,7 +416,7 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen boolean needConfirm = true; /** It's not first put if !serverBlocking, so we auto accept it */ - if (!mServerBlocking) { + if (!mServerBlocking && mAccepted == BluetoothShare.USER_CONFIRMATION_CONFIRMED) { values.put(BluetoothShare.USER_CONFIRMATION, BluetoothShare.USER_CONFIRMATION_AUTO_CONFIRMED); needConfirm = false; diff --git a/src/com/android/bluetooth/opp/BluetoothOppService.java b/src/com/android/bluetooth/opp/BluetoothOppService.java index ab85f9739..7318c793b 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppService.java +++ b/src/com/android/bluetooth/opp/BluetoothOppService.java @@ -821,7 +821,7 @@ public class BluetoothOppService extends Service { info.mDestination = stringFromCursor(info.mDestination, cursor, BluetoothShare.DESTINATION); int newVisibility = cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.VISIBILITY)); - boolean confirmed = false; + boolean confirmUpdated = false; int newConfirm = cursor.getInt(cursor .getColumnIndexOrThrow(BluetoothShare.USER_CONFIRMATION)); @@ -834,10 +834,8 @@ public class BluetoothOppService extends Service { info.mVisibility = newVisibility; if (info.mConfirm == BluetoothShare.USER_CONFIRMATION_PENDING - && (newConfirm == BluetoothShare.USER_CONFIRMATION_CONFIRMED || - newConfirm == BluetoothShare.USER_CONFIRMATION_AUTO_CONFIRMED || - newConfirm == BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED)) { - confirmed = true; + && newConfirm != BluetoothShare.USER_CONFIRMATION_PENDING) { + confirmUpdated = true; } info.mConfirm = newConfirm; int newStatus = cursor.getInt(statusColumn); @@ -854,14 +852,14 @@ public class BluetoothOppService extends Service { info.mTimestamp = cursor.getLong(cursor.getColumnIndexOrThrow(BluetoothShare.TIMESTAMP)); info.mMediaScanned = (cursor.getInt(cursor.getColumnIndexOrThrow(Constants.MEDIA_SCANNED)) != Constants.MEDIA_SCANNED_NOT_SCANNED); - if (confirmed) { - if (V) Log.v(TAG, "Service handle info " + info.mId + " confirmed"); - /* Inbounds transfer get user confirmation, so we start it */ + if (confirmUpdated) { + if (V) Log.v(TAG, "Service handle info " + info.mId + " confirmation updated"); + /* Inbounds transfer user confirmation status changed, update the session server */ int i = findBatchWithTimeStamp(info.mTimestamp); if (i != -1) { BluetoothOppBatch batch = mBatchs.get(i); if (mServerTransfer != null && batch.mId == mServerTransfer.getBatchId()) { - mServerTransfer.setConfirmed(); + mServerTransfer.confirmStatusChanged(); } //TODO need to think about else } } @@ -1006,7 +1004,7 @@ public class BluetoothOppService extends Service { BluetoothOppShareInfo mPendingShare = nextBatch.getPendingShare(); if ((mPendingShare != null) && (mPendingShare.mConfirm == BluetoothShare.USER_CONFIRMATION_CONFIRMED)) { - mServerTransfer.setConfirmed(); + mServerTransfer.confirmStatusChanged(); } return; } diff --git a/src/com/android/bluetooth/opp/BluetoothOppTransfer.java b/src/com/android/bluetooth/opp/BluetoothOppTransfer.java index acdd188de..917bf53ee 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppTransfer.java +++ b/src/com/android/bluetooth/opp/BluetoothOppTransfer.java @@ -561,7 +561,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch if (V) Log.v(TAG, "processCurrentShare" + mCurrentShare.mId); mSession.addShare(mCurrentShare); if (mCurrentShare.mConfirm == BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED) { - setConfirmed(); + confirmStatusChanged(); } } @@ -569,7 +569,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch * Set transfer confirmed status. It should only be called for inbound * transfer */ - public void setConfirmed() { + public void confirmStatusChanged() { /* unblock server session */ final Thread notifyThread = new Thread("Server Unblock thread") { public void run() { @@ -579,7 +579,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch } } }; - if (V) Log.v(TAG, "setConfirmed to unblock mSession" + mSession.toString()); + if (V) Log.v(TAG, "confirmStatusChanged to unblock mSession" + mSession.toString()); notifyThread.start(); } @@ -843,7 +843,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch if (V) Log.v(TAG, "Transfer continue session for info " + mCurrentShare.mId + " from batch " + mBatch.mId); processCurrentShare(); - setConfirmed(); + confirmStatusChanged(); } } } |