diff options
author | Steve Howard <showard@google.com> | 2010-09-16 12:04:17 -0700 |
---|---|---|
committer | Steve Howard <showard@google.com> | 2010-09-20 13:45:30 -0700 |
commit | b9a0ad7182209d4aca708e13e876e9b1b43ffafc (patch) | |
tree | e49d39e80dfc9c2ffc6a43c81f08ee0edce26c31 /src/com/android/providers/downloads/DownloadProvider.java | |
parent | dbefa6f5eff88f97dd91a8adfd65dbd946adb99e (diff) | |
download | android_packages_providers_DownloadProvider-b9a0ad7182209d4aca708e13e876e9b1b43ffafc.tar.gz android_packages_providers_DownloadProvider-b9a0ad7182209d4aca708e13e876e9b1b43ffafc.tar.bz2 android_packages_providers_DownloadProvider-b9a0ad7182209d4aca708e13e876e9b1b43ffafc.zip |
Improve file error reporting + new detailed error messages in UI
* support new error code for "destination file already exists"
* improve error handling for various file error cases to return a more
specific error code when appropriate
* make UI support more detailed error messages for some cases
* use Uri.getPath() instead of Uri.getSchemeSpecificPart() for file
URIs
Change-Id: Icb01d4d3b47c7776be3ddcd8347212e950cd023e
Diffstat (limited to 'src/com/android/providers/downloads/DownloadProvider.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadProvider.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java index df7ca71d..102c611d 100644 --- a/src/com/android/providers/downloads/DownloadProvider.java +++ b/src/com/android/providers/downloads/DownloadProvider.java @@ -121,6 +121,7 @@ public final class DownloadProvider extends ContentProvider { Downloads.Impl.COLUMN_DESCRIPTION, Downloads.Impl.COLUMN_URI, Downloads.Impl.COLUMN_IS_VISIBLE_IN_DOWNLOADS_UI, + Downloads.Impl.COLUMN_FILE_NAME_HINT, }; private static HashSet<String> sAppReadableColumnsSet; @@ -508,9 +509,12 @@ public final class DownloadProvider extends ContentProvider { if (!uri.getScheme().equals("file")) { throw new IllegalArgumentException("Not a file URI: " + uri); } - File path = new File(uri.getSchemeSpecificPart()); + String path = uri.getPath(); + if (path == null) { + throw new IllegalArgumentException("Invalid file URI: " + uri); + } String externalPath = Environment.getExternalStorageDirectory().getAbsolutePath(); - if (!path.getPath().startsWith(externalPath)) { + if (!path.startsWith(externalPath)) { throw new SecurityException("Destination must be on external storage: " + uri); } } |