summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByunghun Jeon <bjeon@codeaurora.org>2016-05-17 17:42:36 -0700
committerSteve Kondik <steve@cyngn.com>2016-08-21 18:45:51 -0700
commit34bc69174e257aba8b180d3a4cccc0fbdecc2687 (patch)
treef2f647efd9ebac045342e8c1ff39d4c0ac079bd5
parentd0493a008e85841baf4d6ab83921011c537942d5 (diff)
downloadandroid_packages_apps_Snap-34bc69174e257aba8b180d3a4cccc0fbdecc2687.zip
android_packages_apps_Snap-34bc69174e257aba8b180d3a4cccc0fbdecc2687.tar.gz
android_packages_apps_Snap-34bc69174e257aba8b180d3a4cccc0fbdecc2687.tar.bz2
SnapdragonCamera: Fix front camera and scene mode picture taking issues
Fix front camera picture taking issues. Fix scene mode picture taking issues. For both front camera and scene mode issue, focus state was not updating properly so it was stuck waiting for focus to finish. So added another logic to check such case and continue to next step. Change-Id: I99d2164a77cc2903f3df50c7ff9478e718b112c0 CRs-Fixed: 1018118
-rw-r--r--res/values/camera2arrays.xml4
-rw-r--r--src/com/android/camera/CaptureModule.java47
-rw-r--r--src/com/android/camera/CaptureUI.java9
-rw-r--r--src/com/android/camera/SettingsManager.java18
4 files changed, 61 insertions, 17 deletions
diff --git a/res/values/camera2arrays.xml b/res/values/camera2arrays.xml
index 8e54a2a..9b7db30 100644
--- a/res/values/camera2arrays.xml
+++ b/res/values/camera2arrays.xml
@@ -83,11 +83,11 @@
<!-- Refer to CONTROL_SCENE_MODE of Camera2 API for values
-1 refers to ones not supported in Camera2 API
0 is special case added for auto (meaning off)
- -5 is for dual mode
+ 100 is for dual mode (Custom-Scenemodes start from 100)
-->
<string-array name="pref_camera2_scenemode_entryvalues" translatable="false">
<item>0</item>
- <item>-5</item>
+ <item>100</item>
<item>18</item>
<item>-1</item>
<item>-1</item>
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index ab2c886..a4658da 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -207,6 +207,7 @@ public class CaptureModule implements CameraModule, PhotoController,
private int mJpegFileSizeEstimation;
private boolean mFirstPreviewLoaded;
private int[] mPrecaptureRequestHashCode = new int[MAX_NUM_CAM];
+ private int[] mLockRequestHashCode = new int[MAX_NUM_CAM];
private class MediaSaveNotifyThread extends Thread {
private Uri uri;
@@ -318,7 +319,9 @@ public class CaptureModule implements CameraModule, PhotoController,
if (CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState ||
CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState ||
CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED == afState ||
- CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED == afState) {
+ CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED == afState ||
+ (mLockRequestHashCode[id] == result.getRequest().hashCode() &&
+ afState == CaptureResult.CONTROL_AF_STATE_INACTIVE)) {
// CONTROL_AE_STATE can be null on some devices
if (aeState == null || (aeState == CaptureResult
.CONTROL_AE_STATE_CONVERGED) && isFlashOff(id)) {
@@ -453,7 +456,7 @@ public class CaptureModule implements CameraModule, PhotoController,
private int getCameraMode() {
String value = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
- if (value != null && value.equals("-5")) return DUAL_MODE;
+ if (value != null && value.equals(SettingsManager.SCENE_MODE_DUAL_STRING)) return DUAL_MODE;
value = mSettingsManager.getValue(SettingsManager.KEY_MONO_ONLY);
if (value == null || !value.equals("on")) return BAYER_MODE;
return MONO_MODE;
@@ -696,9 +699,10 @@ public class CaptureModule implements CameraModule, PhotoController,
builder.addTarget(getPreviewSurface(id));
applySettingsForLockFocus(builder, id);
-
+ CaptureRequest request = builder.build();
+ mLockRequestHashCode[id] = request.hashCode();
mState[id] = STATE_WAITING_LOCK;
- mCaptureSession[id].capture(builder.build(), mCaptureCallback, mCameraHandler);
+ mCaptureSession[id].capture(request, mCaptureCallback, mCameraHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
@@ -770,7 +774,7 @@ public class CaptureModule implements CameraModule, PhotoController,
// Orientation
int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
- captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATIONS.get(rotation));
+ captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, CameraUtil.getJpegRotation(id, rotation));
captureBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
captureBuilder.addTarget(getPreviewSurface(id));
captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, mControlAFMode);
@@ -1223,6 +1227,7 @@ public class CaptureModule implements CameraModule, PhotoController,
} else {
initializeSecondTime();
}
+ mUI.reInitUI();
mActivity.updateStorageSpaceAndHint();
estimateJpegFileSize();
mUI.enableShutter(true);
@@ -1388,13 +1393,27 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
- public boolean isTouchToFocusAllowed() {
+ public boolean isTakingPicture() {
for (int i = 0; i < mTakingPicture.length; i++) {
- if (mTakingPicture[i]) return false;
+ if (mTakingPicture[i]) return true;
}
+ return false;
+ }
+
+ private boolean isTouchToFocusAllowed() {
+ if (isTakingPicture() || isSceneModeOn()) return false;
return true;
}
+ private boolean isSceneModeOn() {
+ String scene = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
+ if (scene == null) return false;
+ int mode = Integer.parseInt(scene);
+ if (mode != SettingsManager.SCENE_MODE_DUAL_INT && mode != CaptureRequest
+ .CONTROL_SCENE_MODE_DISABLED) return true;
+ return false;
+ }
+
@Override
public void onCountDownFinished() {
mUI.showUIAfterCountDown();
@@ -1690,6 +1709,10 @@ public class CaptureModule implements CameraModule, PhotoController,
updatePreview = true;
applyFlash(mPreviewRequestBuilder[cameraId], cameraId);
break;
+ case SettingsManager.KEY_ISO:
+ updatePreview = true;
+ applyIso(mPreviewRequestBuilder[cameraId]);
+ break;
}
return updatePreview;
}
@@ -1720,7 +1743,8 @@ public class CaptureModule implements CameraModule, PhotoController,
String value = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
if (value == null) return;
int mode = Integer.parseInt(value);
- if (mode != CaptureRequest.CONTROL_SCENE_MODE_DISABLED && mode != -5) {
+ if (mode != CaptureRequest.CONTROL_SCENE_MODE_DISABLED && mode !=
+ SettingsManager.SCENE_MODE_DUAL_INT) {
request.set(CaptureRequest.CONTROL_SCENE_MODE, mode);
request.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_USE_SCENE_MODE);
} else {
@@ -1945,9 +1969,12 @@ public class CaptureModule implements CameraModule, PhotoController,
}
private int mCurrentMode;
+
private boolean checkNeedToRestart(String value) {
- if (value.equals("-5") && mCurrentMode != DUAL_MODE) return true;
- if (!value.equals("-5") && mCurrentMode == DUAL_MODE) return true;
+ if (value.equals(SettingsManager.SCENE_MODE_DUAL_STRING) && mCurrentMode != DUAL_MODE)
+ return true;
+ if (!value.equals(SettingsManager.SCENE_MODE_DUAL_STRING) && mCurrentMode == DUAL_MODE)
+ return true;
return false;
}
diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java
index f474015..5010457 100644
--- a/src/com/android/camera/CaptureUI.java
+++ b/src/com/android/camera/CaptureUI.java
@@ -90,7 +90,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
SettingsManager.KEY_TIMER,
SettingsManager.KEY_CAMERA_SAVEPATH,
SettingsManager.KEY_LONGSHOT,
- SettingsManager.KEY_ISO,
SettingsManager.KEY_EXPOSURE,
SettingsManager.KEY_WHITE_BALANCE,
SettingsManager.KEY_CAMERA2
@@ -275,6 +274,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
return mSceneAndFilterLayout;
}
+ public void reInitUI() {
+ initializeSettingMenu();
+ initSceneModeButton();
+ initFilterModeButton();
+ }
+
// called from onResume but only the first time
public void initializeFirstTime() {
// Initialize shutter button.
@@ -987,7 +992,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
mThumbnail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (!CameraControls.isAnimating() && mModule.isTouchToFocusAllowed())
+ if (!CameraControls.isAnimating() && !mModule.isTakingPicture())
mActivity.gotoGallery();
}
});
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
index 86ecd62..a01d254 100644
--- a/src/com/android/camera/SettingsManager.java
+++ b/src/com/android/camera/SettingsManager.java
@@ -57,6 +57,9 @@ import java.util.Set;
public class SettingsManager implements ListMenu.SettingsListener {
public static final int RESOURCE_TYPE_THUMBNAIL = 0;
public static final int RESOURCE_TYPE_LARGEICON = 1;
+ // Custom-Scenemodes start from 100
+ public static final int SCENE_MODE_DUAL_INT = 100;
+ public static final String SCENE_MODE_DUAL_STRING = "100";
public static final String KEY_CAMERA_SAVEPATH = "pref_camera2_savepath_key";
public static final String KEY_RECORD_LOCATION = "pref_camera2_recordlocation_key";
public static final String KEY_JPEG_QUALITY = "pref_camera2_jpegquality_key";
@@ -80,7 +83,6 @@ public class SettingsManager implements ListMenu.SettingsListener {
public static final String KEY_INITIAL_CAMERA = "pref_camera2_initial_camera_key";
private static final String TAG = "SnapCam_SettingsManager";
private static final List<CameraCharacteristics> mCharacteristics = new ArrayList<>();
- private static final int NOT_FOUND = -1;
private static SettingsManager sInstance;
@@ -636,6 +638,16 @@ public class SettingsManager implements ListMenu.SettingsListener {
return maxAfRegions != null && maxAfRegions > 0;
}
+ public boolean isFixedFocus(int id) {
+ Float focusDistance = mCharacteristics.get(id).get(CameraCharacteristics
+ .LENS_INFO_MINIMUM_FOCUS_DISTANCE);
+ if (focusDistance == null || focusDistance == 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public boolean isFlashSupported(int id) {
return mCharacteristics.get(id).get(CameraCharacteristics.FLASH_INFO_AVAILABLE) &&
mValuesMap.get(KEY_FLASH_MODE) != null;
@@ -667,7 +679,7 @@ public class SettingsManager implements ListMenu.SettingsListener {
.CONTROL_AVAILABLE_SCENE_MODES);
List<String> modes = new ArrayList<>();
modes.add("0"); // need special case handle for auto scene mode
- if (mIsMonoCameraPresent) modes.add("-5"); // need special case handle for dual mode
+ if (mIsMonoCameraPresent) modes.add(SCENE_MODE_DUAL_STRING); // need special case handle for dual mode
for (int mode : sceneModes) {
modes.add("" + mode);
}
@@ -730,7 +742,7 @@ public class SettingsManager implements ListMenu.SettingsListener {
dependency.add(new KeyValue(KEY_CLEARSIGHT, "off"));
dependency.add(new KeyValue(KEY_MONO_PREVIEW, "off"));
break;
- case "-5":
+ case SCENE_MODE_DUAL_STRING:
dependency.add(new KeyValue(KEY_LONGSHOT, "off"));
dependency.add(new KeyValue(KEY_MONO_ONLY, "off"));
break;