diff --git a/frameworks/native/sensor/src/sensor_agent_proxy.cpp b/frameworks/native/sensor/src/sensor_agent_proxy.cpp index 50cd8821dca77fc7c77dfb8c5c66b1a6499212ac..23cfa0672cdf52dca6745ffc92660250444df5db 100644 --- a/frameworks/native/sensor/src/sensor_agent_proxy.cpp +++ b/frameworks/native/sensor/src/sensor_agent_proxy.cpp @@ -73,15 +73,12 @@ void SensorAgentProxy::HandleSensorData(SensorEvent *events, int32_t num, void * SensorEvent eventStream; for (int32_t i = 0; i < num; ++i) { eventStream = events[i]; - std::lock_guard subscribeLock(subscribeMutex_); - auto iter = g_subscribeMap.find(eventStream.sensorTypeId); - if (iter == g_subscribeMap.end()) { - SEN_HILOGE("sensor:%{public}d is not subscribed", iter->first); + if (g_subscribeMap.find(eventStream.sensorTypeId) == g_subscribeMap.end()) { + SEN_HILOGE("sensorTypeId not in g_subscribeMap"); return; } - const SensorUser *user = iter->second; - CHKPV(user); - user->callback(&eventStream); + CHKPV(g_subscribeMap[eventStream.sensorTypeId]); + g_subscribeMap[eventStream.sensorTypeId]->callback(&eventStream); } }