summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByunghun Jeon <bjeon@codeaurora.org>2016-05-16 11:13:06 -0700
committerSteve Kondik <steve@cyngn.com>2016-08-25 21:55:20 -0700
commit20dda4e93265987059c6c276ff4c717a5cc893be (patch)
tree3f35843011ec1f0ffdac9249dc040a72d408642f
parentbafafb5f195854c0c24c1682f5abd42dfc582643 (diff)
downloadandroid_packages_apps_Snap-20dda4e93265987059c6c276ff4c717a5cc893be.zip
android_packages_apps_Snap-20dda4e93265987059c6c276ff4c717a5cc893be.tar.gz
android_packages_apps_Snap-20dda4e93265987059c6c276ff4c717a5cc893be.tar.bz2
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
-rw-r--r--src/com/android/camera/CaptureModule.java76
-rw-r--r--src/com/android/camera/CaptureUI.java23
2 files changed, 59 insertions, 40 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 8e64bbd..ab2c886 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -20,8 +20,10 @@
package com.android.camera;
import android.app.ActivityManager;
+import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.ImageFormat;
@@ -385,7 +387,7 @@ public class CaptureModule implements CameraModule, PhotoController,
if (mPaused) {
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);
mCameraHandler.sendMessage(msg);
}
@@ -442,14 +444,14 @@ public class CaptureModule implements CameraModule, PhotoController,
else return false;
}
- private boolean isBackMode() {
+ private boolean isBackCamera() {
String value = mSettingsManager.getValue(SettingsManager.KEY_CAMERA_ID);
if (value == null) return true;
if (Integer.parseInt(value) == BAYER_ID) return true;
return false;
}
- private int getMode() {
+ private int getCameraMode() {
String value = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
if (value != null && value.equals("-5")) return DUAL_MODE;
value = mSettingsManager.getValue(SettingsManager.KEY_MONO_ONLY);
@@ -460,7 +462,7 @@ public class CaptureModule implements CameraModule, PhotoController,
private boolean isClearSightOn() {
String value = mSettingsManager.getValue(SettingsManager.KEY_CLEARSIGHT);
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) {
@@ -540,7 +542,6 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
- // The camera is already closed
if (mPaused || null == mCameraDevice[id]) {
return;
}
@@ -548,7 +549,7 @@ public class CaptureModule implements CameraModule, PhotoController,
mCaptureSession[id] = cameraCaptureSession;
initializePreviewConfiguration(id);
try {
- if (isBackMode() && getMode() == DUAL_MODE) {
+ if (isBackCamera() && getCameraMode() == DUAL_MODE) {
linkBayerMono(id);
mIsLinked = true;
}
@@ -566,7 +567,19 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
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
@@ -645,8 +658,9 @@ public class CaptureModule implements CameraModule, PhotoController,
*/
private void takePicture() {
Log.d(TAG, "takePicture");
- if (isBackMode()) {
- switch (getMode()) {
+ mUI.enableShutter(false);
+ if (isBackCamera()) {
+ switch (getCameraMode()) {
case DUAL_MODE:
lockFocus(BAYER_ID);
lockFocus(MONO_ID);
@@ -967,6 +981,12 @@ public class CaptureModule implements CameraModule, PhotoController,
mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id].build(),
mCaptureCallback, mCameraHandler);
mTakingPicture[id] = false;
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mUI.enableShutter(true);
+ }
+ });
} catch (CameraAccessException e) {
e.printStackTrace();
}
@@ -1168,12 +1188,12 @@ public class CaptureModule implements CameraModule, PhotoController,
}
private void setCurrentMode() {
- mCurrentMode = isBackMode() ? getMode() : FRONT_MODE;
+ mCurrentMode = isBackCamera() ? getCameraMode() : FRONT_MODE;
}
@Override
public void onResumeAfterSuper() {
- Log.d(TAG, "onResume " + getMode());
+ Log.d(TAG, "onResume " + getCameraMode());
mUI.showSurfaceView();
mUI.setSwitcherIndex();
mCameraIdList = new ArrayList<>();
@@ -1181,8 +1201,8 @@ public class CaptureModule implements CameraModule, PhotoController,
startBackgroundThread();
Message msg = Message.obtain();
msg.what = OPEN_CAMERA;
- if (isBackMode()) {
- switch (getMode()) {
+ if (isBackCamera()) {
+ switch (getCameraMode()) {
case DUAL_MODE:
case BAYER_MODE:
msg.obj = BAYER_ID;
@@ -1252,8 +1272,8 @@ public class CaptureModule implements CameraModule, PhotoController,
public void onZoomChanged(float requestedZoom) {
mZoomValue = requestedZoom;
- if (isBackMode()) {
- switch (getMode()) {
+ if (isBackCamera()) {
+ switch (getCameraMode()) {
case DUAL_MODE:
applyZoomAndUpdate(BAYER_ID);
applyZoomAndUpdate(MONO_ID);
@@ -1271,8 +1291,8 @@ public class CaptureModule implements CameraModule, PhotoController,
}
private boolean isInMode(int cameraId) {
- if (isBackMode()) {
- switch (getMode()) {
+ if (isBackCamera()) {
+ switch (getCameraMode()) {
case DUAL_MODE:
return cameraId == BAYER_ID || cameraId == MONO_ID;
case BAYER_MODE:
@@ -1335,8 +1355,8 @@ public class CaptureModule implements CameraModule, PhotoController,
Log.d(TAG, "onSingleTapUp " + x + " " + y);
mUI.setFocusPosition(x, y);
mUI.onFocusStarted();
- if (isBackMode()) {
- switch (getMode()) {
+ if (isBackCamera()) {
+ switch (getCameraMode()) {
case DUAL_MODE:
triggerFocusAtPoint(x, y, BAYER_ID);
triggerFocusAtPoint(x, y, MONO_ID);
@@ -1354,8 +1374,8 @@ public class CaptureModule implements CameraModule, PhotoController,
}
private int getMainCameraId() {
- if (isBackMode()) {
- switch (getMode()) {
+ if (isBackCamera()) {
+ switch (getCameraMode()) {
case DUAL_MODE:
case BAYER_MODE:
return BAYER_ID;
@@ -1408,8 +1428,8 @@ public class CaptureModule implements CameraModule, PhotoController,
}
Log.d(TAG, "onPreviewUIReady");
mSurfaceReady = true;
- if (isBackMode()) {
- switch (getMode()) {
+ if (isBackCamera()) {
+ switch (getCameraMode()) {
case DUAL_MODE:
createSession(BAYER_ID);
createSession(MONO_ID);
@@ -1523,7 +1543,7 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
public void onShutterButtonLongClick() {
- if (isBackMode() && getMode() == DUAL_MODE) return;
+ if (isBackCamera() && getCameraMode() == DUAL_MODE) return;
String longshot = mSettingsManager.getValue(SettingsManager.KEY_LONGSHOT);
if (longshot.equals("on")) {
@@ -1769,8 +1789,8 @@ public class CaptureModule implements CameraModule, PhotoController,
}
private Surface getPreviewSurface(int id) {
- if (isBackMode()) {
- if (getMode() == DUAL_MODE && id == MONO_ID) {
+ if (isBackCamera()) {
+ if (getCameraMode() == DUAL_MODE && id == MONO_ID) {
return mUI.getSurfaceHolder2().getSurface();
} else {
return mUI.getSurfaceHolder().getSurface();
@@ -1880,8 +1900,8 @@ public class CaptureModule implements CameraModule, PhotoController,
break;
}
- if (isBackMode()) {
- switch (getMode()) {
+ if (isBackCamera()) {
+ switch (getCameraMode()) {
case BAYER_MODE:
updatePreviewBayer |= applyPreferenceToPreview(BAYER_ID, key, value);
break;
diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java
index bc0d310..f474015 100644
--- a/src/com/android/camera/CaptureUI.java
+++ b/src/com/android/camera/CaptureUI.java
@@ -96,17 +96,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
SettingsManager.KEY_CAMERA2
};
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_CLEARSIGHT,
SettingsManager.KEY_MONO_PREVIEW
@@ -870,8 +859,18 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
mSettingMenu.setSettingsManager(mSettingsManager);
String[] keys = mSettingKeys;
- if (mActivity.isDeveloperMenuEnabled())
+ if (mActivity.isDeveloperMenuEnabled()) {
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);
}