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

Commit 960022da authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Add synchronization when EventFlagQueue is created in sensors HAL init

Bug: 380191409
Test: atest VtsAidlHalSensorsTargetTest:Sensors/SensorsAidlTest#CleanupConnectionsOnInitialize/0_android_hardware_sensors_ISensors_default --rerun-until-failure=200 pass

Change-Id: Ia22cf0278acb7e1b7cc62a75926ffc5aa47610eb
parent 8dd21e5d
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -85,9 +85,6 @@ ScopedAStatus Sensors::initialize(
    ALOGI("Sensors initializing");
    ScopedAStatus result = ScopedAStatus::ok();

    mEventQueue = std::make_unique<AidlMessageQueue<Event, SynchronizedReadWrite>>(
            in_eventQueueDescriptor, true /* resetPointers */);

    // Ensure that all sensors are disabled.
    for (auto sensor : mSensors) {
        sensor.second->activate(false);
@@ -106,6 +103,9 @@ ScopedAStatus Sensors::initialize(
        // Hold the lock to ensure that re-creation of event flag is atomic
        std::lock_guard<std::mutex> lock(mWriteLock);

        mEventQueue = std::make_unique<AidlMessageQueue<Event, SynchronizedReadWrite>>(
                in_eventQueueDescriptor, true /* resetPointers */);

        // Ensure that any existing EventFlag is properly deleted
        deleteEventFlagLocked();