summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Haeberling <haeberling@google.com>2014-08-23 02:05:47 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-08-23 02:05:47 +0000
commitceff90aa9bcb2cfce2f48b187948af8bbbdc9172 (patch)
tree189e5d0d8a51a5b321b869751913cc69f4760231
parent0a395068f1360aafdea215d4c182b0f3df57abd2 (diff)
parent392f249b8295509cf6c31984f2420b876ca5a7ac (diff)
downloadandroid_packages_apps_Camera2-ceff90aa9bcb2cfce2f48b187948af8bbbdc9172.tar.gz
android_packages_apps_Camera2-ceff90aa9bcb2cfce2f48b187948af8bbbdc9172.tar.bz2
android_packages_apps_Camera2-ceff90aa9bcb2cfce2f48b187948af8bbbdc9172.zip
am 392f249b: Merge "Enable switching within CaptureModule to HDR+ and back." into ub-camera-glacier
* commit '392f249b8295509cf6c31984f2420b876ca5a7ac': Enable switching within CaptureModule to HDR+ and back.
-rw-r--r--src/com/android/camera/CameraActivity.java4
-rw-r--r--src/com/android/camera/CaptureModule.java287
-rw-r--r--src/com/android/camera/PhotoModule.java14
-rw-r--r--src/com/android/camera/PhotoUI.java18
-rw-r--r--src/com/android/camera/module/ModulesInfo.java2
-rw-r--r--src/com/android/camera/one/OneCameraManager.java4
-rw-r--r--src/com/android/camera/one/v1/OneCameraManagerImpl.java2
-rw-r--r--src/com/android/camera/one/v2/OneCameraManagerImpl.java9
-rw-r--r--src/com/android/camera/util/ApiHelper.java5
-rw-r--r--src_pd/com/android/camera/one/v2/OneCameraCreator.java3
-rw-r--r--src_pd_gcam/com/android/camera/util/GcamHelper.java5
11 files changed, 244 insertions, 109 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 2fe487684..ed761a7d8 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -1522,7 +1522,7 @@ public class CameraActivity extends Activity
modeIndex = mSettingsManager.getInteger(SettingsManager.SCOPE_GLOBAL,
Keys.KEY_STARTUP_MODULE_INDEX);
if ((modeIndex == gcamIndex &&
- !GcamHelper.hasGcamCapture()) || modeIndex < 0) {
+ !GcamHelper.hasGcamAsSeparateModule()) || modeIndex < 0) {
modeIndex = photoIndex;
}
}
@@ -2074,7 +2074,7 @@ public class CameraActivity extends Activity
public int getPreferredChildModeIndex(int modeIndex) {
if (modeIndex == getResources().getInteger(R.integer.camera_mode_photo)) {
boolean hdrPlusOn = Keys.isHdrPlusOn(mSettingsManager);
- if (hdrPlusOn && GcamHelper.hasGcamCapture()) {
+ if (hdrPlusOn && GcamHelper.hasGcamAsSeparateModule()) {
modeIndex = getResources().getInteger(R.integer.camera_mode_gcam);
}
}
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 4d5fe6231..0b2fb1877 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -55,6 +55,7 @@ import com.android.camera.one.OneCamera.OpenCallback;
import com.android.camera.one.OneCamera.PhotoCaptureParameters;
import com.android.camera.one.OneCamera.PhotoCaptureParameters.Flash;
import com.android.camera.one.OneCameraManager;
+import com.android.camera.one.v2.OneCameraManagerImpl;
import com.android.camera.remote.RemoteCameraModule;
import com.android.camera.session.CaptureSession;
import com.android.camera.settings.Keys;
@@ -62,6 +63,7 @@ import com.android.camera.settings.SettingsManager;
import com.android.camera.ui.PreviewStatusListener;
import com.android.camera.ui.TouchCoordinate;
import com.android.camera.util.CameraUtil;
+import com.android.camera.util.GcamHelper;
import com.android.camera.util.Size;
import com.android.camera.util.UsageStatistics;
import com.android.camera2.R;
@@ -113,40 +115,6 @@ public class CaptureModule extends CameraModule
};
/**
- * Called when the captured media has been saved.
- */
- private final MediaSaver.OnMediaSavedListener mOnMediaSavedListener =
- new MediaSaver.OnMediaSavedListener() {
- @Override
- public void onMediaSaved(Uri uri) {
- if (uri != null) {
- mAppController.notifyNewMedia(uri);
- }
- }
- };
-
- /**
- * Called when the user pressed the back/front camera switch button.
- */
- private final ButtonManager.ButtonCallback mCameraSwitchCallback =
- new ButtonManager.ButtonCallback() {
- @Override
- public void onStateChanged(int cameraId) {
- // At the time this callback is fired, the camera id
- // has be set to the desired camera.
- if (mPaused) {
- return;
- }
-
- mSettingsManager.set(mAppController.getModuleScope(), Keys.KEY_CAMERA_ID,
- cameraId);
-
- Log.d(TAG, "Start to switch camera. cameraId=" + cameraId);
- switchCamera(getFacingFromCameraId(cameraId));
- }
- };
-
- /**
* Show AF target in center of preview and start animation.
*/
Runnable mShowAutoFocusTargetInCenterRunnable = new Runnable() {
@@ -185,6 +153,13 @@ public class CaptureModule extends CameraModule
private static final boolean FOCUS_DEBUG_UI = DebugPropertyHelper.showFocusDebugUI();
private final Object mDimensionLock = new Object();
+
+ /**
+ * Sticky Gcam mode is when this module's sole purpose it to be the Gcam mode.
+ * If true, the device uses {@link PhotoModule} for normal picture taking.
+ */
+ private final boolean mStickyGcamCamera;
+
/**
* Lock for race conditions in the SurfaceTextureListener callbacks.
*/
@@ -202,6 +177,9 @@ public class CaptureModule extends CameraModule
private OneCamera mCamera;
/** The direction the currently opened camera is facing to. */
private Facing mCameraFacing = Facing.BACK;
+ /** Whether HDR is currently enabled. */
+ private boolean mHdrEnabled = false;
+
/** The texture used to render the preview in. */
private SurfaceTexture mPreviewTexture;
@@ -286,14 +264,21 @@ public class CaptureModule extends CameraModule
// private String mFlashMode;
/** CLEAN UP END */
- /** Constructs a new capture module. */
public CaptureModule(AppController appController) {
+ this(appController, false);
+ }
+
+ /** Constructs a new capture module. */
+ public CaptureModule(AppController appController, boolean stickyHdr) {
super(appController);
mAppController = appController;
mContext = mAppController.getAndroidContext();
mSettingsManager = mAppController.getSettingsManager();
mSettingsManager.addListener(this);
mDebugDataDir = mContext.getExternalCacheDir();
+ mStickyGcamCamera = stickyHdr;
+ // TODO: Read HDR setting from user preferences.
+ mHdrEnabled = stickyHdr;
}
@Override
@@ -414,52 +399,53 @@ public class CaptureModule extends CameraModule
mPreviewTexture = surface;
closeCamera();
- mCameraManager.open(mCameraFacing, getPictureSizeFromSettings(), new OpenCallback() {
- @Override
- public void onFailure() {
- Log.e(TAG, "Could not open camera.");
- mCamera = null;
- mAppController.showErrorAndFinish(R.string.cannot_connect_camera);
- }
-
- @Override
- public void onCameraOpened(final OneCamera camera) {
- Log.d(TAG, "onCameraOpened: " + camera);
- mCamera = camera;
- updatePreviewBufferDimension();
-
- // If the surface texture is not destroyed, it may have the last
- // frame lingering.
- // We need to hold off setting transform until preview is
- // started.
- resetDefaultBufferSize();
- mState = ModuleState.WATCH_FOR_NEXT_FRAME_AFTER_PREVIEW_STARTED;
-
- Log.d(TAG, "starting preview ...");
-
- // TODO: Consider rolling these two calls into one.
- camera.startPreview(new Surface(surface), new CaptureReadyCallback() {
-
+ // Only enable HDR on the back camera
+ boolean useHdr = mHdrEnabled && mCameraFacing == Facing.BACK;
+ mCameraManager.open(mCameraFacing, useHdr, getPictureSizeFromSettings(),
+ new OpenCallback() {
@Override
- public void onSetupFailed() {
- Log.e(TAG, "Could not set up preview.");
- mCamera.close(null);
+ public void onFailure() {
+ Log.e(TAG, "Could not open camera.");
mCamera = null;
- // TODO: Show an error message and exit.
+ mAppController.showErrorAndFinish(R.string.cannot_connect_camera);
}
@Override
- public void onReadyForCapture() {
- Log.d(TAG, "Ready for capture.");
- onPreviewStarted();
- // Enable zooming after preview has started.
- mUI.initializeZoom(mCamera.getMaxZoom());
- mCamera.setFocusStateListener(CaptureModule.this);
- mCamera.setReadyStateChangedListener(CaptureModule.this);
+ public void onCameraOpened(final OneCamera camera) {
+ Log.d(TAG, "onCameraOpened: " + camera);
+ mCamera = camera;
+ updatePreviewBufferDimension();
+
+ // If the surface texture is not destroyed, it may have
+ // the last frame lingering. We need to hold off setting
+ // transform until preview is started.
+ resetDefaultBufferSize();
+ mState = ModuleState.WATCH_FOR_NEXT_FRAME_AFTER_PREVIEW_STARTED;
+ Log.d(TAG, "starting preview ...");
+
+ // TODO: Consider rolling these two calls into one.
+ camera.startPreview(new Surface(surface), new CaptureReadyCallback() {
+
+ @Override
+ public void onSetupFailed() {
+ Log.e(TAG, "Could not set up preview.");
+ mCamera.close(null);
+ mCamera = null;
+ // TODO: Show an error message and exit.
+ }
+
+ @Override
+ public void onReadyForCapture() {
+ Log.d(TAG, "Ready for capture.");
+ onPreviewStarted();
+ // Enable zooming after preview has started.
+ mUI.initializeZoom(mCamera.getMaxZoom());
+ mCamera.setFocusStateListener(CaptureModule.this);
+ mCamera.setReadyStateChangedListener(CaptureModule.this);
+ }
+ });
}
});
- }
- });
}
@Override
@@ -553,7 +539,13 @@ public class CaptureModule extends CameraModule
@Override
public void hardResetSettings(SettingsManager settingsManager) {
- // TODO Auto-generated method stub
+ if (mStickyGcamCamera) {
+ // Sitcky HDR+ mode should hard reset HDR+ to on, and camera back
+ // facing.
+ settingsManager.set(SettingsManager.SCOPE_GLOBAL, Keys.KEY_CAMERA_HDR_PLUS, true);
+ settingsManager.set(mAppController.getModuleScope(), Keys.KEY_CAMERA_ID,
+ getBackFacingCameraId());
+ }
}
@Override
@@ -566,13 +558,13 @@ public class CaptureModule extends CameraModule
@Override
public boolean isHdrSupported() {
+ // TODO: Check if the device has HDR and not HDR+.
return false;
}
@Override
public boolean isHdrPlusSupported() {
- // TODO: Enable once we support this.
- return false;
+ return GcamHelper.hasGcamCapture();
}
@Override
@@ -587,16 +579,14 @@ public class CaptureModule extends CameraModule
CameraAppUI.BottomBarUISpec bottomBarSpec = new CameraAppUI.BottomBarUISpec();
bottomBarSpec.enableGridLines = true;
bottomBarSpec.enableCamera = true;
- bottomBarSpec.cameraCallback = mCameraSwitchCallback;
- // TODO: Enable once we support this.
- bottomBarSpec.enableHdr = false;
- // TODO: Enable once we support this.
- bottomBarSpec.hdrCallback = null;
+ bottomBarSpec.cameraCallback = getCameraCallback();
+ bottomBarSpec.enableHdr = GcamHelper.hasGcamCapture();
+ bottomBarSpec.hdrCallback = getHdrButtonCallback();
// TODO: Enable once we support this.
bottomBarSpec.enableSelfTimer = false;
bottomBarSpec.showSelfTimer = false;
// TODO: Deal with e.g. HDR+ if it doesn't support it.
- bottomBarSpec.enableFlash = true;
+ // bottomBarSpec.enableFlash = true;
return bottomBarSpec;
}
@@ -632,7 +622,6 @@ public class CaptureModule extends CameraModule
// Currently AF state transitions are controlled in OneCameraImpl.
// PhotoModule uses FocusOverlayManager which uses API1/portability
// logic and coordinates.
-
private void triggerFocusAtScreenCoord(int x, int y) {
mTapToFocusInProgress = true;
// Show UI immediately even though scan has not started yet.
@@ -745,7 +734,7 @@ public class CaptureModule extends CameraModule
@Override
public void onTakePictureProgress(float progress) {
- mUI.setPictureTakingProgress((int)(progress * 100));
+ mUI.setPictureTakingProgress((int) (progress * 100));
}
@Override
@@ -784,6 +773,126 @@ public class CaptureModule extends CameraModule
}
/**
+ * TODO: Remove this method once we are in pure CaptureModule land.
+ */
+ private String getBackFacingCameraId() {
+ if (!(mCameraManager instanceof OneCameraManagerImpl)) {
+ throw new IllegalStateException("This should never be called with Camera API V1");
+ }
+ OneCameraManagerImpl manager = (OneCameraManagerImpl) mCameraManager;
+ return manager.getFirstBackCameraId();
+ }
+
+ /**
+ * @return Depending on whether we're in sticky-HDR mode or not, return the
+ * proper callback to be used for when the HDR/HDR+ button is
+ * pressed.
+ */
+ private ButtonManager.ButtonCallback getHdrButtonCallback() {
+ if (mStickyGcamCamera) {
+ return new ButtonManager.ButtonCallback() {
+ @Override
+ public void onStateChanged(int state) {
+ if (mPaused) {
+ return;
+ }
+ if (state == ButtonManager.ON) {
+ throw new IllegalStateException(
+ "Can't leave hdr plus mode if switching to hdr plus mode.");
+ }
+ SettingsManager settingsManager = mAppController.getSettingsManager();
+ settingsManager.set(mAppController.getModuleScope(),
+ Keys.KEY_REQUEST_RETURN_HDR_PLUS, false);
+ switchToRegularCapture();
+ }
+ };
+ } else {
+ return new ButtonManager.ButtonCallback() {
+ @Override
+ public void onStateChanged(int hdrEnabled) {
+ if (mPaused) {
+ return;
+ }
+ Log.d(TAG, "HDR enabled =" + hdrEnabled);
+ mHdrEnabled = hdrEnabled == 1;
+ switchCamera();
+ }
+ };
+ }
+ }
+
+ /**
+ * @return Depending on whether we're in sticky-HDR mode or not, this
+ * returns the proper callback to be used for when the camera
+ * (front/back switch) button is pressed.
+ */
+ private ButtonManager.ButtonCallback getCameraCallback() {
+ if (mStickyGcamCamera) {
+ return new ButtonManager.ButtonCallback() {
+ @Override
+ public void onStateChanged(int state) {
+ if (mPaused) {
+ return;
+ }
+
+ // At the time this callback is fired, the camera id setting
+ // has changed to the desired camera.
+ SettingsManager settingsManager = mAppController.getSettingsManager();
+ if (Keys.isCameraBackFacing(settingsManager,
+ mAppController.getModuleScope())) {
+ throw new IllegalStateException(
+ "Hdr plus should never be switching from front facing camera.");
+ }
+
+ // Switch to photo mode, but request a return to hdr plus on
+ // switching to back camera again.
+ settingsManager.set(mAppController.getModuleScope(),
+ Keys.KEY_REQUEST_RETURN_HDR_PLUS, true);
+ switchToRegularCapture();
+ }
+ };
+ } else {
+ return new ButtonManager.ButtonCallback() {
+ @Override
+ public void onStateChanged(int cameraId) {
+ if (mPaused) {
+ return;
+ }
+
+ // At the time this callback is fired, the camera id
+ // has be set to the desired camera.
+ mSettingsManager.set(mAppController.getModuleScope(), Keys.KEY_CAMERA_ID,
+ cameraId);
+
+ Log.d(TAG, "Start to switch camera. cameraId=" + cameraId);
+ mCameraFacing = getFacingFromCameraId(cameraId);
+ switchCamera();
+ }
+ };
+ }
+ }
+
+ /**
+ * Switches to PhotoModule to do regular photo captures.
+ * <p>
+ * TODO: Remove this once we use CaptureModule for photo taking.
+ */
+ private void switchToRegularCapture() {
+ // Turn off HDR+ before switching back to normal photo mode.
+ SettingsManager settingsManager = mAppController.getSettingsManager();
+ settingsManager.set(SettingsManager.SCOPE_GLOBAL, Keys.KEY_CAMERA_HDR_PLUS, false);
+
+ // Disable this button to prevent callbacks from this module from firing
+ // while we are transitioning modules.
+ ButtonManager buttonManager = mAppController.getButtonManager();
+ buttonManager.disableButtonClick(ButtonManager.BUTTON_HDR_PLUS);
+ mAppController.getCameraAppUI().freezeScreenUntilPreviewReady();
+ mAppController.onModeSelected(mContext.getResources().getInteger(
+ R.integer.camera_mode_photo));
+ buttonManager.enableButtonClick(ButtonManager.BUTTON_HDR_PLUS);
+ }
+
+ /**
* Called when the preview started. Informs the app controller and queues a
* transform update when the next preview frame arrives.
*/
@@ -969,8 +1078,11 @@ public class CaptureModule extends CameraModule
|| MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(action));
}
- private void switchCamera(Facing switchTo) {
- if (mPaused || mCameraFacing == switchTo) {
+ /**
+ * Re-initialize the camera if e.g. the HDR mode or facing property changed.
+ */
+ private void switchCamera() {
+ if (mPaused) {
return;
}
// TODO: Un-comment once we have timer back.
@@ -978,7 +1090,6 @@ public class CaptureModule extends CameraModule
mAppController.freezeScreenUntilPreviewReady();
- mCameraFacing = switchTo;
initSurface(mPreviewTexture);
// TODO: Un-comment once we have focus back.
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index f59173c53..04093487e 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -527,7 +527,14 @@ public class PhotoModule
}, createAspectRatioDialogCallback());
} else {
// App upgrade. Only show aspect ratio selection.
- mUI.showAspectRatioDialog(createAspectRatioDialogCallback());
+ boolean wasShown = mUI.showAspectRatioDialog(createAspectRatioDialogCallback());
+ if (!wasShown) {
+ // If the dialog was not shown, set this flag to true so that we
+ // never have to check for it again. It means that we don't need
+ // to show the dialog on this device.
+ mActivity.getSettingsManager().set(SettingsManager.SCOPE_GLOBAL,
+ Keys.KEY_USER_SELECTED_ASPECT_RATIO, true);
+ }
}
}
@@ -654,6 +661,7 @@ public class PhotoModule
Log.i(TAG, "Start to switch camera. id=" + mPendingSwitchCameraId);
closeCamera();
mCameraId = mPendingSwitchCameraId;
+
settingsManager.set(mAppController.getModuleScope(), Keys.KEY_CAMERA_ID, mCameraId);
requestCameraOpen();
mUI.clearFaces();
@@ -714,7 +722,7 @@ public class PhotoModule
@Override
public void onStateChanged(int state) {
SettingsManager settingsManager = mActivity.getSettingsManager();
- if (GcamHelper.hasGcamCapture()) {
+ if (GcamHelper.hasGcamAsSeparateModule()) {
// Set the camera setting to default backfacing.
settingsManager.setToDefault(mAppController.getModuleScope(),
Keys.KEY_CAMERA_ID);
@@ -763,7 +771,7 @@ public class PhotoModule
// PhotoModule should hard reset HDR+ to off,
// and HDR to off if HDR+ is supported.
settingsManager.set(SettingsManager.SCOPE_GLOBAL, Keys.KEY_CAMERA_HDR_PLUS, false);
- if (GcamHelper.hasGcamCapture()) {
+ if (GcamHelper.hasGcamAsSeparateModule()) {
settingsManager.set(SettingsManager.SCOPE_GLOBAL, Keys.KEY_CAMERA_HDR, false);
}
}
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index c40a418d7..4d609a9b7 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -19,7 +19,6 @@ package com.android.camera;
import android.app.Dialog;
import android.content.DialogInterface;
import android.graphics.Bitmap;
-import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.graphics.SurfaceTexture;
@@ -44,8 +43,8 @@ import com.android.camera.widget.AspectRatioDialogLayout;
import com.android.camera.widget.AspectRatioSelector;
import com.android.camera.widget.LocationDialogLayout;
import com.android.camera2.R;
-import com.android.ex.camera2.portability.CameraCapabilities;
import com.android.ex.camera2.portability.CameraAgent;
+import com.android.ex.camera2.portability.CameraCapabilities;
import com.android.ex.camera2.portability.CameraSettings;
import java.util.List;
@@ -93,7 +92,7 @@ public class PhotoUI implements PreviewStatusListener,
}
};
private Runnable mRunnableForNextFrame = null;
- private CountDownView mCountdownView;
+ private final CountDownView mCountdownView;
@Override
public GestureDetector.OnGestureListener getGestureListener() {
@@ -399,18 +398,24 @@ public class PhotoUI implements PreviewStatusListener,
}
}
- public void showAspectRatioDialog(final PhotoModule.AspectRatioDialogCallback callback) {
+ /**
+ * @return Whether the dialog was shown.
+ */
+ public boolean showAspectRatioDialog(final PhotoModule.AspectRatioDialogCallback callback) {
if (showAspectRatioDialogOnThisDevice()) {
setDialog(new Dialog(mActivity, android.R.style.Theme_Black_NoTitleBar_Fullscreen));
showAspectRatioDialog(callback, mDialog);
+ return true;
+ } else {
+ return false;
}
}
- private void showAspectRatioDialog(final PhotoModule.AspectRatioDialogCallback callback,
+ private boolean showAspectRatioDialog(final PhotoModule.AspectRatioDialogCallback callback,
final Dialog aspectRatioDialog) {
if (aspectRatioDialog == null) {
Log.e(TAG, "Dialog for aspect ratio is null.");
- return;
+ return false;
}
final AspectRatioDialogLayout aspectRatioDialogLayout =
(AspectRatioDialogLayout) mActivity
@@ -433,6 +438,7 @@ public class PhotoUI implements PreviewStatusListener,
aspectRatioDialog.setContentView(aspectRatioDialogLayout, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
aspectRatioDialog.show();
+ return true;
}
/**
diff --git a/src/com/android/camera/module/ModulesInfo.java b/src/com/android/camera/module/ModulesInfo.java
index 132d5ec78..62ad8e558 100644
--- a/src/com/android/camera/module/ModulesInfo.java
+++ b/src/com/android/camera/module/ModulesInfo.java
@@ -58,7 +58,7 @@ public class ModulesInfo {
registerRefocusModule(moduleManager, context.getResources()
.getInteger(R.integer.camera_mode_refocus));
}
- if (GcamHelper.hasGcamCapture()) {
+ if (GcamHelper.hasGcamAsSeparateModule()) {
registerGcamModule(moduleManager, context.getResources()
.getInteger(R.integer.camera_mode_gcam));
}
diff --git a/src/com/android/camera/one/OneCameraManager.java b/src/com/android/camera/one/OneCameraManager.java
index ec2a5be74..25f34cb4f 100644
--- a/src/com/android/camera/one/OneCameraManager.java
+++ b/src/com/android/camera/one/OneCameraManager.java
@@ -43,12 +43,14 @@ public abstract class OneCameraManager {
*
* @param facing which camera to open. The first camera found in the given
* direction will be opened.
+ * @param enableHdr if an HDR feature exists, open a camera that supports it
* @param captureSize the capture size. This must be one of the supported
* sizes.
* @param callback this listener is called when the camera was opened or
* when it failed to open.
*/
- public abstract void open(Facing facing, Size captureSize, OpenCallback callback);
+ public abstract void open(Facing facing, boolean enableHdr, Size captureSize,
+ OpenCallback callback);
/**
* Returns whether the device has a camera facing the given direction.
diff --git a/src/com/android/camera/one/v1/OneCameraManagerImpl.java b/src/com/android/camera/one/v1/OneCameraManagerImpl.java
index 054aead1c..0be46f261 100644
--- a/src/com/android/camera/one/v1/OneCameraManagerImpl.java
+++ b/src/com/android/camera/one/v1/OneCameraManagerImpl.java
@@ -28,7 +28,7 @@ import com.android.camera.util.Size;
public class OneCameraManagerImpl extends OneCameraManager {
@Override
- public void open(Facing facing, Size pictureSize, OpenCallback callback) {
+ public void open(Facing facing, boolean enableHdr, Size pictureSize, OpenCallback callback) {
throw new RuntimeException("Not implemented yet.");
}
diff --git a/src/com/android/camera/one/v2/OneCameraManagerImpl.java b/src/com/android/camera/one/v2/OneCameraManagerImpl.java
index 32e2d6b3a..c9ef11527 100644
--- a/src/com/android/camera/one/v2/OneCameraManagerImpl.java
+++ b/src/com/android/camera/one/v2/OneCameraManagerImpl.java
@@ -54,7 +54,8 @@ public class OneCameraManagerImpl extends OneCameraManager {
}
@Override
- public void open(Facing facing, final Size pictureSize, final OpenCallback openCallback) {
+ public void open(Facing facing, final boolean useHdr, final Size pictureSize,
+ final OpenCallback openCallback) {
try {
final String cameraId = getCameraId(facing);
Log.i(TAG, "Opening Camera ID " + cameraId);
@@ -76,7 +77,7 @@ public class OneCameraManagerImpl extends OneCameraManager {
CameraCharacteristics characteristics = mCameraManager
.getCameraCharacteristics(device.getId());
// TODO: Set boolean based on whether HDR+ is enabled.
- OneCamera oneCamera = OneCameraCreator.create(true, device,
+ OneCamera oneCamera = OneCameraCreator.create(useHdr, device,
characteristics, pictureSize, mMaxMemoryMB, mDisplayMetrics);
openCallback.onCameraOpened(oneCamera);
} catch (CameraAccessException e) {
@@ -110,7 +111,7 @@ public class OneCameraManagerImpl extends OneCameraManager {
}
/** Returns the ID of the first back-facing camera. */
- private String getFirstBackCameraId() {
+ public String getFirstBackCameraId() {
Log.d(TAG, "Getting First BACK Camera");
String cameraId = getFirstCameraFacing(CameraCharacteristics.LENS_FACING_BACK);
if (cameraId == null) {
@@ -120,7 +121,7 @@ public class OneCameraManagerImpl extends OneCameraManager {
}
/** Returns the ID of the first front-facing camera. */
- private String getFirstFrontCameraId() {
+ public String getFirstFrontCameraId() {
Log.d(TAG, "Getting First FRONT Camera");
String cameraId = getFirstCameraFacing(CameraCharacteristics.LENS_FACING_FRONT);
if (cameraId == null) {
diff --git a/src/com/android/camera/util/ApiHelper.java b/src/com/android/camera/util/ApiHelper.java
index f5576965e..92e62f52d 100644
--- a/src/com/android/camera/util/ApiHelper.java
+++ b/src/com/android/camera/util/ApiHelper.java
@@ -54,7 +54,10 @@ public class ApiHelper {
public static final boolean HAS_HIDEYBARS = isKitKatOrHigher();
- public static final boolean IS_NEXUS_5 = Build.DEVICE.equals("hammerhead");
+ public static final boolean IS_NEXUS_5 = "LGE".equalsIgnoreCase(Build.MANUFACTURER)
+ && "hammerhead".equalsIgnoreCase(Build.DEVICE);
+ public static final boolean IS_NEXUS_6 = "motorola".equalsIgnoreCase(Build.MANUFACTURER)
+ && "shamu".equalsIgnoreCase(Build.DEVICE);
public static int getIntFieldIfExists(Class<?> klass, String fieldName,
Class<?> obj, int defaultVal) {
diff --git a/src_pd/com/android/camera/one/v2/OneCameraCreator.java b/src_pd/com/android/camera/one/v2/OneCameraCreator.java
index bec66d82d..790c17e9d 100644
--- a/src_pd/com/android/camera/one/v2/OneCameraCreator.java
+++ b/src_pd/com/android/camera/one/v2/OneCameraCreator.java
@@ -24,9 +24,10 @@ import com.android.camera.one.OneCamera;
import com.android.camera.util.Size;
public class OneCameraCreator {
- public static OneCamera create(boolean enableHdrPlus, CameraDevice device,
+ public static OneCamera create(boolean useHdr, CameraDevice device,
CameraCharacteristics characteristics, Size pictureSize, int maxMemoryMB,
DisplayMetrics displayMetrics) {
+ // TODO: Might want to switch current camera to vendor HDR.
return new OneCameraImpl(device, characteristics, pictureSize);
}
}
diff --git a/src_pd_gcam/com/android/camera/util/GcamHelper.java b/src_pd_gcam/com/android/camera/util/GcamHelper.java
index 2b9a00036..97d4b2ca0 100644
--- a/src_pd_gcam/com/android/camera/util/GcamHelper.java
+++ b/src_pd_gcam/com/android/camera/util/GcamHelper.java
@@ -19,7 +19,6 @@ import android.content.ContentResolver;
import com.android.camera.CameraModule;
import com.android.camera.app.AppController;
-import com.android.camera.app.CameraServices;
public class GcamHelper {
@@ -27,6 +26,10 @@ public class GcamHelper {
return null;
}
+ public static boolean hasGcamAsSeparateModule() {
+ return false;
+ }
+
public static boolean hasGcamCapture() {
return false;
}