diff options
author | Michael W <baddaemon87@gmail.com> | 2016-05-23 13:17:28 +0200 |
---|---|---|
committer | LuK1337 <priv.luk@gmail.com> | 2019-10-21 21:40:56 +0200 |
commit | ab9effefd018c737d0e77ad11728f80cc4fa43ef (patch) | |
tree | ff272c82415fcf9767fb8976de0d2b701b8805c1 | |
parent | d766ecf7d8247250830ee0063ac55fb9849a5151 (diff) | |
download | android_packages_apps_Gallery2-ab9effefd018c737d0e77ad11728f80cc4fa43ef.tar.gz android_packages_apps_Gallery2-ab9effefd018c737d0e77ad11728f80cc4fa43ef.tar.bz2 android_packages_apps_Gallery2-ab9effefd018c737d0e77ad11728f80cc4fa43ef.zip |
Gallery2: Try to open existing camera
Do not just open Camera2, just open any existing cam
Also get rid of context parameter as it's unused
(Reference: BugReports 13-20160506-12 Line #5)
Change-Id: I120a1561aeceda2fc23721aa2ff4d68710fab76c
-rw-r--r-- | src/com/android/camera/CameraActivity.java | 18 | ||||
-rw-r--r-- | src/com/android/gallery3d/app/Gallery.java | 2 | ||||
-rw-r--r-- | src/com/android/gallery3d/util/GalleryUtils.java | 2 | ||||
-rw-r--r-- | src_pd/com/android/gallery3d/util/IntentHelper.java | 9 |
4 files changed, 17 insertions, 14 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index b74af47b3..9462aed38 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -15,6 +15,7 @@ */ package com.android.camera; +import com.android.gallery3d.util.GalleryUtils; import com.android.gallery3d.util.IntentHelper; import android.app.Activity; @@ -26,13 +27,16 @@ public class CameraActivity extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); - Intent intent = IntentHelper.getCameraIntent(CameraActivity.this); - // Since this is being launched from a homescreen shorcut, - // it's already in a new task. Start Camera activity and - // reset the task to its initial state if needed. - intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); + + if (GalleryUtils.isCameraAvailable(CameraActivity.this)) { + Intent intent = IntentHelper.getCameraIntent(); + // Since this is being launched from a homescreen shorcut, + // it's already in a new task. Start Camera activity and + // reset the task to its initial state if needed. + intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } finish(); } } diff --git a/src/com/android/gallery3d/app/Gallery.java b/src/com/android/gallery3d/app/Gallery.java index fd9097d29..df3c0f957 100644 --- a/src/com/android/gallery3d/app/Gallery.java +++ b/src/com/android/gallery3d/app/Gallery.java @@ -26,7 +26,7 @@ public class Gallery extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - Intent intent = IntentHelper.getGalleryIntent(Gallery.this); + Intent intent = IntentHelper.getGalleryIntent(); // Since this is being launched from a homescreen shortcut, // it's already in a new task. Start Gallery activity and // reset the task to its initial state if needed. diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java index ee355b41a..c62442d9a 100644 --- a/src/com/android/gallery3d/util/GalleryUtils.java +++ b/src/com/android/gallery3d/util/GalleryUtils.java @@ -239,7 +239,7 @@ public class GalleryUtils { public static boolean isCameraAvailable(Context context) { if (sCameraAvailableInitialized) return sCameraAvailable; PackageManager pm = context.getPackageManager(); - Intent cameraIntent = IntentHelper.getCameraIntent(context); + Intent cameraIntent = IntentHelper.getCameraIntent(); List<ResolveInfo> apps = pm.queryIntentActivities(cameraIntent, 0); sCameraAvailableInitialized = true; sCameraAvailable = !apps.isEmpty(); diff --git a/src_pd/com/android/gallery3d/util/IntentHelper.java b/src_pd/com/android/gallery3d/util/IntentHelper.java index 8aebfc1fd..d0fb59ae8 100644 --- a/src_pd/com/android/gallery3d/util/IntentHelper.java +++ b/src_pd/com/android/gallery3d/util/IntentHelper.java @@ -15,17 +15,16 @@ */ package com.android.gallery3d.util; -import android.content.Context; import android.content.Intent; +import android.provider.MediaStore; public class IntentHelper { - public static Intent getCameraIntent(Context context) { - return new Intent(Intent.ACTION_MAIN) - .setClassName("com.android.camera2", "com.android.camera.CameraLauncher"); + public static Intent getCameraIntent() { + return new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); } - public static Intent getGalleryIntent(Context context) { + public static Intent getGalleryIntent() { return new Intent(Intent.ACTION_MAIN) .setClassName("com.android.gallery3d", "com.android.gallery3d.app.GalleryActivity"); } |