From cdaf8bbffd0abd08ca825f0858ff16992f827ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 24 Apr 2025 05:25:45 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- services/engine/src/update_service.cpp | 31 +++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/services/engine/src/update_service.cpp b/services/engine/src/update_service.cpp index 07cb402e..66c94996 100644 --- a/services/engine/src/update_service.cpp +++ b/services/engine/src/update_service.cpp @@ -553,25 +553,26 @@ int32_t UpdateService::CallbackExit(uint32_t code, int32_t result) int32_t UpdateService::CallbackParcel(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - int32_t ret; + // 未加载接口扩展能力,通过idl框架分发 if (!ModuleManager::GetInstance().IsModuleLoaded()) { ENGINE_LOGI("IsModuleLoaded false"); return INT_CALL_SUCCESS; - } else { - ENGINE_LOGI("IsModuleLoaded true, code: %{public}u", code); - if (!ModuleManager::GetInstance().IsMapFuncExist(code)) { - ENGINE_LOGE("UpdateService OnRemoteRequest code %{public}u not found", code); - ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option); - ENGINE_LOGE("UpdateService OnRemoteRequest ret %{public}d", ret); - return INT_CALL_FAIL; - } - ret = ModuleManager::GetInstance().HandleFunc(code, data, reply, option); - ENGINE_LOGE("CallbackParcel deal result code %{public}d", ret); - if (ret != INT_CALL_SUCCESS) { - return ret > CALL_RESULT_OFFSET ? (ret - CALL_RESULT_OFFSET) : ret; - } - return INT_CALL_FAIL; } + + // 加载了接口扩展能力, 但是未拓展当前接口的调用,还是通过idl框架分发 + ENGINE_LOGI("IsModuleLoaded true, code: %{public}u", code); + if (!ModuleManager::GetInstance().IsMapFuncExist(code)) { + ENGINE_LOGE("UpdateService OnRemoteRequest code %{public}u not found", code); + return INT_CALL_SUCCESS; + } + + // 加载了接口扩展能力, 并且当前调用接口为拓展当前接口,则通过Hook框架分发 + int32_t ret = ModuleManager::GetInstance().HandleFunc(code, data, reply, option); + ENGINE_LOGE("CallbackParcel deal result code %{public}d", ret); + if (ret != INT_CALL_SUCCESS) { + return ret > CALL_RESULT_OFFSET ? (ret - CALL_RESULT_OFFSET) : ret; + } + return INT_CALL_FAIL; } bool UpdateService::IsCallerValid() -- Gitee From b51c1998ed1d710dc6729ff40b4d2e27fe856b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 24 Apr 2025 08:37:55 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=89=B4=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- services/engine/src/update_service.cpp | 28 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/services/engine/src/update_service.cpp b/services/engine/src/update_service.cpp index 66c94996..c5546c42 100644 --- a/services/engine/src/update_service.cpp +++ b/services/engine/src/update_service.cpp @@ -448,9 +448,9 @@ int UpdateService::Dump(int fd, const std::vector &args) dprintf(fd, "input error, no parameters required\n"); } return 0; - } else { - return ModuleManager::GetInstance().HandleDumpFunc("Dump", fd, args); } + + return ModuleManager::GetInstance().HandleDumpFunc("Dump", fd, args); } #ifdef UPDATE_SERVICE_ENABLE_RUN_ON_DEMAND_QOS @@ -518,13 +518,20 @@ void UpdateService::OnStop(const SystemAbilityOnDemandReason &stopReason) int32_t UpdateService::CallbackEnter(uint32_t code) { - ENGINE_LOGI("CallbackEnter, code: %{public}u", code); + // 未加载接口扩展能力,执行UpdateService鉴权动作 if (!ModuleManager::GetInstance().IsModuleLoaded()) { + ENGINE_LOGI("CallbackEnter, extend module not loaded, code %{public}u", code); + return PermissionCheck(code); + } + + // 加载了扩展能力,但是未拓展当前调用的接口,还是执行UpdateService鉴权动作 + if (!ModuleManager::GetInstance().IsMapFuncExist(code)) { + ENGINE_LOGE("CallbackEnter, code %{public}u not extended", code); return PermissionCheck(code); - } else { - ENGINE_LOGI("IsModuleLoaded true"); - return INT_CALL_SUCCESS; } + + // 加载了接口扩展能力,并且当前调用的接口为拓展接口,则由Hook框架进行接口鉴权 + return INT_CALL_SUCCESS; } int32_t UpdateService::PermissionCheck(uint32_t code) @@ -553,22 +560,21 @@ int32_t UpdateService::CallbackExit(uint32_t code, int32_t result) int32_t UpdateService::CallbackParcel(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - // 未加载接口扩展能力,通过idl框架分发 + // 未加载接口扩展能力,通过IDL框架分发 if (!ModuleManager::GetInstance().IsModuleLoaded()) { - ENGINE_LOGI("IsModuleLoaded false"); + ENGINE_LOGI("CallbackParcel, extend module not loaded, code %{public}u", code); return INT_CALL_SUCCESS; } // 加载了接口扩展能力, 但是未拓展当前接口的调用,还是通过idl框架分发 - ENGINE_LOGI("IsModuleLoaded true, code: %{public}u", code); if (!ModuleManager::GetInstance().IsMapFuncExist(code)) { - ENGINE_LOGE("UpdateService OnRemoteRequest code %{public}u not found", code); + ENGINE_LOGE("CallbackParcel, code %{public}u not extended", code); return INT_CALL_SUCCESS; } // 加载了接口扩展能力, 并且当前调用接口为拓展当前接口,则通过Hook框架分发 int32_t ret = ModuleManager::GetInstance().HandleFunc(code, data, reply, option); - ENGINE_LOGE("CallbackParcel deal result code %{public}d", ret); + ENGINE_LOGE("CallbackParcel, code %{public}u extended, result %{public}d", code, ret); if (ret != INT_CALL_SUCCESS) { return ret > CALL_RESULT_OFFSET ? (ret - CALL_RESULT_OFFSET) : ret; } -- Gitee From c1671600888faff43cb10b98ae97307c9a882f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=8F=8B=E6=9D=BE?= Date: Thu, 24 Apr 2025 09:41:29 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邹友松 --- services/engine/src/update_service.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/engine/src/update_service.cpp b/services/engine/src/update_service.cpp index c5546c42..7fa9eb7d 100644 --- a/services/engine/src/update_service.cpp +++ b/services/engine/src/update_service.cpp @@ -524,7 +524,7 @@ int32_t UpdateService::CallbackEnter(uint32_t code) return PermissionCheck(code); } - // 加载了扩展能力,但是未拓展当前调用的接口,还是执行UpdateService鉴权动作 + // 加载了接口扩展能力, 但是当前调用接口不是拓展接口,还是执行UpdateService鉴权动作 if (!ModuleManager::GetInstance().IsMapFuncExist(code)) { ENGINE_LOGE("CallbackEnter, code %{public}u not extended", code); return PermissionCheck(code); @@ -566,13 +566,13 @@ int32_t UpdateService::CallbackParcel(uint32_t code, MessageParcel &data, Messag return INT_CALL_SUCCESS; } - // 加载了接口扩展能力, 但是未拓展当前接口的调用,还是通过idl框架分发 + // 加载了接口扩展能力, 但是当前调用接口不是拓展接口,还是通过idl框架分发 if (!ModuleManager::GetInstance().IsMapFuncExist(code)) { ENGINE_LOGE("CallbackParcel, code %{public}u not extended", code); return INT_CALL_SUCCESS; } - // 加载了接口扩展能力, 并且当前调用接口为拓展当前接口,则通过Hook框架分发 + // 加载了接口扩展能力, 并且当前调用接口为拓展接口,则通过Hook框架分发 int32_t ret = ModuleManager::GetInstance().HandleFunc(code, data, reply, option); ENGINE_LOGE("CallbackParcel, code %{public}u extended, result %{public}d", code, ret); if (ret != INT_CALL_SUCCESS) { -- Gitee