cameraservice: Add AIDL vndk client support
With HIDL being deprecated, vndk camera clients were moved to stable
AIDL interfaces. This CL adds support for AIDL vndk clients to the
cameraservice. It leaves in support for HIDL vndk clients as vendor
partition might not be updated with the system partition.
As of this CL, cameraservice supports both AIDL vndk clients and HIDL
VNDK clients. Specifically, this CL creates a new cameraservice
endpoint for AIDL vndk clients to interact with and creates a thin
shim that translates vndk AIDL data structures to ndk AIDL data
structures before passing it to main cameraservice logic.
Bug: 243593375
Test: Migrating VTS test in a future CL
Change-Id: Iaf7a434650d5f95149ccb7fcbf1a134852d6f71c
diff --git a/services/camera/libcameraservice/hidl/AidlCameraDeviceCallbacks.cpp b/services/camera/libcameraservice/hidl/AidlCameraDeviceCallbacks.cpp
index 3392db1..de51ffa 100644
--- a/services/camera/libcameraservice/hidl/AidlCameraDeviceCallbacks.cpp
+++ b/services/camera/libcameraservice/hidl/AidlCameraDeviceCallbacks.cpp
@@ -17,6 +17,7 @@
#include <hidl/AidlCameraDeviceCallbacks.h>
#include <hidl/Utils.h>
+#include <aidl/AidlUtils.h>
namespace android {
namespace frameworks {
@@ -144,7 +145,7 @@
// Convert Metadata into HCameraMetadata;
FmqSizeOrMetadata hResult;
- using hardware::cameraservice::utils::conversion::filterVndkKeys;
+ using hardware::cameraservice::utils::conversion::aidl::filterVndkKeys;
if (filterVndkKeys(mVndkVersion, result, /*isStatic*/false) != OK) {
ALOGE("%s: filtering vndk keys from result failed, not sending onResultReceived callback",
__FUNCTION__);
diff --git a/services/camera/libcameraservice/hidl/HidlCameraService.cpp b/services/camera/libcameraservice/hidl/HidlCameraService.cpp
index 259e8a5..1d5213d 100644
--- a/services/camera/libcameraservice/hidl/HidlCameraService.cpp
+++ b/services/camera/libcameraservice/hidl/HidlCameraService.cpp
@@ -21,6 +21,7 @@
#include <hidl/HidlCameraService.h>
#include <hidl/HidlCameraDeviceUser.h>
#include <hidl/Utils.h>
+#include <aidl/AidlUtils.h>
#include <hidl/HidlTransportSupport.h>
@@ -34,9 +35,9 @@
using frameworks::cameraservice::service::V2_0::implementation::HidlCameraService;
using hardware::hidl_vec;
using hardware::cameraservice::utils::conversion::convertToHidl;
-using hardware::cameraservice::utils::conversion::filterVndkKeys;
using hardware::cameraservice::utils::conversion::B2HStatus;
using hardware::Void;
+using hardware::cameraservice::utils::conversion::aidl::filterVndkKeys;
using device::V2_0::implementation::H2BCameraDeviceCallbacks;
using device::V2_1::implementation::HidlCameraDeviceUser;
diff --git a/services/camera/libcameraservice/hidl/Utils.cpp b/services/camera/libcameraservice/hidl/Utils.cpp
index 057a6e9..2a24a23 100644
--- a/services/camera/libcameraservice/hidl/Utils.cpp
+++ b/services/camera/libcameraservice/hidl/Utils.cpp
@@ -15,7 +15,6 @@
*/
#include <hidl/Utils.h>
-#include <hidl/VndkVersionMetadataTags.h>
#include <gui/bufferqueue/1.0/H2BGraphicBufferProducer.h>
#include <cutils/native_handle.h>
#include <mediautils/AImageReaderUtils.h>
@@ -298,31 +297,6 @@
return hPhysicalCaptureResultInfos;
}
-status_t filterVndkKeys(int vndkVersion, CameraMetadata &metadata, bool isStatic) {
- if (vndkVersion == __ANDROID_API_FUTURE__) {
- // VNDK version in ro.vndk.version is a version code-name that
- // corresponds to the current version.
- return OK;
- }
- const auto &apiLevelToKeys =
- isStatic ? static_api_level_to_keys : dynamic_api_level_to_keys;
- // Find the vndk versions above the given vndk version. All the vndk
- // versions above the given one, need to have their keys filtered from the
- // metadata in order to avoid metadata invalidation.
- auto it = apiLevelToKeys.upper_bound(vndkVersion);
- while (it != apiLevelToKeys.end()) {
- for (const auto &key : it->second) {
- status_t res = metadata.erase(key);
- if (res != OK) {
- ALOGE("%s metadata key %d could not be erased", __FUNCTION__, key);
- return res;
- }
- }
- it++;
- }
- return OK;
-}
-
} //conversion
} // utils
} //cameraservice
diff --git a/services/camera/libcameraservice/hidl/Utils.h b/services/camera/libcameraservice/hidl/Utils.h
index e6d4393..ec06571 100644
--- a/services/camera/libcameraservice/hidl/Utils.h
+++ b/services/camera/libcameraservice/hidl/Utils.h
@@ -97,8 +97,6 @@
HStatus B2HStatus(const binder::Status &bStatus);
-status_t filterVndkKeys(int vndk_version, CameraMetadata &metadata, bool isStatic = true);
-
} // conversion
} // utils
} // cameraservice
diff --git a/services/camera/libcameraservice/hidl/VndkVersionMetadataTags.h b/services/camera/libcameraservice/hidl/VndkVersionMetadataTags.h
deleted file mode 100644
index 9098fe8..0000000
--- a/services/camera/libcameraservice/hidl/VndkVersionMetadataTags.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <map>
-#include <vector>
-#pragma once
-/**
- * ! Do not edit this file directly !
- *
- * Generated automatically from vndk_camera_metadata_tags.mako. To be included in libcameraservice
- * only by hidl/Utils.cpp.
- */
-
-/**
- * API level to static keys mapping. To be used for filtering out keys depending on vndk version
- * used by vendor clients.
- */
-std::map<int, std::vector<camera_metadata_tag>> static_api_level_to_keys{
- {30, {
- ANDROID_CONTROL_AVAILABLE_EXTENDED_SCENE_MODE_MAX_SIZES,
- ANDROID_CONTROL_AVAILABLE_EXTENDED_SCENE_MODE_ZOOM_RATIO_RANGES,
- ANDROID_CONTROL_ZOOM_RATIO_RANGE,
- ANDROID_SCALER_AVAILABLE_ROTATE_AND_CROP_MODES,
- } },
- {31, {
- ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_MIN_FRAME_DURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STALL_DURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_HEIC_AVAILABLE_HEIC_MIN_FRAME_DURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_HEIC_AVAILABLE_HEIC_STALL_DURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_LENS_DISTORTION_MAXIMUM_RESOLUTION,
- ANDROID_LENS_INTRINSIC_CALIBRATION_MAXIMUM_RESOLUTION,
- ANDROID_SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP_MAXIMUM_RESOLUTION,
- ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_SCALER_AVAILABLE_STALL_DURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_SCALER_DEFAULT_SECURE_IMAGE_SIZE,
- ANDROID_SCALER_MULTI_RESOLUTION_STREAM_SUPPORTED,
- ANDROID_SCALER_PHYSICAL_CAMERA_MULTI_RESOLUTION_STREAM_CONFIGURATIONS,
- ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION,
- ANDROID_SENSOR_INFO_BINNING_FACTOR,
- ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE_MAXIMUM_RESOLUTION,
- ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION,
- ANDROID_SENSOR_OPAQUE_RAW_SIZE_MAXIMUM_RESOLUTION,
- } },
- {32, {
- ANDROID_INFO_DEVICE_STATE_ORIENTATIONS,
- } },
- {33, {
- ANDROID_AUTOMOTIVE_LENS_FACING,
- ANDROID_AUTOMOTIVE_LOCATION,
- ANDROID_FLASH_INFO_STRENGTH_DEFAULT_LEVEL,
- ANDROID_FLASH_INFO_STRENGTH_MAXIMUM_LEVEL,
- ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP,
- ANDROID_REQUEST_RECOMMENDED_TEN_BIT_DYNAMIC_RANGE_PROFILE,
- ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES,
- ANDROID_SENSOR_READOUT_TIMESTAMP,
- } },
- {34, {
- ANDROID_CONTROL_AUTOFRAMING_AVAILABLE,
- ANDROID_CONTROL_AVAILABLE_SETTINGS_OVERRIDES,
- ANDROID_JPEGR_AVAILABLE_JPEG_R_MIN_FRAME_DURATIONS,
- ANDROID_JPEGR_AVAILABLE_JPEG_R_MIN_FRAME_DURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_JPEGR_AVAILABLE_JPEG_R_STALL_DURATIONS,
- ANDROID_JPEGR_AVAILABLE_JPEG_R_STALL_DURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_JPEGR_AVAILABLE_JPEG_R_STREAM_CONFIGURATIONS,
- ANDROID_JPEGR_AVAILABLE_JPEG_R_STREAM_CONFIGURATIONS_MAXIMUM_RESOLUTION,
- ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP,
- } },
-};
-
-/**
- * API level to dynamic keys mapping. To be used for filtering out keys depending on vndk version
- * used by vendor clients.
- */
-std::map<int, std::vector<camera_metadata_tag>> dynamic_api_level_to_keys{
- {30, {
- ANDROID_CONTROL_EXTENDED_SCENE_MODE,
- ANDROID_CONTROL_ZOOM_RATIO,
- ANDROID_SCALER_ROTATE_AND_CROP,
- } },
- {31, {
- ANDROID_SENSOR_PIXEL_MODE,
- ANDROID_SENSOR_RAW_BINNING_FACTOR_USED,
- } },
- {34, {
- ANDROID_CONTROL_AUTOFRAMING,
- ANDROID_CONTROL_AUTOFRAMING_STATE,
- ANDROID_CONTROL_SETTINGS_OVERRIDE,
- ANDROID_CONTROL_SETTINGS_OVERRIDING_FRAME_NUMBER,
- ANDROID_EXTENSION_CURRENT_TYPE,
- ANDROID_EXTENSION_STRENGTH,
- } },
-};