diff --git a/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp b/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp index cc039caa023a0513fdeff764aaa064b0ba2f91ae..e20a6404dbdaac02c2f05135ddb7d2a87197337d 100644 --- a/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp @@ -147,6 +147,7 @@ int32_t CompatibleConnection::SensorDataCallback(const struct SensorEvents *even } CHKPR(reportDataCallback_, ERR_NO_INIT); CHKPR(reportDataCb_, ERR_NO_INIT); + std::unique_lock lk(ISensorHdiConnection::dataMutex_); (void)(reportDataCallback_->*reportDataCb_)(&sensorEvent, reportDataCallback_); ISensorHdiConnection::dataCondition_.notify_one(); return ERR_OK; diff --git a/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp b/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp index 531b49cbca73bdbe36d47ab77bda253ceeda2b13..290e7065703efb427095e2fc8fb236c6cf700e86 100644 --- a/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp +++ b/services/sensor/hdi_connection/adapter/src/sensor_event_callback.cpp @@ -47,6 +47,7 @@ int32_t SensorEventCallback::OnDataEvent(const HdfSensorEvents& event) for (int32_t i = 0; i < static_cast(dataSize); i++) { sensorEvent.data[i] = event.data[i]; } + std::unique_lock lk(ISensorHdiConnection::dataMutex_); (void)(reportDataCallback_->*(reportDataCb_))(&sensorEvent, reportDataCallback_); ISensorHdiConnection::dataCondition_.notify_one(); return ERR_OK;