diff options
author | Rohan Shah <shahrk@google.com> | 2016-08-22 20:47:49 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-08-22 20:47:49 +0000 |
commit | 0f1787b8e40fe0e813d059e66c8a082947b5a03f (patch) | |
tree | 933b834b4477dd583e3cc88c80c6b8ab2d1bb29d | |
parent | 91910ffe05620f59024ae0767989922d9034eff3 (diff) | |
parent | 87be55a2c52f7234fd0eed1563a93d30c7110678 (diff) | |
download | android_packages_apps_Email-0f1787b8e40fe0e813d059e66c8a082947b5a03f.tar.gz android_packages_apps_Email-0f1787b8e40fe0e813d059e66c8a082947b5a03f.tar.bz2 android_packages_apps_Email-0f1787b8e40fe0e813d059e66c8a082947b5a03f.zip |
DO NOT MERGE Limit account id and id to longs am: 4d43d4ae1c
am: 87be55a2c5
Change-Id: Id7a231bc6408ce29b3ce6e623cfd1deb6ce05adf
-rw-r--r-- | src/com/android/email/provider/AttachmentProvider.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/com/android/email/provider/AttachmentProvider.java b/src/com/android/email/provider/AttachmentProvider.java index c64fb4e4c..0abed9712 100644 --- a/src/com/android/email/provider/AttachmentProvider.java +++ b/src/com/android/email/provider/AttachmentProvider.java @@ -166,8 +166,8 @@ public class AttachmentProvider extends ContentProvider { long callingId = Binder.clearCallingIdentity(); try { List<String> segments = uri.getPathSegments(); - String accountId = segments.get(0); - String id = segments.get(1); + final long accountId = Long.parseLong(segments.get(0)); + final long id = Long.parseLong(segments.get(1)); String format = segments.get(2); if (AttachmentUtilities.FORMAT_THUMBNAIL.equals(format)) { int width = Integer.parseInt(segments.get(3)); @@ -176,8 +176,7 @@ public class AttachmentProvider extends ContentProvider { File dir = getContext().getCacheDir(); File file = new File(dir, filename); if (!file.exists()) { - Uri attachmentUri = AttachmentUtilities. - getAttachmentUri(Long.parseLong(accountId), Long.parseLong(id)); + Uri attachmentUri = AttachmentUtilities.getAttachmentUri(accountId, id); Cursor c = query(attachmentUri, new String[] { Columns.DATA }, null, null, null); if (c != null) { @@ -218,9 +217,14 @@ public class AttachmentProvider extends ContentProvider { } else { return ParcelFileDescriptor.open( - new File(getContext().getDatabasePath(accountId + ".db_att"), id), + new File(getContext().getDatabasePath(accountId + ".db_att"), + String.valueOf(id)), ParcelFileDescriptor.MODE_READ_ONLY); } + } catch (NumberFormatException e) { + LogUtils.e(Logging.LOG_TAG, + "AttachmentProvider.openFile: Failed to open as id is not a long"); + return null; } finally { Binder.restoreCallingIdentity(callingId); } |