From 1731cea5d7d496f6b28378539c442fa47ea88fde Mon Sep 17 00:00:00 2001 From: hhh2 Date: Thu, 24 Nov 2022 11:29:18 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!288=20:?= =?UTF-8?q?=20fix=EF=BC=9A=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E5=A4=9A=E7=BA=BF=E7=A8=8B=E9=97=AE=E9=A2=98'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/native/sensor/src/sensor_agent_proxy.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/frameworks/native/sensor/src/sensor_agent_proxy.cpp b/frameworks/native/sensor/src/sensor_agent_proxy.cpp index 50cd8821..23cfa067 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); } } -- Gitee