summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByunghun Jeon <bjeon@codeaurora.org>2016-05-12 18:03:45 -0700
committerSteve Kondik <steve@cyngn.com>2016-08-21 18:45:51 -0700
commitcdcdc1dfa49cc27dace2b127aa515c501cff31e3 (patch)
treef28e7a2ab4bade715744b9af8f34a1239ad42e41
parent4137ed16ff29aaa83c1396b1ac748e6aafe536b3 (diff)
downloadandroid_packages_apps_Snap-cdcdc1dfa49cc27dace2b127aa515c501cff31e3.zip
android_packages_apps_Snap-cdcdc1dfa49cc27dace2b127aa515c501cff31e3.tar.gz
android_packages_apps_Snap-cdcdc1dfa49cc27dace2b127aa515c501cff31e3.tar.bz2
SnapdragonCamera: Fix clearsight session creation and flash
Fixed flash by waiting for proper AE update result. Fixed clearsight session creation by reducing preview size. Change-Id: I17563bb1b8c107696fc7272bdc21796bb6dfddef CRs-Fixed: 1018118
-rw-r--r--src/com/android/camera/CaptureModule.java41
1 files changed, 34 insertions, 7 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 962ee48..8e64bbd 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -54,6 +54,7 @@ import android.util.SparseIntArray;
import android.view.KeyEvent;
import android.view.OrientationEventListener;
import android.view.Surface;
+import android.view.SurfaceHolder;
import android.view.View;
import android.widget.Toast;
@@ -203,6 +204,7 @@ public class CaptureModule implements CameraModule, PhotoController,
private byte[] mLastJpegData;
private int mJpegFileSizeEstimation;
private boolean mFirstPreviewLoaded;
+ private int[] mPrecaptureRequestHashCode = new int[MAX_NUM_CAM];
private class MediaSaveNotifyThread extends Thread {
private Uri uri;
@@ -334,7 +336,8 @@ public class CaptureModule implements CameraModule, PhotoController,
aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE ||
aeState == CaptureResult.CONTROL_AE_STATE_FLASH_REQUIRED ||
aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED) {
- mState[id] = STATE_WAITING_NON_PRECAPTURE;
+ if (mPrecaptureRequestHashCode[id] == result.getRequest().hashCode())
+ mState[id] = STATE_WAITING_NON_PRECAPTURE;
}
break;
}
@@ -858,11 +861,11 @@ public class CaptureModule implements CameraModule, PhotoController,
.TEMPLATE_PREVIEW);
builder.setTag(id);
builder.addTarget(getPreviewSurface(id));
-
applySettingsForPrecapture(builder, id);
-
+ CaptureRequest request = builder.build();
+ mPrecaptureRequestHashCode[id] = request.hashCode();
mState[id] = STATE_WAITING_PRECAPTURE;
- mCaptureSession[id].capture(builder.build(), mCaptureCallback, mCameraHandler);
+ mCaptureSession[id].capture(request, mCaptureCallback, mCameraHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
@@ -895,6 +898,15 @@ public class CaptureModule implements CameraModule, PhotoController,
.KEY_PICTURE_SIZE);
Size size = parsePictureSize(pictureSize);
+
+ if (i == getMainCameraId()) {
+ Point screenSize = new Point();
+ mActivity.getWindowManager().getDefaultDisplay().getSize(screenSize);
+ Size[] prevSizes = map.getOutputSizes(SurfaceHolder.class);
+ Size prevSize = getOptimalPreviewSize(size, prevSizes, screenSize.x,
+ screenSize.y);
+ mUI.setPreviewSize(prevSize.getWidth(), prevSize.getHeight());
+ }
if (isClearSightOn()) {
ClearSightImageProcessor.getInstance().init(size.getWidth(), size.getHeight(),
mActivity, mOnMediaSavedListener);
@@ -1163,9 +1175,6 @@ public class CaptureModule implements CameraModule, PhotoController,
public void onResumeAfterSuper() {
Log.d(TAG, "onResume " + getMode());
mUI.showSurfaceView();
- String pictureSize = mSettingsManager.getValue(SettingsManager.KEY_PICTURE_SIZE);
- Size size = parsePictureSize(pictureSize);
- mUI.setPreviewSize(size.getWidth(), size.getHeight());
mUI.setSwitcherIndex();
mCameraIdList = new ArrayList<>();
setUpCameraOutputs();
@@ -1938,6 +1947,24 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
+ private Size getOptimalPreviewSize(Size pictureSize, Size[] prevSizes, int screenW, int
+ screenH) {
+ Size optimal = prevSizes[0];
+ float ratio = (float) pictureSize.getWidth() / pictureSize.getHeight();
+ for (Size prevSize: prevSizes) {
+ float prevRatio = (float) prevSize.getWidth() / prevSize.getHeight();
+ if (Math.abs(prevRatio - ratio) < 0.01) {
+ // flip w and h
+ if (prevSize.getWidth() <= screenH && prevSize.getHeight() <= screenW) {
+ return prevSize;
+ } else {
+ optimal = prevSize;
+ }
+ }
+ }
+ return optimal;
+ }
+
/**
* Compares two {@code Size}s based on their areas.
*/