From fa5d402906010cd17c8ed7de0dbcbfdcb78dab20 Mon Sep 17 00:00:00 2001 From: Nick Pelly Date: Tue, 1 Sep 2009 13:46:01 -0700 Subject: Workaround bug in Poloroid Pogo. Rename extra dots to underscores. Working with Poloroid to get an updated list of affected MAC addresses. For now we just have 00:04:48. --- .../opp/BluetoothOppObexClientSession.java | 38 +++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java') diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java index 92305bd02..0b240f1c5 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java +++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java @@ -296,7 +296,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { if (V) Log.v(TAG, "Client thread processShareInfo() " + mInfo.mId); BluetoothOppSendFileInfo fileInfo = BluetoothOppSendFileInfo.generateFileInfo( - mContext1, mInfo.mUri, mInfo.mMimetype); + mContext1, mInfo.mUri, mInfo.mMimetype, mInfo.mDestination); if (fileInfo.mFileName == null || fileInfo.mLength == 0) { if (V) Log.v(TAG, "BluetoothOppSendFileInfo get invalid file"); Constants.updateShareStatus(mContext1, mInfo.mId, fileInfo.mStatus); @@ -333,6 +333,8 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { request.setHeader(HeaderSet.NAME, fileInfo.mFileName); request.setHeader(HeaderSet.TYPE, fileInfo.mMimetype); + applyRemoteDeviceQuirks(request, fileInfo); + Constants.updateShareStatus(mContext1, mInfo.mId, BluetoothShare.STATUS_RUNNING); request.setHeader(HeaderSet.LENGTH, fileInfo.mLength); @@ -546,6 +548,40 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { } } + public static void applyRemoteDeviceQuirks(HeaderSet request, BluetoothOppSendFileInfo info) { + String address = info.mDestAddr; + if (address == null) { + return; + } + if (address.startsWith("00:04:48")) { + // Poloroid Pogo + // 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; + for (int i = c.length - 1; i >= 0; i--) { + if (c[i] == '.') { + if (!firstDot) { + modified = true; + c[i] = '_'; + } + firstDot = false; + } + } + + if (modified) { + String newFilename = new String(c); + request.setHeader(HeaderSet.NAME, newFilename); + Log.i(TAG, "Sending file \"" + filename + "\" as \"" + newFilename + + "\" to workaround Poloroid filename quirk"); + } + } + } + public void unblock() { // Not used for client case } -- cgit v1.2.3