From b2e0072cafb7e100c8b516695951a5d6cb293868 Mon Sep 17 00:00:00 2001 From: luyifan <842825214@qq.com> Date: Sun, 27 Apr 2025 15:43:09 +0800 Subject: [PATCH] Pass apiTargetVersion to xpm. Signed-off-by: luyifan<842825214@qq.com> --- services/appmgr/include/app_spawn_client.h | 1 + services/appmgr/src/app_mgr_service_inner.cpp | 1 + services/appmgr/src/app_spawn_client.cpp | 7 +++++++ .../app_spawn_client_second_test.cpp | 1 + 4 files changed, 10 insertions(+) diff --git a/services/appmgr/include/app_spawn_client.h b/services/appmgr/include/app_spawn_client.h index a41f8f75f4f..9a27064905c 100644 --- a/services/appmgr/include/app_spawn_client.h +++ b/services/appmgr/include/app_spawn_client.h @@ -71,6 +71,7 @@ struct AppSpawnStartMsg { uint32_t flags; uint32_t hapFlags = 0; // whether is pre installed hap uint32_t mountPermissionFlags; + uint32_t apiTargetVersion = 0; uint64_t accessTokenIdEx; std::vector gids; std::string procName; diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index f2b989ba7f6..f5736472c93 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -3668,6 +3668,7 @@ void AppMgrServiceInner::SetAppInfo(const BundleInfo &bundleInfo, AppSpawnStartM startMsg.apl = bundleInfo.applicationInfo.appPrivilegeLevel; startMsg.ownerId = bundleInfo.signatureInfo.appIdentifier; startMsg.provisionType = bundleInfo.applicationInfo.appProvisionType; + startMsg.apiTargetVersion = bundleInfo.applicationInfo.apiTargetVersion % API_VERSION_MOD; #ifdef SUPPORT_CHILD_PROCESS if (bundleInfo.applicationInfo.apiTargetVersion % API_VERSION_MOD < API15) { startMsg.maxChildProcess = 0; diff --git a/services/appmgr/src/app_spawn_client.cpp b/services/appmgr/src/app_spawn_client.cpp index 0705486005e..3ab4b1b3265 100644 --- a/services/appmgr/src/app_spawn_client.cpp +++ b/services/appmgr/src/app_spawn_client.cpp @@ -380,6 +380,13 @@ int32_t AppSpawnClient::AppspawnSetExtMsg(const AppSpawnStartMsg &startMsg, AppS } } + std::string apiTargetVersionStr = std::to_string(startMsg.apiTargetVersion); + ret = AppSpawnReqMsgAddStringInfo(reqHandle, MSG_EXT_NAME_API_TARGET_VERSION, apiTargetVersionStr.c_str()); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "Send apiTargetVersion fail, ret: %{public}d", ret); + return ret; + } + return AppspawnSetExtMsgMore(startMsg, reqHandle); } diff --git a/test/unittest/app_spawn_client_second_test/app_spawn_client_second_test.cpp b/test/unittest/app_spawn_client_second_test/app_spawn_client_second_test.cpp index 637b1b048e7..6a6e691ebaf 100644 --- a/test/unittest/app_spawn_client_second_test/app_spawn_client_second_test.cpp +++ b/test/unittest/app_spawn_client_second_test/app_spawn_client_second_test.cpp @@ -358,6 +358,7 @@ HWTEST_F(AppSpawnClientSecondTest, AppspawnSetExtMsg_002, TestSize.Level0) startMsg.atomicAccount = "testAtomicAccount"; startMsg.code = MSG_APP_SPAWN; startMsg.procName = "testProcName"; + startMsg.apiTargetVersion = 1; AppSpawnReqMsgHandle reqHandle = nullptr; int ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); EXPECT_EQ(ret, ERR_OK); -- Gitee