summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordianlujitao <dianlujitao@lineageos.org>2018-12-19 13:59:45 +0800
committerMichael Bestas <mkbestas@lineageos.org>2019-11-09 22:47:37 +0200
commite7c1dcf8673fda50a93d5dca9926385b4b39719a (patch)
treee668af85c26f3fcbc87ae5692f766c50373a9f1f
parent751504ff01632d6a97163a42360b980dd1f1d89b (diff)
downloadandroid_packages_apps_Snap-e7c1dcf8673fda50a93d5dca9926385b4b39719a.zip
android_packages_apps_Snap-e7c1dcf8673fda50a93d5dca9926385b4b39719a.tar.gz
android_packages_apps_Snap-e7c1dcf8673fda50a93d5dca9926385b4b39719a.tar.bz2
DisableCameraReceiver: Initialize CameraHolder before use
Change-Id: If4c38d19d3c88317ddd4f651acea5e036dbe8544
-rw-r--r--src/com/android/camera/DisableCameraReceiver.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/com/android/camera/DisableCameraReceiver.java b/src/com/android/camera/DisableCameraReceiver.java
index 3551a43..6248741 100644
--- a/src/com/android/camera/DisableCameraReceiver.java
+++ b/src/com/android/camera/DisableCameraReceiver.java
@@ -23,6 +23,8 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.Camera.CameraInfo;
import android.util.Log;
+import com.android.camera.util.CameraUtil;
+import org.codeaurora.snapcam.R;
// We want to disable camera-related activities if there is no camera. This
// receiver runs when BOOT_COMPLETED intent is received. After running once
@@ -33,9 +35,21 @@ public class DisableCameraReceiver extends BroadcastReceiver {
private static final String ACTIVITIES[] = {
"com.android.camera.CameraLauncher",
};
+ private boolean mCamera2supported = false;
+ private boolean mCamera2enabled = false;
@Override
public void onReceive(Context context, Intent intent) {
+ // Check if the device supports Camera API 2
+ mCamera2supported = CameraUtil.isCamera2Supported(context);
+ Log.d(TAG, "Camera API 2 supported: " + mCamera2supported);
+
+ mCamera2enabled = mCamera2supported &&
+ context.getResources().getBoolean(R.bool.support_camera_api_v2);
+ Log.d(TAG, "Camera API 2 enabled: " + mCamera2enabled);
+
+ CameraHolder.setCamera2Mode(context, mCamera2enabled);
+
// Disable camera-related activities if there is no camera.
boolean needCameraActivity = CHECK_BACK_CAMERA_ONLY
? hasBackCamera()