diff options
| author | yongga <yongga@codeaurora.org> | 2016-01-13 19:28:54 +0800 |
|---|---|---|
| committer | yongga <yongga@codeaurora.org> | 2016-01-13 19:28:54 +0800 |
| commit | 6a3206462ab29390ec31fc62e75f71b037bab353 (patch) | |
| tree | c1ee2ad17e2a6bcdf52fbd8f46a2a6c230fe7789 /src/com | |
| parent | 24af2c506c4b7ad200669cc951c43f664228eac9 (diff) | |
| download | android_packages_apps_Gallery2-6a3206462ab29390ec31fc62e75f71b037bab353.tar.gz android_packages_apps_Gallery2-6a3206462ab29390ec31fc62e75f71b037bab353.tar.bz2 android_packages_apps_Gallery2-6a3206462ab29390ec31fc62e75f71b037bab353.zip | |
Gallery2: fix a crash when print a photo received from Bluetooth.
An IllegalArgumentException occurs when getLocalPathFromUri().
catch this Exception and ensure print job work normally.
Change-Id: I6c1f9912ac58ea23224c420da6327475a6935267
CRs-Fixed: 960251
Diffstat (limited to 'src/com')
| -rw-r--r-- | src/com/android/gallery3d/app/AbstractGalleryActivity.java | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index b9007d57e..a7c54ee29 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -366,23 +366,32 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext if (uri == null) { return; } - String path = ImageLoader.getLocalPathFromUri(this, uri); - if (path != null) { - path = getLastPathSegment(path); - } else { - path = uri.getLastPathSegment(); - } + String printJobName = getLastPathSegment(uri); PrintHelper printer = new PrintHelper(this); try { - printer.printBitmap(path, uri); + printer.printBitmap(printJobName, uri); } catch (FileNotFoundException fnfe) { Log.e(TAG, "Error printing an image", fnfe); } } - private String getLastPathSegment(String path) { - if (path == null) return null; - Uri localUri = Uri.parse(path); + private String getLastPathSegment(Uri uri) { + String path = ""; + if (uri == null) return path; + try { + path = ImageLoader.getLocalPathFromUri(this, uri); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + + Uri localUri; + if (path != null) { + localUri = Uri.parse(path); + } else { + path = uri.getPath(); + localUri = uri; + } + String lastPathSegment = localUri.getLastPathSegment(); // uri.getLastPathSegment will return null if localUri contains |
