Merge \"Camera2: Add @hide variant for openCamera for UID forwarding\" into nyc-mr1-dev
am: 8c22370331
Change-Id: Ie03815d4793fd432f8e49d2119d2a9478bdd4332
This commit is contained in:
@@ -267,6 +267,10 @@ public final class CameraManager {
|
||||
* @param cameraId The unique identifier of the camera device to open
|
||||
* @param callback The callback for the camera. Must not be null.
|
||||
* @param handler The handler to invoke the callback on. Must not be null.
|
||||
* @param uid The UID of the application actually opening the camera.
|
||||
* Must be USE_CALLING_UID unless the caller is a service
|
||||
* that is trusted to open the device on behalf of an
|
||||
* application and to forward the real UID.
|
||||
*
|
||||
* @throws CameraAccessException if the camera is disabled by device policy,
|
||||
* too many camera devices are already open, or the cameraId does not match
|
||||
@@ -281,7 +285,7 @@ public final class CameraManager {
|
||||
* @see android.app.admin.DevicePolicyManager#setCameraDisabled
|
||||
*/
|
||||
private CameraDevice openCameraDeviceUserAsync(String cameraId,
|
||||
CameraDevice.StateCallback callback, Handler handler)
|
||||
CameraDevice.StateCallback callback, Handler handler, final int uid)
|
||||
throws CameraAccessException {
|
||||
CameraCharacteristics characteristics = getCameraCharacteristics(cameraId);
|
||||
CameraDevice device = null;
|
||||
@@ -317,7 +321,7 @@ public final class CameraManager {
|
||||
"Camera service is currently unavailable");
|
||||
}
|
||||
cameraUser = cameraService.connectDevice(callbacks, id,
|
||||
mContext.getOpPackageName(), USE_CALLING_UID);
|
||||
mContext.getOpPackageName(), uid);
|
||||
} else {
|
||||
// Use legacy camera implementation for HAL1 devices
|
||||
Log.i(TAG, "Using legacy camera HAL.");
|
||||
@@ -434,6 +438,29 @@ public final class CameraManager {
|
||||
@NonNull final CameraDevice.StateCallback callback, @Nullable Handler handler)
|
||||
throws CameraAccessException {
|
||||
|
||||
openCameraForUid(cameraId, callback, handler, USE_CALLING_UID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a connection to a camera with the given ID, on behalf of another application
|
||||
* specified by clientUid.
|
||||
*
|
||||
* <p>The behavior of this method matches that of {@link #openCamera}, except that it allows
|
||||
* the caller to specify the UID to use for permission/etc verification. This can only be
|
||||
* done by services trusted by the camera subsystem to act on behalf of applications and
|
||||
* to forward the real UID.</p>
|
||||
*
|
||||
* @param clientUid
|
||||
* The UID of the application on whose behalf the camera is being opened.
|
||||
* Must be USE_CALLING_UID unless the caller is a trusted service.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void openCameraForUid(@NonNull String cameraId,
|
||||
@NonNull final CameraDevice.StateCallback callback, @Nullable Handler handler,
|
||||
int clientUid)
|
||||
throws CameraAccessException {
|
||||
|
||||
if (cameraId == null) {
|
||||
throw new IllegalArgumentException("cameraId was null");
|
||||
} else if (callback == null) {
|
||||
@@ -447,7 +474,7 @@ public final class CameraManager {
|
||||
}
|
||||
}
|
||||
|
||||
openCameraDeviceUserAsync(cameraId, callback, handler);
|
||||
openCameraDeviceUserAsync(cameraId, callback, handler, clientUid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user