From 1f0fc26568c1babf0c66d2c75812b72e894eb0de Mon Sep 17 00:00:00 2001 From: Lixin Yue Date: Wed, 16 Dec 2009 16:07:53 +0800 Subject: [PATCH] Fix non-existing received file still appearing in live folder issue After receiving a file by OPP from Bluetooth remote device, user can delete this file from Gallery or 3rd party application. In Opp live folder, user could still open this file, but with dialog "file not exist" displayed, and there is no way to make this file disappear from liver folder. Current solution is to delete the BT OPP DB record after openning an invalid uri associated with the file in folder, as an easy method without syncing. --- src/com/android/bluetooth/opp/BluetoothOppReceiver.java | 2 +- src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java | 2 +- src/com/android/bluetooth/opp/BluetoothOppUtility.java | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/android/bluetooth/opp/BluetoothOppReceiver.java b/src/com/android/bluetooth/opp/BluetoothOppReceiver.java index 516947f0..7ce5cbc8 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppReceiver.java +++ b/src/com/android/bluetooth/opp/BluetoothOppReceiver.java @@ -153,7 +153,7 @@ public class BluetoothOppReceiver extends BroadcastReceiver { && BluetoothShare.isStatusSuccess(transInfo.mStatus)) { // if received file successfully, open this file BluetoothOppUtility.openReceivedFile(context, transInfo.mFileName, - transInfo.mFileType, transInfo.mTimeStamp); + transInfo.mFileType, transInfo.mTimeStamp, uri); BluetoothOppUtility.updateVisibilityToHidden(context, uri); } else { Intent in = new Intent(context, BluetoothOppTransferActivity.class); diff --git a/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java b/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java index e98771f8..4290d782 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java +++ b/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java @@ -347,7 +347,7 @@ public class BluetoothOppTransferActivity extends AlertActivity implements if (mWhichDialog == DIALOG_RECEIVE_COMPLETE_SUCCESS) { // "Open" - open receive file BluetoothOppUtility.openReceivedFile(this, mTransInfo.mFileName, - mTransInfo.mFileType, mTransInfo.mTimeStamp); + mTransInfo.mFileType, mTransInfo.mTimeStamp, mUri); // make current transfer "hidden" BluetoothOppUtility.updateVisibilityToHidden(this, mUri); diff --git a/src/com/android/bluetooth/opp/BluetoothOppUtility.java b/src/com/android/bluetooth/opp/BluetoothOppUtility.java index 00752272..1b42f745 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppUtility.java +++ b/src/com/android/bluetooth/opp/BluetoothOppUtility.java @@ -155,7 +155,7 @@ public class BluetoothOppUtility { * application to handle, display error dialog. */ public static void openReceivedFile(Context context, String fileName, String mimetype, - Long timeStamp) { + Long timeStamp, Uri uri) { if (fileName == null || mimetype == null) { Log.e(TAG, "ERROR: Para fileName ==null, or mimetype == null"); return; @@ -168,6 +168,11 @@ public class BluetoothOppUtility { in.putExtra("title", context.getString(R.string.not_exist_file)); in.putExtra("content", context.getString(R.string.not_exist_file_desc)); context.startActivity(in); + + // Due to the file is not existing, delete related info in btopp db + // to prevent this file from appearing in live folder + if (V) Log.d(TAG, "This uri will be deleted: " + uri); + context.getContentResolver().delete(uri, null, null); return; } -- 2.11.0