From 504eef3b38ca39f932955b0f3c318278ca75f1fe Mon Sep 17 00:00:00 2001 From: qimengp Date: Fri, 29 Jul 2016 14:16:29 +0800 Subject: SnapdragonCamera: Fix view video in Gallery the init state not pause Gallery app package name has been changed. so Camera cannot find the its name, and start with a common action "Intent.ACTION_VIEW" instead which is only to play the current video. Use a package name check for original Gallery and our new Gallery can be better compatible, and can fix this issue. Change-Id: I42863c00769093fab7629898298842fbf5b4ce9d --- src_pd/com/android/camera/util/IntentHelper.java | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) mode change 100644 => 100755 src_pd/com/android/camera/util/IntentHelper.java diff --git a/src_pd/com/android/camera/util/IntentHelper.java b/src_pd/com/android/camera/util/IntentHelper.java old mode 100644 new mode 100755 index 6f17a624b..7949eca2a --- a/src_pd/com/android/camera/util/IntentHelper.java +++ b/src_pd/com/android/camera/util/IntentHelper.java @@ -17,21 +17,38 @@ package com.android.camera.util; import android.content.Context; import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; import android.net.Uri; public class IntentHelper { private static final String GALLERY_PACKAGE_NAME = "com.android.gallery3d"; + private static final String SNAPDRAGON_GALLERY_PACKAGE_NAME = "org.codeaurora.gallery"; private static final String GALLERY_ACTIVITY_CLASS = - "com.android.gallery3d.app.GalleryActivity"; + "com.android.gallery3d.app.GalleryActivity"; public static Intent getGalleryIntent(Context context) { + String packageName = packageExist(context, SNAPDRAGON_GALLERY_PACKAGE_NAME) ? + SNAPDRAGON_GALLERY_PACKAGE_NAME : GALLERY_PACKAGE_NAME; return new Intent(Intent.ACTION_MAIN) - .setClassName(GALLERY_PACKAGE_NAME, GALLERY_ACTIVITY_CLASS); + .setClassName(packageName, GALLERY_ACTIVITY_CLASS); } public static Intent getVideoPlayerIntent(Context context, Uri uri) { return new Intent(Intent.ACTION_VIEW) - .setDataAndType(uri, "video/*"); + .setDataAndType(uri, "video/*"); + } + + private static boolean packageExist(Context context, String packageName) { + if (packageName == null || "".equals(packageName)) { + return false; + } + try { + context.getPackageManager().getApplicationInfo(packageName, 0); + return true; + } catch (PackageManager.NameNotFoundException e) { + return false; + } } } -- cgit v1.2.3