Implement device awareness in camera service
- Modify ICameraServiceListener to pass device id
(i.e., the id of the device owning the camera, for
virtual camera this would be the id of the virtual
device, and for real cameras this would be
Context#DEVICE_ID_DEFAULT) and the mapped camera id
(for virtual devices, the back and front virtual cameras
of that device would have 0 and 1 respectively as their
mapped camera id, and for real cameras this would be
their actual camera id) in the callbacks. Cameraserver
exposes vitual cameras only to callers having context
associated with a custom policy virtual device.
- Modify ICameraService to accept device id and device
policy for binder calls related to camera operations.
Based on these, cameraserver maps the input camera id into
a virtual camera id (if applicable).
- Modify virtual camera HAL service to pass the device id
of virtual cameras using the metadata key ANDROID_INFO_DEVICE_ID.
- This change adds device-awareness to both camera2 and legacy
camera API's.
- This change prevents camera injection, session params injection,
and package name based cameraId-remapping if a virtual camera is
involved.
- This change modifies the NDK implementation to ignore callbacks
for non-default device id's. So virtual cameras are not accessible
using the NDK with this change (if the feature flag for camera
device awareness is enabled). Device awareness for camera NDK will
be added in a future CL.
Test: atest CtsVirtualDevicesCameraTestCases
Bug: 291736219
Change-Id: Iffe2a2e337a9e5801b84495d3ce1e8a1584b4993
diff --git a/camera/ndk/impl/ACameraManager.h b/camera/ndk/impl/ACameraManager.h
index c135d0f..c6e2bf9 100644
--- a/camera/ndk/impl/ACameraManager.h
+++ b/camera/ndk/impl/ACameraManager.h
@@ -87,23 +87,24 @@
class CameraServiceListener final : public hardware::BnCameraServiceListener {
public:
explicit CameraServiceListener(CameraManagerGlobal* cm) : mCameraManager(cm) {}
- virtual binder::Status onStatusChanged(int32_t status, const std::string& cameraId);
+ virtual binder::Status onStatusChanged(int32_t status, const std::string& cameraId,
+ int32_t deviceId);
virtual binder::Status onPhysicalCameraStatusChanged(int32_t status,
- const std::string& cameraId, const std::string& physicalCameraId);
+ const std::string& cameraId, const std::string& physicalCameraId, int32_t deviceId);
// Torch API not implemented yet
- virtual binder::Status onTorchStatusChanged(int32_t, const std::string&) {
+ virtual binder::Status onTorchStatusChanged(int32_t, const std::string&, int32_t) {
return binder::Status::ok();
}
- virtual binder::Status onTorchStrengthLevelChanged(const std::string&, int32_t) {
+ virtual binder::Status onTorchStrengthLevelChanged(const std::string&, int32_t, int32_t) {
return binder::Status::ok();
}
virtual binder::Status onCameraAccessPrioritiesChanged();
- virtual binder::Status onCameraOpened(const std::string&, const std::string&) {
+ virtual binder::Status onCameraOpened(const std::string&, const std::string&, int32_t) {
return binder::Status::ok();
}
- virtual binder::Status onCameraClosed(const std::string&) {
+ virtual binder::Status onCameraClosed(const std::string&, int32_t) {
return binder::Status::ok();
}