diff --git a/bundle.json b/bundle.json index bd19c6760b0a261d1ba7a5eba249c3e2a62991ea..10d428cf5d7fb0f3ae56e184a9d2c738916add5c 100644 --- a/bundle.json +++ b/bundle.json @@ -17,6 +17,7 @@ ], "features": [ "update_service_dupdate_config_path", + "update_service_enable_run_on_demand_qos", "update_service_updater_sa_cfg_path", "update_service_sa_profile_path" ], diff --git a/services/engine/engine_sa.gni b/services/engine/engine_sa.gni index a421035772ed62744e0a65627c43c2a2fef9a2e9..602a0f14091ebdf2189d5d7491947b68a408e75c 100644 --- a/services/engine/engine_sa.gni +++ b/services/engine/engine_sa.gni @@ -27,6 +27,11 @@ declare_args() { if (!defined(global_parts_info.distributeddatamgr_preferences)) { preference_native_preferences_enable = false } + + update_service_enable_run_on_demand_qos = true + if (!defined(global_parts_info.update_service_enable_run_on_demand_qos)) { + update_service_enable_run_on_demand_qos = false + } } sa_sources = [ @@ -188,6 +193,9 @@ if (communication_netmanager_base_enable) { if (preference_native_preferences_enable) { sa_defines += [ "NATIVE_PREFERENCES_ENABLE" ] } +if (update_service_enable_run_on_demand_qos) { + sa_defines += [ "UPDATE_SERVICE_ENABLE_RUN_ON_DEMAND_QOS" ] +} sa_defines += sqlite_defines sa_cflags = [ diff --git a/services/engine/include/update_service.h b/services/engine/include/update_service.h index a123318f0677f1f1381dd6e6aaa6f28fb2d8bed6..85e18c950d6a62279496615bd005fc4d91f7450f 100644 --- a/services/engine/include/update_service.h +++ b/services/engine/include/update_service.h @@ -97,6 +97,11 @@ public: sptr GetUpgradeCallback(const UpgradeInfo &info); +#ifdef UPDATE_SERVICE_ENABLE_RUN_ON_DEMAND_QOS +private: + void SetThreadPrio(int priority); +#endif + #ifndef UPDATER_UT protected: #endif diff --git a/services/engine/src/update_service.cpp b/services/engine/src/update_service.cpp index 7b2dd0ee73c3709fc6475b3085524a54287b844c..53d8cddca7aff55c16d6725770a111fb4d8dbbc8 100644 --- a/services/engine/src/update_service.cpp +++ b/services/engine/src/update_service.cpp @@ -36,6 +36,10 @@ #include "update_service_module.h" #include "module_manager.h" +#ifdef UPDATE_SERVICE_ENABLE_RUN_ON_DEMAND_QOS +#include +#include +#endif namespace OHOS { namespace UpdateEngine { @@ -43,6 +47,11 @@ REGISTER_SYSTEM_ABILITY_BY_ID(UpdateService, UPDATE_DISTRIBUTED_SERVICE_ID, true OHOS::sptr UpdateService::updateService_ { nullptr }; +#ifdef UPDATE_SERVICE_ENABLE_RUN_ON_DEMAND_QOS +constexpr int OPEN_SO_PRIO = -20; +constexpr int NORMAL_PRIO = 0; +#endif + void UpdateService::ClientDeathRecipient::OnRemoteDied(const wptr &remote) { ENGINE_LOGI("client DeathRecipient OnRemoteDied: %{public}s", upgradeInfo_.ToString().c_str()); @@ -425,6 +434,17 @@ int UpdateService::Dump(int fd, const std::vector &args) } } +#ifdef UPDATE_SERVICE_ENABLE_RUN_ON_DEMAND_QOS +void UpdateService::SetThreadPrio(int priority) +{ + int tid = syscall(SYS_gettid); + ENGINE_LOGI("set tid: %{public}d priority:%{public}d.", tid, priority); + if (setpriority(PRIO_PROCESS, tid, priority) != 0) { + ENGINE_LOGE("set tid: %{public}d priority:%{public}d failed.", tid, priority); + } +} +#endif + void UpdateService::OnStart(const SystemAbilityOnDemandReason &startReason) { ENGINE_LOGI("UpdaterService oh OnStart, startReason name %{public}s, id %{public}d, value %{public}s", @@ -437,7 +457,13 @@ void UpdateService::OnStart(const SystemAbilityOnDemandReason &startReason) DelayedSingleton::GetInstance()->LoadConfigInfo(); // 启动读取配置信息 std::string libPath = DelayedSingleton::GetInstance()->GetModuleLibPath(); ENGINE_LOGI("GetModuleLibPath %{public}s ", libPath.c_str()); +#ifdef UPDATE_SERVICE_ENABLE_RUN_ON_DEMAND_QOS + SetThreadPrio(OPEN_SO_PRIO); +#endif ModuleManager::GetInstance().LoadModule(libPath); +#ifdef UPDATE_SERVICE_ENABLE_RUN_ON_DEMAND_QOS + SetThreadPrio(NORMAL_PRIO); +#endif ENGINE_LOGI("RegisterOhFunc HandleOhRemoteRequest"); RegisterOhFunc();