From d9a0f11f067bb5dab04175b1e02b95ef1fbf9125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Wed, 12 Mar 2025 06:37:00 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E4=BC=98=E5=85=88?= =?UTF-8?q?=E7=BA=A7=E6=8F=90=E5=8D=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- bundle.json | 1 + services/engine/engine_sa.gni | 8 ++++++++ services/engine/include/update_service.h | 5 +++++ services/engine/src/update_service.cpp | 23 +++++++++++++++++++++++ 4 files changed, 37 insertions(+) diff --git a/bundle.json b/bundle.json index bd19c676..10d428cf 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 a4210357..19a2b63e 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_DEMMAND_QOS" ] +} sa_defines += sqlite_defines sa_cflags = [ diff --git a/services/engine/include/update_service.h b/services/engine/include/update_service.h index a123318f..85e18c95 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 7b2dd0ee..cd55b923 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_LOGI("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,6 +457,9 @@ 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); ENGINE_LOGI("RegisterOhFunc HandleOhRemoteRequest"); -- Gitee From a366c48a156e95e7d5fe2a741e1e0206faae18a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Wed, 12 Mar 2025 11:00:55 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- services/engine/src/update_service.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/engine/src/update_service.cpp b/services/engine/src/update_service.cpp index cd55b923..3d66f086 100644 --- a/services/engine/src/update_service.cpp +++ b/services/engine/src/update_service.cpp @@ -461,6 +461,9 @@ void UpdateService::OnStart(const SystemAbilityOnDemandReason &startReason) 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(); -- Gitee From 12cd2c82f05c7eb31c514e2cb1916a26e8d51b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 13 Mar 2025 01:21:20 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=BC=E5=86=99?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- services/engine/engine_sa.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/engine/engine_sa.gni b/services/engine/engine_sa.gni index 19a2b63e..602a0f14 100644 --- a/services/engine/engine_sa.gni +++ b/services/engine/engine_sa.gni @@ -194,7 +194,7 @@ 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_DEMMAND_QOS" ] + sa_defines += [ "UPDATE_SERVICE_ENABLE_RUN_ON_DEMAND_QOS" ] } sa_defines += sqlite_defines -- Gitee From f391904b17c19346e507786ec5e146b7bab4f758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 13 Mar 2025 01:25:33 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=BA=A7=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- services/engine/src/update_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/engine/src/update_service.cpp b/services/engine/src/update_service.cpp index 3d66f086..53d8cddc 100644 --- a/services/engine/src/update_service.cpp +++ b/services/engine/src/update_service.cpp @@ -440,7 +440,7 @@ 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_LOGI("set tid: %{public}d priority:%{public}d failed.", tid, priority); + ENGINE_LOGE("set tid: %{public}d priority:%{public}d failed.", tid, priority); } } #endif -- Gitee