diff --git a/plugins/ext/include/standby_messsage.h b/plugins/ext/include/standby_messsage.h index e921a72d9565fcc30a06983ce9746bb051b5c233..c5f7f762a0a44b0f7602f54a816548809726caf7 100644 --- a/plugins/ext/include/standby_messsage.h +++ b/plugins/ext/include/standby_messsage.h @@ -54,6 +54,7 @@ struct StandbyMessageType { GATT_CONNECT_STATE, BROKER_GATT_CONNECT, THERMAL_SCENARIO_REPORT, + CONTINUOUS_TASK_CHANGE, }; }; diff --git a/services/core/include/standby_service_impl.h b/services/core/include/standby_service_impl.h index ca154b497ff8c713f852b650313225f88e64d0a2..458464f58d84412f60f277c69b5060c480741f7f 100644 --- a/services/core/include/standby_service_impl.h +++ b/services/core/include/standby_service_impl.h @@ -215,6 +215,7 @@ private: void HandleActionChanged([[maybe_unused]]uint32_t resType, const std::string &module, uint32_t action); void DumpOnActionChanged(const std::vector &argsInStr, std::string &result); + void HandleContinuousTaskChanged(const int64_t value, const std::string &sceneInfo); private: std::atomic isServiceReady_ {false}; diff --git a/services/core/src/standby_service_impl.cpp b/services/core/src/standby_service_impl.cpp index 102473c8abfee0c21db66a214b0e31407b6c678c..f2757a8406adc6e89b8e4ab6dd1b43871e4ff935 100644 --- a/services/core/src/standby_service_impl.cpp +++ b/services/core/src/standby_service_impl.cpp @@ -1433,6 +1433,36 @@ void StandbyServiceImpl::HandleThermalScenarioReport(const int64_t value, const DispatchEvent(standbyMessage); } +void StandbyServiceImpl::HandleContinuousTaskChanged(const int64_t value, const std::string &sceneInfo) +{ + nlohmann::json payload = nlohmann::json::parse(sceneInfo, nullptr, false); + if (payload.is_discarded()) { + STANDBYSERVICE_LOGE("parse json failed"); + return; + } + if (!payload.contains("pid") || !payload.contains("uid")) { + STANDBYSERVICE_LOGE("param does not exist"); + return; + } + if (!payload.at("pid").is_string() || !payload.at("uid").is_string()) { + STANDBYSERVICE_LOGE("param is invalid"); + return; + } + pid_t pid = atoi(payload.at("pid").get().c_str()); + int32_t uid = atoi(payload.at("uid").get().c_str()); + appMgrClient_ = std::make_unique(); + if (appMgrClient_ == nullptr) { + STANDBYSERVICE_LOGE("failed get appmgr client"); + } + std::string bundleName; + appMgrClient_->GetBundleNameByPid(pid, bundleName, uid); + StandbyMessage standbyMessage {StandbyMessageType::CONTINUOUS_TASK_CHANGE}; + standbyMessage.want_ = AAFwk::Want {}; + standbyMessage.want_->SetParam("bundleName", bundleName); + standbyMessage.want_->SetParam("value", static_cast(value)); + DispatchEvent(standbyMessage); +} + ErrCode StandbyServiceImpl::HandleCommonEvent(const uint32_t resType, const int64_t value, const std::string &sceneInfo) { STANDBYSERVICE_LOGD("HandleCommonEvent resType = %{public}u, value = %{public}lld, sceneInfo = %{public}s", @@ -1479,6 +1509,9 @@ ErrCode StandbyServiceImpl::HandleCommonEvent(const uint32_t resType, const int6 case ResourceSchedule::ResType::RES_TYPE_THERMAL_SCENARIO_REPORT: HandleThermalScenarioReport(value, sceneInfo); break; + case ResourceSchedule::ResType::RES_TYPE_CONTINUOUS_TASK: + HandleContinuousTaskChanged(value, sceneInfo); + break; default: AppEventHandler(resType, value, sceneInfo); break;