Hi all,

I had one test for bluetooth OPP:

1. pair phone A and phone B
2. select 10 files on phone A, and try to send them via bluetooth to phone 
B.
3. on phone B, refuse the file transfer request.

Then from the logcat of phone A, I found some files will be closed twice. 
The log is like this:
  10-16 10:01:17.181  1659  1885 D BluetoothOppUtility: getSendFileInfo: 
uri=content://media/external/images/media/67974
  10-16 10:01:17.181  1659  1885 D BluetoothOppUtility: closeSendFileInfo: 
uri=content://media/external/images/media/67974
Then this file is closed again:
  10-16 10:01:17.290  1659  1885 D BluetoothOppUtility: getSendFileInfo: 
uri=content://media/external/images/media/67974
  10-16 10:01:17.290  1659  1885 D BluetoothOppUtility: closeSendFileInfo: 
uri=content://media/external/images/media/67974

Then I checked the android 4.3 source code under 
packages/apps/Bluetooth/src/com/android/bluetooth/opp, and found the code's 
logic is not good.
The sequence causes some files be closed twice are:
1. remote side reject file transfer, so on phone A, the function "private 
int sendFile(BluetoothOppSendFileInfo fileInfo)" 
in BluetoothOppObexClientSession.java is executed.
2. the statement "Constants.updateShareStatus(mContext1, mInfo.mId, 
status);" in function sendFile() is called, it 
triggers BluetoothShareContentObserver in BluetoothOppService.java to use 
UpdateThread() to read data from database to update mShares.
3. UpdateThread query database only once, then use the query result to 
update mShares. It lasts a long time.
4. It calls function "private void markBatchFailed(int failReason)" 
in BluetoothOppTransfer.java to mark all files to STATUS_FORBIDDEN. It 
updates both database and mShares.
5. UpdateThread in step 3 is not finished, it uses old query result to 
update mShares.
6. So although one file in step 4 is marked as STATUS_FORBIDDEN, then in 
step 5, is is updated to STUATS_PENDING again. Then it will be closed again.

I think the code logic is not good, can anyone hep to optimize it?

-- 
-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting

--- 
You received this message because you are subscribed to the Google Groups 
"android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-porting+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to