OSDN Git Service

Revert "Bluetooth-OPP: Enable support to send same file multiple times"
authorPavlin Radoslavov <pavlin@google.com>
Sat, 8 Aug 2015 01:13:07 +0000 (18:13 -0700)
committerPavlin Radoslavov <pavlin@google.com>
Sat, 8 Aug 2015 02:45:28 +0000 (02:45 +0000)
This reverts commit 86449ac4bc7a8f4b2afeab4da420ae4f980c850a.

The revert is needed to address an issue that crashes Bluetooth.

Bug: 22836458
Change-Id: I8c8b51544637dd1c2250eb91e86cb2ca1bbc9fe7

src/com/android/bluetooth/opp/BluetoothOppManager.java
src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java
src/com/android/bluetooth/opp/BluetoothOppUtility.java

index 593034a..dd8efe0 100644 (file)
@@ -250,13 +250,11 @@ public class BluetoothOppManager {
         synchronized (BluetoothOppManager.this) {
             mMultipleFlag = false;
             mMimeTypeOfSendingFile = mimeType;
+            mUriOfSendingFile = uriString;
             mIsHandoverInitiated = isHandover;
             Uri uri = Uri.parse(uriString);
-            BluetoothOppSendFileInfo sendFileInfo =
-                BluetoothOppSendFileInfo.generateFileInfo(mContext, uri, mimeType);
-            uri = BluetoothOppUtility.generateUri(uri, sendFileInfo);
-            BluetoothOppUtility.putSendFileInfo(uri, sendFileInfo);
-            mUriOfSendingFile = uri.toString();
+            BluetoothOppUtility.putSendFileInfo(uri,
+                    BluetoothOppSendFileInfo.generateFileInfo(mContext, uri, mimeType));
             storeApplicationData();
         }
     }
@@ -265,14 +263,11 @@ public class BluetoothOppManager {
         synchronized (BluetoothOppManager.this) {
             mMultipleFlag = true;
             mMimeTypeOfSendingFiles = mimeType;
-            mUrisOfSendingFiles = new ArrayList<Uri>();
+            mUrisOfSendingFiles = uris;
             mIsHandoverInitiated = isHandover;
             for (Uri uri : uris) {
-                BluetoothOppSendFileInfo sendFileInfo =
-                    BluetoothOppSendFileInfo.generateFileInfo(mContext, uri, mimeType);
-                uri = BluetoothOppUtility.generateUri(uri, sendFileInfo);
-                mUrisOfSendingFiles.add(uri);
-                BluetoothOppUtility.putSendFileInfo(uri, sendFileInfo);
+                BluetoothOppUtility.putSendFileInfo(uri,
+                        BluetoothOppSendFileInfo.generateFileInfo(mContext, uri, mimeType));
             }
             storeApplicationData();
         }
@@ -431,21 +426,15 @@ public class BluetoothOppManager {
             Long ts = System.currentTimeMillis();
             for (int i = 0; i < count; i++) {
                 Uri fileUri = mUris.get(i);
-
-                ContentValues values = new ContentValues();
-                values.put(BluetoothShare.URI, fileUri.toString());
-
                 ContentResolver contentResolver = mContext.getContentResolver();
-                fileUri = BluetoothOppUtility.originalUri(fileUri);
                 String contentType = contentResolver.getType(fileUri);
                 if (V) Log.v(TAG, "Got mimetype: " + contentType + "  Got uri: " + fileUri);
                 if (TextUtils.isEmpty(contentType)) {
                     contentType = mTypeOfMultipleFiles;
                 }
 
-                BluetoothOppSendFileInfo fileInfo = BluetoothOppSendFileInfo.generateFileInfo(
-                                                        mContext, fileUri, contentType);
-                values.put(BluetoothShare.FILENAME_HINT, fileInfo.mFileName);
+                ContentValues values = new ContentValues();
+                values.put(BluetoothShare.URI, fileUri.toString());
                 values.put(BluetoothShare.MIMETYPE, contentType);
                 values.put(BluetoothShare.DESTINATION, mRemoteDevice.getAddress());
                 values.put(BluetoothShare.TIMESTAMP, ts);
index bbcb15d..01312e4 100644 (file)
@@ -371,12 +371,6 @@ public class BluetoothOppTransferActivity extends AlertActivity implements
                             .cancel(mTransInfo.mID);
 
                     // retry the failed transfer
-                    Uri uri = BluetoothOppUtility.originalUri(Uri.parse(mTransInfo.mFileUri));
-                    BluetoothOppSendFileInfo sendFileInfo =
-                        BluetoothOppSendFileInfo.generateFileInfo(this, uri, mTransInfo.mFileType);
-                    uri = BluetoothOppUtility.generateUri(uri, sendFileInfo);
-                    BluetoothOppUtility.putSendFileInfo(uri, sendFileInfo);
-                    mTransInfo.mFileUri = uri.toString();
                     BluetoothOppUtility.retryTransfer(this, mTransInfo);
 
                     BluetoothDevice remoteDevice = mAdapter.getRemoteDevice(mTransInfo.mDestAddr);
index e453bbd..ea465f4 100644 (file)
@@ -97,7 +97,7 @@ public class BluetoothOppUtility {
                 info.mFileUri = cursor.getString(cursor.getColumnIndexOrThrow(BluetoothShare.URI));
 
                 if (info.mFileUri != null) {
-                    Uri u = originalUri(Uri.parse(info.mFileUri));
+                    Uri u = Uri.parse(info.mFileUri);
                     info.mFileType = context.getContentResolver().getType(u);
                 } else {
                     Uri u = Uri.parse(info.mFileName);
@@ -308,26 +308,6 @@ public class BluetoothOppUtility {
                 transInfo.mDeviceName);
     }
 
-    static Uri originalUri(Uri uri) {
-        String mUri = uri.toString();
-        int atIndex = mUri.lastIndexOf("@");
-        if (atIndex != -1) {
-            mUri = mUri.substring(0, atIndex);
-            uri = Uri.parse(mUri);
-        }
-        if (V) Log.v(TAG, "originalUri: " + uri);
-        return uri;
-    }
-
-    static Uri generateUri(Uri uri, BluetoothOppSendFileInfo sendFileInfo) {
-        String fileInfo = sendFileInfo.toString();
-        int atIndex = fileInfo.lastIndexOf("@");
-        fileInfo = fileInfo.substring(atIndex);
-        uri = Uri.parse(uri + fileInfo);
-        if (V) Log.v(TAG, "generateUri: " + uri);
-        return uri;
-    }
-
     static void putSendFileInfo(Uri uri, BluetoothOppSendFileInfo sendFileInfo) {
         if (D) Log.d(TAG, "putSendFileInfo: uri=" + uri + " sendFileInfo=" + sendFileInfo);
         sSendFileMap.put(uri, sendFileInfo);