Loading AndroidTestTemplate.xml +2 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,8 @@ </target_preparer> <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> <option name="run-command" value="settings put global ble_scan_always_enabled 0" /> <option name="run-command" value="svc bluetooth disable" /> <option name="run-command" value="cmd bluetooth_manager disable" /> <option name="run-command" value="cmd bluetooth_manager wait-for-state:STATE_OFF" /> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.FolderSaver"> <option name="device-path" value="/data/vendor/ssrdump" /> Loading android/app/src/com/android/bluetooth/BluetoothMethodProxy.java +19 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.content.res.AssetFileDescriptor; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; Loading @@ -34,6 +35,7 @@ import com.android.obex.HeaderSet; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; /** * Proxy class for method calls to help with unit testing Loading Loading @@ -132,6 +134,23 @@ public class BluetoothMethodProxy { return contentResolver.openFileDescriptor(uri, mode); } /** * Proxies {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. */ public AssetFileDescriptor contentResolverOpenAssetFileDescriptor( ContentResolver contentResolver, final Uri uri, final String mode) throws FileNotFoundException { return contentResolver.openAssetFileDescriptor(uri, mode); } /** * Proxies {@link ContentResolver#openInputStream(Uri)}. */ public InputStream contentResolverOpenInputStream(ContentResolver contentResolver, final Uri uri) throws FileNotFoundException { return contentResolver.openInputStream(uri); } /** * Proxies {@link Context#sendBroadcast(Intent)}. */ Loading android/app/src/com/android/bluetooth/map/BluetoothMapContent.java +24 −14 Original line number Diff line number Diff line Loading @@ -71,7 +71,8 @@ public class BluetoothMapContent { // Parameter Mask for selection of parameters to return in listings private static final int MASK_SUBJECT = 0x00000001; private static final int MASK_DATETIME = 0x00000002; @VisibleForTesting static final int MASK_DATETIME = 0x00000002; private static final int MASK_SENDER_NAME = 0x00000004; private static final int MASK_SENDER_ADDRESSING = 0x00000008; private static final int MASK_RECIPIENT_NAME = 0x00000010; Loading @@ -80,7 +81,8 @@ public class BluetoothMapContent { private static final int MASK_SIZE = 0x00000080; private static final int MASK_RECEPTION_STATUS = 0x00000100; private static final int MASK_TEXT = 0x00000200; private static final int MASK_ATTACHMENT_SIZE = 0x00000400; @VisibleForTesting static final int MASK_ATTACHMENT_SIZE = 0x00000400; private static final int MASK_PRIORITY = 0x00000800; private static final int MASK_READ = 0x00001000; private static final int MASK_SENT = 0x00002000; Loading @@ -88,7 +90,8 @@ public class BluetoothMapContent { private static final int MASK_REPLYTO_ADDRESSING = 0x00008000; // TODO: Duplicate in proposed spec // private static final int MASK_RECEPTION_STATE = 0x00010000; private static final int MASK_DELIVERY_STATUS = 0x00010000; @VisibleForTesting static final int MASK_DELIVERY_STATUS = 0x00010000; private static final int MASK_CONVERSATION_ID = 0x00020000; private static final int MASK_CONVERSATION_NAME = 0x00040000; private static final int MASK_FOLDER_TYPE = 0x00100000; Loading Loading @@ -154,7 +157,8 @@ public class BluetoothMapContent { private String mMessageVersion = BluetoothMapUtils.MAP_V10_STR; private int mRemoteFeatureMask = BluetoothMapUtils.MAP_FEATURE_DEFAULT_BITMASK; private int mMsgListingVersion = BluetoothMapUtils.MAP_MESSAGE_LISTING_FORMAT_V10; @VisibleForTesting int mMsgListingVersion = BluetoothMapUtils.MAP_MESSAGE_LISTING_FORMAT_V10; static final String[] SMS_PROJECTION = new String[]{ BaseColumns._ID, Loading Loading @@ -592,7 +596,8 @@ public class BluetoothMapContent { * the total message size. To provide a more accurate attachment size, one could * extract the length (in bytes) of the text parts. */ private void setAttachment(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, @VisibleForTesting void setAttachment(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, BluetoothMapAppParams ap) { if ((ap.getParameterMask() & MASK_ATTACHMENT_SIZE) != 0) { int size = 0; Loading Loading @@ -687,7 +692,8 @@ public class BluetoothMapContent { } } private void setDeliveryStatus(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, @VisibleForTesting void setDeliveryStatus(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, BluetoothMapAppParams ap) { if ((ap.getParameterMask() & MASK_DELIVERY_STATUS) != 0) { String deliveryStatus = "delivered"; Loading Loading @@ -1247,8 +1253,8 @@ public class BluetoothMapContent { } } private void setDateTime(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, @VisibleForTesting void setDateTime(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, BluetoothMapAppParams ap) { if ((ap.getParameterMask() & MASK_DATETIME) != 0) { long date = 0; Loading Loading @@ -2036,8 +2042,9 @@ public class BluetoothMapContent { /* Used only for SMS/MMS */ private void setConvoWhereFilterSmsMms(StringBuilder selection, ArrayList<String> selectionArgs, FilterInfo fi, BluetoothMapAppParams ap) { @VisibleForTesting void setConvoWhereFilterSmsMms(StringBuilder selection, FilterInfo fi, BluetoothMapAppParams ap) { if (smsSelected(fi, ap) || mmsSelected(ap)) { Loading Loading @@ -2088,7 +2095,8 @@ public class BluetoothMapContent { * @param ap * @return boolean true if sms is selected, false if not */ private boolean smsSelected(FilterInfo fi, BluetoothMapAppParams ap) { @VisibleForTesting boolean smsSelected(FilterInfo fi, BluetoothMapAppParams ap) { int msgType = ap.getFilterMessageType(); int phoneType = fi.mPhoneType; Loading Loading @@ -2125,7 +2133,8 @@ public class BluetoothMapContent { * @param ap * @return boolean true if mms is selected, false if not */ private boolean mmsSelected(BluetoothMapAppParams ap) { @VisibleForTesting boolean mmsSelected(BluetoothMapAppParams ap) { int msgType = ap.getFilterMessageType(); if (D) { Loading Loading @@ -2193,7 +2202,8 @@ public class BluetoothMapContent { return false; } private void setFilterInfo(FilterInfo fi) { @VisibleForTesting void setFilterInfo(FilterInfo fi) { TelephonyManager tm = mContext.getSystemService(TelephonyManager.class); if (tm != null) { fi.mPhoneType = tm.getPhoneType(); Loading Loading @@ -2762,7 +2772,7 @@ public class BluetoothMapContent { StringBuilder selection = new StringBuilder(120); // This covers most cases ArrayList<String> selectionArgs = new ArrayList<String>(12); // Covers all cases selection.append("1=1 "); // just to simplify building the where-clause setConvoWhereFilterSmsMms(selection, selectionArgs, fi, ap); setConvoWhereFilterSmsMms(selection, fi, ap); String[] args = null; if (selectionArgs.size() > 0) { args = new String[selectionArgs.size()]; Loading android/app/src/com/android/bluetooth/map/SmsMmsContacts.java +13 −5 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ import android.provider.Telephony.CanonicalAddressesColumns; import android.provider.Telephony.MmsSms; import android.util.Log; import com.android.bluetooth.BluetoothMethodProxy; import com.android.internal.annotations.VisibleForTesting; import java.util.Arrays; import java.util.HashMap; import java.util.regex.Pattern; Loading @@ -40,7 +43,8 @@ public class SmsMmsContacts { private static final String TAG = "SmsMmsContacts"; private HashMap<Long, String> mPhoneNumbers = null; private final HashMap<String, MapContact> mNames = new HashMap<String, MapContact>(10); @VisibleForTesting final HashMap<String, MapContact> mNames = new HashMap<String, MapContact>(10); private static final Uri ADDRESS_URI = MmsSms.CONTENT_URI.buildUpon().appendPath("canonical-addresses").build(); Loading Loading @@ -78,7 +82,8 @@ public class SmsMmsContacts { public static String getPhoneNumberUncached(ContentResolver resolver, long id) { String where = CanonicalAddressesColumns._ID + " = " + id; Cursor c = resolver.query(ADDRESS_URI, ADDRESS_PROJECTION, where, null, null); Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(resolver, ADDRESS_URI, ADDRESS_PROJECTION, where, null, null); try { if (c != null) { if (c.moveToPosition(0)) { Loading Loading @@ -111,8 +116,10 @@ public class SmsMmsContacts { * a new query. * @param resolver the ContantResolver to be used. */ private void fillPhoneCache(ContentResolver resolver) { Cursor c = resolver.query(ADDRESS_URI, ADDRESS_PROJECTION, null, null, null); @VisibleForTesting void fillPhoneCache(ContentResolver resolver) { Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(resolver, ADDRESS_URI, ADDRESS_PROJECTION, null, null, null); if (mPhoneNumbers == null) { int size = 0; if (c != null) { Loading Loading @@ -184,7 +191,8 @@ public class SmsMmsContacts { selectionArgs = new String[]{"%" + contactNameFilter.replace("*", "%") + "%"}; } Cursor c = resolver.query(uri, CONTACT_PROJECTION, selection, selectionArgs, null); Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(resolver, uri, CONTACT_PROJECTION, selection, selectionArgs, null); try { if (c != null && c.getCount() >= 1) { c.moveToFirst(); Loading android/app/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java +13 −7 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.provider.OpenableColumns; import android.util.EventLog; import android.util.Log; import com.android.bluetooth.BluetoothMethodProxy; import com.android.bluetooth.R; import java.io.File; Loading Loading @@ -119,7 +120,8 @@ public class BluetoothOppSendFileInfo { contentType = contentResolver.getType(uri); Cursor metadataCursor; try { metadataCursor = contentResolver.query(uri, new String[]{ metadataCursor = BluetoothMethodProxy.getInstance().contentResolverQuery( contentResolver, uri, new String[]{ OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }, null, null, null); } catch (SQLiteException e) { Loading Loading @@ -180,7 +182,8 @@ public class BluetoothOppSendFileInfo { // right size in _OpenableColumns.SIZE // As a second source of getting the correct file length, // get a file descriptor and get the stat length AssetFileDescriptor fd = contentResolver.openAssetFileDescriptor(uri, "r"); AssetFileDescriptor fd = BluetoothMethodProxy.getInstance() .contentResolverOpenAssetFileDescriptor(contentResolver, uri, "r"); long statLength = fd.getLength(); if (length != statLength && statLength > 0) { Log.e(TAG, "Content provider length is wrong (" + Long.toString(length) Loading @@ -200,7 +203,8 @@ public class BluetoothOppSendFileInfo { length = getStreamSize(is); Log.w(TAG, "File length not provided. Length from stream = " + length); // Reset the stream fd = contentResolver.openAssetFileDescriptor(uri, "r"); fd = BluetoothMethodProxy.getInstance() .contentResolverOpenAssetFileDescriptor(contentResolver, uri, "r"); is = fd.createInputStream(); } } catch (IOException e) { Loading @@ -219,14 +223,16 @@ public class BluetoothOppSendFileInfo { if (is == null) { try { is = (FileInputStream) contentResolver.openInputStream(uri); is = (FileInputStream) BluetoothMethodProxy.getInstance() .contentResolverOpenInputStream(contentResolver, uri); // If the database doesn't contain the file size, get the size // by reading through the entire stream if (length == 0) { length = getStreamSize(is); // Reset the stream is = (FileInputStream) contentResolver.openInputStream(uri); is = (FileInputStream) BluetoothMethodProxy.getInstance() .contentResolverOpenInputStream(contentResolver, uri); } } catch (FileNotFoundException e) { return SEND_FILE_INFO_ERROR; Loading Loading
AndroidTestTemplate.xml +2 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,8 @@ </target_preparer> <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> <option name="run-command" value="settings put global ble_scan_always_enabled 0" /> <option name="run-command" value="svc bluetooth disable" /> <option name="run-command" value="cmd bluetooth_manager disable" /> <option name="run-command" value="cmd bluetooth_manager wait-for-state:STATE_OFF" /> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.FolderSaver"> <option name="device-path" value="/data/vendor/ssrdump" /> Loading
android/app/src/com/android/bluetooth/BluetoothMethodProxy.java +19 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.content.res.AssetFileDescriptor; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; Loading @@ -34,6 +35,7 @@ import com.android.obex.HeaderSet; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; /** * Proxy class for method calls to help with unit testing Loading Loading @@ -132,6 +134,23 @@ public class BluetoothMethodProxy { return contentResolver.openFileDescriptor(uri, mode); } /** * Proxies {@link ContentResolver#openAssetFileDescriptor(Uri, String)}. */ public AssetFileDescriptor contentResolverOpenAssetFileDescriptor( ContentResolver contentResolver, final Uri uri, final String mode) throws FileNotFoundException { return contentResolver.openAssetFileDescriptor(uri, mode); } /** * Proxies {@link ContentResolver#openInputStream(Uri)}. */ public InputStream contentResolverOpenInputStream(ContentResolver contentResolver, final Uri uri) throws FileNotFoundException { return contentResolver.openInputStream(uri); } /** * Proxies {@link Context#sendBroadcast(Intent)}. */ Loading
android/app/src/com/android/bluetooth/map/BluetoothMapContent.java +24 −14 Original line number Diff line number Diff line Loading @@ -71,7 +71,8 @@ public class BluetoothMapContent { // Parameter Mask for selection of parameters to return in listings private static final int MASK_SUBJECT = 0x00000001; private static final int MASK_DATETIME = 0x00000002; @VisibleForTesting static final int MASK_DATETIME = 0x00000002; private static final int MASK_SENDER_NAME = 0x00000004; private static final int MASK_SENDER_ADDRESSING = 0x00000008; private static final int MASK_RECIPIENT_NAME = 0x00000010; Loading @@ -80,7 +81,8 @@ public class BluetoothMapContent { private static final int MASK_SIZE = 0x00000080; private static final int MASK_RECEPTION_STATUS = 0x00000100; private static final int MASK_TEXT = 0x00000200; private static final int MASK_ATTACHMENT_SIZE = 0x00000400; @VisibleForTesting static final int MASK_ATTACHMENT_SIZE = 0x00000400; private static final int MASK_PRIORITY = 0x00000800; private static final int MASK_READ = 0x00001000; private static final int MASK_SENT = 0x00002000; Loading @@ -88,7 +90,8 @@ public class BluetoothMapContent { private static final int MASK_REPLYTO_ADDRESSING = 0x00008000; // TODO: Duplicate in proposed spec // private static final int MASK_RECEPTION_STATE = 0x00010000; private static final int MASK_DELIVERY_STATUS = 0x00010000; @VisibleForTesting static final int MASK_DELIVERY_STATUS = 0x00010000; private static final int MASK_CONVERSATION_ID = 0x00020000; private static final int MASK_CONVERSATION_NAME = 0x00040000; private static final int MASK_FOLDER_TYPE = 0x00100000; Loading Loading @@ -154,7 +157,8 @@ public class BluetoothMapContent { private String mMessageVersion = BluetoothMapUtils.MAP_V10_STR; private int mRemoteFeatureMask = BluetoothMapUtils.MAP_FEATURE_DEFAULT_BITMASK; private int mMsgListingVersion = BluetoothMapUtils.MAP_MESSAGE_LISTING_FORMAT_V10; @VisibleForTesting int mMsgListingVersion = BluetoothMapUtils.MAP_MESSAGE_LISTING_FORMAT_V10; static final String[] SMS_PROJECTION = new String[]{ BaseColumns._ID, Loading Loading @@ -592,7 +596,8 @@ public class BluetoothMapContent { * the total message size. To provide a more accurate attachment size, one could * extract the length (in bytes) of the text parts. */ private void setAttachment(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, @VisibleForTesting void setAttachment(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, BluetoothMapAppParams ap) { if ((ap.getParameterMask() & MASK_ATTACHMENT_SIZE) != 0) { int size = 0; Loading Loading @@ -687,7 +692,8 @@ public class BluetoothMapContent { } } private void setDeliveryStatus(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, @VisibleForTesting void setDeliveryStatus(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, BluetoothMapAppParams ap) { if ((ap.getParameterMask() & MASK_DELIVERY_STATUS) != 0) { String deliveryStatus = "delivered"; Loading Loading @@ -1247,8 +1253,8 @@ public class BluetoothMapContent { } } private void setDateTime(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, @VisibleForTesting void setDateTime(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, BluetoothMapAppParams ap) { if ((ap.getParameterMask() & MASK_DATETIME) != 0) { long date = 0; Loading Loading @@ -2036,8 +2042,9 @@ public class BluetoothMapContent { /* Used only for SMS/MMS */ private void setConvoWhereFilterSmsMms(StringBuilder selection, ArrayList<String> selectionArgs, FilterInfo fi, BluetoothMapAppParams ap) { @VisibleForTesting void setConvoWhereFilterSmsMms(StringBuilder selection, FilterInfo fi, BluetoothMapAppParams ap) { if (smsSelected(fi, ap) || mmsSelected(ap)) { Loading Loading @@ -2088,7 +2095,8 @@ public class BluetoothMapContent { * @param ap * @return boolean true if sms is selected, false if not */ private boolean smsSelected(FilterInfo fi, BluetoothMapAppParams ap) { @VisibleForTesting boolean smsSelected(FilterInfo fi, BluetoothMapAppParams ap) { int msgType = ap.getFilterMessageType(); int phoneType = fi.mPhoneType; Loading Loading @@ -2125,7 +2133,8 @@ public class BluetoothMapContent { * @param ap * @return boolean true if mms is selected, false if not */ private boolean mmsSelected(BluetoothMapAppParams ap) { @VisibleForTesting boolean mmsSelected(BluetoothMapAppParams ap) { int msgType = ap.getFilterMessageType(); if (D) { Loading Loading @@ -2193,7 +2202,8 @@ public class BluetoothMapContent { return false; } private void setFilterInfo(FilterInfo fi) { @VisibleForTesting void setFilterInfo(FilterInfo fi) { TelephonyManager tm = mContext.getSystemService(TelephonyManager.class); if (tm != null) { fi.mPhoneType = tm.getPhoneType(); Loading Loading @@ -2762,7 +2772,7 @@ public class BluetoothMapContent { StringBuilder selection = new StringBuilder(120); // This covers most cases ArrayList<String> selectionArgs = new ArrayList<String>(12); // Covers all cases selection.append("1=1 "); // just to simplify building the where-clause setConvoWhereFilterSmsMms(selection, selectionArgs, fi, ap); setConvoWhereFilterSmsMms(selection, fi, ap); String[] args = null; if (selectionArgs.size() > 0) { args = new String[selectionArgs.size()]; Loading
android/app/src/com/android/bluetooth/map/SmsMmsContacts.java +13 −5 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ import android.provider.Telephony.CanonicalAddressesColumns; import android.provider.Telephony.MmsSms; import android.util.Log; import com.android.bluetooth.BluetoothMethodProxy; import com.android.internal.annotations.VisibleForTesting; import java.util.Arrays; import java.util.HashMap; import java.util.regex.Pattern; Loading @@ -40,7 +43,8 @@ public class SmsMmsContacts { private static final String TAG = "SmsMmsContacts"; private HashMap<Long, String> mPhoneNumbers = null; private final HashMap<String, MapContact> mNames = new HashMap<String, MapContact>(10); @VisibleForTesting final HashMap<String, MapContact> mNames = new HashMap<String, MapContact>(10); private static final Uri ADDRESS_URI = MmsSms.CONTENT_URI.buildUpon().appendPath("canonical-addresses").build(); Loading Loading @@ -78,7 +82,8 @@ public class SmsMmsContacts { public static String getPhoneNumberUncached(ContentResolver resolver, long id) { String where = CanonicalAddressesColumns._ID + " = " + id; Cursor c = resolver.query(ADDRESS_URI, ADDRESS_PROJECTION, where, null, null); Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(resolver, ADDRESS_URI, ADDRESS_PROJECTION, where, null, null); try { if (c != null) { if (c.moveToPosition(0)) { Loading Loading @@ -111,8 +116,10 @@ public class SmsMmsContacts { * a new query. * @param resolver the ContantResolver to be used. */ private void fillPhoneCache(ContentResolver resolver) { Cursor c = resolver.query(ADDRESS_URI, ADDRESS_PROJECTION, null, null, null); @VisibleForTesting void fillPhoneCache(ContentResolver resolver) { Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(resolver, ADDRESS_URI, ADDRESS_PROJECTION, null, null, null); if (mPhoneNumbers == null) { int size = 0; if (c != null) { Loading Loading @@ -184,7 +191,8 @@ public class SmsMmsContacts { selectionArgs = new String[]{"%" + contactNameFilter.replace("*", "%") + "%"}; } Cursor c = resolver.query(uri, CONTACT_PROJECTION, selection, selectionArgs, null); Cursor c = BluetoothMethodProxy.getInstance().contentResolverQuery(resolver, uri, CONTACT_PROJECTION, selection, selectionArgs, null); try { if (c != null && c.getCount() >= 1) { c.moveToFirst(); Loading
android/app/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java +13 −7 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.provider.OpenableColumns; import android.util.EventLog; import android.util.Log; import com.android.bluetooth.BluetoothMethodProxy; import com.android.bluetooth.R; import java.io.File; Loading Loading @@ -119,7 +120,8 @@ public class BluetoothOppSendFileInfo { contentType = contentResolver.getType(uri); Cursor metadataCursor; try { metadataCursor = contentResolver.query(uri, new String[]{ metadataCursor = BluetoothMethodProxy.getInstance().contentResolverQuery( contentResolver, uri, new String[]{ OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE }, null, null, null); } catch (SQLiteException e) { Loading Loading @@ -180,7 +182,8 @@ public class BluetoothOppSendFileInfo { // right size in _OpenableColumns.SIZE // As a second source of getting the correct file length, // get a file descriptor and get the stat length AssetFileDescriptor fd = contentResolver.openAssetFileDescriptor(uri, "r"); AssetFileDescriptor fd = BluetoothMethodProxy.getInstance() .contentResolverOpenAssetFileDescriptor(contentResolver, uri, "r"); long statLength = fd.getLength(); if (length != statLength && statLength > 0) { Log.e(TAG, "Content provider length is wrong (" + Long.toString(length) Loading @@ -200,7 +203,8 @@ public class BluetoothOppSendFileInfo { length = getStreamSize(is); Log.w(TAG, "File length not provided. Length from stream = " + length); // Reset the stream fd = contentResolver.openAssetFileDescriptor(uri, "r"); fd = BluetoothMethodProxy.getInstance() .contentResolverOpenAssetFileDescriptor(contentResolver, uri, "r"); is = fd.createInputStream(); } } catch (IOException e) { Loading @@ -219,14 +223,16 @@ public class BluetoothOppSendFileInfo { if (is == null) { try { is = (FileInputStream) contentResolver.openInputStream(uri); is = (FileInputStream) BluetoothMethodProxy.getInstance() .contentResolverOpenInputStream(contentResolver, uri); // If the database doesn't contain the file size, get the size // by reading through the entire stream if (length == 0) { length = getStreamSize(is); // Reset the stream is = (FileInputStream) contentResolver.openInputStream(uri); is = (FileInputStream) BluetoothMethodProxy.getInstance() .contentResolverOpenInputStream(contentResolver, uri); } } catch (FileNotFoundException e) { return SEND_FILE_INFO_ERROR; Loading