From d0be3c81f5fe118a575b290c5724cee4c5e97755 Mon Sep 17 00:00:00 2001 From: h00514358 Date: Thu, 24 Nov 2022 17:43:46 +0800 Subject: [PATCH] update Signed-off-by: h00514358 Change-Id: I047e3879149f9b93a12e38b2f50194880a6de6b1 --- frameworks/native/sensor/src/sensor_agent_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/sensor/src/sensor_agent_proxy.cpp b/frameworks/native/sensor/src/sensor_agent_proxy.cpp index 23cfa067..b9c589fd 100644 --- a/frameworks/native/sensor/src/sensor_agent_proxy.cpp +++ b/frameworks/native/sensor/src/sensor_agent_proxy.cpp @@ -133,7 +133,6 @@ int32_t SensorAgentProxy::ActivateSensor(int32_t sensorId, const SensorUser *use { CHKPR(user, OHOS::Sensors::ERROR); CHKPR(user->callback, OHOS::Sensors::ERROR); - std::lock_guard subscribeLock(subscribeMutex_); if (g_samplingInterval < 0 || g_reportInterval < 0) { SEN_HILOGE("samplingPeriod or g_reportInterval is invalid"); return ERROR; @@ -142,6 +141,7 @@ int32_t SensorAgentProxy::ActivateSensor(int32_t sensorId, const SensorUser *use SEN_HILOGE("sensorId is invalid, %{public}d", sensorId); return PARAMETER_ERROR; } + std::lock_guard subscribeLock(subscribeMutex_); if ((g_subscribeMap.find(sensorId) == g_subscribeMap.end()) || (g_subscribeMap[sensorId] != user)) { SEN_HILOGE("subscribe sensorId first"); return ERROR; -- Gitee