From 21a4a7c612e47af9f06550976b74aa984f5a6b69 Mon Sep 17 00:00:00 2001 From: weijiew Date: Fri, 17 Mar 2017 15:04:06 +0800 Subject: 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 --- .../snapcam/wrapper/CamcorderProfileWrapper.java | 59 ++ .../snapcam/wrapper/CameraInfoWrapper.java | 46 ++ .../codeaurora/snapcam/wrapper/CameraWrapper.java | 122 +++ .../snapcam/wrapper/ExtendedFaceWrapper.java | 233 ++++++ .../snapcam/wrapper/ParametersWrapper.java | 816 +++++++++++++++++++++ .../org/codeaurora/snapcam/wrapper/Wrapper.java | 84 +++ 6 files changed, 1360 insertions(+) create mode 100644 src_wrapper/org/codeaurora/snapcam/wrapper/CamcorderProfileWrapper.java create mode 100644 src_wrapper/org/codeaurora/snapcam/wrapper/CameraInfoWrapper.java create mode 100644 src_wrapper/org/codeaurora/snapcam/wrapper/CameraWrapper.java create mode 100644 src_wrapper/org/codeaurora/snapcam/wrapper/ExtendedFaceWrapper.java create mode 100644 src_wrapper/org/codeaurora/snapcam/wrapper/ParametersWrapper.java create mode 100644 src_wrapper/org/codeaurora/snapcam/wrapper/Wrapper.java (limited to 'src_wrapper') 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 getSupportedIsoValues(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedIsoValues"); + return null; + } + List supportedList = null; + try { + if (method_getSupportedIsoValues == null) { + method_getSupportedIsoValues = + Parameters.class.getDeclaredMethod("getSupportedIsoValues"); + } + supportedList = (List) 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 getSupportedAutoexposure(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedAutoexposure"); + return null; + } + List supportedList = null; + try { + if (method_getSupportedAutoexposure == null) { + method_getSupportedAutoexposure = + Parameters.class.getDeclaredMethod("getSupportedAutoexposure"); + } + supportedList = (List)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 getSupportedTouchAfAec(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedTouchAfAec"); + return null; + } + List supportedList = null; + try { + if (method_getSupportedTouchAfAec == null) { + method_getSupportedTouchAfAec = + Parameters.class.getDeclaredMethod("getSupportedTouchAfAec"); + } + supportedList = (List) 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 getSupportedSelectableZoneAf(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedSelectableZoneAf"); + return null; + } + List supportedList = null; + try { + if (method_getSupportedSelectableZoneAf == null) { + method_getSupportedSelectableZoneAf = + Parameters.class.getDeclaredMethod("getSupportedSelectableZoneAf"); + } + supportedList = (List)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 getSupportedRedeyeReductionModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedRedeyeReductionModes"); + return null; + } + List supportedList = null; + try { + if (method_getSupportedRedeyeReductionModes == null) { + method_getSupportedRedeyeReductionModes = + Parameters.class.getDeclaredMethod("getSupportedRedeyeReductionModes"); + } + supportedList = (List)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 getSupportedDenoiseModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedDenoiseModes"); + return null; + } + List supportedList = null; + try { + if (method_getSupportedDenoiseModes == null) { + method_getSupportedDenoiseModes = + Parameters.class.getDeclaredMethod("getSupportedDenoiseModes"); + } + supportedList = (List) 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 getSupportedVideoHDRModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedVideoHDRModes"); + return null; + } + List supportedList = null; + try{ + if ( method_getSupportedVideoHDRModes == null ){ + method_getSupportedVideoHDRModes = + Parameters.class.getDeclaredMethod("getSupportedVideoHDRModes"); + } + supportedList = (List)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 getSupportedHistogramModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedHistogramModes"); + return null; + } + List supportedList = null; + try{ + if ( method_getSupportedHistogramModes == null ){ + method_getSupportedHistogramModes = + Parameters.class.getDeclaredMethod("getSupportedHistogramModes"); + } + supportedList = (List)method_getSupportedHistogramModes.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_getSupportedHfrSizes = null; + public static List getSupportedHfrSizes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedHfrSizes"); + return null; + } + List supportedList = null; + try{ + if ( method_getSupportedHfrSizes == null ){ + method_getSupportedHfrSizes = + Parameters.class.getDeclaredMethod("getSupportedHfrSizes"); + } + supportedList = (List)method_getSupportedHfrSizes.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_getSupportedVideoHighFrameRateModes = null; + public static List getSupportedVideoHighFrameRateModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedVideoHighFrameRateModes"); + return null; + } + List supportedList = null; + try{ + if ( method_getSupportedVideoHighFrameRateModes == null ){ + method_getSupportedVideoHighFrameRateModes = + Parameters.class.getDeclaredMethod("getSupportedVideoHighFrameRateModes"); + } + supportedList = + (List)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 getSupportedVideoRotationValues(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedVideoRotationValues"); + return null; + } + List supportedList = null; + try{ + if ( method_getSupportedVideoRotationValues == null ){ + method_getSupportedVideoRotationValues = + Parameters.class.getDeclaredMethod("getSupportedVideoRotationValues"); + } + supportedList = (List)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 getSupportedFaceDetectionModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedFaceDetectionModes"); + return null; + } + List supportedList = null; + try{ + if ( method_getSupportedFaceDetectionModes == null ) { + method_getSupportedFaceDetectionModes = + Parameters.class.getDeclaredMethod("getSupportedFaceDetectionModes"); + } + supportedList = (List)method_getSupportedFaceDetectionModes.invoke(parameters); + }catch(Exception exception){ + exception.printStackTrace(); + } + return supportedList; + } + + private static Method method_getSupportedZSLModes = null; + public static List getSupportedZSLModes(Parameters parameters) { + if ( DEBUG ){ + Log.e(TAG, "Debug:" + Parameters.class + " no getSupportedZSLModes"); + return null; + } + List supportedList = null; + try{ + if ( method_getSupportedZSLModes == null ) { + method_getSupportedZSLModes = + Parameters.class.getDeclaredMethod("getSupportedZSLModes"); + } + supportedList = (List)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; + } +} -- cgit v1.2.3