summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordianlujitao <dianlujitao@lineageos.org>2018-12-19 13:59:45 +0800
committerdianlujitao <dianlujitao@lineageos.org>2018-12-19 13:59:45 +0800
commit11e0f6e0fafc8694294076a4ba7fcb4f1b933479 (patch)
tree43391da3b06b321bf304911dc7b68f104e6c1b42
parentde505919d978eeb62ffedb4ea8e0e98fa7888e05 (diff)
downloadandroid_packages_apps_Snap-11e0f6e0fafc8694294076a4ba7fcb4f1b933479.zip
android_packages_apps_Snap-11e0f6e0fafc8694294076a4ba7fcb4f1b933479.tar.gz
android_packages_apps_Snap-11e0f6e0fafc8694294076a4ba7fcb4f1b933479.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()