Unhide Camera lock and unlock API.

This commit is contained in:
Wu-cheng Li
2009-09-10 16:49:17 +08:00
parent 2092361d58
commit ffe1cf251a
3 changed files with 41 additions and 19 deletions

View File

@@ -67328,6 +67328,17 @@
visibility="public" visibility="public"
> >
</method> </method>
<method name="lock"
return="void"
abstract="false"
native="true"
synchronized="false"
static="false"
final="true"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="open" <method name="open"
return="android.hardware.Camera" return="android.hardware.Camera"
abstract="false" abstract="false"
@@ -67488,6 +67499,17 @@
<parameter name="jpeg" type="android.hardware.Camera.PictureCallback"> <parameter name="jpeg" type="android.hardware.Camera.PictureCallback">
</parameter> </parameter>
</method> </method>
<method name="unlock"
return="void"
abstract="false"
native="true"
synchronized="false"
static="false"
final="true"
deprecated="not deprecated"
visibility="public"
>
</method>
<field name="CAMERA_ERROR_SERVER_DIED" <field name="CAMERA_ERROR_SERVER_DIED"
type="int" type="int"
transient="false" transient="false"

View File

@@ -137,7 +137,6 @@ public class Camera {
* *
* @throws IOException if the method fails. * @throws IOException if the method fails.
* *
* FIXME: Unhide after approval
* @hide * @hide
*/ */
public native final void reconnect() throws IOException; public native final void reconnect() throws IOException;
@@ -150,25 +149,20 @@ public class Camera {
* Camera object is locked. Locking it again from the same process will * 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 * have no effect. Attempting to lock it from another process if it has
* not been unlocked will fail. * not been unlocked will fail.
* Returns 0 if lock was successful.
* *
* FIXME: Unhide after approval * @throws RuntimeException if the method fails.
* @hide
*/ */
public native final int lock(); public native final void lock();
/** /**
* Unlock the camera to allow another process to access it. To save * Unlock the camera to allow another process to access it. To save
* setup/teardown time, a client of Camera can pass an initialized Camera * 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 to another process. This method is used to unlock the Camera
* object before handing off the Camera object to the other process. * object before handing off the Camera object to the other process.
* Returns 0 if unlock was successful.
* *
* FIXME: Unhide after approval * @throws RuntimeException if the method fails.
* @hide
*/ */
public native final int unlock(); public native final void unlock();
/** /**
* Sets the SurfaceHolder to be used for a picture preview. If the surface * Sets the SurfaceHolder to be used for a picture preview. If the surface

View File

@@ -55,7 +55,7 @@ private:
jobject mCameraJObjectWeak; // weak reference to java object jobject mCameraJObjectWeak; // weak reference to java object
jclass mCameraJClass; // strong reference to java class 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; Mutex mLock;
}; };
@@ -391,20 +391,26 @@ static void android_hardware_Camera_reconnect(JNIEnv *env, jobject thiz)
} }
} }
static jint android_hardware_Camera_lock(JNIEnv *env, jobject thiz) static void android_hardware_Camera_lock(JNIEnv *env, jobject thiz)
{ {
LOGV("lock"); LOGV("lock");
sp<Camera> camera = get_native_camera(env, thiz, NULL); sp<Camera> camera = get_native_camera(env, thiz, NULL);
if (camera == 0) return INVALID_OPERATION; if (camera == 0) return;
return (jint) camera->lock();
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"); LOGV("unlock");
sp<Camera> camera = get_native_camera(env, thiz, NULL); sp<Camera> camera = get_native_camera(env, thiz, NULL);
if (camera == 0) return INVALID_OPERATION; if (camera == 0) return;
return (jint) camera->unlock();
if (camera->unlock() != NO_ERROR) {
jniThrowException(env, "java/lang/RuntimeException", "unlock failed");
}
} }
//------------------------------------------------- //-------------------------------------------------
@@ -450,10 +456,10 @@ static JNINativeMethod camMethods[] = {
"()V", "()V",
(void*)android_hardware_Camera_reconnect }, (void*)android_hardware_Camera_reconnect },
{ "lock", { "lock",
"()I", "()V",
(void*)android_hardware_Camera_lock }, (void*)android_hardware_Camera_lock },
{ "unlock", { "unlock",
"()I", "()V",
(void*)android_hardware_Camera_unlock }, (void*)android_hardware_Camera_unlock },
}; };