aidl: camera: provider: Allow exposing additional camera IDs
* Move the soong configs here, since HIDL is deprecated
Change-Id: I34b82250b457f40b2be27ee976149de17a3b4e9f
diff --git a/aidl/camera/provider/Android.bp b/aidl/camera/provider/Android.bp
index 1c223f0..b1c8aa2 100644
--- a/aidl/camera/provider/Android.bp
+++ b/aidl/camera/provider/Android.bp
@@ -4,9 +4,29 @@
// SPDX-License-Identifier: Apache-2.0
//
+soong_config_module_type {
+ name: "extra_ids",
+ module_type: "cc_defaults",
+ config_namespace: "samsungCameraVars",
+ value_variables: ["extra_ids"],
+ properties: ["cppflags"],
+}
+
+extra_ids {
+ name: "extra_id_defaults",
+ soong_config_variables: {
+ extra_ids: {
+ cppflags: ["-DEXTRA_IDS=%s"],
+ },
+ },
+}
+
cc_binary {
name: "android.hardware.camera.provider-service.samsung",
- defaults: ["samsung_camera3_defaults"],
+ defaults: [
+ "extra_id_defaults",
+ "samsung_camera3_defaults"
+ ],
init_rc: ["android.hardware.camera.provider-service.samsung.rc"],
vintf_fragments: ["android.hardware.camera.provider-service.samsung.xml"],
vendor: true,
diff --git a/aidl/camera/provider/CameraProvider.cpp b/aidl/camera/provider/CameraProvider.cpp
index 8487201..329c34b 100644
--- a/aidl/camera/provider/CameraProvider.cpp
+++ b/aidl/camera/provider/CameraProvider.cpp
@@ -158,6 +158,29 @@
CameraProvider::~CameraProvider() {}
+bool CameraProvider::initCamera(int id) {
+ struct camera_info info;
+ auto rc = mModule->getCameraInfo(id, &info);
+ if (rc != NO_ERROR) {
+ ALOGE("%s: Camera info query failed!", __func__);
+ return true;
+ }
+
+ if (checkCameraVersion(id, info) != OK) {
+ ALOGE("%s: Camera version check failed!", __func__);
+ return true;
+ }
+
+ char cameraId[kMaxCameraIdLen];
+ snprintf(cameraId, sizeof(cameraId), "%d", id);
+ std::string cameraIdStr(cameraId);
+ mCameraStatusMap[cameraIdStr] = CAMERA_DEVICE_STATUS_PRESENT;
+
+ addDeviceNames(id);
+
+ return false;
+}
+
bool CameraProvider::initialize() {
camera_module_t* rawModule;
int err = hw_get_module(CAMERA_HARDWARE_MODULE_ID, (const hw_module_t**)&rawModule);
@@ -191,26 +214,23 @@
mNumberOfLegacyCameras = mModule->getNumberOfCameras();
for (int i = 0; i < mNumberOfLegacyCameras; i++) {
- struct camera_info info;
- auto rc = mModule->getCameraInfo(i, &info);
- if (rc != NO_ERROR) {
- ALOGE("%s: Camera info query failed!", __func__);
+ if (initCamera(i)) {
mModule.clear();
return true;
}
-
- if (checkCameraVersion(i, info) != OK) {
- ALOGE("%s: Camera version check failed!", __func__);
+ }
+ std::vector<int> extraIDs = {
+#ifdef EXTRA_IDS
+ EXTRA_IDS
+#endif
+ };
+ for (int i : extraIDs) {
+ if (initCamera(i)) {
mModule.clear();
return true;
+ } else {
+ mNumberOfLegacyCameras++;
}
-
- char cameraId[kMaxCameraIdLen];
- snprintf(cameraId, sizeof(cameraId), "%d", i);
- std::string cameraIdStr(cameraId);
- mCameraStatusMap[cameraIdStr] = CAMERA_DEVICE_STATUS_PRESENT;
-
- addDeviceNames(i);
}
return false; // mInitFailed
diff --git a/aidl/camera/provider/CameraProvider.h b/aidl/camera/provider/CameraProvider.h
index cedc2df..411b331 100644
--- a/aidl/camera/provider/CameraProvider.h
+++ b/aidl/camera/provider/CameraProvider.h
@@ -65,6 +65,7 @@
// Must be queried before using any APIs.
// APIs will only work when this returns true
bool mInitFailed;
+ bool initCamera(int id);
bool initialize();
std::vector<VendorTagSection> mVendorTagSections;
diff --git a/hidl/camera/provider/2.5/Android.bp b/hidl/camera/provider/2.5/Android.bp
index dc70852..4ed98ae 100644
--- a/hidl/camera/provider/2.5/Android.bp
+++ b/hidl/camera/provider/2.5/Android.bp
@@ -1,20 +1,3 @@
-soong_config_module_type {
- name: "extra_ids",
- module_type: "cc_defaults",
- config_namespace: "samsungCameraVars",
- value_variables: ["extra_ids"],
- properties: ["cppflags"],
-}
-
-extra_ids {
- name: "extra_id_defaults",
- soong_config_variables: {
- extra_ids: {
- cppflags: ["-DEXTRA_IDS=%s"],
- },
- },
-}
-
cc_library_shared {
name: "android.hardware.camera.provider@2.5-legacy.samsung",
defaults: ["extra_id_defaults"],