CameraService: Don't block on camera HAL start in all cases

When initially starting up, use tryGetService instead of getService to
avoid blocking camera service start in cases where the camera HAL is stuck.

Test: atest cameraservice_test && atest CameraManagerTest, with and without
  lazy camera HAL

Change-Id: I2ad5c542e77e748902cfb49f90a55620b29ad4cd
gugelfrei
Eino-Ville Talvala 5 years ago
parent 4bebef8d59
commit ec96060c3b

@ -1154,7 +1154,7 @@ status_t CameraProviderManager::addProviderLocked(const std::string& newProvider
}
sp<provider::V2_4::ICameraProvider> interface;
interface = mServiceProxy->getService(newProvider);
interface = mServiceProxy->tryGetService(newProvider);
if (interface == nullptr) {
ALOGE("%s: Camera provider HAL '%s' is not actually available", __FUNCTION__,

@ -96,6 +96,10 @@ public:
const std::string &serviceName,
const sp<hidl::manager::V1_0::IServiceNotification>
&notification) = 0;
// Will not wait for service to start if it's not already running
virtual sp<hardware::camera::provider::V2_4::ICameraProvider> tryGetService(
const std::string &serviceName) = 0;
// Will block for service if it exists but isn't running
virtual sp<hardware::camera::provider::V2_4::ICameraProvider> getService(
const std::string &serviceName) = 0;
virtual hardware::hidl_vec<hardware::hidl_string> listServices() = 0;
@ -112,6 +116,10 @@ public:
return hardware::camera::provider::V2_4::ICameraProvider::registerForNotifications(
serviceName, notification);
}
virtual sp<hardware::camera::provider::V2_4::ICameraProvider> tryGetService(
const std::string &serviceName) override {
return hardware::camera::provider::V2_4::ICameraProvider::tryGetService(serviceName);
}
virtual sp<hardware::camera::provider::V2_4::ICameraProvider> getService(
const std::string &serviceName) override {
return hardware::camera::provider::V2_4::ICameraProvider::getService(serviceName);

@ -199,6 +199,11 @@ struct TestInteractionProxy : public CameraProviderManager::ServiceInteractionPr
return true;
}
virtual sp<hardware::camera::provider::V2_4::ICameraProvider> tryGetService(
const std::string &serviceName) override {
return getService(serviceName);
}
virtual sp<hardware::camera::provider::V2_4::ICameraProvider> getService(
const std::string &serviceName) override {
mLastRequestedServiceNames.push_back(serviceName);

Loading…
Cancel
Save