summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2012-05-21 12:45:06 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-21 12:45:06 -0700
commit2598c1600b004d8fd71f8aec72bc7c9346d335a3 (patch)
tree90d976014e86e5b9b4be99d46950b45bfbad75e1 /src
parentd47de4a5de519ffd56aefb04c37537a9c1fc2275 (diff)
parentbeb7b1b4b95b1762b507eb2a9c6380e24c8b7a62 (diff)
downloadpackages_apps_nfc-2598c1600b004d8fd71f8aec72bc7c9346d335a3.zip
packages_apps_nfc-2598c1600b004d8fd71f8aec72bc7c9346d335a3.tar.gz
packages_apps_nfc-2598c1600b004d8fd71f8aec72bc7c9346d335a3.tar.bz2
am beb7b1b4: am 0de27370: Bluetooth Beam: generate unique filenames.
* commit 'beb7b1b4b95b1762b507eb2a9c6380e24c8b7a62': Bluetooth Beam: generate unique filenames.
Diffstat (limited to 'src')
-rw-r--r--src/com/android/nfc/handover/HandoverManager.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/com/android/nfc/handover/HandoverManager.java b/src/com/android/nfc/handover/HandoverManager.java
index 9458472..a1458b9 100644
--- a/src/com/android/nfc/handover/HandoverManager.java
+++ b/src/com/android/nfc/handover/HandoverManager.java
@@ -255,7 +255,7 @@ public class HandoverManager implements BluetoothProfile.ServiceListener,
// We need to receive an update within this time period
// to still consider this transfer to be "alive" (ie
// a reason to keep the handover transport enabled).
- static final int ALIVE_CHECK_MS = 10000;
+ static final int ALIVE_CHECK_MS = 20000;
// The amount of time to wait for a new transfer
// once the current one completes.
@@ -452,7 +452,9 @@ public class HandoverManager implements BluetoothProfile.ServiceListener,
String mimeType = btMimeTypes.get(i);
File srcFile = new File(uri.getPath());
- File dstFile = new File(beamPath + "/" + uri.getLastPathSegment());
+
+ File dstFile = generateUniqueDestination(beamPath + "/" +
+ uri.getLastPathSegment());
if (!srcFile.renameTo(dstFile)) {
if (DBG) Log.d(TAG, "Failed to rename from " + srcFile + " to " + dstFile);
srcFile.delete();
@@ -548,6 +550,17 @@ public class HandoverManager implements BluetoothProfile.ServiceListener,
return pi;
}
+ synchronized File generateUniqueDestination(String baseFileName) {
+ File dstFile = new File(baseFileName);
+ int count = 0;
+ while (dstFile.exists()) {
+ dstFile = new File(baseFileName + "-" + Integer.toString(count));
+ count++;
+ }
+
+ return dstFile;
+ }
+
synchronized File generateMultiplePath(String beamRoot) {
// Generate a unique directory with the date
String format = "yyyy-MM-dd";