diff --git a/services/appmgr/include/app_spawn_client.h b/services/appmgr/include/app_spawn_client.h index a41f8f75f4f133e41c96e2fd4d646f15a44e396c..9a27064905cfa069d6e7482638824189e0803527 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 f2b989ba7f68f5b20ffd5a35fa4c730b012f0c5c..f5736472c9341960f257893900c69e0b9c19570f 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 0705486005e8c067882f56eb5ce1d3ddbe83504e..3ab4b1b3265220f92922f6387f2b75927c5fdbba 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 637b1b048e7c87928ea2ad63f3c9cbd8efa182b5..6a6e691ebaf3487e8647a44d68b1ed3452df0f31 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);