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

Commit 8526b697 authored by Ivan Vecera's avatar Ivan Vecera Committed by Luca Stefani
Browse files

Camera: Maintain set of non-external cameras

External cameras are currently identified by comparison of camera ID
and stored number of legacy cameras reported by camera HAL. This simple
check assumes that a legacy camera ID belong to range <0,
mNumberOfLegacyCameras>.

Some camera HALs support camera ID remapping so its legacy camera IDs
can be arbitrary number also outside the specified range.

Maintain the set of non-external (legacy) cameras and use this set to
check if particular camera is legacy or external one at existing places.

Change-Id: I78670a39b2c6f650d49d666c521335b7167a594a
parent 2a6684e3
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -314,6 +314,8 @@ bool LegacyCameraProviderImpl_2_4::initialize() {

    mNumberOfLegacyCameras = mModule->getNumberOfCameras();
    for (int i = 0; i < mNumberOfLegacyCameras; i++) {
        mLegacyCameras.insert(i);

        struct camera_info info;
        auto rc = mModule->getCameraInfo(i, &info);
        if (rc != NO_ERROR) {
@@ -457,7 +459,7 @@ Return<Status> LegacyCameraProviderImpl_2_4::setCallback(
    for (auto const& statusPair : mCameraStatusMap) {
        int id = std::stoi(statusPair.first);
        auto status = static_cast<CameraDeviceStatus>(statusPair.second);
        if (id >= mNumberOfLegacyCameras && status != CameraDeviceStatus::NOT_PRESENT) {
        if (!mLegacyCameras.contains(id) && status != CameraDeviceStatus::NOT_PRESENT) {
            addDeviceNames(id, status, true);
        }
    }
@@ -475,7 +477,7 @@ Return<void> LegacyCameraProviderImpl_2_4::getCameraIdList(
        ICameraProvider::getCameraIdList_cb _hidl_cb) {
    std::vector<hidl_string> deviceNameList;
    for (auto const& deviceNamePair : mCameraDeviceNames) {
        if (std::stoi(deviceNamePair.first) >= mNumberOfLegacyCameras) {
        if (!mLegacyCameras.contains(std::stoi(deviceNamePair.first))) {
            // External camera devices must be reported through the device status change callback,
            // not in this list.
            continue;
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#ifndef ANDROID_HARDWARE_CAMERA_PROVIDER_V2_4_LEGACYCAMERAPROVIDER_H
#define ANDROID_HARDWARE_CAMERA_PROVIDER_V2_4_LEGACYCAMERAPROVIDER_H

#include <set>
#include <android/hardware/camera/provider/2.4/ICameraProvider.h>
#include "hardware/camera_common.h"
#include "utils/Mutex.h"
@@ -84,6 +85,7 @@ protected:
    int mNumberOfLegacyCameras;
    std::map<std::string, camera_device_status_t> mCameraStatusMap; // camera id -> status
    std::map<std::string, bool> mOpenLegacySupported; // camera id -> open_legacy HAL1.0 supported
    std::set<int> mLegacyCameras; // non-external cameras
    SortedVector<std::string> mCameraIds; // the "0"/"1" legacy camera Ids
    // (cameraId string, hidl device name) pairs
    SortedVector<std::pair<std::string, std::string>> mCameraDeviceNames;