summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/camera/AndroidCameraManagerImpl.java43
-rw-r--r--src/com/android/camera/app/CameraApp.java7
2 files changed, 39 insertions, 11 deletions
diff --git a/src/com/android/camera/AndroidCameraManagerImpl.java b/src/com/android/camera/AndroidCameraManagerImpl.java
index b151c1914..74f822694 100644
--- a/src/com/android/camera/AndroidCameraManagerImpl.java
+++ b/src/com/android/camera/AndroidCameraManagerImpl.java
@@ -21,10 +21,12 @@ import static com.android.camera.util.CameraUtil.Assert;
import java.io.IOException;
import android.annotation.TargetApi;
+import android.content.Context;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.AutoFocusMoveCallback;
+import android.hardware.Camera.CameraInfo;
import android.hardware.Camera.ErrorCallback;
import android.hardware.Camera.FaceDetectionListener;
import android.hardware.Camera.OnZoomChangeListener;
@@ -45,6 +47,10 @@ import com.android.camera.util.ApiHelper;
import android.os.ConditionVariable;
import java.lang.reflect.Method;
+import com.android.camera.app.CameraApp;
+
+import org.codeaurora.snapcam.R;
+
/**
* A class to implement {@link CameraManager} of the Android camera framework.
*/
@@ -207,23 +213,38 @@ class AndroidCameraManagerImpl implements CameraManager {
try {
switch (msg.what) {
case OPEN_CAMERA:
- try {
- Method openMethod = Class.forName("android.hardware.Camera").getMethod(
- "openLegacy", int.class, int.class);
- mCamera = (android.hardware.Camera) openMethod.invoke(
- null, msg.arg1, CAMERA_HAL_API_VERSION_1_0);
- } catch (Exception e) {
- /* Retry with open if openLegacy doesn't exist/fails */
- Log.v(TAG, "openLegacy failed due to " + e.getMessage()
- + ", using open instead");
- mCamera = android.hardware.Camera.open(msg.arg1);
+ int cameraId = msg.arg1;
+ Context context = CameraApp.getContext();
+
+ boolean backCameraOpenLegacy = context.getResources().
+ getBoolean(R.bool.back_camera_open_legacy);
+ boolean frontCameraOpenLegacy = context.getResources().
+ getBoolean(R.bool.front_camera_open_legacy);
+
+ CameraInfo info = CameraHolder.instance().getCameraInfo()[cameraId];
+
+ if (info.facing == CameraInfo.CAMERA_FACING_BACK && backCameraOpenLegacy ||
+ info.facing == CameraInfo.CAMERA_FACING_FRONT && frontCameraOpenLegacy) {
+ try {
+ Method openMethod = Class.forName("android.hardware.Camera").getMethod(
+ "openLegacy", int.class, int.class);
+ mCamera = (android.hardware.Camera) openMethod.invoke(
+ null, cameraId, CAMERA_HAL_API_VERSION_1_0);
+ } catch (Exception e) {
+ /* Retry with open if openLegacy doesn't exist/fails */
+ Log.v(TAG, "openLegacy failed due to " + e.getMessage()
+ + ", using open instead");
+ mCamera = android.hardware.Camera.open(cameraId);
+ }
+ } else {
+ mCamera = android.hardware.Camera.open(cameraId);
}
if (mCamera != null) {
mParametersIsDirty = true;
} else {
if (msg.obj != null) {
- ((CameraOpenErrorCallback) msg.obj).onDeviceOpenFailure(msg.arg1);
+ ((CameraOpenErrorCallback) msg.obj).onDeviceOpenFailure(cameraId);
}
}
return;
diff --git a/src/com/android/camera/app/CameraApp.java b/src/com/android/camera/app/CameraApp.java
index 6261159ec..3c1381f4d 100644
--- a/src/com/android/camera/app/CameraApp.java
+++ b/src/com/android/camera/app/CameraApp.java
@@ -19,12 +19,14 @@ package com.android.camera.app;
import android.app.ActivityManager;
import android.app.Application;
+import android.content.Context;
import com.android.camera.SDCard;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.UsageStatistics;
public class CameraApp extends Application {
+ private static Application mApp = null;
private static long mMaxSystemMemory;
public static boolean mIsLowMemoryDevice = false;
private static final long LOW_MEMORY_DEVICE_THRESHOLD = 2L*1024*1024*1024;
@@ -32,6 +34,7 @@ public class CameraApp extends Application {
@Override
public void onCreate() {
super.onCreate();
+ mApp = this;
ActivityManager actManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
actManager.getMemoryInfo(memInfo);
@@ -44,4 +47,8 @@ public class CameraApp extends Application {
CameraUtil.initialize(this);
SDCard.initialize(this);
}
+
+ public static Context getContext() {
+ return mApp.getApplicationContext();
+ }
}