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

Commit c19bb16f authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Camera: Fix race between notifyDeviceStateChange and removeProvider"...

Merge "Camera: Fix race between notifyDeviceStateChange and removeProvider" am: c9f2c53a am: 807f72bf am: 2daf0cc9 am: 00bc85fe am: 75502744

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/2117608



Change-Id: I827b6a1a6db44d7a0cdbb61245f5fc2a4b228478
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents aba097ce 75502744
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -579,7 +579,11 @@ status_t CameraProviderManager::notifyDeviceStateChange(int64_t newState) {
    std::lock_guard<std::mutex> lock(mInterfaceMutex);
    std::lock_guard<std::mutex> lock(mInterfaceMutex);
    mDeviceState = newState;
    mDeviceState = newState;
    status_t res = OK;
    status_t res = OK;
    for (auto& provider : mProviders) {
    // Make a copy of mProviders because we unlock mInterfaceMutex temporarily
    // within the loop. It's possible that during the time mInterfaceMutex is
    // unlocked, mProviders has changed.
    auto providers = mProviders;
    for (auto& provider : providers) {
        ALOGV("%s: Notifying %s for new state 0x%" PRIx64,
        ALOGV("%s: Notifying %s for new state 0x%" PRIx64,
                __FUNCTION__, provider->mProviderName.c_str(), newState);
                __FUNCTION__, provider->mProviderName.c_str(), newState);
        // b/199240726 Camera providers can for example try to add/remove
        // b/199240726 Camera providers can for example try to add/remove