summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-06-14 17:27:19 -0700
committerSteve Kondik <steve@cyngn.com>2016-08-25 21:55:20 -0700
commitb46799d987d26e3e106c0ac30ac63bccb8aa44f2 (patch)
tree79f90a089a04e890bbe454c10832e1ba550506af
parentac2a409a45a2d4f1430f86dbe39549a82875900f (diff)
downloadandroid_packages_apps_Snap-b46799d987d26e3e106c0ac30ac63bccb8aa44f2.zip
android_packages_apps_Snap-b46799d987d26e3e106c0ac30ac63bccb8aa44f2.tar.gz
android_packages_apps_Snap-b46799d987d26e3e106c0ac30ac63bccb8aa44f2.tar.bz2
SnapdragonCamera: fix front back camera toggle crash
- Fix logic when switching camera id from front to back in dual camera setup. - Only init Clearsight once. - Wait for second surface for aux camera to become ready before attempting to create session. CRs-Fixed: 993611 Change-Id: Icec4af06535f29bc75790b1d57eed212f7a86727
-rw-r--r--src/com/android/camera/CaptureModule.java14
-rw-r--r--src/com/android/camera/CaptureUI.java29
2 files changed, 36 insertions, 7 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 36f787b..8ac48af 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -564,6 +564,9 @@ public class CaptureModule implements CameraModule, PhotoController,
// are initialized.
if (s != null) {
s.setListener(this);
+ if (isClearSightOn()) {
+ ClearSightImageProcessor.getInstance().setMediaSaveService(s);
+ }
}
mNamedImages = new NamedImages();
@@ -577,6 +580,9 @@ public class CaptureModule implements CameraModule, PhotoController,
MediaSaveService s = mActivity.getMediaSaveService();
if (s != null) {
s.setListener(this);
+ if (isClearSightOn()) {
+ ClearSightImageProcessor.getInstance().setMediaSaveService(s);
+ }
}
mNamedImages = new NamedImages();
}
@@ -1081,9 +1087,11 @@ public class CaptureModule implements CameraModule, PhotoController,
mUI.setPreviewSize(mFrameProcPreviewOutputSize.getWidth(), mFrameProcPreviewOutputSize.getHeight());
}
if (isClearSightOn()) {
- ClearSightImageProcessor.getInstance().init(size.getWidth(), size.getHeight(),
- mActivity, mOnMediaSavedListener);
- ClearSightImageProcessor.getInstance().setCallback(this);
+ if(i == getMainCameraId()) {
+ ClearSightImageProcessor.getInstance().init(size.getWidth(), size.getHeight(),
+ mActivity, mOnMediaSavedListener);
+ ClearSightImageProcessor.getInstance().setCallback(this);
+ }
} else {
// No Clearsight
mImageReader[i] = ImageReader.newInstance(size.getWidth(), size.getHeight(), imageFormat, MAX_IMAGE_NUM);
diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java
index 3d766fa..71d39e0 100644
--- a/src/com/android/camera/CaptureUI.java
+++ b/src/com/android/camera/CaptureUI.java
@@ -136,15 +136,14 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
public void surfaceCreated(SurfaceHolder holder) {
Log.v(TAG, "surfaceCreated");
mSurfaceHolder = holder;
- mModule.onPreviewUIReady();
- mActivity.updateThumbnail(mThumbnail);
+ previewUIReady();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
Log.v(TAG, "surfaceDestroyed");
mSurfaceHolder = null;
- mModule.onPreviewUIDestroyed();
+ previewUIDestroyed();
}
};
@@ -172,19 +171,39 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
// SurfaceHolder callbacks
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ Log.v(TAG, "surfaceChanged2");
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
+ Log.v(TAG, "surfaceCreated2");
mSurfaceHolder2 = holder;
+ previewUIReady();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
+ Log.v(TAG, "surfaceDestroyed2");
mSurfaceHolder2 = null;
+ previewUIDestroyed();
}
};
+ private void previewUIReady() {
+ if((mSurfaceHolder != null && mSurfaceHolder.getSurface().isValid()) &&
+ (mSurfaceView2.getVisibility() != View.VISIBLE ||
+ (mSurfaceView2.getVisibility() == View.VISIBLE &&
+ mSurfaceHolder2 != null &&
+ mSurfaceHolder2.getSurface().isValid()))) {
+ mModule.onPreviewUIReady();
+ mActivity.updateThumbnail(mThumbnail);
+ }
+ }
+
+ private void previewUIDestroyed() {
+ mModule.onPreviewUIDestroyed();
+ }
+
public CaptureUI(CameraActivity activity, CaptureModule module, View parent) {
mActivity = activity;
mModule = module;
@@ -349,7 +368,9 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
int index = mSettingsManager.getValueIndex(SettingsManager.KEY_CAMERA_ID);
CharSequence[] entries = mSettingsManager.getEntries(SettingsManager.KEY_CAMERA_ID);
- index = (index + 1) % entries.length;
+ do {
+ index = (index + 1) % entries.length;
+ } while (entries[index] == null);
mSettingsManager.setValueIndex(SettingsManager.KEY_CAMERA_ID, index);
int[] largeIcons = mSettingsManager.getResource(SettingsManager.KEY_CAMERA_ID,
SettingsManager.RESOURCE_TYPE_LARGEICON);