Add camera HAL ready property when running from APEX
Allows GCA to poll a property instead of using framework event listener
to determine approximately when the HAL cameras become ready
Bug: 189110511
Test: adb shell getprop
Change-Id: Iff958d71c4c1471d0d9974c6ce7636fdddf65655
diff --git a/common/hal/hidl_service/Android.bp b/common/hal/hidl_service/Android.bp
index 97e78d7..29f7203 100644
--- a/common/hal/hidl_service/Android.bp
+++ b/common/hal/hidl_service/Android.bp
@@ -101,6 +101,7 @@
"android.hardware.graphics.mapper@4.0",
"android.hardware.thermal@2.0",
"libbinder",
+ "libbase",
"libcamera_metadata",
"libcutils",
"libfmq",
diff --git a/common/hal/hidl_service/hidl_camera_provider.cc b/common/hal/hidl_service/hidl_camera_provider.cc
index c2f63a4..1c572e3 100644
--- a/common/hal/hidl_service/hidl_camera_provider.cc
+++ b/common/hal/hidl_service/hidl_camera_provider.cc
@@ -164,13 +164,23 @@
Return<Status> HidlCameraProvider::setCallback(
const sp<ICameraProviderCallback>& callback) {
+ bool first_time = false;
{
std::unique_lock<std::mutex> lock(callbacks_lock_);
+ first_time = callbacks_ == nullptr;
callbacks_ = callback;
}
-
google_camera_provider_->TriggerDeferredCallbacks();
-
+#ifdef __ANDROID_APEX__
+ if (first_time) {
+ std::string ready_property_name = "vendor.camera.hal.ready.count";
+ int ready_count = property_get_int32(ready_property_name.c_str(), 0);
+ property_set(ready_property_name.c_str(),
+ std::to_string(++ready_count).c_str());
+ ALOGI("HidlCameraProvider::setCallback() first time ready count: %d ",
+ ready_count);
+ }
+#endif
return Status::OK;
}
@@ -203,7 +213,6 @@
Return<void> HidlCameraProvider::getCameraIdList(getCameraIdList_cb _hidl_cb) {
std::vector<uint32_t> camera_ids;
hidl_vec<hidl_string> hidl_camera_ids;
-
status_t res = google_camera_provider_->GetCameraIdList(&camera_ids);
if (res != OK) {
ALOGE("%s: Getting camera ID list failed: %s(%d)", __FUNCTION__,