diff --git a/frameworks/native/src/sensor_service_client.cpp b/frameworks/native/src/sensor_service_client.cpp index 21243bea7de6f65f83ed0348152f9c9849a563ea..ce8b778d1439decfcfca0907a45e5ddb3ba0cbe2 100644 --- a/frameworks/native/src/sensor_service_client.cpp +++ b/frameworks/native/src/sensor_service_client.cpp @@ -245,6 +245,7 @@ void SensorServiceClient::ReenableSensor() CALL_LOG_ENTER; std::lock_guard mapLock(mapMutex_); for (const auto &it : sensorInfoMap_) { + std::lock_guard clientLock(clientMutex_); if (sensorServer_ != nullptr) { sensorServer_->EnableSensor(it.first, it.second.GetSamplingPeriodNs(), it.second.GetMaxReportDelayNs()); } @@ -286,6 +287,7 @@ void SensorServiceClient::ProcessDeathObserver(const wptr &object SENSOR_AGENT_IMPL->SetIsChannelCreated(false); return; } + std::lock_guard clientLock(clientMutex_); if (sensorServer_ != nullptr && sensorClientStub_ != nullptr) { auto remoteObject = sensorClientStub_->AsObject(); if (remoteObject != nullptr) {