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

Commit 02df11df authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

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

Merge "cameraserver: system camera rules should be checked before making onPhysicalCameraStatusChanged callbacks." into rvc-dev am: eca178fb am: 8c6abfd7 am: 384e321e am: 7437d174

Change-Id: Ifd92e9281bc935bf34feab9fe26be0044f9d9f38
parents d1d053f5 7437d174
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);
        }
        }
@@ -3751,7 +3762,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();
@@ -3869,7 +3880,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;
@@ -3885,6 +3897,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
@@ -1006,7 +1006,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);