Camera: remove wait for remote HIDL interface
The new getService implementation does it.
Test: fixing Marlin flashlight control
Bug: 34821019
Change-Id: Ifd21f41313b85ef0abbd306d2862524e19b94e7d
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index f691dc1..a23c3f6 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -47,43 +47,25 @@
status_t CameraProviderManager::initialize(wp<CameraProviderManager::StatusListener> listener,
ServiceInteractionProxy* proxy) {
- int numProviders = 0;
- {
- std::lock_guard<std::mutex> lock(mInterfaceMutex);
- if (proxy == nullptr) {
- ALOGE("%s: No valid service interaction proxy provided", __FUNCTION__);
- return BAD_VALUE;
- }
- mListener = listener;
- mServiceProxy = proxy;
-
- // Registering will trigger notifications for all already-known providers
- bool success = mServiceProxy->registerForNotifications(
- /* instance name, empty means no filter */ "",
- this);
- if (!success) {
- ALOGE("%s: Unable to register with hardware service manager for notifications "
- "about camera providers", __FUNCTION__);
- return INVALID_OPERATION;
- }
- numProviders = mProviders.size();
+ std::lock_guard<std::mutex> lock(mInterfaceMutex);
+ if (proxy == nullptr) {
+ ALOGE("%s: No valid service interaction proxy provided", __FUNCTION__);
+ return BAD_VALUE;
}
+ mListener = listener;
+ mServiceProxy = proxy;
- if (numProviders == 0) {
- // Remote provider might have not been initialized
- // Wait for a bit and see if we get one registered
- std::mutex mtx;
- std::unique_lock<std::mutex> lock(mtx);
- mProviderRegistered.wait_for(lock, std::chrono::seconds(15));
- if (mProviders.size() == 0) {
- ALOGI("%s: Unable to get one registered provider within timeout!",
- __FUNCTION__);
- std::lock_guard<std::mutex> lock(mInterfaceMutex);
- // See if there's a passthrough HAL, but let's not complain if there's not
- addProvider(kLegacyProviderName, /*expected*/ false);
- }
+ // Registering will trigger notifications for all already-known providers
+ bool success = mServiceProxy->registerForNotifications(
+ /* instance name, empty means no filter */ "",
+ this);
+ if (!success) {
+ ALOGE("%s: Unable to register with hardware service manager for notifications "
+ "about camera providers", __FUNCTION__);
+ return INVALID_OPERATION;
}
-
+ // See if there's a passthrough HAL, but let's not complain if there's not
+ addProvider(kLegacyProviderName, /*expected*/ false);
return OK;
}
@@ -294,7 +276,6 @@
std::lock_guard<std::mutex> lock(mInterfaceMutex);
addProvider(name);
- mProviderRegistered.notify_one();
return hardware::Return<void>();
}
@@ -335,12 +316,11 @@
mServiceProxy->getService(newProvider);
if (interface == nullptr) {
+ ALOGW("%s: Camera provider HAL '%s' is not actually available", __FUNCTION__,
+ newProvider.c_str());
if (expected) {
- ALOGW("%s: Camera provider HAL '%s' is not actually available", __FUNCTION__,
- newProvider.c_str());
return BAD_VALUE;
} else {
- // Not guaranteed to be found, so not an error if it wasn't
return OK;
}
}
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.h b/services/camera/libcameraservice/common/CameraProviderManager.h
index f21e07d..5ae16cd 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.h
+++ b/services/camera/libcameraservice/common/CameraProviderManager.h
@@ -20,7 +20,6 @@
#include <vector>
#include <string>
#include <mutex>
-#include <condition_variable>
#include <camera/CameraParameters2.h>
#include <camera/CameraMetadata.h>
@@ -220,8 +219,6 @@
// All private members, unless otherwise noted, expect mInterfaceMutex to be locked before use
mutable std::mutex mInterfaceMutex;
- std::condition_variable mProviderRegistered;
-
// the status listener update callbacks will lock mStatusMutex
mutable std::mutex mStatusListenerMutex;
wp<StatusListener> mListener;