Loading services/sensorservice/SensorService.cpp +11 −13 Original line number Original line Diff line number Diff line Loading @@ -1626,19 +1626,17 @@ void SensorService::onProximityActiveLocked(bool isActive) { } } void SensorService::notifyProximityStateLocked( void SensorService::notifyProximityStateLocked( const std::vector<sp<ProximityActiveListener>>& listnrs) { const std::vector<sp<ProximityActiveListener>>& listeners) { std::async( const bool isActive = mProximityActiveCount > 0; std::launch::async, const uint64_t mySeq = ++curProxCallbackSeq; [](uint64_t mySeq, bool isActive, std::vector<sp<ProximityActiveListener>> listeners) { std::thread t([isActive, mySeq, listenersCopy = listeners]() { while (completedCallbackSeq.load() != mySeq - 1) while (completedCallbackSeq.load() != mySeq - 1) std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(1ms); for (auto& listener : listeners) for (auto& listener : listenersCopy) listener->onProximityActive(isActive); listener->onProximityActive(isActive); completedCallbackSeq++; completedCallbackSeq++; }, }); ++curProxCallbackSeq, mProximityActiveCount > 0, t.detach(); listnrs /* (this is meant to be a copy) */ ); } } status_t SensorService::addProximityActiveListener(const sp<ProximityActiveListener>& callback) { status_t SensorService::addProximityActiveListener(const sp<ProximityActiveListener>& callback) { Loading Loading
services/sensorservice/SensorService.cpp +11 −13 Original line number Original line Diff line number Diff line Loading @@ -1626,19 +1626,17 @@ void SensorService::onProximityActiveLocked(bool isActive) { } } void SensorService::notifyProximityStateLocked( void SensorService::notifyProximityStateLocked( const std::vector<sp<ProximityActiveListener>>& listnrs) { const std::vector<sp<ProximityActiveListener>>& listeners) { std::async( const bool isActive = mProximityActiveCount > 0; std::launch::async, const uint64_t mySeq = ++curProxCallbackSeq; [](uint64_t mySeq, bool isActive, std::vector<sp<ProximityActiveListener>> listeners) { std::thread t([isActive, mySeq, listenersCopy = listeners]() { while (completedCallbackSeq.load() != mySeq - 1) while (completedCallbackSeq.load() != mySeq - 1) std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(1ms); for (auto& listener : listeners) for (auto& listener : listenersCopy) listener->onProximityActive(isActive); listener->onProximityActive(isActive); completedCallbackSeq++; completedCallbackSeq++; }, }); ++curProxCallbackSeq, mProximityActiveCount > 0, t.detach(); listnrs /* (this is meant to be a copy) */ ); } } status_t SensorService::addProximityActiveListener(const sp<ProximityActiveListener>& callback) { status_t SensorService::addProximityActiveListener(const sp<ProximityActiveListener>& callback) { Loading