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

Commit e8e9e191 authored by Yin-Chia Yeh's avatar Yin-Chia Yeh
Browse files

Camera: fix number of cameras logic

Test: no Camera CTS regression
Bug: 36289841
Change-Id: I7218347a0f2e8184dd43a9f35acc0554b761e15e
parent 94c68e09
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

#include <chrono>
#include <inttypes.h>
#include <set>
#include <hidl/ServiceManagement.h>

namespace android {
@@ -75,7 +76,7 @@ int CameraProviderManager::getCameraCount() const {
    std::lock_guard<std::mutex> lock(mInterfaceMutex);
    int count = 0;
    for (auto& provider : mProviders) {
        count += provider->mDevices.size();
        count += provider->mUniqueDeviceCount;
    }
    return count;
}
@@ -85,7 +86,7 @@ int CameraProviderManager::getStandardCameraCount() const {
    int count = 0;
    for (auto& provider : mProviders) {
        if (kStandardProviderTypes.find(provider->getType()) != std::string::npos) {
            count += provider->mDevices.size();
            count += provider->mUniqueDeviceCount;
        }
    }
    return count;
@@ -471,6 +472,12 @@ status_t CameraProviderManager::ProviderInfo::initialize() {
        }
    }

    std::set<std::string> uniqueCameraIds;
    for (auto& device : mDevices) {
        uniqueCameraIds.insert(device->mId);
    }
    mUniqueDeviceCount = uniqueCameraIds.size();

    ALOGI("Camera provider %s ready with %zu camera devices",
            mProviderName.c_str(), mDevices.size());

+1 −0
Original line number Diff line number Diff line
@@ -292,6 +292,7 @@ private:
            static status_t setTorchMode(InterfaceT& interface, bool enabled);
        };
        std::vector<std::unique_ptr<DeviceInfo>> mDevices;
        int mUniqueDeviceCount;

        // HALv1-specific camera fields, including the actual device interface
        struct DeviceInfo1 : public DeviceInfo {