Skip to content

Commit 0df5b48

Browse files
author
qimengp
committed
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
1 parent 1243fa7 commit 0df5b48

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src_pd/com/android/camera/util/IntentHelper.java

100644100755
+20-3
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,38 @@
1717

1818
import android.content.Context;
1919
import android.content.Intent;
20+
import android.content.pm.ApplicationInfo;
21+
import android.content.pm.PackageManager;
2022
import android.net.Uri;
2123

2224
public class IntentHelper {
2325

2426
private static final String GALLERY_PACKAGE_NAME = "com.android.gallery3d";
27+
private static final String SNAPDRAGON_GALLERY_PACKAGE_NAME = "org.codeaurora.gallery";
2528
private static final String GALLERY_ACTIVITY_CLASS =
26-
"com.android.gallery3d.app.GalleryActivity";
29+
"com.android.gallery3d.app.GalleryActivity";
2730

2831
public static Intent getGalleryIntent(Context context) {
32+
String packageName = packageExist(context, SNAPDRAGON_GALLERY_PACKAGE_NAME) ?
33+
SNAPDRAGON_GALLERY_PACKAGE_NAME : GALLERY_PACKAGE_NAME;
2934
return new Intent(Intent.ACTION_MAIN)
30-
.setClassName(GALLERY_PACKAGE_NAME, GALLERY_ACTIVITY_CLASS);
35+
.setClassName(packageName, GALLERY_ACTIVITY_CLASS);
3136
}
3237

3338
public static Intent getVideoPlayerIntent(Context context, Uri uri) {
3439
return new Intent(Intent.ACTION_VIEW)
35-
.setDataAndType(uri, "video/*");
40+
.setDataAndType(uri, "video/*");
41+
}
42+
43+
private static boolean packageExist(Context context, String packageName) {
44+
if (packageName == null || "".equals(packageName)) {
45+
return false;
46+
}
47+
try {
48+
context.getPackageManager().getApplicationInfo(packageName, 0);
49+
return true;
50+
} catch (PackageManager.NameNotFoundException e) {
51+
return false;
52+
}
3653
}
3754
}

0 commit comments

Comments
 (0)