OSDN Git Service

Fix non-existing received file still appearing in live folder issue
authorLixin Yue <L.X.YUE@motorola.com>
Wed, 16 Dec 2009 08:07:53 +0000 (16:07 +0800)
committerJaikumar Ganesh <jaikumar@google.com>
Tue, 22 Dec 2009 18:06:58 +0000 (10:06 -0800)
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
src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java
src/com/android/bluetooth/opp/BluetoothOppUtility.java

index 516947f..7ce5cbc 100644 (file)
@@ -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);
index e98771f..4290d78 100644 (file)
@@ -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);
index 0075227..1b42f74 100644 (file)
@@ -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;
         }