summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcodeworkx <codeworkx@cyanogenmod.org>2016-12-26 20:47:16 +0100
committerArne Coucheron <arco68@gmail.com>2018-01-27 00:41:41 +0100
commitba57c48121628a3bb8ebf160d8ba3233e1de19ef (patch)
treed5448f1eb1181e5891c5f37f943b71610ef4b57d
parenteaad57426c2bb2a0e61a65b24ba1c7feeccf3255 (diff)
downloadandroid_packages_apps_Snap-ba57c48121628a3bb8ebf160d8ba3233e1de19ef.zip
android_packages_apps_Snap-ba57c48121628a3bb8ebf160d8ba3233e1de19ef.tar.gz
android_packages_apps_Snap-ba57c48121628a3bb8ebf160d8ba3233e1de19ef.tar.bz2
Snap: CaptureModule: check if ZSL is supported before using it
Change-Id: Ifde34ce367ceeb19ad71bcff0c4518d578bb52a5
-rwxr-xr-xsrc/com/android/camera/CaptureModule.java58
-rw-r--r--src/com/android/camera/SettingsManager.java13
-rwxr-xr-xsrc/com/android/camera/imageprocessor/PostProcessor.java44
3 files changed, 70 insertions, 45 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 506c323..61aaf9d 100755
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -294,7 +294,7 @@ public class CaptureModule implements CameraModule, PhotoController,
private float mZoomValue = 1f;
private FocusStateListener mFocusStateListener;
private LocationManager mLocationManager;
- private SettingsManager mSettingsManager;
+ public SettingsManager mSettingsManager;
private long SECONDARY_SERVER_MEM;
private boolean mLongshotActive = false;
private CameraCharacteristics mMainCameraCharacteristics;
@@ -1775,7 +1775,9 @@ public class CaptureModule implements CameraModule, PhotoController,
* @param width The width of available size for camera preview
* @param height The height of available size for camera preview
*/
- private void setUpCameraOutputs(int imageFormat) {
+ private void setUpCameraOutputs(boolean isFilterOrZslEnabled) {
+ int imageFormat = ImageFormat.JPEG;
+
Log.d(TAG, "setUpCameraOutputs");
CameraManager manager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
try {
@@ -1784,6 +1786,8 @@ public class CaptureModule implements CameraModule, PhotoController,
String cameraId = cameraIdList[i];
CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
+ int [] capabilities = characteristics.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
+
if (isInMode(i))
mCameraIdList.add(i);
if(i == getMainCameraId()) {
@@ -1798,6 +1802,21 @@ public class CaptureModule implements CameraModule, PhotoController,
}
mCameraId[i] = cameraId;
+ // Set ImageFormat for ZSL
+ if (isFilterOrZslEnabled) {
+ for (int capability : capabilities) {
+ // YUV has higher priority
+ if (capability == CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING) {
+ Log.d(TAG, "ImageFormat: YUV_420_888");
+ imageFormat = ImageFormat.YUV_420_888;
+ break;
+ } else if (capability == CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING) {
+ Log.d(TAG, "ImageFormat: PRIVATE");
+ imageFormat = ImageFormat.PRIVATE;
+ }
+ }
+ }
+
if (isClearSightOn()) {
if(i == getMainCameraId()) {
// ClearSightImageProcessor.getInstance().init(map, mPictureSize.getWidth(),
@@ -2468,15 +2487,11 @@ public class CaptureModule implements CameraModule, PhotoController,
mFrameProcessor.onOpen(getFrameProcFilterId(), mPreviewSize);
}
- if(mPostProcessor.isZSLEnabled()) {
- mChosenImageFormat = ImageFormat.PRIVATE;
- } else if(mPostProcessor.isFilterOn() || getFrameFilters().size() != 0 || mPostProcessor.isSelfieMirrorOn()) {
- mChosenImageFormat = ImageFormat.YUV_420_888;
+ if(mPostProcessor.isFilterOn() || getFrameFilters().size() != 0 || mPostProcessor.isSelfieMirrorOn()) {
+ setUpCameraOutputs(true);
} else {
- mChosenImageFormat = ImageFormat.JPEG;
+ setUpCameraOutputs(false);
}
- setUpCameraOutputs(mChosenImageFormat);
-
}
@Override
@@ -2497,27 +2512,10 @@ public class CaptureModule implements CameraModule, PhotoController,
openProcessors();
Message msg = Message.obtain();
msg.what = OPEN_CAMERA;
- if (isBackCamera()) {
- switch (getCameraMode()) {
- case DUAL_MODE:
- case BAYER_MODE:
- msg.arg1 = BAYER_ID;
- mCameraHandler.sendMessage(msg);
- break;
- case MONO_MODE:
- msg.arg1 = MONO_ID;
- mCameraHandler.sendMessage(msg);
- break;
- case SWITCH_MODE:
- msg.arg1 = SWITCH_ID;
- mCameraHandler.sendMessage(msg);
- break;
- }
- } else {
- int cameraId = SWITCH_ID == -1? FRONT_ID : SWITCH_ID;
- msg.arg1 = cameraId;
- mCameraHandler.sendMessage(msg);
- }
+ int cameraId = getMainCameraId();
+ msg.arg1 = cameraId;
+ mCameraHandler.sendMessage(msg);
+
mUI.showSurfaceView();
if (!mFirstTimeInitialized) {
initializeFirstTime();
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
index 0108b09..30881ab 100644
--- a/src/com/android/camera/SettingsManager.java
+++ b/src/com/android/camera/SettingsManager.java
@@ -1124,6 +1124,19 @@ public class SettingsManager implements ListMenu.SettingsListener {
mValuesMap.get(KEY_FLASH_MODE) != null;
}
+ public boolean isZslSupported(int id) {
+ boolean zslSupported = false;
+ int [] capabilities = mCharacteristics.get(id).get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
+ for (int capability : capabilities) {
+ if (capability == CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING ||
+ capability == CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING) {
+ zslSupported = true;
+ }
+ }
+ Log.d(TAG, "isZslSupported=" + zslSupported);
+ return zslSupported;
+ }
+
private List<Size> getSupportedPictureSizeList(int cameraId) {
StreamConfigurationMap map = mCharacteristics.get(cameraId).get(
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
diff --git a/src/com/android/camera/imageprocessor/PostProcessor.java b/src/com/android/camera/imageprocessor/PostProcessor.java
index acaf9ea..f133c66 100755
--- a/src/com/android/camera/imageprocessor/PostProcessor.java
+++ b/src/com/android/camera/imageprocessor/PostProcessor.java
@@ -132,7 +132,7 @@ public class PostProcessor{
private CameraCaptureSession mCaptureSession;
private ImageReader mImageReader;
private ImageReader mZSLReprocessImageReader;
- private boolean mUseZSL = true;
+ private boolean mUseZSL = false;
private boolean mSaveRaw = false;
private Handler mZSLHandler;
private HandlerThread mZSLHandlerThread;
@@ -147,6 +147,14 @@ public class PostProcessor{
private int mPendingContinuousRequestCount = 0;
public int mMaxRequiredImageNum;
+ private void checkAndEnableZSL(int cameraId) {
+ if (mController.mSettingsManager.isZslSupported(cameraId)) {
+ mUseZSL = true;
+ } else {
+ mUseZSL = false;
+ }
+ }
+
public int getMaxRequiredImageNum() {
return mMaxRequiredImageNum;
}
@@ -619,6 +627,7 @@ public class PostProcessor{
public PostProcessor(CameraActivity activity, CaptureModule module) {
mController = module;
mActivity = activity;
+ checkAndEnableZSL(mController.getMainCameraId());
mNamedImages = new PhotoModule.NamedImages();
}
@@ -679,21 +688,26 @@ public class PostProcessor{
boolean isSupportedQcfa) {
mImageHandlerTask = new ImageHandlerTask();
mSaveRaw = isSaveRaw;
- if(setFilter(postFilterId) || isFlashModeOn || isTrackingFocusOn || isMakeupOn || isSelfieMirrorOn
- || PersistUtil.getCameraZSLDisabled()
- || !SettingsManager.getInstance().isZSLInAppEnabled()
- || SettingsManager.SCENE_MODE_BOKEH_STRING.equals(
- SettingsManager.getInstance().getValue(SettingsManager.KEY_SCENE_MODE))
- || "enable".equals(
- SettingsManager.getInstance().getValue(SettingsManager.KEY_AUTO_HDR))
- || SettingsManager.getInstance().isCamera2HDRSupport()
- || "18".equals(SettingsManager.getInstance().getValue(
- SettingsManager.KEY_SCENE_MODE))
- || mController.getCameraMode() == CaptureModule.DUAL_MODE
- || isSupportedQcfa) {
- mUseZSL = false;
+ if (mController.mSettingsManager.isZslSupported(mController.getMainCameraId())) {
+ if(setFilter(postFilterId) || isFlashModeOn || isTrackingFocusOn || isMakeupOn || isSelfieMirrorOn
+ || PersistUtil.getCameraZSLDisabled()
+ || !SettingsManager.getInstance().isZSLInAppEnabled()
+ || "disable".equals(SettingsManager.getInstance().getValue(SettingsManager.KEY_ZSL))
+ || SettingsManager.SCENE_MODE_BOKEH_STRING.equals(
+ SettingsManager.getInstance().getValue(SettingsManager.KEY_SCENE_MODE))
+ || "enable".equals(
+ SettingsManager.getInstance().getValue(SettingsManager.KEY_AUTO_HDR))
+ || SettingsManager.getInstance().isCamera2HDRSupport()
+ || "18".equals(SettingsManager.getInstance().getValue(
+ SettingsManager.KEY_SCENE_MODE))
+ || mController.getCameraMode() == CaptureModule.DUAL_MODE
+ || isSupportedQcfa) {
+ mUseZSL = false;
+ } else {
+ mUseZSL = true;
+ }
} else {
- mUseZSL = true;
+ mUseZSL = false;
}
Log.d(TAG,"ZSL is "+mUseZSL);
startBackgroundThread();