diff --git a/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp b/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp index 0f8b84879eb69dc9e045286d0a6078f6b5711528..1161f5f168ce0dccb49c4e8b124b99265ed96186 100644 --- a/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/sensor/hdi_connection/adapter/src/hdi_connection.cpp @@ -297,15 +297,19 @@ void HdiConnection::reconnect() std::lock_guard sensorInfoLock(sensorBasicInfoMutex_); for (const auto &sensorInfo: sensorBasicInfoMap_) { int32_t sensorTypeId = sensorInfo.first; - ret = SetBatch(sensorTypeId, sensorInfo.second.GetSamplingPeriodNs(), - sensorInfo.second.GetMaxReportDelayNs()); - if (ret != 0 || sensorInfo.second.GetSensorState() != true) { - SEN_HILOGE("sensorTypeId: %{public}d set batch fail or not need enable sensor", sensorTypeId); + SensorBasicInfo info = sensorInfo.second; + if (info.GetSensorState() != true) { + SEN_HILOGE("sensorTypeId: %{public}d don't need enable sensor", sensorTypeId); continue; } - ret = EnableSensor(sensorTypeId); + ret = sensorInterface_->SetBatch(sensorTypeId, info.GetSamplingPeriodNs(), info.GetMaxReportDelayNs()); if (ret != 0) { - SEN_HILOGE("enable sensor fail, sensorTypeId: %{public}d", sensorTypeId); + SEN_HILOGE("sensorTypeId: %{public}d set batch fail, error: %{public}d", sensorTypeId, ret); + continue; + } + ret = sensorInterface_->Enable(sensorTypeId); + if (ret != 0) { + SEN_HILOGE("enable sensor fail, sensorTypeId: %{public}d, error: %{public}d", sensorTypeId, ret); } } }