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

Commit 831ed185 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera: Fix ProviderInfo leak" into rvc-dev

parents 6da8961b 79680438
Loading
Loading
Loading
Loading
+19 −7
Original line number Diff line number Diff line
@@ -326,8 +326,11 @@ status_t CameraProviderManager::setTorchMode(const std::string &id, bool enabled

    // Pass the camera ID to start interface so that it will save it to the map of ICameraProviders
    // that are currently in use.
    const sp<provider::V2_4::ICameraProvider> interface =
            deviceInfo->mParentProvider->startProviderInterface();
    sp<ProviderInfo> parentProvider = deviceInfo->mParentProvider.promote();
    if (parentProvider == nullptr) {
        return DEAD_OBJECT;
    }
    const sp<provider::V2_4::ICameraProvider> interface = parentProvider->startProviderInterface();
    if (interface == nullptr) {
        return DEAD_OBJECT;
    }
@@ -380,8 +383,11 @@ status_t CameraProviderManager::openSession(const std::string &id,
    if (deviceInfo == nullptr) return NAME_NOT_FOUND;

    auto *deviceInfo3 = static_cast<ProviderInfo::DeviceInfo3*>(deviceInfo);
    const sp<provider::V2_4::ICameraProvider> provider =
            deviceInfo->mParentProvider->startProviderInterface();
    sp<ProviderInfo> parentProvider = deviceInfo->mParentProvider.promote();
    if (parentProvider == nullptr) {
        return DEAD_OBJECT;
    }
    const sp<provider::V2_4::ICameraProvider> provider = parentProvider->startProviderInterface();
    if (provider == nullptr) {
        return DEAD_OBJECT;
    }
@@ -423,8 +429,11 @@ status_t CameraProviderManager::openSession(const std::string &id,
    if (deviceInfo == nullptr) return NAME_NOT_FOUND;

    auto *deviceInfo1 = static_cast<ProviderInfo::DeviceInfo1*>(deviceInfo);
    const sp<provider::V2_4::ICameraProvider> provider =
            deviceInfo->mParentProvider->startProviderInterface();
    sp<ProviderInfo> parentProvider = deviceInfo->mParentProvider.promote();
    if (parentProvider == nullptr) {
        return DEAD_OBJECT;
    }
    const sp<provider::V2_4::ICameraProvider> provider = parentProvider->startProviderInterface();
    if (provider == nullptr) {
        return DEAD_OBJECT;
    }
@@ -2044,7 +2053,10 @@ sp<InterfaceT> CameraProviderManager::ProviderInfo::DeviceInfo::startDeviceInter
    sp<InterfaceT> device;
    ATRACE_CALL();
    if (mSavedInterface == nullptr) {
        device = mParentProvider->startDeviceInterface<InterfaceT>(mName);
        sp<ProviderInfo> parentProvider = mParentProvider.promote();
        if (parentProvider != nullptr) {
            device = parentProvider->startDeviceInterface<InterfaceT>(mName);
        }
    } else {
        device = (InterfaceT *) mSavedInterface.get();
    }
+1 −1
Original line number Diff line number Diff line
@@ -447,7 +447,7 @@ private:
            std::map<std::string, hardware::camera::common::V1_0::CameraDeviceStatus>
                    mPhysicalStatus;

            sp<ProviderInfo> mParentProvider;
            wp<ProviderInfo> mParentProvider;

            bool hasFlashUnit() const { return mHasFlashUnit; }
            bool supportNativeZoomRatio() const { return mSupportNativeZoomRatio; }