diff options
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | core/java/android/hardware/Camera.java | 15 | ||||
-rw-r--r-- | core/jni/android_hardware_Camera.cpp | 10 |
3 files changed, 26 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index ec930c4..c7ce8aa 100644 --- a/api/current.txt +++ b/api/current.txt @@ -9746,6 +9746,7 @@ package android.hardware { ctor public Camera.CameraInfo(); field public static final int CAMERA_FACING_BACK = 0; // 0x0 field public static final int CAMERA_FACING_FRONT = 1; // 0x1 + field public boolean canDisableShutterSound; field public int facing; field public int orientation; } diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index 7b3a8af..375d788 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -233,6 +233,21 @@ public class Camera { * @see Parameters#setJpegThumbnailSize(int, int) */ public int orientation; + + /** + * <p>Whether the shutter sound can be disabled.</p> + * + * <p>On some devices, the camera shutter sound cannot be turned off + * through {@link #enableShutterSound enableShutterSound}. This field + * can be used to determine whether a call to disable the shutter sound + * will succeed.</p> + * + * <p>If this field is set to true, then a call of + * {@code enableShutterSound(false)} will be successful. If set to + * false, then that call will fail, and the shutter sound will be played + * when {@link Camera#takePicture takePicture} is called.</p> + */ + public boolean canDisableShutterSound; }; /** diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index e1e97a1..99d49ec 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -23,6 +23,7 @@ #include "JNIHelp.h" #include "android_runtime/AndroidRuntime.h" +#include <cutils/properties.h> #include <utils/Vector.h> #include <gui/SurfaceTexture.h> @@ -38,6 +39,7 @@ struct fields_t { jfieldID surfaceTexture; jfieldID facing; jfieldID orientation; + jfieldID canDisableShutterSound; jfieldID face_rect; jfieldID face_score; jfieldID rect_left; @@ -453,6 +455,12 @@ static void android_hardware_Camera_getCameraInfo(JNIEnv *env, jobject thiz, } env->SetIntField(info_obj, fields.facing, cameraInfo.facing); env->SetIntField(info_obj, fields.orientation, cameraInfo.orientation); + + char value[PROPERTY_VALUE_MAX]; + property_get("ro.camera.sound.forced", value, "0"); + jboolean canDisableShutterSound = (strncmp(value, "0", 2) == 0); + env->SetBooleanField(info_obj, fields.canDisableShutterSound, + canDisableShutterSound); } // connect to camera service @@ -962,6 +970,8 @@ int register_android_hardware_Camera(JNIEnv *env) ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID, "I", &fields.surfaceTexture }, { "android/hardware/Camera$CameraInfo", "facing", "I", &fields.facing }, { "android/hardware/Camera$CameraInfo", "orientation", "I", &fields.orientation }, + { "android/hardware/Camera$CameraInfo", "canDisableShutterSound", "Z", + &fields.canDisableShutterSound }, { "android/hardware/Camera$Face", "rect", "Landroid/graphics/Rect;", &fields.face_rect }, { "android/hardware/Camera$Face", "score", "I", &fields.face_score }, { "android/graphics/Rect", "left", "I", &fields.rect_left }, |