Loading src/java/com/google/android/mms/pdu/PduPersister.java +4 −60 Original line number Diff line number Diff line Loading @@ -23,10 +23,9 @@ import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.DatabaseUtils; import android.database.sqlite.SQLiteException; import android.drm.DrmManagerClient; import android.net.Uri; import android.provider.MediaStore; import android.os.ParcelFileDescriptor; import android.provider.Telephony; import android.provider.Telephony.Mms; import android.provider.Telephony.Mms.Addr; Loading Loading @@ -805,17 +804,9 @@ public class PduPersister { boolean isDrm = DownloadDrmHelper.isDrmConvertNeeded(contentType); if (isDrm) { if (uri != null) { try { path = convertUriToPath(mContext, uri); if (LOCAL_LOGV) { Log.v(TAG, "drm uri: " + uri + " path: " + path); } File f = new File(path); long len = f.length(); if (LOCAL_LOGV) { Log.v(TAG, "drm path: " + path + " len: " + len); } if (len > 0) { try (ParcelFileDescriptor pfd = mContentResolver.openFileDescriptor(uri, "r")) { if (pfd.getStatSize() > 0) { // we're not going to re-persist and re-encrypt an already // converted drm file return; Loading Loading @@ -918,53 +909,6 @@ public class PduPersister { } } /** * This method expects uri in the following format * content://media/<table_name>/<row_index> (or) * file://sdcard/test.mp4 * http://test.com/test.mp4 * * Here <table_name> shall be "video" or "audio" or "images" * <row_index> the index of the content in given table */ static public String convertUriToPath(Context context, Uri uri) { String path = null; if (null != uri) { String scheme = uri.getScheme(); if (null == scheme || scheme.equals("") || scheme.equals(ContentResolver.SCHEME_FILE)) { path = uri.getPath(); } else if (scheme.equals("http")) { path = uri.toString(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { String[] projection = new String[] {MediaStore.MediaColumns.DATA}; Cursor cursor = null; try { cursor = context.getContentResolver().query(uri, projection, null, null, null); if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) { throw new IllegalArgumentException("Given Uri could not be found" + " in media store"); } int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA); path = cursor.getString(pathIndex); } catch (SQLiteException e) { throw new IllegalArgumentException("Given Uri is not formatted in a way " + "so that it can be found in media store."); } finally { if (null != cursor) { cursor.close(); } } } else { throw new IllegalArgumentException("Given Uri scheme is not supported"); } } return path; } private void updateAddress( long msgId, int type, EncodedStringValue[] array) { // Delete old address information and then insert new ones. Loading Loading
src/java/com/google/android/mms/pdu/PduPersister.java +4 −60 Original line number Diff line number Diff line Loading @@ -23,10 +23,9 @@ import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.DatabaseUtils; import android.database.sqlite.SQLiteException; import android.drm.DrmManagerClient; import android.net.Uri; import android.provider.MediaStore; import android.os.ParcelFileDescriptor; import android.provider.Telephony; import android.provider.Telephony.Mms; import android.provider.Telephony.Mms.Addr; Loading Loading @@ -805,17 +804,9 @@ public class PduPersister { boolean isDrm = DownloadDrmHelper.isDrmConvertNeeded(contentType); if (isDrm) { if (uri != null) { try { path = convertUriToPath(mContext, uri); if (LOCAL_LOGV) { Log.v(TAG, "drm uri: " + uri + " path: " + path); } File f = new File(path); long len = f.length(); if (LOCAL_LOGV) { Log.v(TAG, "drm path: " + path + " len: " + len); } if (len > 0) { try (ParcelFileDescriptor pfd = mContentResolver.openFileDescriptor(uri, "r")) { if (pfd.getStatSize() > 0) { // we're not going to re-persist and re-encrypt an already // converted drm file return; Loading Loading @@ -918,53 +909,6 @@ public class PduPersister { } } /** * This method expects uri in the following format * content://media/<table_name>/<row_index> (or) * file://sdcard/test.mp4 * http://test.com/test.mp4 * * Here <table_name> shall be "video" or "audio" or "images" * <row_index> the index of the content in given table */ static public String convertUriToPath(Context context, Uri uri) { String path = null; if (null != uri) { String scheme = uri.getScheme(); if (null == scheme || scheme.equals("") || scheme.equals(ContentResolver.SCHEME_FILE)) { path = uri.getPath(); } else if (scheme.equals("http")) { path = uri.toString(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { String[] projection = new String[] {MediaStore.MediaColumns.DATA}; Cursor cursor = null; try { cursor = context.getContentResolver().query(uri, projection, null, null, null); if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) { throw new IllegalArgumentException("Given Uri could not be found" + " in media store"); } int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA); path = cursor.getString(pathIndex); } catch (SQLiteException e) { throw new IllegalArgumentException("Given Uri is not formatted in a way " + "so that it can be found in media store."); } finally { if (null != cursor) { cursor.close(); } } } else { throw new IllegalArgumentException("Given Uri scheme is not supported"); } } return path; } private void updateAddress( long msgId, int type, EncodedStringValue[] array) { // Delete old address information and then insert new ones. Loading