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

Commit 90e63699 authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

cameraserver: filter out non-HAL3 devices from HIDL addListener.



Bug: 143192708

Test: Use vendor clients of cameraserver
Test: GCA (sanity)

Change-Id: Ic31f71887b55f3d838ca35274a5f65802ea50584
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 33e8ef86
Loading
Loading
Loading
Loading
+18 −5
Original line number Original line Diff line number Diff line
@@ -3448,10 +3448,21 @@ void CameraService::updateStatus(StatusInternal status, const String8& cameraId,
        ALOGE("%s: Invalid camera id %s, skipping", __FUNCTION__, cameraId.string());
        ALOGE("%s: Invalid camera id %s, skipping", __FUNCTION__, cameraId.string());
        return;
        return;
    }
    }

    bool supportsHAL3 = false;
    // supportsCameraApi also holds mInterfaceMutex, we can't call it in the
    // HIDL onStatusChanged wrapper call (we'll hold mStatusListenerLock and
    // mInterfaceMutex together, which can lead to deadlocks)
    binder::Status sRet =
            supportsCameraApi(String16(cameraId), hardware::ICameraService::API_VERSION_2,
                    &supportsHAL3);
    if (!sRet.isOk()) {
        ALOGW("%s: Failed to determine if device supports HAL3 %s, supportsCameraApi call failed",
                __FUNCTION__, cameraId.string());
        return;
    }
    // Update the status for this camera state, then send the onStatusChangedCallbacks to each
    // Update the status for this camera state, then send the onStatusChangedCallbacks to each
    // of the listeners with both the mStatusStatus and mStatusListenerLock held
    // of the listeners with both the mStatusStatus and mStatusListenerLock held
    state->updateStatus(status, cameraId, rejectSourceStates, [this, &deviceKind]
    state->updateStatus(status, cameraId, rejectSourceStates, [this, &deviceKind, &supportsHAL3]
            (const String8& cameraId, StatusInternal status) {
            (const String8& cameraId, StatusInternal status) {


            if (status != StatusInternal::ENUMERATING) {
            if (status != StatusInternal::ENUMERATING) {
@@ -3473,9 +3484,11 @@ void CameraService::updateStatus(StatusInternal status, const String8& cameraId,
            Mutex::Autolock lock(mStatusListenerLock);
            Mutex::Autolock lock(mStatusListenerLock);


            for (auto& listener : mListenerList) {
            for (auto& listener : mListenerList) {
                if (shouldSkipStatusUpdates(deviceKind, listener->isVendorListener(),
                bool isVendorListener = listener->isVendorListener();
                        listener->getListenerPid(), listener->getListenerUid())) {
                if (shouldSkipStatusUpdates(deviceKind, isVendorListener,
                    ALOGV("Skipping camera discovery callback for system-only camera %s",
                        listener->getListenerPid(), listener->getListenerUid()) ||
                    (isVendorListener && !supportsHAL3)) {
                    ALOGV("Skipping discovery callback for system-only camera/HAL1 device %s",
                            cameraId.c_str());
                            cameraId.c_str());
                    continue;
                    continue;
                }
                }
+8 −0
Original line number Original line Diff line number Diff line
@@ -191,6 +191,14 @@ Return<void> HidlCameraService::addListener(const sp<HCameraServiceListener>& hC
      _hidl_cb(status, {});
      _hidl_cb(status, {});
      return Void();
      return Void();
    }
    }
    cameraStatusAndIds.erase(std::remove_if(cameraStatusAndIds.begin(), cameraStatusAndIds.end(),
            [this](const hardware::CameraStatus& s) {
              bool supportsHAL3 = false;
              binder::Status sRet =
                            mAidlICameraService->supportsCameraApi(String16(s.cameraId),
                                    hardware::ICameraService::API_VERSION_2, &supportsHAL3);
              return !sRet.isOk() || !supportsHAL3;
            }), cameraStatusAndIds.end());
    hidl_vec<HCameraStatusAndId> hCameraStatusAndIds;
    hidl_vec<HCameraStatusAndId> hCameraStatusAndIds;
    //Convert cameraStatusAndIds to HIDL and call callback
    //Convert cameraStatusAndIds to HIDL and call callback
    convertToHidl(cameraStatusAndIds, &hCameraStatusAndIds);
    convertToHidl(cameraStatusAndIds, &hCameraStatusAndIds);