diff options
author | Martijn Coenen <maco@google.com> | 2012-05-18 13:26:01 -0700 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2012-05-18 13:29:30 -0700 |
commit | 0de2737031fd18aeeadcbc8f46cd0ebcb18ee730 (patch) | |
tree | bd85af3d229c42710ae7c2e4df6d4709d54ce1df /src/com | |
parent | 0f2b555fe51f3d8a828cf61d269b8be6eecbf68b (diff) | |
download | packages_apps_nfc-0de2737031fd18aeeadcbc8f46cd0ebcb18ee730.zip packages_apps_nfc-0de2737031fd18aeeadcbc8f46cd0ebcb18ee730.tar.gz packages_apps_nfc-0de2737031fd18aeeadcbc8f46cd0ebcb18ee730.tar.bz2 |
Bluetooth Beam: generate unique filenames.
When moving files to beam/, make sure the destination
file is unique.
Also, give the transfer a little more time to be initiated;
OPP can take quite some time to startup, especially with
debug logging.
Change-Id: I304c297587e3ad2f339438201bb0b53152084af4
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/nfc/handover/HandoverManager.java | 17 |
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"; |