Skip to content
Snippets Groups Projects
Commit 6ad6a36f authored by Byunghun Jeon's avatar Byunghun Jeon Committed by Gerrit - the friendly Code Review server
Browse files

SnapdragonCamera: Show popup and close when createSession fails

Show popup and close the app when createSession fails.
Also modify camera mode related function names.

Change-Id: I859af7f0a4e9be86fc8599ff0c3778e5f52f6d0b
CRs-Fixed: 1018118
parent b183ce6d
No related branches found
No related tags found
No related merge requests found
...@@ -20,8 +20,10 @@ ...@@ -20,8 +20,10 @@
package com.android.camera; package com.android.camera;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.AlertDialog;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.ImageFormat; import android.graphics.ImageFormat;
...@@ -385,7 +387,7 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -385,7 +387,7 @@ public class CaptureModule implements CameraModule, PhotoController,
if (mPaused) { if (mPaused) {
return; return;
} }
if (isBackMode() && getMode() == DUAL_MODE && id == BAYER_ID) { if (isBackCamera() && getCameraMode() == DUAL_MODE && id == BAYER_ID) {
Message msg = mCameraHandler.obtainMessage(OPEN_CAMERA, MONO_ID); Message msg = mCameraHandler.obtainMessage(OPEN_CAMERA, MONO_ID);
mCameraHandler.sendMessage(msg); mCameraHandler.sendMessage(msg);
} }
...@@ -442,14 +444,14 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -442,14 +444,14 @@ public class CaptureModule implements CameraModule, PhotoController,
else return false; else return false;
} }
private boolean isBackMode() { private boolean isBackCamera() {
String value = mSettingsManager.getValue(SettingsManager.KEY_CAMERA_ID); String value = mSettingsManager.getValue(SettingsManager.KEY_CAMERA_ID);
if (value == null) return true; if (value == null) return true;
if (Integer.parseInt(value) == BAYER_ID) return true; if (Integer.parseInt(value) == BAYER_ID) return true;
return false; return false;
} }
private int getMode() { private int getCameraMode() {
String value = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE); String value = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
if (value != null && value.equals("-5")) return DUAL_MODE; if (value != null && value.equals("-5")) return DUAL_MODE;
value = mSettingsManager.getValue(SettingsManager.KEY_MONO_ONLY); value = mSettingsManager.getValue(SettingsManager.KEY_MONO_ONLY);
...@@ -460,7 +462,7 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -460,7 +462,7 @@ public class CaptureModule implements CameraModule, PhotoController,
private boolean isClearSightOn() { private boolean isClearSightOn() {
String value = mSettingsManager.getValue(SettingsManager.KEY_CLEARSIGHT); String value = mSettingsManager.getValue(SettingsManager.KEY_CLEARSIGHT);
if (value == null) return false; if (value == null) return false;
return isBackMode() && getMode() == DUAL_MODE && value.equals("on"); return isBackCamera() && getCameraMode() == DUAL_MODE && value.equals("on");
} }
public static int getQualityNumber(String jpegQuality) { public static int getQualityNumber(String jpegQuality) {
...@@ -540,7 +542,6 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -540,7 +542,6 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override @Override
public void onConfigured(CameraCaptureSession cameraCaptureSession) { public void onConfigured(CameraCaptureSession cameraCaptureSession) {
// The camera is already closed
if (mPaused || null == mCameraDevice[id]) { if (mPaused || null == mCameraDevice[id]) {
return; return;
} }
...@@ -548,7 +549,7 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -548,7 +549,7 @@ public class CaptureModule implements CameraModule, PhotoController,
mCaptureSession[id] = cameraCaptureSession; mCaptureSession[id] = cameraCaptureSession;
initializePreviewConfiguration(id); initializePreviewConfiguration(id);
try { try {
if (isBackMode() && getMode() == DUAL_MODE) { if (isBackCamera() && getCameraMode() == DUAL_MODE) {
linkBayerMono(id); linkBayerMono(id);
mIsLinked = true; mIsLinked = true;
} }
...@@ -566,7 +567,19 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -566,7 +567,19 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override @Override
public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) { public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
Log.d(TAG, "cameracapturesession - onConfigureFailed"); Log.e(TAG, "cameracapturesession - onConfigureFailed");
new AlertDialog.Builder(mActivity)
.setTitle("Camera Initialization Failed")
.setMessage("Closing SnapdragonCamera")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
closeCamera();
mActivity.finish();
}
})
.setCancelable(false)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
} }
@Override @Override
...@@ -645,8 +658,9 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -645,8 +658,9 @@ public class CaptureModule implements CameraModule, PhotoController,
*/ */
private void takePicture() { private void takePicture() {
Log.d(TAG, "takePicture"); Log.d(TAG, "takePicture");
if (isBackMode()) { mUI.enableShutter(false);
switch (getMode()) { if (isBackCamera()) {
switch (getCameraMode()) {
case DUAL_MODE: case DUAL_MODE:
lockFocus(BAYER_ID); lockFocus(BAYER_ID);
lockFocus(MONO_ID); lockFocus(MONO_ID);
...@@ -967,6 +981,12 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -967,6 +981,12 @@ public class CaptureModule implements CameraModule, PhotoController,
mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id].build(), mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id].build(),
mCaptureCallback, mCameraHandler); mCaptureCallback, mCameraHandler);
mTakingPicture[id] = false; mTakingPicture[id] = false;
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
mUI.enableShutter(true);
}
});
} catch (CameraAccessException e) { } catch (CameraAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -1168,12 +1188,12 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -1168,12 +1188,12 @@ public class CaptureModule implements CameraModule, PhotoController,
} }
private void setCurrentMode() { private void setCurrentMode() {
mCurrentMode = isBackMode() ? getMode() : FRONT_MODE; mCurrentMode = isBackCamera() ? getCameraMode() : FRONT_MODE;
} }
@Override @Override
public void onResumeAfterSuper() { public void onResumeAfterSuper() {
Log.d(TAG, "onResume " + getMode()); Log.d(TAG, "onResume " + getCameraMode());
mUI.showSurfaceView(); mUI.showSurfaceView();
mUI.setSwitcherIndex(); mUI.setSwitcherIndex();
mCameraIdList = new ArrayList<>(); mCameraIdList = new ArrayList<>();
...@@ -1181,8 +1201,8 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -1181,8 +1201,8 @@ public class CaptureModule implements CameraModule, PhotoController,
startBackgroundThread(); startBackgroundThread();
Message msg = Message.obtain(); Message msg = Message.obtain();
msg.what = OPEN_CAMERA; msg.what = OPEN_CAMERA;
if (isBackMode()) { if (isBackCamera()) {
switch (getMode()) { switch (getCameraMode()) {
case DUAL_MODE: case DUAL_MODE:
case BAYER_MODE: case BAYER_MODE:
msg.obj = BAYER_ID; msg.obj = BAYER_ID;
...@@ -1252,8 +1272,8 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -1252,8 +1272,8 @@ public class CaptureModule implements CameraModule, PhotoController,
public void onZoomChanged(float requestedZoom) { public void onZoomChanged(float requestedZoom) {
mZoomValue = requestedZoom; mZoomValue = requestedZoom;
if (isBackMode()) { if (isBackCamera()) {
switch (getMode()) { switch (getCameraMode()) {
case DUAL_MODE: case DUAL_MODE:
applyZoomAndUpdate(BAYER_ID); applyZoomAndUpdate(BAYER_ID);
applyZoomAndUpdate(MONO_ID); applyZoomAndUpdate(MONO_ID);
...@@ -1271,8 +1291,8 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -1271,8 +1291,8 @@ public class CaptureModule implements CameraModule, PhotoController,
} }
private boolean isInMode(int cameraId) { private boolean isInMode(int cameraId) {
if (isBackMode()) { if (isBackCamera()) {
switch (getMode()) { switch (getCameraMode()) {
case DUAL_MODE: case DUAL_MODE:
return cameraId == BAYER_ID || cameraId == MONO_ID; return cameraId == BAYER_ID || cameraId == MONO_ID;
case BAYER_MODE: case BAYER_MODE:
...@@ -1335,8 +1355,8 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -1335,8 +1355,8 @@ public class CaptureModule implements CameraModule, PhotoController,
Log.d(TAG, "onSingleTapUp " + x + " " + y); Log.d(TAG, "onSingleTapUp " + x + " " + y);
mUI.setFocusPosition(x, y); mUI.setFocusPosition(x, y);
mUI.onFocusStarted(); mUI.onFocusStarted();
if (isBackMode()) { if (isBackCamera()) {
switch (getMode()) { switch (getCameraMode()) {
case DUAL_MODE: case DUAL_MODE:
triggerFocusAtPoint(x, y, BAYER_ID); triggerFocusAtPoint(x, y, BAYER_ID);
triggerFocusAtPoint(x, y, MONO_ID); triggerFocusAtPoint(x, y, MONO_ID);
...@@ -1354,8 +1374,8 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -1354,8 +1374,8 @@ public class CaptureModule implements CameraModule, PhotoController,
} }
private int getMainCameraId() { private int getMainCameraId() {
if (isBackMode()) { if (isBackCamera()) {
switch (getMode()) { switch (getCameraMode()) {
case DUAL_MODE: case DUAL_MODE:
case BAYER_MODE: case BAYER_MODE:
return BAYER_ID; return BAYER_ID;
...@@ -1408,8 +1428,8 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -1408,8 +1428,8 @@ public class CaptureModule implements CameraModule, PhotoController,
} }
Log.d(TAG, "onPreviewUIReady"); Log.d(TAG, "onPreviewUIReady");
mSurfaceReady = true; mSurfaceReady = true;
if (isBackMode()) { if (isBackCamera()) {
switch (getMode()) { switch (getCameraMode()) {
case DUAL_MODE: case DUAL_MODE:
createSession(BAYER_ID); createSession(BAYER_ID);
createSession(MONO_ID); createSession(MONO_ID);
...@@ -1523,7 +1543,7 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -1523,7 +1543,7 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override @Override
public void onShutterButtonLongClick() { public void onShutterButtonLongClick() {
if (isBackMode() && getMode() == DUAL_MODE) return; if (isBackCamera() && getCameraMode() == DUAL_MODE) return;
String longshot = mSettingsManager.getValue(SettingsManager.KEY_LONGSHOT); String longshot = mSettingsManager.getValue(SettingsManager.KEY_LONGSHOT);
if (longshot.equals("on")) { if (longshot.equals("on")) {
...@@ -1769,8 +1789,8 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -1769,8 +1789,8 @@ public class CaptureModule implements CameraModule, PhotoController,
} }
private Surface getPreviewSurface(int id) { private Surface getPreviewSurface(int id) {
if (isBackMode()) { if (isBackCamera()) {
if (getMode() == DUAL_MODE && id == MONO_ID) { if (getCameraMode() == DUAL_MODE && id == MONO_ID) {
return mUI.getSurfaceHolder2().getSurface(); return mUI.getSurfaceHolder2().getSurface();
} else { } else {
return mUI.getSurfaceHolder().getSurface(); return mUI.getSurfaceHolder().getSurface();
...@@ -1880,8 +1900,8 @@ public class CaptureModule implements CameraModule, PhotoController, ...@@ -1880,8 +1900,8 @@ public class CaptureModule implements CameraModule, PhotoController,
break; break;
} }
if (isBackMode()) { if (isBackCamera()) {
switch (getMode()) { switch (getCameraMode()) {
case BAYER_MODE: case BAYER_MODE:
updatePreviewBayer |= applyPreferenceToPreview(BAYER_ID, key, value); updatePreviewBayer |= applyPreferenceToPreview(BAYER_ID, key, value);
break; break;
... ...
......
...@@ -96,17 +96,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, ...@@ -96,17 +96,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
SettingsManager.KEY_CAMERA2 SettingsManager.KEY_CAMERA2
}; };
String[] mDeveloperKeys = new String[]{ String[] mDeveloperKeys = new String[]{
SettingsManager.KEY_FLASH_MODE,
SettingsManager.KEY_RECORD_LOCATION,
SettingsManager.KEY_PICTURE_SIZE,
SettingsManager.KEY_JPEG_QUALITY,
SettingsManager.KEY_TIMER,
SettingsManager.KEY_CAMERA_SAVEPATH,
SettingsManager.KEY_LONGSHOT,
SettingsManager.KEY_ISO,
SettingsManager.KEY_EXPOSURE,
SettingsManager.KEY_WHITE_BALANCE,
SettingsManager.KEY_CAMERA2,
SettingsManager.KEY_MONO_ONLY, SettingsManager.KEY_MONO_ONLY,
SettingsManager.KEY_CLEARSIGHT, SettingsManager.KEY_CLEARSIGHT,
SettingsManager.KEY_MONO_PREVIEW SettingsManager.KEY_MONO_PREVIEW
...@@ -870,8 +859,18 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, ...@@ -870,8 +859,18 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
mSettingMenu.setSettingsManager(mSettingsManager); mSettingMenu.setSettingsManager(mSettingsManager);
String[] keys = mSettingKeys; String[] keys = mSettingKeys;
if (mActivity.isDeveloperMenuEnabled()) if (mActivity.isDeveloperMenuEnabled()) {
keys = mDeveloperKeys; keys = mDeveloperKeys;
String[] combined = new String[mSettingKeys.length + mDeveloperKeys.length];
int idx = 0;
for (String key: mSettingKeys) {
combined[idx++] = key;
}
for (String key: mDeveloperKeys) {
combined[idx++] = key;
}
keys = combined;
}
mSettingMenu.initializeForCamera2(keys); mSettingMenu.initializeForCamera2(keys);
} }
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment