diff options
author | weijiew <weijiew@codeaurora.org> | 2017-03-17 15:04:06 +0800 |
---|---|---|
committer | Weijie Wang <weijiew@codeaurora.org> | 2017-08-29 14:48:48 +0800 |
commit | 21a4a7c612e47af9f06550976b74aa984f5a6b69 (patch) | |
tree | 42d6c38c057d2eda70bf437b45b841514ffda293 | |
parent | a5eb667e4f654501063ade99f2ce7ededed1515a (diff) | |
download | android_packages_apps_Snap-21a4a7c612e47af9f06550976b74aa984f5a6b69.tar.gz android_packages_apps_Snap-21a4a7c612e47af9f06550976b74aa984f5a6b69.tar.bz2 android_packages_apps_Snap-21a4a7c612e47af9f06550976b74aa984f5a6b69.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
16 files changed, 1624 insertions, 339 deletions
diff --git a/Android.mk b/Android.mk index 2f9723815..23b97472c 100644 --- a/Android.mk +++ b/Android.mk @@ -11,6 +11,7 @@ LOCAL_STATIC_JAVA_LIBRARIES += xmp_toolkit LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_SRC_FILES += $(call all-java-files-under, src_pd) LOCAL_SRC_FILES += $(call all-java-files-under, src_pd_gcam) +LOCAL_SRC_FILES += $(call all-java-files-under, src_wrapper) LOCAL_SRC_FILES += $(call all-renderscript-files-under, rs) LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/res diff --git a/src/com/android/camera/AndroidCameraManagerImpl.java b/src/com/android/camera/AndroidCameraManagerImpl.java index 987691bb6..cad136cde 100755..100644 --- a/src/com/android/camera/AndroidCameraManagerImpl.java +++ b/src/com/android/camera/AndroidCameraManagerImpl.java @@ -45,6 +45,8 @@ 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,19 @@ class AndroidCameraManagerImpl implements CameraManager { return; case SET_HISTOGRAM_MODE: - mCamera.setHistogramMode((CameraDataCallback) msg.obj); + CameraWrapper.setHistogramMode(mCamera, (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, (CameraMetaDataCallback) msg.obj); break; default: diff --git a/src/com/android/camera/CameraManager.java b/src/com/android/camera/CameraManager.java index 7f59975df..b93e7182b 100644 --- a/src/com/android/camera/CameraManager.java +++ b/src/com/android/camera/CameraManager.java @@ -27,7 +27,6 @@ import android.os.Handler; import android.view.SurfaceHolder; import android.hardware.Camera.CameraDataCallback; import android.hardware.Camera.CameraMetaDataCallback; - /** * An interface which provides possible camera device operations. * diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index 4cd447587..e0141ed11 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); @@ -346,8 +356,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) { @@ -360,14 +374,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) { @@ -772,36 +790,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) { @@ -826,7 +844,7 @@ public class CameraSettings { if (autoExposure != null) { filterUnsupportedOptions(group, - autoExposure, mParameters.getSupportedAutoexposure()); + autoExposure, ParametersWrapper.getSupportedAutoexposure(mParameters)); } if(videoSnapSize != null) { @@ -836,7 +854,7 @@ public class CameraSettings { if (histogram!= null) { filterUnsupportedOptions(group, - histogram, mParameters.getSupportedHistogramModes()); + histogram, ParametersWrapper.getSupportedHistogramModes(mParameters)); } if (pictureFormat!= null) { @@ -854,7 +872,7 @@ public class CameraSettings { if (videoRotation != null) { filterUnsupportedOptions(group, - videoRotation, mParameters.getSupportedVideoRotationValues()); + videoRotation, ParametersWrapper.getSupportedVideoRotationValues(mParameters)); } if (manualFocus != null) { @@ -876,6 +894,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) { @@ -917,7 +945,7 @@ public class CameraSettings { } if ((videoHfrMode != null) && - (mParameters.getSupportedHfrSizes() == null)) { + (ParametersWrapper.getSupportedHfrSizes(mParameters) == null)) { filterUnsupportedOptions(group, videoHfrMode, null); } @@ -1341,9 +1369,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)); } } @@ -1368,9 +1396,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 2b4fb06f9..17d45890a 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(); } } @@ -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 830c04079..4332048a1 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; - } -} diff --git a/src_wrapper/org/codeaurora/snapcam/wrapper/CamcorderProfileWrapper.java b/src_wrapper/org/codeaurora/snapcam/wrapper/CamcorderProfileWrapper.java new file mode 100644 index 000000000..e57d3fa37 --- /dev/null +++ b/src_wrapper/org/codeaurora/snapcam/wrapper/CamcorderProfileWrapper.java @@ -0,0 +1,59 @@ +/* + * 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.util.List; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import android.hardware.Camera.CameraInfo; +import android.media.CamcorderProfile; +import android.util.Log; + +public class CamcorderProfileWrapper extends Wrapper{ + public static final int QUALITY_VGA = getFieldValue( + getField(CamcorderProfile.class, "QUALITY_VGA"), -1); + public final static int QUALITY_4KDCI = getFieldValue( + getField(CamcorderProfile.class, "QUALITY_4KDCI"), -1); + public final static int QUALITY_TIME_LAPSE_VGA = getFieldValue( + getField(CamcorderProfile.class, "QUALITY_TIME_LAPSE_VGA"), -1); + public static final int QUALITY_TIME_LAPSE_4KDCI = getFieldValue( + getField(CamcorderProfile.class, "QUALITY_TIME_LAPSE_4KDCI"), -1); + public final static int QUALITY_HIGH_SPEED_CIF = getFieldValue( + getField(CamcorderProfile.class, "QUALITY_HIGH_SPEED_CIF"), -1); + public static final int QUALITY_HIGH_SPEED_VGA = getFieldValue( + getField(CamcorderProfile.class, "QUALITY_HIGH_SPEED_VGA"), -1); + public final static int QUALITY_HIGH_SPEED_4KDCI = getFieldValue( + getField(CamcorderProfile.class, "QUALITY_HIGH_SPEED_4KDCI"), -1); + public static final int QUALITY_QHD = getFieldValue( + getField(CamcorderProfile.class, "QUALITY_QHD"), -1); + public final static int QUALITY_2k = getFieldValue( + getField(CamcorderProfile.class, "QUALITY_2k"), -1); +} diff --git a/src_wrapper/org/codeaurora/snapcam/wrapper/CameraInfoWrapper.java b/src_wrapper/org/codeaurora/snapcam/wrapper/CameraInfoWrapper.java new file mode 100644 index 000000000..70c96a995 --- /dev/null +++ b/src_wrapper/org/codeaurora/snapcam/wrapper/CameraInfoWrapper.java @@ -0,0 +1,46 @@ +/* + * 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.util.List; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import android.hardware.Camera.CameraInfo; +import android.util.Log; + +public class CameraInfoWrapper extends Wrapper{ + private final static String TAG = "CameraInfo"; + public final static int CAMERA_SUPPORT_MODE_ZSL = getFieldValue( + getField(CameraInfo.class, "CAMERA_SUPPORT_MODE_ZSL"), 2); + public static final int CAMERA_SUPPORT_MODE_NONZSL = getFieldValue( + getField(CameraInfo.class, "CAMERA_SUPPORT_MODE_NONZSL"), 3); + +} diff --git a/src_wrapper/org/codeaurora/snapcam/wrapper/CameraWrapper.java b/src_wrapper/org/codeaurora/snapcam/wrapper/CameraWrapper.java new file mode 100644 index 000000000..6739686e9 --- /dev/null +++ b/src_wrapper/org/codeaurora/snapcam/wrapper/CameraWrapper.java @@ -0,0 +1,122 @@ +/* + * 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.io.IOException; +import java.lang.reflect.Method; + +import android.graphics.SurfaceTexture; +import android.hardware.Camera; +import android.hardware.Camera.AutoFocusCallback; +import android.hardware.Camera.AutoFocusMoveCallback; +import android.hardware.Camera.ErrorCallback; +import android.hardware.Camera.FaceDetectionListener; +import android.hardware.Camera.OnZoomChangeListener; +import android.hardware.Camera.Parameters; +import android.hardware.Camera.PictureCallback; +import android.hardware.Camera.PreviewCallback; +import android.hardware.Camera.ShutterCallback; +import android.util.Log; +import android.view.SurfaceHolder; + +import android.hardware.Camera.CameraMetaDataCallback; +import android.hardware.Camera.CameraDataCallback; + +public class CameraWrapper extends Wrapper{ + + private static Method method_setMetadataCb = null; + public static final void setMetadataCb(Camera camera, CameraMetaDataCallback cb){ + if ( DEBUG ){ + Log.e(TAG, "" + Camera.class + " no setMetadataCb"); + return; + } + try{ + if ( method_setMetadataCb == null ){ + method_setMetadataCb = Camera.class.getMethod("setMetadataCb", + android.hardware.Camera.CameraMetaDataCallback.class); + } + method_setMetadataCb.invoke(camera, cb); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + + + private static Method method_setHistogramMode = null; + public static final void setHistogramMode(Camera camera, CameraDataCallback cb) { + if ( DEBUG ){ + Log.e(TAG, "" + Camera.class + " no setHistogramMode"); + return; + } + try{ + if ( method_setHistogramMode == null ){ + method_setHistogramMode = Camera.class.getMethod("setHistogramMode", + CameraDataCallback.class); + } + method_setHistogramMode.invoke(camera, cb); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_sendHistogramData = null; + public static final void sendHistogramData(Camera camera){ + if ( DEBUG ){ + Log.e(TAG, "" + Camera.class + " no sendHistogramData"); + return; + } + try{ + if ( method_sendHistogramData == null ){ + method_sendHistogramData = Camera.class.getMethod("sendHistogramData"); + } + method_sendHistogramData.invoke(camera); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_setLongshot = null; + public static final void setLongshot(Camera camera, boolean enable){ + if ( DEBUG ){ + Log.e(TAG, "" + Camera.class + " no setLongshot"); + return; + } + try { + if (method_setLongshot == null) { + method_setLongshot = + Camera.class.getDeclaredMethod("setLongshot", boolean.class); + } + method_setLongshot.invoke(camera, enable); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + +} diff --git a/src_wrapper/org/codeaurora/snapcam/wrapper/ExtendedFaceWrapper.java b/src_wrapper/org/codeaurora/snapcam/wrapper/ExtendedFaceWrapper.java new file mode 100644 index 000000000..3a6150558 --- /dev/null +++ b/src_wrapper/org/codeaurora/snapcam/wrapper/ExtendedFaceWrapper.java @@ -0,0 +1,233 @@ +/* + * 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; +import android.util.Log; + +public class ExtendedFaceWrapper extends Wrapper{ + private final static String CLASS_NAME = "org.codeaurora.camera.ExtendedFace"; + private static Class<?> mExtendFaceClass; + + 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); + } + + private static Method method_getSmileDegree = null; + public static int getSmileDegree(Face face) { + int degree = 0; + try { + if (method_getSmileDegree == null) { + method_getSmileDegree = getMethod("getSmileDegree"); + } + degree = (int) method_getSmileDegree.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return degree; + } + + private static Method method_getSmileScore = null; + public static int getSmileScore(Face face) { + int score = 0; + try{ + if ( method_getSmileScore == null ){ + method_getSmileScore = getMethod("getSmileScore"); + } + score = (int)method_getSmileScore.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return score; + } + + private static Method method_getBlinkDetected = null; + public static int getBlinkDetected(Face face) { + int blink = 0; + try{ + if ( method_getBlinkDetected == null ){ + method_getBlinkDetected = getMethod("getBlinkDetected"); + } + blink = (int)method_getBlinkDetected.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return blink; + } + + private static Method method_getFaceRecognized = null; + public static int getFaceRecognized(Face face) { + int faces = 0; + try{ + if ( method_getFaceRecognized == null ){ + method_getFaceRecognized = getMethod("getFaceRecognized"); + } + faces = (int)method_getFaceRecognized.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return faces; + } + + private static Method method_getGazeAngle = null; + public static int getGazeAngle(Face face) { + int angle = 0; + try{ + if ( method_getGazeAngle == null ){ + method_getGazeAngle = getMethod("getGazeAngle"); + } + angle = (int)method_getGazeAngle.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return angle; + } + + private static Method method_getUpDownDirection = null; + public static int getUpDownDirection(Face face) { + int direction = 0; + try{ + if ( method_getUpDownDirection == null ){ + method_getUpDownDirection = getMethod("getUpDownDirection"); + } + direction = (int)method_getUpDownDirection.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return direction; + } + + private static Method method_getLeftRightDirection = null; + public static int getLeftRightDirection(Face face) { + int direction = 0; + try{ + if ( method_getLeftRightDirection == null ){ + method_getLeftRightDirection = getMethod("getLeftRightDirection"); + } + direction = (int)method_getLeftRightDirection.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return direction; + } + + private static Method method_getRollDirection = null; + public static int getRollDirection(Face face) { + int direction = 0; + try{ + if ( method_getRollDirection == null ){ + method_getRollDirection = getMethod("getRollDirection"); + } + direction = (int)method_getRollDirection.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return direction; + } + + private static Method method_getLeftEyeBlinkDegree = null; + public static int getLeftEyeBlinkDegree(Face face) { + int degree = 0; + try{ + if ( method_getLeftEyeBlinkDegree == null ){ + method_getLeftEyeBlinkDegree = getMethod("getLeftEyeBlinkDegree"); + } + degree = (int)method_getLeftEyeBlinkDegree.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return degree; + } + + private static Method method_getRightEyeBlinkDegree = null; + public static int getRightEyeBlinkDegree(Face face) { + int degree = 0; + try{ + if ( method_getRightEyeBlinkDegree == null ){ + method_getRightEyeBlinkDegree = getMethod("getRightEyeBlinkDegree"); + } + degree = (int)method_getRightEyeBlinkDegree.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return degree; + } + + private static Method method_getLeftRightGazeDegree = null; + public static int getLeftRightGazeDegree(Face face) { + int degree = 0; + try{ + if ( method_getLeftRightGazeDegree == null ){ + method_getLeftRightGazeDegree = getMethod("getLeftRightGazeDegree"); + } + degree = (int)method_getLeftRightGazeDegree.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return degree; + } + + private static Method method_getTopBottomGazeDegree = null; + public static int getTopBottomGazeDegree(Face face) { + int degree = 0; + try{ + if ( method_getTopBottomGazeDegree == null ){ + method_getTopBottomGazeDegree = getMethod("getTopBottomGazeDegree"); + } + degree = (int)method_getTopBottomGazeDegree.invoke(face); + }catch(Exception exception){ + exception.printStackTrace(); + } + return degree; + } + + + private static Method getMethod(String name) throws Exception{ + if ( DEBUG ){ + Log.e(TAG, "Debug:" + CLASS_NAME + " no " + name); + return null; + } + if (mExtendFaceClass == null) { + mExtendFaceClass = Class.forName(CLASS_NAME); + } + return mExtendFaceClass.getDeclaredMethod(name); + } +} diff --git a/src_wrapper/org/codeaurora/snapcam/wrapper/ParametersWrapper.java b/src_wrapper/org/codeaurora/snapcam/wrapper/ParametersWrapper.java new file mode 100644 index 000000000..30398ffd5 --- /dev/null +++ b/src_wrapper/org/codeaurora/snapcam/wrapper/ParametersWrapper.java @@ -0,0 +1,816 @@ +/* + * 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.util.List; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import android.hardware.Camera.Parameters; +import android.hardware.Camera.Size; +import android.util.Log; + +public class ParametersWrapper extends Wrapper{ + private final static String TAG = "ParametersWrapper"; + public final static String FACE_DETECTION_ON = getFieldValue( + getField(Parameters.class, "FACE_DETECTION_ON"), "off"); + public static final String FACE_DETECTION_OFF = getFieldValue( + getField(Parameters.class, "FACE_DETECTION_OFF"), "off"); + public static final String ZSL_OFF = getFieldValue( + getField(Parameters.class, "ZSL_OFF"), "off"); + public static final String TOUCH_AF_AEC_ON = getFieldValue( + getField(Parameters.class, "TOUCH_AF_AEC_ON"), "touch-off"); + public static final String TOUCH_AF_AEC_OFF = getFieldValue( + getField(Parameters.class, "TOUCH_AF_AEC_OFF"), "touch-off"); + public static final String DENOISE_OFF = getFieldValue( + getField(Parameters.class, "DENOISE_OFF"), "denoise-off"); + public static final String DENOISE_ON = getFieldValue( + getField(Parameters.class, "DENOISE_ON"), "denoise-off"); + public static final String ISO_AUTO = getFieldValue( + getField(Parameters.class, "ISO_AUTO"), "auto"); + public static final String FOCUS_MODE_MANUAL_POSITION = getFieldValue( + getField(Parameters.class, "FOCUS_MODE_MANUAL_POSITION"), "manual"); + + private static Method method_isPowerModeSupported = null; + public static boolean isPowerModeSupported(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no isPowerModeSupported"); + return false; + } + boolean supported = false; + try { + if (method_isPowerModeSupported == null) { + method_isPowerModeSupported = + Parameters.class.getDeclaredMethod("isPowerModeSupported"); + } + supported = (boolean)method_isPowerModeSupported.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supported; + } + + private static Method method_setPowerMode = null; + public static void setPowerMode(Parameters parameters, String value) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setPowerMode"); + return; + } + try { + if (method_setPowerMode == null) { + method_setPowerMode = + Parameters.class.getDeclaredMethod("setPowerMode", String.class); + } + method_setPowerMode.invoke(parameters, value); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getPowerMode = null; + public static String getPowerMode(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getPowerMode"); + return null; + } + String powerMode = null; + try { + if (method_getPowerMode == null) { + method_getPowerMode = Parameters.class.getDeclaredMethod("getPowerMode"); + } + powerMode = (String) method_getPowerMode.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return powerMode; + } + + private static Method method_setCameraMode = null; + public static void setCameraMode(Parameters parameters, int cameraMode) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setCameraMode"); + return; + } + try{ + if ( method_setCameraMode == null ){ + method_setCameraMode = Parameters.class.getDeclaredMethod("setCameraMode", + int.class); + } + method_setCameraMode.invoke(parameters, cameraMode); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getSupportedIsoValues = null; + public static List<String> getSupportedIsoValues(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedIsoValues"); + return null; + } + List<String> supportedList = null; + try { + if (method_getSupportedIsoValues == null) { + method_getSupportedIsoValues = + Parameters.class.getDeclaredMethod("getSupportedIsoValues"); + } + supportedList = (List<String>) method_getSupportedIsoValues.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_getISOValue = null; + public static String getISOValue(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getISOValue"); + return null; + } + String isoValue = null; + try{ + if ( method_getISOValue == null ){ + method_getISOValue = Parameters.class.getDeclaredMethod("getISOValue"); + } + isoValue = (String)method_getISOValue.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return isoValue; + } + + private static Method method_setISOValue = null; + public static void setISOValue(Parameters parameters, String iso) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setISOValue"); + return; + } + try{ + if ( method_setISOValue == null ) { + method_setISOValue = Parameters.class.getDeclaredMethod("setISOValue", + String.class); + } + method_setISOValue.invoke(parameters, iso); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getSupportedAutoexposure = null; + public static List<String> getSupportedAutoexposure(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedAutoexposure"); + return null; + } + List<String> supportedList = null; + try { + if (method_getSupportedAutoexposure == null) { + method_getSupportedAutoexposure = + Parameters.class.getDeclaredMethod("getSupportedAutoexposure"); + } + supportedList = (List<String>)method_getSupportedAutoexposure.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_getAutoExposure = null; + public static String getAutoExposure(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getAutoExposure"); + return null; + } + String autoExposure = null; + try { + if (method_getAutoExposure == null) { + method_getAutoExposure = Parameters.class.getDeclaredMethod("getAutoExposure"); + } + autoExposure = (String)method_getAutoExposure.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return autoExposure; + } + + private static Method method_setAutoExposure = null; + public static void setAutoExposure(Parameters parameters, String value) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setAutoExposure"); + return; + } + try{ + if ( method_setAutoExposure == null ){ + method_setAutoExposure = Parameters.class.getDeclaredMethod("setAutoExposure", + String.class); + } + method_setAutoExposure.invoke(parameters, value); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getSupportedTouchAfAec = null; + public static List<String> getSupportedTouchAfAec(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedTouchAfAec"); + return null; + } + List<String> supportedList = null; + try { + if (method_getSupportedTouchAfAec == null) { + method_getSupportedTouchAfAec = + Parameters.class.getDeclaredMethod("getSupportedTouchAfAec"); + } + supportedList = (List<String>) method_getSupportedTouchAfAec.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_getTouchAfAec = null; + public static String getTouchAfAec(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getTouchAfAec"); + return null; + } + String touchAfAec = null; + try { + if (method_getTouchAfAec == null) { + method_getTouchAfAec = Parameters.class.getDeclaredMethod("getTouchAfAec"); + } + touchAfAec = (String)method_getTouchAfAec.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return touchAfAec; + } + + private static Method method_setTouchAfAec = null; + public static void setTouchAfAec(Parameters parameters, String value) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setTouchAfAec"); + return; + } + try { + if (method_setTouchAfAec == null) { + method_setTouchAfAec = Parameters.class.getDeclaredMethod("setTouchAfAec", + String.class); + } + method_setTouchAfAec.invoke(parameters, value); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getSupportedSelectableZoneAf = null; + public static List<String> getSupportedSelectableZoneAf(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedSelectableZoneAf"); + return null; + } + List<String> supportedList = null; + try { + if (method_getSupportedSelectableZoneAf == null) { + method_getSupportedSelectableZoneAf = + Parameters.class.getDeclaredMethod("getSupportedSelectableZoneAf"); + } + supportedList = (List<String>)method_getSupportedSelectableZoneAf.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_setSelectableZoneAf = null; + public static void setSelectableZoneAf(Parameters parameters, String value) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setSelectableZoneAf"); + return; + } + try{ + if ( method_setSelectableZoneAf == null ) { + method_setSelectableZoneAf = + Parameters.class.getDeclaredMethod("setSelectableZoneAf", String.class); + } + method_setSelectableZoneAf.invoke(parameters, value); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getSupportedRedeyeReductionModes = null; + public static List<String> getSupportedRedeyeReductionModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedRedeyeReductionModes"); + return null; + } + List<String> supportedList = null; + try { + if (method_getSupportedRedeyeReductionModes == null) { + method_getSupportedRedeyeReductionModes = + Parameters.class.getDeclaredMethod("getSupportedRedeyeReductionModes"); + } + supportedList = (List<String>)method_getSupportedRedeyeReductionModes.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_setRedeyeReductionMode = null; + public static void setRedeyeReductionMode(Parameters parameters, String value) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setRedeyeReductionMode"); + return; + } + try { + if (method_setRedeyeReductionMode == null) { + method_setRedeyeReductionMode = Parameters.class.getDeclaredMethod( + "setRedeyeReductionMode", String.class); + } + method_setRedeyeReductionMode.invoke(parameters, value); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getSupportedDenoiseModes = null; + public static List<String> getSupportedDenoiseModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedDenoiseModes"); + return null; + } + List<String> supportedList = null; + try { + if (method_getSupportedDenoiseModes == null) { + method_getSupportedDenoiseModes = + Parameters.class.getDeclaredMethod("getSupportedDenoiseModes"); + } + supportedList = (List<String>) method_getSupportedDenoiseModes.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_setDenoise = null; + public static void setDenoise(Parameters parameters,String value) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setDenoise"); + return; + } + try{ + if ( method_setDenoise == null ) { + method_setDenoise = Parameters.class.getDeclaredMethod("setDenoise", + String.class); + } + method_setDenoise.invoke(parameters, value); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getSupportedVideoHDRModes = null; + public static List<String> getSupportedVideoHDRModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedVideoHDRModes"); + return null; + } + List<String> supportedList = null; + try{ + if ( method_getSupportedVideoHDRModes == null ){ + method_getSupportedVideoHDRModes = + Parameters.class.getDeclaredMethod("getSupportedVideoHDRModes"); + } + supportedList = (List<String>)method_getSupportedVideoHDRModes.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_getVideoHDRMode = null; + public static String getVideoHDRMode(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getVideoHDRMode"); + return null; + } + String hdrMode = null; + try{ + if ( method_getVideoHDRMode == null ){ + method_getVideoHDRMode = Parameters.class.getDeclaredMethod("getVideoHDRMode"); + } + hdrMode = (String)method_getVideoHDRMode.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return hdrMode; + } + + private static Method method_setVideoHDRMode = null; + public static void setVideoHDRMode(Parameters parameters, String videohdr) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setVideoHDRMode"); + return; + } + try{ + if ( method_setVideoHDRMode == null ){ + method_setVideoHDRMode = Parameters.class.getDeclaredMethod("setVideoHDRMode", + String.class); + } + method_setVideoHDRMode.invoke(parameters, videohdr); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getSupportedHistogramModes = null; + public static List<String> getSupportedHistogramModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedHistogramModes"); + return null; + } + List<String> supportedList = null; + try{ + if ( method_getSupportedHistogramModes == null ){ + method_getSupportedHistogramModes = + Parameters.class.getDeclaredMethod("getSupportedHistogramModes"); + } + supportedList = (List<String>)method_getSupportedHistogramModes.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_getSupportedHfrSizes = null; + public static List<Size> getSupportedHfrSizes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedHfrSizes"); + return null; + } + List<Size> supportedList = null; + try{ + if ( method_getSupportedHfrSizes == null ){ + method_getSupportedHfrSizes = + Parameters.class.getDeclaredMethod("getSupportedHfrSizes"); + } + supportedList = (List<Size>)method_getSupportedHfrSizes.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_getSupportedVideoHighFrameRateModes = null; + public static List<String> getSupportedVideoHighFrameRateModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedVideoHighFrameRateModes"); + return null; + } + List<String> supportedList = null; + try{ + if ( method_getSupportedVideoHighFrameRateModes == null ){ + method_getSupportedVideoHighFrameRateModes = + Parameters.class.getDeclaredMethod("getSupportedVideoHighFrameRateModes"); + } + supportedList = + (List<String>)method_getSupportedVideoHighFrameRateModes.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_getVideoHighFrameRate = null; + public static String getVideoHighFrameRate(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getVideoHighFrameRate"); + return null; + } + String hfr = null; + try{ + if ( method_getVideoHighFrameRate == null ){ + method_getVideoHighFrameRate = + Parameters.class.getDeclaredMethod("getVideoHighFrameRate"); + } + hfr = (String)method_getVideoHighFrameRate.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return hfr; + } + + private static Method method_setVideoHighFrameRate = null; + public static void setVideoHighFrameRate(Parameters parameters, String hfr) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setVideoHighFrameRate"); + return; + } + try{ + if ( method_setVideoHighFrameRate == null ){ + method_setVideoHighFrameRate = Parameters.class.getDeclaredMethod( + "setVideoHighFrameRate", String.class); + } + method_setVideoHighFrameRate.invoke(parameters, hfr); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getSupportedVideoRotationValues = null; + public static List<String> getSupportedVideoRotationValues(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedVideoRotationValues"); + return null; + } + List<String> supportedList = null; + try{ + if ( method_getSupportedVideoRotationValues == null ){ + method_getSupportedVideoRotationValues = + Parameters.class.getDeclaredMethod("getSupportedVideoRotationValues"); + } + supportedList = (List<String>)method_getSupportedVideoRotationValues.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_setVideoRotation = null; + public static void setVideoRotation(Parameters parameters, String value) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setVideoRotation"); + return; + } + try{ + if ( method_setVideoRotation == null ) { + method_setVideoRotation = Parameters.class.getDeclaredMethod( + "setVideoRotation", String.class); + } + method_setVideoRotation.invoke(parameters, value); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_setFaceDetectionMode = null; + public static void setFaceDetectionMode(Parameters parameters, String value){ + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setFaceDetectionMode"); + return; + } + try{ + if ( method_setFaceDetectionMode == null ){ + method_setFaceDetectionMode = Parameters.class.getDeclaredMethod( + "setFaceDetectionMode", String.class); + } + method_setFaceDetectionMode.invoke(parameters, value); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getSupportedFaceDetectionModes = null; + public static List<String> getSupportedFaceDetectionModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedFaceDetectionModes"); + return null; + } + List<String> supportedList = null; + try{ + if ( method_getSupportedFaceDetectionModes == null ) { + method_getSupportedFaceDetectionModes = + Parameters.class.getDeclaredMethod("getSupportedFaceDetectionModes"); + } + supportedList = (List<String>)method_getSupportedFaceDetectionModes.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_getSupportedZSLModes = null; + public static List<String> getSupportedZSLModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedZSLModes"); + return null; + } + List<String> supportedList = null; + try{ + if ( method_getSupportedZSLModes == null ) { + method_getSupportedZSLModes = + Parameters.class.getDeclaredMethod("getSupportedZSLModes"); + } + supportedList = (List<String>)method_getSupportedZSLModes.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_setZSLMode = null; + public static void setZSLMode(Parameters parameters, String zsl) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setZSLMode"); + return; + } + try { + if ( method_setZSLMode == null ) { + method_setZSLMode = Parameters.class.getDeclaredMethod("setZSLMode", + String.class); + } + method_setZSLMode.invoke(parameters, zsl); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getSharpness = null; + public static int getSharpness(Parameters parameters){ + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSharpness"); + return -1; + } + int sharpness = -1; + try{ + if ( method_getSharpness == null ) { + method_getSharpness = Parameters.class.getDeclaredMethod("getSharpness"); + } + sharpness = (int)method_getSharpness.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return sharpness; + } + + private static Method method_setSharpness = null; + public static void setSharpness(Parameters parameters, int sharpness){ + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setSharpness"); + return; + } + try{ + if ( method_setSharpness == null ) { + method_setSharpness = + Parameters.class.getDeclaredMethod("setSharpness", int.class); + } + method_setSharpness.invoke(parameters, sharpness); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getMaxSharpness = null; + public static int getMaxSharpness(Parameters parameters){ + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getMaxSharpness"); + return -1; + } + int maxSharpness = -1; + try{ + if ( method_getMaxSharpness == null ) { + method_getMaxSharpness = Parameters.class.getDeclaredMethod("getMaxSharpness"); + } + maxSharpness = (int)method_getMaxSharpness.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return maxSharpness; + } + + private static Method method_getSaturation = null; + public static int getSaturation(Parameters parameters){ + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSaturation"); + return -1; + } + int saturation = -1; + try{ + if ( method_getSaturation == null ) { + method_getSaturation = Parameters.class.getDeclaredMethod("getSaturation"); + } + saturation = (int)method_getSaturation.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return saturation; + } + + private static Method method_setSaturation = null; + public static void setSaturation(Parameters parameters, int saturation){ + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setSaturation"); + return ; + } + try{ + if ( method_setSaturation == null ) { + method_setSaturation = + Parameters.class.getDeclaredMethod("setSaturation", int.class); + } + method_setSaturation.invoke(parameters, saturation); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getMaxSaturation = null; + public static int getMaxSaturation(Parameters parameters){ + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getMaxSaturation"); + return -1; + } + int maxSaturation = -1; + try{ + if ( method_getMaxSaturation == null ) { + method_getMaxSaturation = Parameters.class.getDeclaredMethod("getMaxSaturation"); + } + maxSaturation = (int)method_getMaxSaturation.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return maxSaturation; + } + + private static Method method_getContrast = null; + public static int getContrast(Parameters parameters){ + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getContrast"); + return -1; + } + int contrast = -1; + try{ + if ( method_getContrast == null ) { + method_getContrast = Parameters.class.getDeclaredMethod("getContrast"); + } + contrast = (int)method_getContrast.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return contrast; + } + + private static Method method_setContrast = null; + public static void setContrast(Parameters parameters, int contrast){ + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no setContrast"); + return; + } + try{ + if ( method_setContrast == null ) { + method_setContrast = + Parameters.class.getDeclaredMethod("setContrast", int.class); + } + method_setContrast.invoke(parameters, contrast); + }catch(Exception exception){ + exception.printStackTrace(); + } + } + + private static Method method_getMaxContrast = null; + public static int getMaxContrast(Parameters parameters){ + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getMaxContrast"); + return -1; + } + int maxContrast = -1; + try{ + if ( method_getMaxContrast == null ) { + method_getMaxContrast = Parameters.class.getDeclaredMethod("getMaxContrast"); + } + maxContrast = (int)method_getMaxContrast.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return maxContrast; + } +} diff --git a/src_wrapper/org/codeaurora/snapcam/wrapper/Wrapper.java b/src_wrapper/org/codeaurora/snapcam/wrapper/Wrapper.java new file mode 100644 index 000000000..541d4cc77 --- /dev/null +++ b/src_wrapper/org/codeaurora/snapcam/wrapper/Wrapper.java @@ -0,0 +1,84 @@ +/* + * 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.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import android.os.SystemProperties; +import android.util.Log; + +public class Wrapper{ + protected final static boolean DEBUG = + SystemProperties.getBoolean("persist.camera.wrapper.debug", false); + protected final static String TAG = "Wrapper"; + + protected static int getFieldValue(Field field, int def){ + int value = def; + if ( field != null ) { + try { + value = (int) field.get(null); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + return value; + } + + protected static String getFieldValue(Field field, String def){ + String value = def; + if ( field != null ) { + try { + value = (String) field.get(null); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + return value; + } + protected static Field getField(Class<?> classInstance, String name) { + Log.d(TAG, "getField:" + classInstance + " field:"+ name); + if ( DEBUG ){ + Log.e(TAG, "" + classInstance + " no " + name); + return null; + } + + Field field = null; + try{ + field = classInstance.getField(name); + Log.d(TAG, "getField:" + classInstance + " " + name); + }catch (Exception exception){ + exception.printStackTrace(); + } + return field; + } +} |