summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjinwu <jinwu@codeaurora.org>2017-02-09 18:43:53 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2017-02-16 00:03:38 -0800
commit88d617210005ffdbbd72e1cf0a779fb686a7e8c8 (patch)
treed13dfc71c62f37076f41fd61cd580da78ce1f562
parent63948b5c01ae00b82e385b7502f0e626b24e7e09 (diff)
downloadandroid_packages_apps_Gallery2-88d617210005ffdbbd72e1cf0a779fb686a7e8c8.tar.gz
android_packages_apps_Gallery2-88d617210005ffdbbd72e1cf0a779fb686a7e8c8.tar.bz2
android_packages_apps_Gallery2-88d617210005ffdbbd72e1cf0a779fb686a7e8c8.zip
SnapdragonGallery: Fix crash of viewing download uri
Check the permission and flag before viewing downloan uri to avoid app's crash. Change-Id: I32bfb4a9c8230500d2f2e4750232fc1ac2f1ad61 CRs-Fixed: 2003220
-rwxr-xr-xsrc/com/android/gallery3d/app/GalleryActivity.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java
index bdcc0c6b4..9f4b8eeb3 100755
--- a/src/com/android/gallery3d/app/GalleryActivity.java
+++ b/src/com/android/gallery3d/app/GalleryActivity.java
@@ -27,6 +27,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
+import android.content.UriMatcher;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
@@ -91,6 +92,17 @@ public final class GalleryActivity extends AbstractGalleryActivity implements On
public static final String KEY_FROM_SNAPCAM = "from-snapcam";
public static final String KEY_TOTAL_NUMBER = "total-number";
+ private static final int ALL_DOWNLOADS = 1;
+ private static final int ALL_DOWNLOADS_ID = 2;
+ private static final UriMatcher sURIMatcher =
+ new UriMatcher(UriMatcher.NO_MATCH);
+ public static final String PERMISSION_ACCESS_ALL =
+ "android.permission.ACCESS_ALL_DOWNLOADS";
+ static {
+ sURIMatcher.addURI("downloads", "all_downloads", ALL_DOWNLOADS);
+ sURIMatcher.addURI("downloads", "all_downloads/#", ALL_DOWNLOADS_ID);
+ }
+
private static final String TAG = "GalleryActivity";
private Dialog mVersionCheckDialog;
private ListView mDrawerListView;
@@ -366,6 +378,17 @@ public final class GalleryActivity extends AbstractGalleryActivity implements On
} else if (Intent.ACTION_VIEW.equalsIgnoreCase(action)
|| ACTION_REVIEW.equalsIgnoreCase(action)){
mDrawerLayoutSupported = false;
+ Uri uri = intent.getData();
+ int flag = intent.getFlags();
+ int match = sURIMatcher.match(uri);
+ if ((match == ALL_DOWNLOADS || match == ALL_DOWNLOADS_ID) &&
+ (flag & Intent.FLAG_GRANT_READ_URI_PERMISSION) == 0) {
+ if (checkCallingOrSelfPermission(
+ PERMISSION_ACCESS_ALL) != PackageManager.PERMISSION_GRANTED) {
+ Log.w(TAG, "no permission to view: " + uri);
+ return;
+ }
+ }
startViewAction(intent);
} else {
mDrawerLayoutSupported = true;