diff --git a/services/include/sensor_power_policy.h b/services/include/sensor_power_policy.h index c8be31665d9a5eb73cb4ca468ff4b47b74402e30..b1dba0d6ef1a462bcd05d57c61ce4e2e2801826c 100644 --- a/services/include/sensor_power_policy.h +++ b/services/include/sensor_power_policy.h @@ -32,6 +32,7 @@ public: ErrCode ResetSensors(); std::vector GetActiveInfoList(int32_t pid); void ReportActiveInfo(const ActiveInfo &activeInfo, const std::vector &sessionList); + void DeleteDeathPidSensorInfo(int32_t pid); private: bool CheckFreezingSensor(int32_t sensorId); diff --git a/services/src/sensor_power_policy.cpp b/services/src/sensor_power_policy.cpp index f4adf2a9bd6366b75e919140ff51ca0ded353c1e..e5c817484a6fbdaab421f1a750f1647c7a589ed5 100644 --- a/services/src/sensor_power_policy.cpp +++ b/services/src/sensor_power_policy.cpp @@ -259,5 +259,16 @@ void SensorPowerPolicy::ReportActiveInfo(const ActiveInfo &activeInfo, } } } + +void SensorPowerPolicy::DeleteDeathPidSensorInfo(int32_t pid) +{ + CALL_LOG_ENTER; + std::lock_guard pidSensorInfoLock(pidSensorInfoMutex_); + auto pidSensorInfoIt = pidSensorInfoMap_.find(pid); + if (pidSensorInfoIt != pidSensorInfoMap_.end()) { + SEN_HILOGD("Delete death pid sensor info, pid:%{public}d", pid); + pidSensorInfoMap_.erase(pidSensorInfoIt); + } +} } // namespace Sensors } // namespace OHOS \ No newline at end of file diff --git a/services/src/sensor_service.cpp b/services/src/sensor_service.cpp index 3a2a74429baee700a4dcd88a53a16b1a0df8733c..84f939d2c0fdc44dbaff95f82f83f214737e068a 100644 --- a/services/src/sensor_service.cpp +++ b/services/src/sensor_service.cpp @@ -537,6 +537,7 @@ void SensorService::ProcessDeathObserver(const wptr &object) clientInfo_.DestroySensorChannel(pid); clientInfo_.DestroyClientPid(client); clientInfo_.DestroyCmd(clientInfo_.GetUidByPid(pid)); + POWER_POLICY.DeleteDeathPidSensorInfo(pid); } void SensorService::RegisterClientDeathRecipient(sptr sensorClient, int32_t pid)