diff options
author | Jake Hamby <jhamby@google.com> | 2012-07-27 14:38:32 -0700 |
---|---|---|
committer | Jake Hamby <jhamby@google.com> | 2012-09-14 16:00:51 -0700 |
commit | ee52ddf33a0ce2cf89cc028136f60ae600c45de5 (patch) | |
tree | d12ece24296ebc70d613b0880475f47e9119a4d4 /src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java | |
parent | f46f032adaec19a0d0c11b921fb356cbcd7aedbd (diff) | |
download | android_packages_apps_Bluetooth-ee52ddf33a0ce2cf89cc028136f60ae600c45de5.tar.gz android_packages_apps_Bluetooth-ee52ddf33a0ce2cf89cc028136f60ae600c45de5.tar.bz2 android_packages_apps_Bluetooth-ee52ddf33a0ce2cf89cc028136f60ae600c45de5.zip |
Enable Bluetooth sharing of downloaded files.
Change BT OPP to open the InputStreams of files to share in the
BluetoothOppLauncherActivity (or BluetoothOppHandoverReceiver
for NFC shares), while the process has grantUriPermission() on
the URI's to share.
InputStreams are saved inside the existing BluetoothOppSendFileInfo
objects, which no longer include the mDestination field because
this isn't known at the time the SendFileInfo object is now created
(before the user has chosen the destination BT device). These
objects are stored in a static ConcurrentHashMap in BluetoothOppUtility
and are removed when the file is closed (on success or failure).
If the user tries to share thousands of files in one batch, we may
not be able to open InputStreams for all of the files in the batch.
In this case, the open should fail gracefully.
Bug: 6808783
Change-Id: I3f3f86d2dc1a78a837aeb6a888f90b26434ba499
Diffstat (limited to 'src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java')
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java index f234203ce..dce7fa3f3 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java +++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java @@ -305,8 +305,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { private BluetoothOppSendFileInfo processShareInfo() { if (V) Log.v(TAG, "Client thread processShareInfo() " + mInfo.mId); - BluetoothOppSendFileInfo fileInfo = BluetoothOppSendFileInfo.generateFileInfo( - mContext1, mInfo.mUri, mInfo.mMimetype, mInfo.mDestination); + BluetoothOppSendFileInfo fileInfo = BluetoothOppUtility.getSendFileInfo(mInfo.mUri); if (fileInfo.mFileName == null || fileInfo.mLength == 0) { if (V) Log.v(TAG, "BluetoothOppSendFileInfo get invalid file"); Constants.updateShareStatus(mContext1, mInfo.mId, fileInfo.mStatus); @@ -343,7 +342,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { request.setHeader(HeaderSet.NAME, fileInfo.mFileName); request.setHeader(HeaderSet.TYPE, fileInfo.mMimetype); - applyRemoteDeviceQuirks(request, fileInfo); + applyRemoteDeviceQuirks(request, mInfo.mDestination, fileInfo.mFileName); Constants.updateShareStatus(mContext1, mInfo.mId, BluetoothShare.STATUS_RUNNING); @@ -500,7 +499,8 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { handleSendException(e.toString()); } finally { try { - fileInfo.mInputStream.close(); + // Close InputStream and remove SendFileInfo from map + BluetoothOppUtility.closeSendFileInfo(mInfo.mUri); if (!error) { responseCode = putOperation.getResponseCode(); if (responseCode != -1) { @@ -566,8 +566,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { } } - public static void applyRemoteDeviceQuirks(HeaderSet request, BluetoothOppSendFileInfo info) { - String address = info.mDestAddr; + public static void applyRemoteDeviceQuirks(HeaderSet request, String address, String filename) { if (address == null) { return; } @@ -576,8 +575,6 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { // Rejects filenames with more than one '.'. Rename to '_'. // for example: 'a.b.jpg' -> 'a_b.jpg' // 'abc.jpg' NOT CHANGED - String filename = info.mFileName; - char[] c = filename.toCharArray(); boolean firstDot = true; boolean modified = false; |