Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec96060c authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

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
parent 4bebef8d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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__,
+8 −0
Original line number Diff line number Diff line
@@ -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);
+5 −0
Original line number Diff line number Diff line
@@ -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);