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

Commit f70a05b4 authored by Avichal Rakesh's avatar Avichal Rakesh Committed by Android (Google) Code Review
Browse files

Merge "libcameraservice: Reduce unnecessary nesting." into main

parents fac5bbc8 07d3bfcf
Loading
Loading
Loading
Loading
+40 −37
Original line number Diff line number Diff line
@@ -275,22 +275,29 @@ const std::shared_ptr<ICameraProvider> AidlProviderInfo::startProviderInterface(
    if (mSavedInterface != nullptr) {
        return mSavedInterface;
    }

    if (!kEnableLazyHal) {
        ALOGE("Bad provider state! Should not be here on a non-lazy HAL!");
        return nullptr;
    }

    auto interface = mActiveInterface.lock();
    if (interface == nullptr) {
    if (interface != nullptr) {
        ALOGV("Camera provider (%s) already in use. Re-using instance.", mProviderName.c_str());
        return interface;
    }

    // Try to get service without starting
        interface =
                    ICameraProvider::fromBinder(
    interface = ICameraProvider::fromBinder(
            ndk::SpAIBinder(AServiceManager_checkService(mProviderName.c_str())));
        if (interface == nullptr) {
            ALOGV("Camera provider actually needs restart, calling getService(%s)",
                  mProviderName.c_str());
            interface = mManager->mAidlServiceProxy->getAidlService(mProviderName.c_str());
    if (interface != nullptr) {
        // Service is already running. Cache and return.
        mActiveInterface = interface;
        return interface;
    }

    ALOGV("Camera provider actually needs restart, calling getService(%s)", mProviderName.c_str());
    interface = mManager->mAidlServiceProxy->getAidlService(mProviderName.c_str());
    if (interface == nullptr) {
        ALOGD("%s: %s service not started", __FUNCTION__, mProviderName.c_str());
        return nullptr;
@@ -316,12 +323,8 @@ const std::shared_ptr<ICameraProvider> AidlProviderInfo::startProviderInterface(

    // Send current device state
    interface->notifyDeviceStateChange(mDeviceState);
        }
    // Cache interface to return early for future calls.
    mActiveInterface = interface;
    } else {
        ALOGV("Camera provider (%s) already in use. Re-using instance.",
              mProviderName.c_str());
    }

    return interface;
}