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

Commit d1478cea authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

cameraserver: system camera rules should be checked before making...


cameraserver: system camera rules should be checked before making onPhysicalCameraStatusChanged callbacks.

Bug: 152089822

Test: GCA (sanity)
Test: Camera CTS

Change-Id: I1cdca010819550f9743f8a6d1c209b123cb16ba4
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 5120edaa
Loading
Loading
Loading
Loading
+22 −4
Original line number Original line Diff line number Diff line
@@ -467,10 +467,21 @@ void CameraService::onDeviceStatusChanged(const String8& id,
            logDeviceRemoved(idCombo,
            logDeviceRemoved(idCombo,
                    String8::format("Device status changed to %d", newStatus));
                    String8::format("Device status changed to %d", newStatus));
        }
        }

        // Avoid calling getSystemCameraKind() with mStatusListenerLock held (b/141756275)
        SystemCameraKind deviceKind = SystemCameraKind::PUBLIC;
        if (getSystemCameraKind(id, &deviceKind) != OK) {
            ALOGE("%s: Invalid camera id %s, skipping", __FUNCTION__, id.string());
            return;
        }
        String16 id16(id), physicalId16(physicalId);
        String16 id16(id), physicalId16(physicalId);
        Mutex::Autolock lock(mStatusListenerLock);
        Mutex::Autolock lock(mStatusListenerLock);
        for (auto& listener : mListenerList) {
        for (auto& listener : mListenerList) {
            if (shouldSkipStatusUpdates(deviceKind, listener->isVendorListener(),
                    listener->getListenerPid(), listener->getListenerUid())) {
                ALOGV("Skipping discovery callback for system-only camera device %s",
                        id.c_str());
                continue;
            }
            listener->getListener()->onPhysicalCameraStatusChanged(mapToInterface(newStatus),
            listener->getListener()->onPhysicalCameraStatusChanged(mapToInterface(newStatus),
                    id16, physicalId16);
                    id16, physicalId16);
        }
        }
@@ -3755,7 +3766,7 @@ void CameraService::updateStatus(StatusInternal status, const String8& cameraId,


            Mutex::Autolock lock(mStatusListenerLock);
            Mutex::Autolock lock(mStatusListenerLock);


            notifyPhysicalCameraStatusLocked(mapToInterface(status), cameraId);
            notifyPhysicalCameraStatusLocked(mapToInterface(status), cameraId, deviceKind);


            for (auto& listener : mListenerList) {
            for (auto& listener : mListenerList) {
                bool isVendorListener = listener->isVendorListener();
                bool isVendorListener = listener->isVendorListener();
@@ -3873,7 +3884,8 @@ status_t CameraService::setTorchStatusLocked(const String8& cameraId,
    return OK;
    return OK;
}
}


void CameraService::notifyPhysicalCameraStatusLocked(int32_t status, const String8& cameraId) {
void CameraService::notifyPhysicalCameraStatusLocked(int32_t status, const String8& cameraId,
        SystemCameraKind deviceKind) {
    Mutex::Autolock lock(mCameraStatesLock);
    Mutex::Autolock lock(mCameraStatesLock);
    for (const auto& state : mCameraStates) {
    for (const auto& state : mCameraStates) {
        std::vector<std::string> physicalCameraIds;
        std::vector<std::string> physicalCameraIds;
@@ -3889,6 +3901,12 @@ void CameraService::notifyPhysicalCameraStatusLocked(int32_t status, const Strin


        String16 id16(state.first), physicalId16(cameraId);
        String16 id16(state.first), physicalId16(cameraId);
        for (auto& listener : mListenerList) {
        for (auto& listener : mListenerList) {
            if (shouldSkipStatusUpdates(deviceKind, listener->isVendorListener(),
                    listener->getListenerPid(), listener->getListenerUid())) {
                ALOGV("Skipping discovery callback for system-only camera device %s",
                        cameraId.c_str());
                continue;
            }
            listener->getListener()->onPhysicalCameraStatusChanged(status,
            listener->getListener()->onPhysicalCameraStatusChanged(status,
                    id16, physicalId16);
                    id16, physicalId16);
        }
        }
+2 −1
Original line number Original line Diff line number Diff line
@@ -1004,7 +1004,8 @@ private:
            hardware::camera::common::V1_0::TorchModeStatus status);
            hardware::camera::common::V1_0::TorchModeStatus status);


    // notify physical camera status when the physical camera is public.
    // notify physical camera status when the physical camera is public.
    void notifyPhysicalCameraStatusLocked(int32_t status, const String8& cameraId);
    void notifyPhysicalCameraStatusLocked(int32_t status, const String8& cameraId,
            SystemCameraKind deviceKind);


    // IBinder::DeathRecipient implementation
    // IBinder::DeathRecipient implementation
    virtual void        binderDied(const wp<IBinder> &who);
    virtual void        binderDied(const wp<IBinder> &who);