Unhide Camera lock and unlock API.
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index a27307a..cc44400 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -137,7 +137,6 @@
*
* @throws IOException if the method fails.
*
- * FIXME: Unhide after approval
* @hide
*/
public native final void reconnect() throws IOException;
@@ -150,25 +149,20 @@
* Camera object is locked. Locking it again from the same process will
* have no effect. Attempting to lock it from another process if it has
* not been unlocked will fail.
- * Returns 0 if lock was successful.
*
- * FIXME: Unhide after approval
- * @hide
+ * @throws RuntimeException if the method fails.
*/
- public native final int lock();
+ public native final void lock();
/**
* Unlock the camera to allow another process to access it. To save
* setup/teardown time, a client of Camera can pass an initialized Camera
* object to another process. This method is used to unlock the Camera
* object before handing off the Camera object to the other process.
-
- * Returns 0 if unlock was successful.
*
- * FIXME: Unhide after approval
- * @hide
+ * @throws RuntimeException if the method fails.
*/
- public native final int unlock();
+ public native final void unlock();
/**
* Sets the SurfaceHolder to be used for a picture preview. If the surface
diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp
index ce2b10c..6b92994 100644
--- a/core/jni/android_hardware_Camera.cpp
+++ b/core/jni/android_hardware_Camera.cpp
@@ -55,7 +55,7 @@
jobject mCameraJObjectWeak; // weak reference to java object
jclass mCameraJClass; // strong reference to java class
- sp<Camera> mCamera; // strong reference to native object
+ sp<Camera> mCamera; // strong reference to native object
Mutex mLock;
};
@@ -391,20 +391,26 @@
}
}
-static jint android_hardware_Camera_lock(JNIEnv *env, jobject thiz)
+static void android_hardware_Camera_lock(JNIEnv *env, jobject thiz)
{
LOGV("lock");
sp<Camera> camera = get_native_camera(env, thiz, NULL);
- if (camera == 0) return INVALID_OPERATION;
- return (jint) camera->lock();
+ if (camera == 0) return;
+
+ if (camera->lock() != NO_ERROR) {
+ jniThrowException(env, "java/lang/RuntimeException", "lock failed");
+ }
}
-static jint android_hardware_Camera_unlock(JNIEnv *env, jobject thiz)
+static void android_hardware_Camera_unlock(JNIEnv *env, jobject thiz)
{
LOGV("unlock");
sp<Camera> camera = get_native_camera(env, thiz, NULL);
- if (camera == 0) return INVALID_OPERATION;
- return (jint) camera->unlock();
+ if (camera == 0) return;
+
+ if (camera->unlock() != NO_ERROR) {
+ jniThrowException(env, "java/lang/RuntimeException", "unlock failed");
+ }
}
//-------------------------------------------------
@@ -450,10 +456,10 @@
"()V",
(void*)android_hardware_Camera_reconnect },
{ "lock",
- "()I",
+ "()V",
(void*)android_hardware_Camera_lock },
{ "unlock",
- "()I",
+ "()V",
(void*)android_hardware_Camera_unlock },
};