Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2229a8f7 authored by Mangesh Ghiware's avatar Mangesh Ghiware Committed by Android Git Automerger
Browse files

am b6892ab9: Consider camera available only if intent resolves to an activity.

* commit 'b6892ab9':
  Consider camera available only if intent resolves to an activity.
parents c96c059e b6892ab9
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.ui.TiledScreenNail;
import com.android.gallery3d.util.IntentHelper;
import com.android.gallery3d.util.ThreadPool.CancelListener;
import com.android.gallery3d.util.ThreadPool.JobContext;

@@ -235,12 +236,10 @@ public class GalleryUtils {
    public static boolean isCameraAvailable(Context context) {
        if (sCameraAvailableInitialized) return sCameraAvailable;
        PackageManager pm = context.getPackageManager();
        ComponentName name = new ComponentName(context, CAMERA_LAUNCHER_NAME);
        int state = pm.getComponentEnabledSetting(name);
        Intent cameraIntent = IntentHelper.getCameraIntent(context);
        List<ResolveInfo> apps = pm.queryIntentActivities(cameraIntent, 0);
        sCameraAvailableInitialized = true;
        sCameraAvailable =
           (state == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)
           || (state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
        sCameraAvailable = !apps.isEmpty();
        return sCameraAvailable;
    }

+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ public class IntentHelper {

    public static Intent getCameraIntent(Context context) {
        return new Intent(Intent.ACTION_MAIN)
            .setClassName("com.android.camera2", "com.android.camera.CameraActivity");
            .setClassName("com.android.camera2", "com.android.camera.CameraLauncher");
    }

    public static Intent getGalleryIntent(Context context) {