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

Commit 1a586fdb authored by Jyoti Bhayana's avatar Jyoti Bhayana
Browse files

Fixing native crash in cameraserver

Flag: com.android.internal.camera.flags.camera_multi_client
Bug: 379183541
Test: Verify reported crash does not occur.
Change-Id: I04842279bb2172122dde9a59b4fd793d8c5a6c6a
parent 632874b4
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -3811,15 +3811,32 @@ std::vector<sp<CameraService::BasicClient>> CameraService::removeClientsLocked(
        const std::string& cameraId) {
    // Remove from active clients list
    std::vector<sp<CameraService::BasicClient>> clients;
    if (flags::camera_multi_client()) {
        std::vector<CameraService::DescriptorPtr> clientDescriptors;
        clientDescriptors =  mActiveClientManager.removeAll(cameraId);
        for (const auto& clientDescriptorPtr : clientDescriptors) {
            if (clientDescriptorPtr != nullptr) {
                sp<BasicClient> client = clientDescriptorPtr->getValue();
                if (client.get() != nullptr) {
                    cacheClientTagDumpIfNeeded(clientDescriptorPtr->getKey(), client.get());
                    clients.push_back(client);
                }
            }
        }
    } else {
        auto clientDescriptorPtr = mActiveClientManager.remove(cameraId);
        if (clientDescriptorPtr == nullptr) {
            ALOGW("%s: Could not evict client, no client for camera ID %s", __FUNCTION__,
                    cameraId.c_str());
            return clients;
        }

        sp<BasicClient> client = clientDescriptorPtr->getValue();
        if (client.get() != nullptr) {
            cacheClientTagDumpIfNeeded(clientDescriptorPtr->getKey(), client.get());
            clients.push_back(client);
        }
    }
    return clients;
}

+3 −0
Original line number Diff line number Diff line
@@ -631,6 +631,9 @@ public:
        CameraClientManager();
        virtual ~CameraClientManager();

        // Bring all remove() functions into scope
        using ClientManager::remove;

        virtual void remove(const DescriptorPtr& value) override;

        /**
+1 −1
Original line number Diff line number Diff line
@@ -746,9 +746,9 @@ std::vector<std::shared_ptr<ClientDescriptor<KEY, VALUE>>>
        for (auto it = mClients.begin(); it != mClients.end();)
        {
            if ((*it)->getKey() == key) {
                it = mClients.erase(it);
                if (mListener != nullptr) mListener->onClientRemoved(**it);
                clients.push_back(*it);
                it = mClients.erase(it);
            } else {
                ++it;
            }