summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorweijiew <weijiew@codeaurora.org>2017-03-17 15:04:06 +0800
committerweijiew <weijiew@codeaurora.org>2017-03-29 14:43:15 +0800
commit5e10c810767d2e414ef7b5a06263db85716cdf80 (patch)
tree7c617d5776e3281f651a5fee3694953c0b18fe7f /src
parent6d2bbe9cbd95632f812be425b83469e288a2a944 (diff)
downloadandroid_packages_apps_Snap-5e10c810767d2e414ef7b5a06263db85716cdf80.tar.gz
android_packages_apps_Snap-5e10c810767d2e414ef7b5a06263db85716cdf80.tar.bz2
android_packages_apps_Snap-5e10c810767d2e414ef7b5a06263db85716cdf80.zip
SnapdragonCamera: Wrapper for QC API
1. Wrapper for Parameters 2. Wrapper for CameraInfo 3. Wrapper for CamcorderProfile 4. Wrapper for Camera 5. Wrapper for ExtendedFace Change-Id: I8c8605db3696bffc4d975c0bb6f74944ed23a6bd
Diffstat (limited to 'src')
-rw-r--r--[-rwxr-xr-x]src/com/android/camera/AndroidCameraManagerImpl.java19
-rw-r--r--src/com/android/camera/CameraManager.java9
-rw-r--r--src/com/android/camera/CameraSettings.java76
-rw-r--r--[-rwxr-xr-x]src/com/android/camera/PhotoMenu.java12
-rw-r--r--src/com/android/camera/PhotoModule.java166
-rw-r--r--[-rwxr-xr-x]src/com/android/camera/VideoMenu.java2
-rw-r--r--src/com/android/camera/VideoModule.java73
-rwxr-xr-xsrc/com/android/camera/ui/FaceView.java139
-rw-r--r--src/org/codeaurora/snapcam/wrapper/ExtendedFaceWrapper.java127
9 files changed, 274 insertions, 349 deletions
diff --git a/src/com/android/camera/AndroidCameraManagerImpl.java b/src/com/android/camera/AndroidCameraManagerImpl.java
index 4decaec6c..a442d52d9 100755..100644
--- a/src/com/android/camera/AndroidCameraManagerImpl.java
+++ b/src/com/android/camera/AndroidCameraManagerImpl.java
@@ -39,12 +39,14 @@ import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.SurfaceHolder;
-import android.hardware.Camera.CameraDataCallback;
-import android.hardware.Camera.CameraMetaDataCallback;
+import android.hardware.Camera$CameraDataCallback;
+import android.hardware.Camera$CameraMetaDataCallback;
import com.android.camera.util.ApiHelper;
import android.os.ConditionVariable;
import java.lang.reflect.Method;
+import org.codeaurora.snapcam.wrapper.CameraWrapper;
+
/**
* A class to implement {@link CameraManager} of the Android camera framework.
*/
@@ -389,19 +391,20 @@ class AndroidCameraManagerImpl implements CameraManager {
return;
case SET_HISTOGRAM_MODE:
- mCamera.setHistogramMode((CameraDataCallback) msg.obj);
+ CameraWrapper.setHistogramMode(mCamera, (Camera$CameraDataCallback) msg.obj);
break;
case SEND_HISTOGRAM_DATA:
- mCamera.sendHistogramData();
+ CameraWrapper.sendHistogramData(mCamera);
break;
case SET_LONGSHOT:
- mCamera.setLongshot((Boolean) msg.obj);
+ CameraWrapper.setLongshot(mCamera, (Boolean) msg.obj);
break;
case SET_AUTO_HDR_MODE:
- mCamera.setMetadataCb((CameraMetaDataCallback) msg.obj);
+ CameraWrapper.setMetadataCb(mCamera,
+ (Camera$CameraMetaDataCallback) msg.obj);
break;
default:
@@ -503,7 +506,7 @@ class AndroidCameraManagerImpl implements CameraManager {
}
@Override
- public void setMetadataCb(CameraMetaDataCallback cb){
+ public void setMetadataCb(Camera$CameraMetaDataCallback cb){
mCameraHandler.obtainMessage(SET_AUTO_HDR_MODE, cb).sendToTarget();
}
@@ -662,7 +665,7 @@ class AndroidCameraManagerImpl implements CameraManager {
}
@Override
- public void setHistogramMode(CameraDataCallback cb) {
+ public void setHistogramMode(Camera$CameraDataCallback cb) {
mCameraHandler.obtainMessage(SET_HISTOGRAM_MODE, cb).sendToTarget();
}
@Override
diff --git a/src/com/android/camera/CameraManager.java b/src/com/android/camera/CameraManager.java
index 7f59975df..284f7d899 100644
--- a/src/com/android/camera/CameraManager.java
+++ b/src/com/android/camera/CameraManager.java
@@ -25,9 +25,8 @@ import android.hardware.Camera.Parameters;
import android.os.Build;
import android.os.Handler;
import android.view.SurfaceHolder;
-import android.hardware.Camera.CameraDataCallback;
-import android.hardware.Camera.CameraMetaDataCallback;
-
+import android.hardware.Camera$CameraDataCallback;
+import android.hardware.Camera$CameraMetaDataCallback;
/**
* An interface which provides possible camera device operations.
*
@@ -179,7 +178,7 @@ public interface CameraManager {
* Sets the metadata cb
* @cb Metadata callback object
*/
- public void setMetadataCb (CameraMetaDataCallback cb);
+ public void setMetadataCb (Camera$CameraMetaDataCallback cb);
/**
* Reconnects to the camera device.
@@ -372,7 +371,7 @@ public interface CameraManager {
*
* @param cb cameraDataCallback to use
*/
- public void setHistogramMode(CameraDataCallback cb);
+ public void setHistogramMode(Camera$CameraDataCallback cb);
/**
* Send the Histogram Data.
*
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 2a8122872..b134aaa06 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -39,6 +39,8 @@ import com.android.camera.util.ApiHelper;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.GcamHelper;
import org.codeaurora.snapcam.R;
+import org.codeaurora.snapcam.wrapper.CamcorderProfileWrapper;
+import org.codeaurora.snapcam.wrapper.ParametersWrapper;
import java.util.ArrayList;
import java.util.List;
@@ -308,14 +310,22 @@ public class CameraSettings {
VIDEO_ENCODER_TABLE.put(MediaRecorder.VideoEncoder.MPEG_4_SP, "m4v");
//video qualities
- VIDEO_QUALITY_TABLE.put("4096x2160", CamcorderProfile.QUALITY_4KDCI);
+ if ( CamcorderProfileWrapper.QUALITY_4KDCI != -1 ) {
+ VIDEO_QUALITY_TABLE.put("4096x2160", CamcorderProfileWrapper.QUALITY_4KDCI);
+ }
VIDEO_QUALITY_TABLE.put("3840x2160", CamcorderProfile.QUALITY_2160P);
- VIDEO_QUALITY_TABLE.put("2560x1440", CamcorderProfile.QUALITY_QHD);
- VIDEO_QUALITY_TABLE.put("2048x1080", CamcorderProfile.QUALITY_2k);
+ if ( CamcorderProfileWrapper.QUALITY_QHD != -1 ) {
+ VIDEO_QUALITY_TABLE.put("2560x1440", CamcorderProfileWrapper.QUALITY_QHD);
+ }
+ if ( CamcorderProfileWrapper.QUALITY_2k != -1 ) {
+ VIDEO_QUALITY_TABLE.put("2048x1080", CamcorderProfileWrapper.QUALITY_2k);
+ }
VIDEO_QUALITY_TABLE.put("1920x1080", CamcorderProfile.QUALITY_1080P);
VIDEO_QUALITY_TABLE.put("1280x720", CamcorderProfile.QUALITY_720P);
VIDEO_QUALITY_TABLE.put("720x480", CamcorderProfile.QUALITY_480P);
- VIDEO_QUALITY_TABLE.put("640x480", CamcorderProfile.QUALITY_VGA);
+ if ( CamcorderProfileWrapper.QUALITY_VGA != -1 ) {
+ VIDEO_QUALITY_TABLE.put("640x480", CamcorderProfileWrapper.QUALITY_VGA);
+ }
VIDEO_QUALITY_TABLE.put("352x288", CamcorderProfile.QUALITY_CIF);
VIDEO_QUALITY_TABLE.put("320x240", CamcorderProfile.QUALITY_QVGA);
VIDEO_QUALITY_TABLE.put("176x144", CamcorderProfile.QUALITY_QCIF);
@@ -345,8 +355,12 @@ public class CameraSettings {
VIDEO_QUALITY_TO_TIMELAPSE.put(CamcorderProfile.QUALITY_1080P, CamcorderProfile.QUALITY_TIME_LAPSE_1080P);
VIDEO_QUALITY_TO_TIMELAPSE.put(CamcorderProfile.QUALITY_QVGA , CamcorderProfile.QUALITY_TIME_LAPSE_QVGA );
VIDEO_QUALITY_TO_TIMELAPSE.put(CamcorderProfile.QUALITY_2160P, CamcorderProfile.QUALITY_TIME_LAPSE_2160P);
- VIDEO_QUALITY_TO_TIMELAPSE.put(CamcorderProfile.QUALITY_VGA , CamcorderProfile.QUALITY_TIME_LAPSE_VGA );
- VIDEO_QUALITY_TO_TIMELAPSE.put(CamcorderProfile.QUALITY_4KDCI, CamcorderProfile.QUALITY_TIME_LAPSE_4KDCI);
+ if ( CamcorderProfileWrapper.QUALITY_VGA != -1 ) {
+ VIDEO_QUALITY_TO_TIMELAPSE.put(CamcorderProfileWrapper.QUALITY_VGA, CamcorderProfileWrapper.QUALITY_TIME_LAPSE_VGA);
+ }
+ if ( CamcorderProfileWrapper.QUALITY_4KDCI != -1 ) {
+ VIDEO_QUALITY_TO_TIMELAPSE.put(CamcorderProfileWrapper.QUALITY_4KDCI, CamcorderProfileWrapper.QUALITY_TIME_LAPSE_4KDCI);
+ }
}
public static int getTimeLapseQualityFor(int quality) {
@@ -359,14 +373,18 @@ public class CameraSettings {
VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_LOW , CamcorderProfile.QUALITY_HIGH_SPEED_LOW );
VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_HIGH , CamcorderProfile.QUALITY_HIGH_SPEED_HIGH );
VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_QCIF , -1 ); // does not exist
- VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_CIF , CamcorderProfile.QUALITY_HIGH_SPEED_CIF );
+ VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_CIF , CamcorderProfileWrapper.QUALITY_HIGH_SPEED_CIF );
VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_480P , CamcorderProfile.QUALITY_HIGH_SPEED_480P );
VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_720P , CamcorderProfile.QUALITY_HIGH_SPEED_720P );
VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_1080P, CamcorderProfile.QUALITY_HIGH_SPEED_1080P);
VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_QVGA , -1 ); // does not exist
VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_2160P, CamcorderProfile.QUALITY_HIGH_SPEED_2160P);
- VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_VGA , CamcorderProfile.QUALITY_HIGH_SPEED_VGA );
- VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfile.QUALITY_4KDCI, CamcorderProfile.QUALITY_HIGH_SPEED_4KDCI);
+ if ( CamcorderProfileWrapper.QUALITY_VGA != -1 ) {
+ VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfileWrapper.QUALITY_VGA, CamcorderProfileWrapper.QUALITY_HIGH_SPEED_VGA);
+ }
+ if ( CamcorderProfileWrapper.QUALITY_4KDCI != -1 ) {
+ VIDEO_QUALITY_TO_HIGHSPEED.put(CamcorderProfileWrapper.QUALITY_4KDCI, CamcorderProfileWrapper.QUALITY_HIGH_SPEED_4KDCI);
+ }
}
public static int getHighSpeedQualityFor(int quality) {
@@ -771,36 +789,36 @@ public class CameraSettings {
if (touchAfAec != null) {
filterUnsupportedOptions(group,
- touchAfAec, mParameters.getSupportedTouchAfAec());
+ touchAfAec, ParametersWrapper.getSupportedTouchAfAec(mParameters));
}
- if (!mParameters.isPowerModeSupported() && powerMode != null) {
+ if (!ParametersWrapper.isPowerModeSupported(mParameters) && powerMode != null) {
removePreference(group, powerMode.getKey());
}
if (selectableZoneAf != null) {
filterUnsupportedOptions(group,
- selectableZoneAf, mParameters.getSupportedSelectableZoneAf());
+ selectableZoneAf, ParametersWrapper.getSupportedSelectableZoneAf(mParameters));
}
if (mIso != null) {
filterUnsupportedOptions(group,
- mIso, mParameters.getSupportedIsoValues());
+ mIso, ParametersWrapper.getSupportedIsoValues(mParameters));
}
if (redeyeReduction != null) {
filterUnsupportedOptions(group,
- redeyeReduction, mParameters.getSupportedRedeyeReductionModes());
+ redeyeReduction, ParametersWrapper.getSupportedRedeyeReductionModes(mParameters));
}
if (denoise != null) {
filterUnsupportedOptions(group,
- denoise, mParameters.getSupportedDenoiseModes());
+ denoise, ParametersWrapper.getSupportedDenoiseModes(mParameters));
}
if (videoHdr != null) {
filterUnsupportedOptions(group,
- videoHdr, mParameters.getSupportedVideoHDRModes());
+ videoHdr, ParametersWrapper.getSupportedVideoHDRModes(mParameters));
}
if (colorEffect != null) {
@@ -825,7 +843,7 @@ public class CameraSettings {
if (autoExposure != null) {
filterUnsupportedOptions(group,
- autoExposure, mParameters.getSupportedAutoexposure());
+ autoExposure, ParametersWrapper.getSupportedAutoexposure(mParameters));
}
if(videoSnapSize != null) {
@@ -835,7 +853,7 @@ public class CameraSettings {
if (histogram!= null) {
filterUnsupportedOptions(group,
- histogram, mParameters.getSupportedHistogramModes());
+ histogram, ParametersWrapper.getSupportedHistogramModes(mParameters));
}
if (pictureFormat!= null) {
@@ -853,7 +871,7 @@ public class CameraSettings {
if (videoRotation != null) {
filterUnsupportedOptions(group,
- videoRotation, mParameters.getSupportedVideoRotationValues());
+ videoRotation, ParametersWrapper.getSupportedVideoRotationValues(mParameters));
}
if (manualFocus != null) {
@@ -875,6 +893,16 @@ public class CameraSettings {
filterUnsupportedOptions(group,
zoomLevel, getSupportedZoomLevel(mParameters));
}
+
+ if ( zsl != null ) {
+ filterUnsupportedOptions(group,
+ zsl, ParametersWrapper.getSupportedZSLModes(mParameters));
+ }
+
+ if ( faceDetection != null ) {
+ filterUnsupportedOptions(group,
+ faceDetection, ParametersWrapper.getSupportedFaceDetectionModes(mParameters));
+ }
}
private void initPreference(PreferenceGroup group) {
@@ -916,7 +944,7 @@ public class CameraSettings {
}
if ((videoHfrMode != null) &&
- (mParameters.getSupportedHfrSizes() == null)) {
+ (ParametersWrapper.getSupportedHfrSizes(mParameters) == null)) {
filterUnsupportedOptions(group, videoHfrMode, null);
}
@@ -1340,9 +1368,9 @@ public class CameraSettings {
private static void getFineResolutionQuality(ArrayList<String> supported,
int cameraId,Parameters parameters) {
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_4KDCI)) {
+ if (CamcorderProfile.hasProfile(cameraId, CamcorderProfileWrapper.QUALITY_4KDCI)) {
if (checkSupportedVideoQuality(parameters,4096,2160)) {
- supported.add(Integer.toString(CamcorderProfile.QUALITY_4KDCI));
+ supported.add(Integer.toString(CamcorderProfileWrapper.QUALITY_4KDCI));
}
}
@@ -1367,9 +1395,9 @@ public class CameraSettings {
}
}
- if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_VGA)) {
+ if (CamcorderProfile.hasProfile(cameraId, CamcorderProfileWrapper.QUALITY_VGA)) {
if (checkSupportedVideoQuality(parameters,640,480)){
- supported.add(Integer.toString(CamcorderProfile.QUALITY_VGA));
+ supported.add(Integer.toString(CamcorderProfileWrapper.QUALITY_VGA));
}
}
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java
index f1ba93845..7debfc7ef 100755..100644
--- a/src/com/android/camera/PhotoMenu.java
+++ b/src/com/android/camera/PhotoMenu.java
@@ -59,7 +59,6 @@ import com.android.camera.ui.ModuleSwitcher;
import com.android.camera.ui.RotateLayout;
import com.android.camera.ui.RotateImageView;
import com.android.camera.ui.RotateTextToast;
-import org.codeaurora.snapcam.R;
import android.widget.HorizontalScrollView;
import android.view.ViewGroup;
import android.view.WindowManager;
@@ -67,6 +66,9 @@ import android.view.Display;
import com.android.camera.util.CameraUtil;
import java.util.Locale;
+import org.codeaurora.snapcam.R;
+import org.codeaurora.snapcam.wrapper.ParametersWrapper;
+
public class PhotoMenu extends MenuController
implements ListMenu.Listener,
CountdownTimerPopup.Listener,
@@ -705,7 +707,7 @@ public class PhotoMenu extends MenuController
popup1.setPreferenceEnabled(CameraSettings.KEY_SCENE_MODE, false);
}
- if ((faceDetection != null) && !Parameters.FACE_DETECTION_ON.equals(faceDetection)) {
+ if ((faceDetection != null) && !ParametersWrapper.FACE_DETECTION_ON.equals(faceDetection)) {
popup1.setPreferenceEnabled(CameraSettings.KEY_FACE_RECOGNITION, false);
}
popup1.setPreferenceEnabled(CameraSettings.KEY_ZSL, !mUI.isCountingDown());
@@ -728,7 +730,7 @@ public class PhotoMenu extends MenuController
String multiTouchFocusOn = mActivity.getString(R.string.
pref_camera_advanced_feature_value_multi_touch_focus_on);
- if ((zsl != null) && Parameters.ZSL_OFF.equals(zsl)) {
+ if ((zsl != null) && ParametersWrapper.ZSL_OFF.equals(zsl)) {
popup1.overrideSettings(CameraSettings.KEY_ADVANCED_FEATURES,
mActivity.getString(R.string.pref_camera_advanced_feature_default));
@@ -880,7 +882,7 @@ public class PhotoMenu extends MenuController
ListPreference faceDetectPref = mPreferenceGroup.findPreference(CameraSettings.KEY_FACE_DETECTION);
String faceDetection = (faceDetectPref != null) ? faceDetectPref.getValue() : null;
Log.d(TAG, "initMakeupModeButton().onClick(): faceDetection is " + faceDetection);
- if ((faceDetection != null) && Parameters.FACE_DETECTION_OFF.equals(faceDetection)) {
+ if ((faceDetection != null) && ParametersWrapper.FACE_DETECTION_OFF.equals(faceDetection)) {
showAlertDialog(faceDetectPref);
} else {
toggleMakeupSettings();
@@ -912,7 +914,7 @@ public class PhotoMenu extends MenuController
public void onClick(DialogInterface dialog, int which) {
toggleMakeupSettings();
- faceDetectPref.setValue(Parameters.FACE_DETECTION_ON);
+ faceDetectPref.setValue(ParametersWrapper.FACE_DETECTION_ON);
onSettingChanged(faceDetectPref);
}
})
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 49cb09936..6a5ba958f 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -86,7 +86,8 @@ import com.android.camera.util.CameraUtil;
import com.android.camera.util.GcamHelper;
import com.android.camera.util.UsageStatistics;
import org.codeaurora.snapcam.R;
-
+import org.codeaurora.snapcam.wrapper.ParametersWrapper;
+import org.codeaurora.snapcam.wrapper.CameraInfoWrapper;
import android.widget.EditText;
import android.app.AlertDialog;
import android.content.DialogInterface;
@@ -102,6 +103,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.lang.NumberFormatException;
import java.util.List;
import java.util.Vector;
import java.util.HashMap;
@@ -348,7 +350,7 @@ public class PhotoModule
private FocusOverlayManager mFocusManager;
private String mSceneMode;
- private String mCurrTouchAfAec = Parameters.TOUCH_AF_AEC_ON;
+ private String mCurrTouchAfAec = ParametersWrapper.TOUCH_AF_AEC_ON;
private String mSavedFlashMode = null;
private final Handler mHandler = new MainHandler();
@@ -776,7 +778,7 @@ public class PhotoModule
return;
}
mParameters = mCameraDevice.getParameters();
- mInitialParams = mParameters;
+ mInitialParams = mCameraDevice.getParameters();
initializeCapabilities();
CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId];
mMirror = (info.facing == CameraInfo.CAMERA_FACING_FRONT);
@@ -870,17 +872,17 @@ public class PhotoModule
boolean disableQcomMiscSetting =
SystemProperties.getBoolean("camera.qcom.misc.disable", false);
if (disableQcomMiscSetting) {
- mUI.setPreference(CameraSettings.KEY_ZSL, Parameters.ZSL_OFF);
+ mUI.setPreference(CameraSettings.KEY_ZSL, ParametersWrapper.ZSL_OFF);
mUI.setPreference(CameraSettings.KEY_FACE_DETECTION,
- Parameters.FACE_DETECTION_OFF);
+ ParametersWrapper.FACE_DETECTION_OFF);
mUI.setPreference(CameraSettings.KEY_TOUCH_AF_AEC,
- Parameters.TOUCH_AF_AEC_OFF);
+ ParametersWrapper.TOUCH_AF_AEC_OFF);
mUI.setPreference(CameraSettings.KEY_FOCUS_MODE,
Parameters.FOCUS_MODE_AUTO);
mUI.setPreference(CameraSettings.KEY_FLASH_MODE,
Parameters.FLASH_MODE_OFF);
mUI.setPreference(CameraSettings.KEY_DENOISE,
- Parameters.DENOISE_OFF);
+ ParametersWrapper.DENOISE_OFF);
onSharedPreferenceChanged();
}
}
@@ -1147,7 +1149,7 @@ public class PhotoModule
}
}
private final class StatsCallback
- implements android.hardware.Camera.CameraDataCallback {
+ implements android.hardware.Camera$CameraDataCallback {
@Override
public void onCameraData(int [] data, android.hardware.Camera camera) {
//if(!mPreviewing || !mHiston || !mFirstTimeInitialized){
@@ -1168,7 +1170,7 @@ public class PhotoModule
}
private final class MetaDataCallback
- implements android.hardware.Camera.CameraMetaDataCallback{
+ implements android.hardware.Camera$CameraMetaDataCallback{
@Override
public void onCameraMetaData (byte[] data, android.hardware.Camera camera) {
int metadata[] = new int[3];
@@ -1357,7 +1359,7 @@ public class PhotoModule
mReceivedSnapNum = mReceivedSnapNum + 1;
mJpegPictureCallbackTime = System.currentTimeMillis();
- if(mSnapshotMode == CameraInfo.CAMERA_SUPPORT_MODE_ZSL) {
+ if(mSnapshotMode == CameraInfoWrapper.CAMERA_SUPPORT_MODE_ZSL) {
Log.v(TAG, "JpegPictureCallback : in zslmode");
mParameters = mCameraDevice.getParameters();
mBurstSnapNum = mParameters.getInt("num-snaps-per-shutter");
@@ -1386,7 +1388,7 @@ public class PhotoModule
boolean needRestartPreview = !mIsImageCaptureIntent
&& !mPreviewRestartSupport
&& (mCameraState != LONGSHOT)
- && (mSnapshotMode != CameraInfo.CAMERA_SUPPORT_MODE_ZSL)
+ && (mSnapshotMode != CameraInfoWrapper.CAMERA_SUPPORT_MODE_ZSL)
&& (mReceivedSnapNum == mBurstSnapNum);
if (needRestartPreview) {
setupPreview();
@@ -1547,7 +1549,7 @@ public class PhotoModule
mJpegPictureCallbackTime = 0;
}
- if (mHiston && (mSnapshotMode ==CameraInfo.CAMERA_SUPPORT_MODE_ZSL)) {
+ if (mHiston && (mSnapshotMode ==CameraInfoWrapper.CAMERA_SUPPORT_MODE_ZSL)) {
mActivity.runOnUiThread(new Runnable() {
public void run() {
if (mGraphView != null) {
@@ -1557,7 +1559,7 @@ public class PhotoModule
}
});
}
- if (mSnapshotMode == CameraInfo.CAMERA_SUPPORT_MODE_ZSL &&
+ if (mSnapshotMode == CameraInfoWrapper.CAMERA_SUPPORT_MODE_ZSL &&
mCameraState != LONGSHOT &&
mReceivedSnapNum == mBurstSnapNum &&
!mIsImageCaptureIntent) {
@@ -1706,7 +1708,7 @@ public class PhotoModule
final boolean animateBefore = (mSceneMode == CameraUtil.SCENE_MODE_HDR);
if(mHiston) {
- if (mSnapshotMode != CameraInfo.CAMERA_SUPPORT_MODE_ZSL) {
+ if (mSnapshotMode != CameraInfoWrapper.CAMERA_SUPPORT_MODE_ZSL) {
mHiston = false;
mCameraDevice.setHistogramMode(null);
}
@@ -1755,7 +1757,11 @@ public class PhotoModule
mParameters = mCameraDevice.getParameters();
}
- mBurstSnapNum = mParameters.getInt("num-snaps-per-shutter");
+ try {
+ mBurstSnapNum = mParameters.getInt("num-snaps-per-shutter");
+ }catch (NumberFormatException ex){
+ mBurstSnapNum = 1;
+ }
mReceivedSnapNum = 0;
mPreviewRestartSupport = SystemProperties.getBoolean(
PERSIST_PREVIEW_RESTART, false);
@@ -1804,7 +1810,7 @@ public class PhotoModule
mNamedImages.nameNewImage(mCaptureStartTime, mRefocus);
- if (mSnapshotMode != CameraInfo.CAMERA_SUPPORT_MODE_ZSL) {
+ if (mSnapshotMode != CameraInfoWrapper.CAMERA_SUPPORT_MODE_ZSL) {
mFaceDetectionStarted = false;
}
UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
@@ -1838,7 +1844,7 @@ public class PhotoModule
}
private void updateCommonManual3ASettings() {
- String touchAfAec = mParameters.TOUCH_AF_AEC_OFF;
+ String touchAfAec = ParametersWrapper.TOUCH_AF_AEC_OFF;
mSceneMode = Parameters.SCENE_MODE_AUTO;
String flashMode = Parameters.FLASH_MODE_OFF;
String redeyeReduction = mActivity.getString(R.string.
@@ -1848,14 +1854,13 @@ public class PhotoModule
String colorEffect = mActivity.getString(R.string.
pref_camera_coloreffect_default);
String exposureCompensation = CameraSettings.EXPOSURE_DEFAULT_VALUE;
-
if (mManual3AEnabled > 0) {
overrideCameraSettings(flashMode, null, null,
exposureCompensation, touchAfAec,
- mParameters.getAutoExposure(),
- Integer.toString(mParameters.getSaturation()),
- Integer.toString(mParameters.getContrast()),
- Integer.toString(mParameters.getSharpness()),
+ ParametersWrapper.getAutoExposure(mParameters),
+ Integer.toString(ParametersWrapper.getSaturation(mParameters)),
+ Integer.toString(ParametersWrapper.getContrast(mParameters)),
+ Integer.toString(ParametersWrapper.getSharpness(mParameters)),
colorEffect,
mSceneMode, redeyeReduction, aeBracketing);
mUI.overrideSettings(CameraSettings.KEY_LONGSHOT,
@@ -1871,7 +1876,7 @@ public class PhotoModule
mUI.overrideSettings(CameraSettings.KEY_LONGSHOT, null);
}
- String isoMode = mParameters.getISOValue();
+ String isoMode = ParametersWrapper.getISOValue(mParameters);
final String isoManual = CameraSettings.KEY_MANUAL_ISO;
if (isoMode.equals(isoManual)) {
final String isoPref = mPreferences.getString(
@@ -1991,7 +1996,7 @@ public class PhotoModule
// If scene mode is set, for white balance and focus mode
// read settings from preferences so we retain user preferences.
if (!Parameters.SCENE_MODE_AUTO.equals(mSceneMode)) {
- flashMode = mParameters.FLASH_MODE_OFF;
+ flashMode = Parameters.FLASH_MODE_OFF;
String whiteBalance = Parameters.WHITE_BALANCE_AUTO;
focusMode = mFocusManager.getFocusMode();
colorEffect = mParameters.getColorEffect();
@@ -2015,10 +2020,10 @@ public class PhotoModule
overrideCameraSettings(null, whiteBalance, focusMode,
exposureCompensation, touchAfAec,
- mParameters.getAutoExposure(),
- Integer.toString(mParameters.getSaturation()),
- Integer.toString(mParameters.getContrast()),
- Integer.toString(mParameters.getSharpness()),
+ ParametersWrapper.getAutoExposure(mParameters),
+ Integer.toString(ParametersWrapper.getSaturation(mParameters)),
+ Integer.toString(ParametersWrapper.getContrast(mParameters)),
+ Integer.toString(ParametersWrapper.getSharpness(mParameters)),
colorEffect,
sceneMode, redeyeReduction, aeBracketing);
} else if (mFocusManager.isZslEnabled()) {
@@ -2039,7 +2044,7 @@ public class PhotoModule
}
/* Disable focus if aebracket is ON */
String aeBracket = mParameters.get(CameraSettings.KEY_QC_AE_BRACKETING);
- if (!aeBracket.equalsIgnoreCase("off")) {
+ if (aeBracket != null && !aeBracket.equalsIgnoreCase("off")) {
flashMode = Parameters.FLASH_MODE_OFF;
mParameters.setFlashMode(flashMode);
}
@@ -2056,7 +2061,7 @@ public class PhotoModule
if (tsMakeupLevelPref != null &&
!tsMakeupLevelPref.getValue().equalsIgnoreCase(TsMakeupManager.MAKEUP_OFF)) {
mUI.overrideSettings(CameraSettings.KEY_FACE_DETECTION,
- Parameters.FACE_DETECTION_ON);
+ ParametersWrapper.FACE_DETECTION_ON);
}
}
@@ -2370,7 +2375,7 @@ public class PhotoModule
//Need to disable focus for ZSL mode
if (mFocusManager != null) {
- if (mSnapshotMode == CameraInfo.CAMERA_SUPPORT_MODE_ZSL) {
+ if (mSnapshotMode == CameraInfoWrapper.CAMERA_SUPPORT_MODE_ZSL) {
mFocusManager.setZslEnable(true);
} else {
mFocusManager.setZslEnable(false);
@@ -2506,7 +2511,7 @@ public class PhotoModule
}
mParameters = mCameraDevice.getParameters();
mCameraPreviewParamsReady = true;
- mInitialParams = mParameters;
+ mInitialParams = mCameraDevice.getParameters();
if (mFocusManager == null) {
initializeFocusManager();
} else {
@@ -3070,14 +3075,14 @@ public class PhotoModule
mRestartPreview = false;
String zsl = mPreferences.getString(CameraSettings.KEY_ZSL,
mActivity.getString(R.string.pref_camera_zsl_default));
- if(zsl.equals("on") && mSnapshotMode != CameraInfo.CAMERA_SUPPORT_MODE_ZSL
+ if(zsl.equals("on") && mSnapshotMode != CameraInfoWrapper.CAMERA_SUPPORT_MODE_ZSL
&& mCameraState != PREVIEW_STOPPED) {
//Switch on ZSL Camera mode
Log.v(TAG, "Switching to ZSL Camera Mode. Restart Preview");
mRestartPreview = true;
return mRestartPreview;
}
- if(zsl.equals("off") && mSnapshotMode != CameraInfo.CAMERA_SUPPORT_MODE_NONZSL
+ if(zsl.equals("off") && mSnapshotMode != CameraInfoWrapper.CAMERA_SUPPORT_MODE_NONZSL
&& mCameraState != PREVIEW_STOPPED) {
//Switch on Normal Camera mode
Log.v(TAG, "Switching to Normal Camera Mode. Restart Preview");
@@ -3160,16 +3165,17 @@ public class PhotoModule
String touchAfAec = mPreferences.getString(
CameraSettings.KEY_TOUCH_AF_AEC,
mActivity.getString(R.string.pref_camera_touchafaec_default));
- if (CameraUtil.isSupported(touchAfAec, mParameters.getSupportedTouchAfAec())) {
+ if (CameraUtil.isSupported(touchAfAec,
+ ParametersWrapper.getSupportedTouchAfAec(mParameters))) {
mCurrTouchAfAec = touchAfAec;
- mParameters.setTouchAfAec(touchAfAec);
+ ParametersWrapper.setTouchAfAec(mParameters, touchAfAec);
}
} else {
- mParameters.setTouchAfAec(mParameters.TOUCH_AF_AEC_OFF);
+ ParametersWrapper.setTouchAfAec(mParameters, ParametersWrapper.TOUCH_AF_AEC_OFF);
mFocusManager.resetTouchFocus();
}
try {
- if(mParameters.getTouchAfAec().equals(mParameters.TOUCH_AF_AEC_ON))
+ if(ParametersWrapper.getTouchAfAec(mParameters).equals(ParametersWrapper.TOUCH_AF_AEC_ON))
this.mTouchAfAecFlag = true;
else
this.mTouchAfAecFlag = false;
@@ -3226,24 +3232,25 @@ public class PhotoModule
String selectableZoneAf = mPreferences.getString(
CameraSettings.KEY_SELECTABLE_ZONE_AF,
mActivity.getString(R.string.pref_camera_selectablezoneaf_default));
- List<String> str = mParameters.getSupportedSelectableZoneAf();
- if (CameraUtil.isSupported(selectableZoneAf, mParameters.getSupportedSelectableZoneAf())) {
- mParameters.setSelectableZoneAf(selectableZoneAf);
+ List<String> str = ParametersWrapper.getSupportedSelectableZoneAf(mParameters);
+ if (CameraUtil.isSupported(selectableZoneAf,
+ ParametersWrapper.getSupportedSelectableZoneAf(mParameters))) {
+ ParametersWrapper.setSelectableZoneAf(mParameters, selectableZoneAf);
}
// Set wavelet denoise mode
- if (mParameters.getSupportedDenoiseModes() != null) {
+ if (ParametersWrapper.getSupportedDenoiseModes(mParameters) != null) {
String Denoise = mPreferences.getString( CameraSettings.KEY_DENOISE,
mActivity.getString(R.string.pref_camera_denoise_default));
- mParameters.setDenoise(Denoise);
+ ParametersWrapper.setDenoise(mParameters, Denoise);
}
// Set Redeye Reduction
String redeyeReduction = mPreferences.getString(
CameraSettings.KEY_REDEYE_REDUCTION,
mActivity.getString(R.string.pref_camera_redeyereduction_default));
if (CameraUtil.isSupported(redeyeReduction,
- mParameters.getSupportedRedeyeReductionModes())) {
- mParameters.setRedeyeReductionMode(redeyeReduction);
+ ParametersWrapper.getSupportedRedeyeReductionModes(mParameters))) {
+ ParametersWrapper.setRedeyeReductionMode(mParameters, redeyeReduction);
}
// Set ISO parameter
if ((mManual3AEnabled & MANUAL_EXPOSURE) == 0) {
@@ -3251,8 +3258,8 @@ public class PhotoModule
CameraSettings.KEY_ISO,
mActivity.getString(R.string.pref_camera_iso_default));
if (CameraUtil.isSupported(iso,
- mParameters.getSupportedIsoValues())) {
- mParameters.setISOValue(iso);
+ ParametersWrapper.getSupportedIsoValues(mParameters))) {
+ ParametersWrapper.setISOValue(mParameters, iso);
}
}
// Set color effect parameter.
@@ -3270,8 +3277,8 @@ public class PhotoModule
mActivity.getString(R.string.pref_camera_saturation_default));
int saturation = Integer.parseInt(saturationStr);
Log.v(TAG, "Saturation value =" + saturation);
- if((0 <= saturation) && (saturation <= mParameters.getMaxSaturation())){
- mParameters.setSaturation(saturation);
+ if((0 <= saturation) && (saturation <= ParametersWrapper.getMaxSaturation(mParameters))){
+ ParametersWrapper.setSaturation(mParameters, saturation);
}
// Set contrast parameter.
String contrastStr = mPreferences.getString(
@@ -3279,18 +3286,18 @@ public class PhotoModule
mActivity.getString(R.string.pref_camera_contrast_default));
int contrast = Integer.parseInt(contrastStr);
Log.v(TAG, "Contrast value =" +contrast);
- if((0 <= contrast) && (contrast <= mParameters.getMaxContrast())){
- mParameters.setContrast(contrast);
+ if((0 <= contrast) && (contrast <= ParametersWrapper.getMaxContrast(mParameters))){
+ ParametersWrapper.setContrast(mParameters, contrast);
}
// Set sharpness parameter
String sharpnessStr = mPreferences.getString(
CameraSettings.KEY_SHARPNESS,
mActivity.getString(R.string.pref_camera_sharpness_default));
int sharpness = Integer.parseInt(sharpnessStr) *
- (mParameters.getMaxSharpness()/MAX_SHARPNESS_LEVEL);
+ (ParametersWrapper.getMaxSharpness(mParameters)/MAX_SHARPNESS_LEVEL);
Log.v(TAG, "Sharpness value =" + sharpness);
- if((0 <= sharpness) && (sharpness <= mParameters.getMaxSharpness())){
- mParameters.setSharpness(sharpness);
+ if((0 <= sharpness) && (sharpness <= ParametersWrapper.getMaxSharpness(mParameters))){
+ ParametersWrapper.setSharpness(mParameters, sharpness);
}
// Set Face Recognition
String faceRC = mPreferences.getString(
@@ -3499,15 +3506,18 @@ public class PhotoModule
if (mActivity.getString(R.string.pref_camera_advanced_feature_value_trueportrait_on)
.equals(advancedFeature)) {
// face detection must always be on for truePortrait
- if (CameraUtil.isSupported(Parameters.FACE_DETECTION_ON, mParameters.getSupportedFaceDetectionModes())) {
+ if (CameraUtil.isSupported(ParametersWrapper.FACE_DETECTION_ON,
+ ParametersWrapper.getSupportedFaceDetectionModes(mParameters))) {
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
- mUI.overrideSettings(CameraSettings.KEY_FACE_DETECTION, Parameters.FACE_DETECTION_ON);
+ mUI.overrideSettings(CameraSettings.KEY_FACE_DETECTION,
+ ParametersWrapper.FACE_DETECTION_ON);
}
});
- mParameters.setFaceDetectionMode(Parameters.FACE_DETECTION_ON);
+ ParametersWrapper.setFaceDetectionMode(mParameters,
+ ParametersWrapper.FACE_DETECTION_ON);
if(mFaceDetectionEnabled == false) {
mFaceDetectionEnabled = true;
startFaceDetection();
@@ -3527,8 +3537,9 @@ public class PhotoModule
CameraSettings.KEY_FACE_DETECTION,
mActivity.getString(R.string.pref_camera_facedetection_default));
- if (CameraUtil.isSupported(faceDetection, mParameters.getSupportedFaceDetectionModes())) {
- mParameters.setFaceDetectionMode(faceDetection);
+ if (CameraUtil.isSupported(faceDetection,
+ ParametersWrapper.getSupportedFaceDetectionModes(mParameters))) {
+ ParametersWrapper.setFaceDetectionMode(mParameters, faceDetection);
if(faceDetection.equals("on") && mFaceDetectionEnabled == false) {
mFaceDetectionEnabled = true;
startFaceDetection();
@@ -3545,8 +3556,9 @@ public class PhotoModule
CameraSettings.KEY_AUTOEXPOSURE,
mActivity.getString(R.string.pref_camera_autoexposure_default));
Log.v(TAG, "autoExposure value =" + autoExposure);
- if (CameraUtil.isSupported(autoExposure, mParameters.getSupportedAutoexposure())) {
- mParameters.setAutoExposure(autoExposure);
+ if (CameraUtil.isSupported(autoExposure,
+ ParametersWrapper.getSupportedAutoexposure(mParameters))) {
+ ParametersWrapper.setAutoExposure(mParameters, autoExposure);
}
// Set anti banding parameter.
@@ -3586,11 +3598,11 @@ public class PhotoModule
});
}
}
- mParameters.setZSLMode(zsl);
- if(zsl.equals("on")) {
+ ParametersWrapper.setZSLMode(mParameters, zsl);
+ if(zsl.equals("on") && ParametersWrapper.getSupportedZSLModes(mParameters) != null) {
//Switch on ZSL Camera mode
- mSnapshotMode = CameraInfo.CAMERA_SUPPORT_MODE_ZSL;
- mParameters.setCameraMode(1);
+ mSnapshotMode = CameraInfoWrapper.CAMERA_SUPPORT_MODE_ZSL;
+ ParametersWrapper.setCameraMode(mParameters, 1);
mFocusManager.setZslEnable(true);
//Raw picture format is not supported under ZSL mode
@@ -3618,8 +3630,8 @@ public class PhotoModule
});
}
} else if(zsl.equals("off")) {
- mSnapshotMode = CameraInfo.CAMERA_SUPPORT_MODE_NONZSL;
- mParameters.setCameraMode(0);
+ mSnapshotMode = CameraInfoWrapper.CAMERA_SUPPORT_MODE_NONZSL;
+ ParametersWrapper.setCameraMode(mParameters, 0);
mFocusManager.setZslEnable(false);
if ((mManual3AEnabled & MANUAL_FOCUS) == 0) {
mFocusManager.overrideFocusMode(null);
@@ -3664,7 +3676,7 @@ public class PhotoModule
CameraSettings.KEY_HISTOGRAM,
mActivity.getString(R.string.pref_camera_histogram_default));
if (CameraUtil.isSupported(histogram,
- mParameters.getSupportedHistogramModes()) && mCameraDevice != null) {
+ ParametersWrapper.getSupportedHistogramModes(mParameters)) && mCameraDevice != null) {
// Call for histogram
if(histogram.equals("enable")) {
mActivity.runOnUiThread(new Runnable() {
@@ -3693,7 +3705,7 @@ public class PhotoModule
/* Disable focus if aebracket is ON */
String aeBracket = mParameters.get(CameraSettings.KEY_QC_AE_BRACKETING);
- if (!aeBracket.equalsIgnoreCase("off")) {
+ if (aeBracket != null && !aeBracket.equalsIgnoreCase("off")) {
String fMode = Parameters.FLASH_MODE_OFF;
mParameters.setFlashMode(fMode);
}
@@ -3717,7 +3729,7 @@ public class PhotoModule
if (!bokehMode.equals(mActivity.getString(
R.string.pref_camera_bokeh_mode_entry_value_disable))) {
if(!zsl.equals("on")) {
- mParameters.setZSLMode("on");
+ ParametersWrapper.setZSLMode(mParameters, "on");
}
if(mParameters.getSceneMode() != Parameters.SCENE_MODE_AUTO) {
mParameters.setSceneMode(Parameters.SCENE_MODE_AUTO);
@@ -4357,7 +4369,7 @@ public class PhotoModule
int focusPos = focusbar.getProgress();
Log.v(TAG, "Setting focus position : " + focusPos);
mManual3AEnabled |= MANUAL_FOCUS;
- mParameters.setFocusMode(Parameters.FOCUS_MODE_MANUAL_POSITION);
+ mParameters.setFocusMode(ParametersWrapper.FOCUS_MODE_MANUAL_POSITION);
mParameters.set(CameraSettings.KEY_MANUAL_FOCUS_TYPE, 2); // 2 for scale mode
mParameters.set(CameraSettings.KEY_MANUAL_FOCUS_POSITION, focusPos);
updateCommonManual3ASettings();
@@ -4404,7 +4416,7 @@ public class PhotoModule
if (focuspos >= minFocusPos && focuspos <= maxFocusPos) {
Log.v(TAG, "Setting focus position : " + focusStr);
mManual3AEnabled |= MANUAL_FOCUS;
- mParameters.setFocusMode(Parameters.FOCUS_MODE_MANUAL_POSITION);
+ mParameters.setFocusMode(ParametersWrapper.FOCUS_MODE_MANUAL_POSITION);
//focus type 3 is diopter mode
mParameters.set(CameraSettings.KEY_MANUAL_FOCUS_TYPE, 3);
mParameters.set(CameraSettings.KEY_MANUAL_FOCUS_POSITION, focusStr);
@@ -4605,7 +4617,7 @@ public class PhotoModule
mParameters = mCameraDevice.getParameters();
final int minISO = mParameters.getInt(CameraSettings.KEY_MIN_ISO);
final int maxISO = mParameters.getInt(CameraSettings.KEY_MAX_ISO);
- String isoMode = mParameters.getISOValue();
+ String isoMode = ParametersWrapper.getISOValue(mParameters);
final String isoManual = CameraSettings.KEY_MANUAL_ISO;
String currentISO = mParameters.get(CameraSettings.KEY_CURRENT_ISO);
if (currentISO != null) {
@@ -4647,7 +4659,7 @@ public class PhotoModule
if (newISO <= maxISO && newISO >= minISO) {
Log.v(TAG, "Setting ISO : " + newISO);
mManual3AEnabled |= MANUAL_EXPOSURE;
- mParameters.setISOValue(isoManual);
+ ParametersWrapper.setISOValue(mParameters, isoManual);
mParameters.set(CameraSettings.KEY_CONTINUOUS_ISO, newISO);
mParameters.set(CameraSettings.KEY_EXPOSURE_TIME, "0");
updateCommonManual3ASettings();
@@ -4683,8 +4695,8 @@ public class PhotoModule
Log.v(TAG, "Setting Exposure time : " + newExpTime);
mManual3AEnabled |= MANUAL_EXPOSURE;
mParameters.set(CameraSettings.KEY_EXPOSURE_TIME, expTime);
- mParameters.setISOValue(Parameters.ISO_AUTO);
- mUI.setPreference(CameraSettings.KEY_ISO, Parameters.ISO_AUTO);
+ ParametersWrapper.setISOValue(mParameters, ParametersWrapper.ISO_AUTO);
+ mUI.setPreference(CameraSettings.KEY_ISO, ParametersWrapper.ISO_AUTO);
mUI.overrideSettings(CameraSettings.KEY_ISO, null);
updateCommonManual3ASettings();
onSharedPreferenceChanged();
@@ -4735,7 +4747,7 @@ public class PhotoModule
newExpTime >= Double.parseDouble(minExpTime)) {
mManual3AEnabled |= MANUAL_EXPOSURE;
Log.v(TAG, "Setting ISO : " + newISO);
- mParameters.setISOValue(isoManual);
+ ParametersWrapper.setISOValue(mParameters, isoManual);
mParameters.set(CameraSettings.KEY_CONTINUOUS_ISO, newISO);
Log.v(TAG, "Setting Exposure time : " + newExpTime);
mParameters.set(CameraSettings.KEY_EXPOSURE_TIME, expTime);
diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java
index 472630b3c..ca6aa0687 100755..100644
--- a/src/com/android/camera/VideoMenu.java
+++ b/src/com/android/camera/VideoMenu.java
@@ -769,7 +769,7 @@ public class VideoMenu extends MenuController
.findPreference(CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL);
ListPreference videoHDRPref = mPreferenceGroup
.findPreference(CameraSettings.KEY_VIDEO_HDR);
- String disMode = disPref.getValue();
+ String disMode = disPref == null ? "disable" : disPref.getValue();
String videoHDR = videoHDRPref == null ? "off" : videoHDRPref.getValue();
String frameIntervalStr = frameIntervalPref.getValue();
int timeLapseInterval = Integer.parseInt(frameIntervalStr);
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 103529bb8..d57d61c4b 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -70,8 +70,12 @@ import com.android.camera.util.AccessibilityUtils;
import com.android.camera.util.ApiHelper;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.UsageStatistics;
-import org.codeaurora.snapcam.R;
import com.android.camera.PhotoModule;
+
+import org.codeaurora.snapcam.R;
+import org.codeaurora.snapcam.wrapper.ParametersWrapper;
+import org.codeaurora.snapcam.wrapper.CamcorderProfileWrapper;
+
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
@@ -854,24 +858,23 @@ public class VideoModule implements CameraModule,
// 1 minute = 60000ms
mMaxVideoDurationInMs = 60000 * minutes;
}
-
- if(mParameters.isPowerModeSupported()) {
+ if(ParametersWrapper.isPowerModeSupported(mParameters)) {
String powermode = mPreferences.getString(
CameraSettings.KEY_POWER_MODE,
mActivity.getString(R.string.pref_camera_powermode_default));
Log.v(TAG, "read videopreferences power mode =" +powermode);
- String old_mode = mParameters.getPowerMode();
+ String old_mode = ParametersWrapper.getPowerMode(mParameters);
if(!old_mode.equals(powermode) && mPreviewing)
mRestartPreview = true;
- mParameters.setPowerMode(powermode);
+ ParametersWrapper.setPowerMode(mParameters, powermode);
}
// Set wavelet denoise mode
- if (mParameters.getSupportedDenoiseModes() != null) {
+ if (ParametersWrapper.getSupportedDenoiseModes(mParameters) != null) {
String denoise = mPreferences.getString(CameraSettings.KEY_DENOISE,
mActivity.getString(R.string.pref_camera_denoise_default));
- mParameters.setDenoise(denoise);
+ ParametersWrapper.setDenoise(mParameters, denoise);
}
}
@@ -962,7 +965,7 @@ public class VideoModule implements CameraModule,
public boolean is4KEnabled() {
if (mProfile.quality == CamcorderProfile.QUALITY_2160P ||
mProfile.quality == CamcorderProfile.QUALITY_TIME_LAPSE_2160P ||
- mProfile.quality == CamcorderProfile.QUALITY_4KDCI ) {
+ mProfile.quality == CamcorderProfileWrapper.QUALITY_4KDCI ) {
return true;
} else {
return false;
@@ -1023,10 +1026,12 @@ public class VideoModule implements CameraModule,
if(!("off".equals(HighFrameRate))) {
Size size = null;
try {
- if (isSupported(HighFrameRate.substring(3), mParameters.getSupportedVideoHighFrameRateModes())) {
- int index = mParameters.getSupportedVideoHighFrameRateModes().indexOf(
+ if (isSupported(HighFrameRate.substring(3),
+ ParametersWrapper.getSupportedVideoHighFrameRateModes(mParameters))) {
+ int index = ParametersWrapper.
+ getSupportedVideoHighFrameRateModes(mParameters).indexOf(
HighFrameRate.substring(3));
- size = mParameters.getSupportedHfrSizes().get(index);
+ size = ParametersWrapper.getSupportedHfrSizes(mParameters).get(index);
} else {
return false;
}
@@ -1541,7 +1546,7 @@ public class VideoModule implements CameraModule,
mCameraDevice.unlock();
mMediaRecorder.setCamera(mCameraDevice.getCamera());
- String hfr = mParameters.getVideoHighFrameRate();
+ String hfr = ParametersWrapper.getVideoHighFrameRate(mParameters);
String hsr = mParameters.get(CameraSettings.KEY_VIDEO_HSR);
Log.i(TAG,"NOTE: hfr = " + hfr + " : hsr = " + hsr);
@@ -2413,10 +2418,11 @@ public class VideoModule implements CameraModule,
Log.v(TAG, "current set resolution is : "+hfrsize+ " : Rate is : " + hfrRate );
try {
Size size = null;
- if (isSupported(hfrRate, mParameters.getSupportedVideoHighFrameRateModes())) {
- int index = mParameters.getSupportedVideoHighFrameRateModes().indexOf(
- hfrRate);
- size = mParameters.getSupportedHfrSizes().get(index);
+ if (isSupported(hfrRate,
+ ParametersWrapper.getSupportedVideoHighFrameRateModes(mParameters))) {
+ int index = ParametersWrapper.
+ getSupportedVideoHighFrameRateModes(mParameters).indexOf(hfrRate);
+ size = ParametersWrapper.getSupportedHfrSizes(mParameters).get(index);
}
if (size != null) {
if (videoWidth <= size.width && videoHeight <= size.height) {
@@ -2444,13 +2450,13 @@ public class VideoModule implements CameraModule,
if (isHFR) {
mParameters.set(CameraSettings.KEY_VIDEO_HSR, "off");
if (mUnsupportedHFRVideoSize) {
- mParameters.setVideoHighFrameRate("off");
+ ParametersWrapper.setVideoHighFrameRate(mParameters, "off");
Log.v(TAG,"Unsupported hfr resolution");
} else {
- mParameters.setVideoHighFrameRate(hfrRate);
+ ParametersWrapper.setVideoHighFrameRate(mParameters, hfrRate);
}
} else {
- mParameters.setVideoHighFrameRate("off");
+ ParametersWrapper.setVideoHighFrameRate(mParameters, "off");
if (mUnsupportedHSRVideoSize) {
Log.v(TAG,"Unsupported hsr resolution");
mParameters.set(CameraSettings.KEY_VIDEO_HSR, "off");
@@ -2459,7 +2465,7 @@ public class VideoModule implements CameraModule,
}
}
} else {
- mParameters.setVideoHighFrameRate("off");
+ ParametersWrapper.setVideoHighFrameRate(mParameters, "off");
mParameters.set(CameraSettings.KEY_VIDEO_HSR, "off");
}
setFlipValue();
@@ -2606,15 +2612,16 @@ public class VideoModule implements CameraModule,
CameraSettings.KEY_VIDEO_HDR,
mActivity.getString(R.string.pref_camera_video_hdr_default));
Log.v(TAG, "Video HDR Setting =" + videoHDR);
- if (isSupported(videoHDR, mParameters.getSupportedVideoHDRModes())) {
- mParameters.setVideoHDRMode(videoHDR);
+ if (isSupported(videoHDR,
+ ParametersWrapper.getSupportedVideoHDRModes(mParameters))) {
+ ParametersWrapper.setVideoHDRMode(mParameters, videoHDR);
} else
- mParameters.setVideoHDRMode("off");
+ ParametersWrapper.setVideoHDRMode(mParameters, "off");
//HFR/HSR recording not supported with DIS,TimeLapse,HDR option
- String hfr = mParameters.getVideoHighFrameRate();
+ String hfr = ParametersWrapper.getVideoHighFrameRate(mParameters);
String hsr = mParameters.get(CameraSettings.KEY_VIDEO_HSR);
- String hdr = mParameters.getVideoHDRMode();
+ String hdr = ParametersWrapper.getVideoHDRMode(mParameters);
if ( !"off".equals(highFrameRate) ) {
// Read time lapse recording interval.
String frameIntervalStr = mPreferences.getString(
@@ -2630,7 +2637,7 @@ public class VideoModule implements CameraModule,
(disMode.equals("enable") && (rate > PERSIST_EIS_MAX_FPS)) ||
((hdr != null) && (!hdr.equals("off"))) ) {
Log.v(TAG,"HDR/DIS/Time Lapse ON for HFR/HSR selection, turning HFR/HSR off");
- mParameters.setVideoHighFrameRate("off");
+ ParametersWrapper.setVideoHighFrameRate(mParameters, "off");
mParameters.set(CameraSettings.KEY_VIDEO_HSR, "off");
mUI.overrideSettings(CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE, "off");
}
@@ -2653,8 +2660,9 @@ public class VideoModule implements CameraModule,
String videoRotation = mPreferences.getString(
CameraSettings.KEY_VIDEO_ROTATION,
mActivity.getString(R.string.pref_camera_video_rotation_default));
- if (isSupported(videoRotation, mParameters.getSupportedVideoRotationValues())) {
- mParameters.setVideoRotation(videoRotation);
+ if (isSupported(videoRotation,
+ ParametersWrapper.getSupportedVideoRotationValues(mParameters))) {
+ ParametersWrapper.setVideoRotation(mParameters, videoRotation);
}
//set power mode settings
@@ -2665,9 +2673,10 @@ public class VideoModule implements CameraModule,
CameraSettings.KEY_FACE_DETECTION,
mActivity.getString(R.string.pref_camera_facedetection_default));
- if (CameraUtil.isSupported(faceDetection, mParameters.getSupportedFaceDetectionModes())) {
+ if (CameraUtil.isSupported(faceDetection,
+ ParametersWrapper.getSupportedFaceDetectionModes(mParameters))) {
Log.d(TAG, "setFaceDetectionMode "+faceDetection);
- mParameters.setFaceDetectionMode(faceDetection);
+ ParametersWrapper.setFaceDetectionMode(mParameters, faceDetection);
if(faceDetection.equals("on") && mFaceDetectionEnabled == false) {
mFaceDetectionEnabled = true;
startFaceDetection();
@@ -2838,7 +2847,7 @@ public class VideoModule implements CameraModule,
if (CameraSettings.VIDEO_QUALITY_TABLE.containsKey(videoQuality)) {
int quality = CameraSettings.VIDEO_QUALITY_TABLE.get(videoQuality);
if ((quality == CamcorderProfile.QUALITY_2160P
- || quality == CamcorderProfile.QUALITY_4KDCI)
+ || quality == CamcorderProfileWrapper.QUALITY_4KDCI)
&& mPreferences != null) {
String disDisable = mActivity.getString(R.string.pref_camera_dis_value_disable);
if (!disDisable.equals(
@@ -3000,7 +3009,7 @@ public class VideoModule implements CameraModule,
return;
}
forceFlashOffIfSupported(forceOff);
- mCameraDevice.setParameters(mParameters);
+ mCameraDevice.setParameters(mCameraDevice.getParameters());
mUI.updateOnScreenIndicators(mParameters, mPreferences);
}
diff --git a/src/com/android/camera/ui/FaceView.java b/src/com/android/camera/ui/FaceView.java
index db37dbcb3..b617891e5 100755
--- a/src/com/android/camera/ui/FaceView.java
+++ b/src/com/android/camera/ui/FaceView.java
@@ -234,112 +234,111 @@ public class FaceView extends View
canvas.drawOval(mRect, mPaint);
if (ExtendedFaceWrapper.isExtendedFaceInstance(mFaces[i])) {
- ExtendedFaceWrapper wrapper = new ExtendedFaceWrapper(mFaces[i]);
float[] point = new float[4];
int delta_x = mFaces[i].rect.width() / 12;
int delta_y = mFaces[i].rect.height() / 12;
- Log.e(TAG, "blink: (" + wrapper.getLeftEyeBlinkDegree()+ ", " +
- wrapper.getRightEyeBlinkDegree() + ")");
- if (wrapper.mFace.leftEye != null) {
+ Log.e(TAG, "blink: (" + ExtendedFaceWrapper.getLeftEyeBlinkDegree(mFaces[i])+ ", " +
+ ExtendedFaceWrapper.getRightEyeBlinkDegree(mFaces[i]) + ")");
+ if (mFaces[i].leftEye != null) {
if ((mDisplayRotation == 0) ||
(mDisplayRotation == 180)) {
- point[0] = wrapper.mFace.leftEye.x;
- point[1] = wrapper.mFace.leftEye.y - delta_y / 2;
- point[2] = wrapper.mFace.leftEye.x;
- point[3] = wrapper.mFace.leftEye.y + delta_y / 2;
+ point[0] = mFaces[i].leftEye.x;
+ point[1] = mFaces[i].leftEye.y - delta_y / 2;
+ point[2] = mFaces[i].leftEye.x;
+ point[3] = mFaces[i].leftEye.y + delta_y / 2;
} else {
- point[0] = wrapper.mFace.leftEye.x - delta_x / 2;
- point[1] = wrapper.mFace.leftEye.y;
- point[2] = wrapper.mFace.leftEye.x + delta_x / 2;
- point[3] = wrapper.mFace.leftEye.y;
+ point[0] = mFaces[i].leftEye.x - delta_x / 2;
+ point[1] = mFaces[i].leftEye.y;
+ point[2] = mFaces[i].leftEye.x + delta_x / 2;
+ point[3] = mFaces[i].leftEye.y;
}
mMatrix.mapPoints (point);
- if (wrapper.getLeftEyeBlinkDegree() >= blink_threshold) {
+ if (ExtendedFaceWrapper.getLeftEyeBlinkDegree(mFaces[i]) >= blink_threshold) {
canvas.drawLine(point[0]+ dx, point[1]+ dy,
point[2]+ dx, point[3]+ dy, mPaint);
}
}
- if (wrapper.mFace.rightEye != null) {
+ if (mFaces[i].rightEye != null) {
if ((mDisplayRotation == 0) ||
(mDisplayRotation == 180)) {
- point[0] = wrapper.mFace.rightEye.x;
- point[1] = wrapper.mFace.rightEye.y - delta_y / 2;
- point[2] = wrapper.mFace.rightEye.x;
- point[3] = wrapper.mFace.rightEye.y + delta_y / 2;
+ point[0] = mFaces[i].rightEye.x;
+ point[1] = mFaces[i].rightEye.y - delta_y / 2;
+ point[2] = mFaces[i].rightEye.x;
+ point[3] = mFaces[i].rightEye.y + delta_y / 2;
} else {
- point[0] = wrapper.mFace.rightEye.x - delta_x / 2;
- point[1] = wrapper.mFace.rightEye.y;
- point[2] = wrapper.mFace.rightEye.x + delta_x / 2;
- point[3] = wrapper.mFace.rightEye.y;
+ point[0] = mFaces[i].rightEye.x - delta_x / 2;
+ point[1] = mFaces[i].rightEye.y;
+ point[2] = mFaces[i].rightEye.x + delta_x / 2;
+ point[3] = mFaces[i].rightEye.y;
}
mMatrix.mapPoints (point);
- if (wrapper.getRightEyeBlinkDegree() >= blink_threshold) {
+ if (ExtendedFaceWrapper.getRightEyeBlinkDegree(mFaces[i]) >= blink_threshold) {
//Add offset to the points if the rect has an offset
canvas.drawLine(point[0] + dx, point[1] + dy,
point[2] +dx, point[3] +dy, mPaint);
}
}
- if (wrapper.getLeftRightGazeDegree() != 0
- || wrapper.getTopBottomGazeDegree() != 0 ) {
+ if (ExtendedFaceWrapper.getLeftRightGazeDegree(mFaces[i]) != 0
+ || ExtendedFaceWrapper.getTopBottomGazeDegree(mFaces[i]) != 0 ) {
double length =
- Math.sqrt((wrapper.mFace.leftEye.x - wrapper.mFace.rightEye.x) *
- (wrapper.mFace.leftEye.x - wrapper.mFace.rightEye.x) +
- (wrapper.mFace.leftEye.y - wrapper.mFace.rightEye.y) *
- (wrapper.mFace.leftEye.y - wrapper.mFace.rightEye.y)) / 2.0;
- double nGazeYaw = -wrapper.getLeftRightGazeDegree();
- double nGazePitch = -wrapper.getTopBottomGazeDegree();
+ Math.sqrt((mFaces[i].leftEye.x - mFaces[i].rightEye.x) *
+ (mFaces[i].leftEye.x - mFaces[i].rightEye.x) +
+ (mFaces[i].leftEye.y - mFaces[i].rightEye.y) *
+ (mFaces[i].leftEye.y - mFaces[i].rightEye.y)) / 2.0;
+ double nGazeYaw = -ExtendedFaceWrapper.getLeftRightGazeDegree(mFaces[i]);
+ double nGazePitch = -ExtendedFaceWrapper.getTopBottomGazeDegree(mFaces[i]);
float gazeRollX =
(float)((-Math.sin(nGazeYaw/180.0*Math.PI) *
- Math.cos(-wrapper.getRollDirection()/
+ Math.cos(-ExtendedFaceWrapper.getRollDirection(mFaces[i])/
180.0*Math.PI) +
Math.sin(nGazePitch/180.0*Math.PI) *
Math.cos(nGazeYaw/180.0*Math.PI) *
- Math.sin(-wrapper.getRollDirection()/
+ Math.sin(-ExtendedFaceWrapper.getRollDirection(mFaces[i])/
180.0*Math.PI)) *
(-length) + 0.5);
float gazeRollY =
(float)((Math.sin(-nGazeYaw/180.0*Math.PI) *
- Math.sin(-wrapper.getRollDirection()/
+ Math.sin(-ExtendedFaceWrapper.getRollDirection(mFaces[i])/
180.0*Math.PI)-
Math.sin(nGazePitch/180.0*Math.PI) *
Math.cos(nGazeYaw/180.0*Math.PI) *
- Math.cos(-wrapper.getRollDirection()/
+ Math.cos(-ExtendedFaceWrapper.getRollDirection(mFaces[i])/
180.0*Math.PI)) *
(-length) + 0.5);
- if (wrapper.getLeftEyeBlinkDegree() < blink_threshold) {
+ if (ExtendedFaceWrapper.getLeftEyeBlinkDegree(mFaces[i]) < blink_threshold) {
if ((mDisplayRotation == 90) ||
(mDisplayRotation == 270)) {
- point[0] = wrapper.mFace.leftEye.x;
- point[1] = wrapper.mFace.leftEye.y;
- point[2] = wrapper.mFace.leftEye.x + gazeRollX;
- point[3] = wrapper.mFace.leftEye.y + gazeRollY;
+ point[0] = mFaces[i].leftEye.x;
+ point[1] = mFaces[i].leftEye.y;
+ point[2] = mFaces[i].leftEye.x + gazeRollX;
+ point[3] = mFaces[i].leftEye.y + gazeRollY;
} else {
- point[0] = wrapper.mFace.leftEye.x;
- point[1] = wrapper.mFace.leftEye.y;
- point[2] = wrapper.mFace.leftEye.x + gazeRollY;
- point[3] = wrapper.mFace.leftEye.y + gazeRollX;
+ point[0] = mFaces[i].leftEye.x;
+ point[1] = mFaces[i].leftEye.y;
+ point[2] = mFaces[i].leftEye.x + gazeRollY;
+ point[3] = mFaces[i].leftEye.y + gazeRollX;
}
mMatrix.mapPoints (point);
canvas.drawLine(point[0] +dx, point[1] + dy,
point[2] + dx, point[3] +dy, mPaint);
}
- if (wrapper.getRightEyeBlinkDegree() < blink_threshold) {
+ if (ExtendedFaceWrapper.getRightEyeBlinkDegree(mFaces[i]) < blink_threshold) {
if ((mDisplayRotation == 90) ||
(mDisplayRotation == 270)) {
- point[0] = wrapper.mFace.rightEye.x;
- point[1] = wrapper.mFace.rightEye.y;
- point[2] = wrapper.mFace.rightEye.x + gazeRollX;
- point[3] = wrapper.mFace.rightEye.y + gazeRollY;
+ point[0] = mFaces[i].rightEye.x;
+ point[1] = mFaces[i].rightEye.y;
+ point[2] = mFaces[i].rightEye.x + gazeRollX;
+ point[3] = mFaces[i].rightEye.y + gazeRollY;
} else {
- point[0] = wrapper.mFace.rightEye.x;
- point[1] = wrapper.mFace.rightEye.y;
- point[2] = wrapper.mFace.rightEye.x + gazeRollY;
- point[3] = wrapper.mFace.rightEye.y + gazeRollX;
+ point[0] = mFaces[i].rightEye.x;
+ point[1] = mFaces[i].rightEye.y;
+ point[2] = mFaces[i].rightEye.x + gazeRollY;
+ point[3] = mFaces[i].rightEye.y + gazeRollX;
}
mMatrix.mapPoints (point);
@@ -348,35 +347,35 @@ public class FaceView extends View
}
}
- if (wrapper.mFace.mouth != null) {
- Log.e(TAG, "smile: " + wrapper.getSmileDegree() + "," +
- wrapper.getSmileScore());
- if (wrapper.getSmileDegree() < smile_threashold_no_smile) {
- point[0] = wrapper.mFace.mouth.x + dx - delta_x;
- point[1] = wrapper.mFace.mouth.y;
- point[2] = wrapper.mFace.mouth.x + dx + delta_x;
- point[3] = wrapper.mFace.mouth.y;
+ if (mFaces[i].mouth != null) {
+ Log.e(TAG, "smile: " + ExtendedFaceWrapper.getSmileDegree(mFaces[i]) + "," +
+ ExtendedFaceWrapper.getSmileScore(mFaces[i]));
+ if (ExtendedFaceWrapper.getSmileDegree(mFaces[i]) < smile_threashold_no_smile) {
+ point[0] = mFaces[i].mouth.x + dx - delta_x;
+ point[1] = mFaces[i].mouth.y;
+ point[2] = mFaces[i].mouth.x + dx + delta_x;
+ point[3] = mFaces[i].mouth.y;
Matrix faceMatrix = new Matrix(mMatrix);
- faceMatrix.preRotate(wrapper.getRollDirection(),
- wrapper.mFace.mouth.x, wrapper.mFace.mouth.y);
+ faceMatrix.preRotate(ExtendedFaceWrapper.getRollDirection(mFaces[i]),
+ mFaces[i].mouth.x, mFaces[i].mouth.y);
faceMatrix.mapPoints(point);
canvas.drawLine(point[0] + dx, point[1] + dy,
point[2] + dx, point[3] + dy, mPaint);
- } else if (wrapper.getSmileDegree() <
+ } else if (ExtendedFaceWrapper.getSmileDegree(mFaces[i]) <
smile_threashold_small_smile) {
int rotation_mouth = 360 - mDisplayRotation;
- mRect.set(wrapper.mFace.mouth.x-delta_x,
- wrapper.mFace.mouth.y-delta_y, wrapper.mFace.mouth.x+delta_x,
- wrapper.mFace.mouth.y+delta_y);
+ mRect.set(mFaces[i].mouth.x-delta_x,
+ mFaces[i].mouth.y-delta_y, mFaces[i].mouth.x+delta_x,
+ mFaces[i].mouth.y+delta_y);
mMatrix.mapRect(mRect);
mRect.offset(dx, dy);
canvas.drawArc(mRect, rotation_mouth,
180, true, mPaint);
} else {
- mRect.set(wrapper.mFace.mouth.x-delta_x,
- wrapper.mFace.mouth.y-delta_y, wrapper.mFace.mouth.x+delta_x,
- wrapper.mFace.mouth.y+delta_y);
+ mRect.set(mFaces[i].mouth.x-delta_x,
+ mFaces[i].mouth.y-delta_y, mFaces[i].mouth.x+delta_x,
+ mFaces[i].mouth.y+delta_y);
mMatrix.mapRect(mRect);
mRect.offset(dx, dy);
canvas.drawOval(mRect, mPaint);
diff --git a/src/org/codeaurora/snapcam/wrapper/ExtendedFaceWrapper.java b/src/org/codeaurora/snapcam/wrapper/ExtendedFaceWrapper.java
deleted file mode 100644
index 4c92e630d..000000000
--- a/src/org/codeaurora/snapcam/wrapper/ExtendedFaceWrapper.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.codeaurora.snapcam.wrapper;
-
-import java.lang.reflect.Method;
-
-import android.hardware.Camera.Face;
-import android.os.Bundle;
-
-public class ExtendedFaceWrapper{
- private final static String CLASS_NAME = "org.codeaurora.camera.ExtendedFace";
- private static Class<?> mExtendFaceClass;
- public Face mFace;
- public ExtendedFaceWrapper(Face face){
- mFace = face;
- }
-
- public static boolean isExtendedFaceInstance(Object object) {
- if ( mExtendFaceClass == null ){
- try {
- mExtendFaceClass = Class.forName(CLASS_NAME);
- }catch (Exception exception){
- exception.printStackTrace();
- return false;
- }
- }
- return mExtendFaceClass.isInstance(object);
- }
-
- public int getSmileDegree() {
- return (int)invokeMethod("getSmileDegree");
- }
-
- public int getSmileScore() {
- return (int)invokeMethod("getSmileScore");
- }
-
- public int getBlinkDetected() {
- return (int)invokeMethod("getBlinkDetected");
- }
-
-
- public int getFaceRecognized() {
- return (int)invokeMethod("getFaceRecognized");
- }
-
- public int getGazeAngle() {
- return (int)invokeMethod("getGazeAngle");
- }
-
- public int getUpDownDirection() {
- return (int)invokeMethod("getUpDownDirection");
- }
-
- public int getLeftRightDirection() {
- return (int)invokeMethod("getLeftRightDirection");
- }
-
-
- public int getRollDirection() {
- return (int)invokeMethod("getRollDirection");
- }
-
- public int getLeftEyeBlinkDegree() {
- return (int)invokeMethod("getLeftEyeBlinkDegree");
- }
-
-
- public int getRightEyeBlinkDegree() {
- return (int)invokeMethod("getRightEyeBlinkDegree");
- }
-
-
- public int getLeftRightGazeDegree() {
- return (int)invokeMethod("getLeftRightGazeDegree");
- }
-
-
- public int getTopBottomGazeDegree() {
- return (int)invokeMethod("getTopBottomGazeDegree");
- }
-
- public Bundle getExtendedFaceInfo() {
- return (Bundle)invokeMethod("getExtendedFaceInfo");
- }
-
- private Object invokeMethod(String name){
- Object result = null;
- try {
- if ( mExtendFaceClass == null ){
- mExtendFaceClass = Class.forName(CLASS_NAME);
- }
- Method method = mExtendFaceClass.getDeclaredMethod(name);
- result = method.invoke(mFace);
- }catch(Exception exception){
- exception.printStackTrace();
- }
- return result;
- }
-}