Skip to content

Commit f66bc73

Browse files
Wu-cheng LiAndroid (Google) Code Review
authored andcommitted
Merge "Remove new camera open API."
2 parents 3c3b5b5 + 7bc1b21 commit f66bc73

File tree

2 files changed

+8
-86
lines changed

2 files changed

+8
-86
lines changed

core/java/android/hardware/Camera.java

Lines changed: 5 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -233,48 +233,6 @@ public static class CameraInfo {
233233
public int orientation;
234234
};
235235

236-
/**
237-
* Creates a new Camera object to access a particular hardware camera.
238-
*
239-
* <p>When <code>force</code> is set to false, this will throw an exception
240-
* if the same camera is already opened by other clients. If true, the other
241-
* client will be disconnected from the camera they opened. If the device
242-
* can only support one camera running at a time, all camera-using clients
243-
* will be disconnected from their cameras.
244-
*
245-
* <p>A camera being held by an application can be taken away by other
246-
* applications at any time. Before the camera is taken, applications will
247-
* get {@link #CAMERA_ERROR_RELEASED} and have some time to clean up. Apps
248-
* receiving this callback must immediately stop video recording and then
249-
* call {@link #release()} on their camera object. Otherwise, it will be
250-
* released by the frameworks in a short time. After receiving
251-
* CAMERA_ERROR_RELEASED, apps should not call any method except <code>
252-
* release</code> and {@link #isReleased()}. After a camera is taken away,
253-
* all methods will throw exceptions except <code>isReleased</code> and
254-
* <code>release</code>. Apps can use <code>isReleased</code> to see if the
255-
* camera has been taken away. If the camera is taken away, the apps can
256-
* silently finish themselves or show a dialog.
257-
*
258-
* <p>Applications with android.permission.KEEP_CAMERA can request to keep
259-
* the camera. That is, the camera will not be taken by other applications
260-
* while it is opened. The permission can only be obtained by trusted
261-
* platform applications, such as those implementing lock screen security
262-
* features.
263-
*
264-
* @param cameraId the hardware camera to access, between 0 and
265-
* {@link #getNumberOfCameras()}-1.
266-
* @param force true to take the ownership from the existing client if the
267-
* camera has been opened by other clients.
268-
* @param keep true if the applications do not want other apps to take the
269-
* camera. Only the apps with android.permission.KEEP_CAMERA can keep
270-
* the camera.
271-
* @return a new Camera object, connected, locked and ready for use.
272-
* @hide
273-
*/
274-
public static Camera open(int cameraId, boolean force, boolean keep) {
275-
return new Camera(cameraId, force, keep);
276-
}
277-
278236
/**
279237
* Creates a new Camera object to access a particular hardware camera. If
280238
* the same camera is opened by other applications, this will throw a
@@ -305,7 +263,7 @@ public static Camera open(int cameraId, boolean force, boolean keep) {
305263
* @see android.app.admin.DevicePolicyManager#getCameraDisabled(android.content.ComponentName)
306264
*/
307265
public static Camera open(int cameraId) {
308-
return new Camera(cameraId, false, false);
266+
return new Camera(cameraId);
309267
}
310268

311269
/**
@@ -320,13 +278,13 @@ public static Camera open() {
320278
for (int i = 0; i < numberOfCameras; i++) {
321279
getCameraInfo(i, cameraInfo);
322280
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
323-
return new Camera(i, false, false);
281+
return new Camera(i);
324282
}
325283
}
326284
return null;
327285
}
328286

329-
Camera(int cameraId, boolean force, boolean keep) {
287+
Camera(int cameraId) {
330288
mShutterCallback = null;
331289
mRawImageCallback = null;
332290
mJpegCallback = null;
@@ -343,7 +301,7 @@ public static Camera open() {
343301
mEventHandler = null;
344302
}
345303

346-
native_setup(new WeakReference<Camera>(this), cameraId, force, keep);
304+
native_setup(new WeakReference<Camera>(this), cameraId);
347305
}
348306

349307
/**
@@ -356,8 +314,7 @@ protected void finalize() {
356314
release();
357315
}
358316

359-
private native final void native_setup(Object camera_this, int cameraId,
360-
boolean force, boolean keep);
317+
private native final void native_setup(Object camera_this, int cameraId);
361318
private native final void native_release();
362319

363320

@@ -371,18 +328,6 @@ public final void release() {
371328
mFaceDetectionRunning = false;
372329
}
373330

374-
/**
375-
* Whether the camera is released. When any camera method throws an
376-
* exception, applications can use this to check whether the camera has been
377-
* taken by other clients. If true, it means other clients have taken the
378-
* camera. The applications can silently finish themselves or show a dialog.
379-
*
380-
* @return whether the camera is released.
381-
* @see #open(int, boolean, boolean)
382-
* @hide
383-
*/
384-
public native final boolean isReleased();
385-
386331
/**
387332
* Unlocks the camera to allow another process to access it.
388333
* Normally, the camera is locked to the process with an active Camera
@@ -1376,17 +1321,6 @@ public Face() {
13761321
*/
13771322
public static final int CAMERA_ERROR_UNKNOWN = 1;
13781323

1379-
/**
1380-
* Camera was released because another client has opened the camera. The
1381-
* application should call {@link #release()} after getting this. The apps
1382-
* should not call any method except <code>release</code> and {@link #isReleased()}
1383-
* after this.
1384-
*
1385-
* @see Camera.ErrorCallback
1386-
* @hide
1387-
*/
1388-
public static final int CAMERA_ERROR_RELEASED = 2;
1389-
13901324
/**
13911325
* Media server died. In this case, the application must release the
13921326
* Camera object and instantiate a new one.

core/jni/android_hardware_Camera.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,9 @@ static void android_hardware_Camera_getCameraInfo(JNIEnv *env, jobject thiz,
457457

458458
// connect to camera service
459459
static void android_hardware_Camera_native_setup(JNIEnv *env, jobject thiz,
460-
jobject weak_this, jint cameraId, jboolean force, jboolean keep)
460+
jobject weak_this, jint cameraId)
461461
{
462-
sp<Camera> camera = Camera::connect(cameraId, force, keep);
462+
sp<Camera> camera = Camera::connect(cameraId);
463463

464464
if (camera == NULL) {
465465
jniThrowRuntimeException(env, "Fail to connect to camera service");
@@ -821,15 +821,6 @@ static void android_hardware_Camera_enableFocusMoveCallback(JNIEnv *env, jobject
821821
}
822822
}
823823

824-
static bool android_hardware_Camera_isReleased(JNIEnv *env, jobject thiz)
825-
{
826-
ALOGV("isReleased");
827-
sp<Camera> camera = get_native_camera(env, thiz, NULL);
828-
if (camera == 0) return true;
829-
830-
return (camera->sendCommand(CAMERA_CMD_PING, 0, 0) != NO_ERROR);
831-
}
832-
833824
//-------------------------------------------------
834825

835826
static JNINativeMethod camMethods[] = {
@@ -840,7 +831,7 @@ static JNINativeMethod camMethods[] = {
840831
"(ILandroid/hardware/Camera$CameraInfo;)V",
841832
(void*)android_hardware_Camera_getCameraInfo },
842833
{ "native_setup",
843-
"(Ljava/lang/Object;IZZ)V",
834+
"(Ljava/lang/Object;I)V",
844835
(void*)android_hardware_Camera_native_setup },
845836
{ "native_release",
846837
"()V",
@@ -908,9 +899,6 @@ static JNINativeMethod camMethods[] = {
908899
{ "enableFocusMoveCallback",
909900
"(I)V",
910901
(void *)android_hardware_Camera_enableFocusMoveCallback},
911-
{ "isReleased",
912-
"()Z",
913-
(void *)android_hardware_Camera_isReleased},
914902
};
915903

916904
struct field {

0 commit comments

Comments
 (0)