AMS传递给appspawn孵化器增加bundleIndex字段

Signed-off-by: Zhang Qilong <zql2016@mail.ustc.edu.cn>
This commit is contained in:
Zhang Qilong 2022-06-28 15:43:05 +08:00 committed by William Dean
parent 0f28efd18f
commit a7efdcddfa
6 changed files with 22 additions and 13 deletions

View File

@ -570,7 +570,8 @@ private:
* @return
*/
void StartProcess(const std::string &appName, const std::string &processName, uint32_t startFlags,
const std::shared_ptr<AppRunningRecord> &appRecord, const int uid, const std::string &bundleName);
const std::shared_ptr<AppRunningRecord> &appRecord, const int uid,
const std::string &bundleName, const int32_t bundleIndex);
/**
* PushAppFront, Adjust the latest application record to the top level.

View File

@ -38,6 +38,7 @@ struct AppSpawnStartMsg {
int32_t pid;
int32_t code = 0; // 0: DEFAULT; 1: GET_RENDER_TERMINATION_STATUS
uint32_t flags;
int32_t bundleIndex; // when dlp launch another app used, default is 0
};
using AppSpawnMsg = AppSpawn::ClientSocket::AppProperty;

View File

@ -70,6 +70,7 @@ const std::string FUNC_NAME = "main";
const std::string SO_PATH = "system/lib64/libmapleappkit.z.so";
const std::string RENDER_PARAM = "invalidparam";
const std::string COLD_START = "coldStart";
const std::string DLP_PARAMS_INDEX = "ohos.dlp.params.index";
const int32_t SIGNAL_KILL = 9;
constexpr int32_t USER_SCALE = 200000;
#define ENUM_TO_STRING(s) #s
@ -162,8 +163,9 @@ void AppMgrServiceInner::LoadAbility(const sptr<IRemoteObject> &token, const spt
return;
}
uint32_t startFlags = (want == nullptr) ? 0 : BuildStartFlags(*want, *abilityInfo);
int32_t bundleIndex = (want == nullptr) ? 0 : want->GetIntParam(DLP_PARAMS_INDEX, 0);
StartProcess(abilityInfo->applicationName, processName, startFlags, appRecord,
appInfo->uid, appInfo->bundleName);
appInfo->uid, appInfo->bundleName, bundleIndex);
} else {
StartAbility(token, preToken, abilityInfo, appRecord, hapModuleInfo, want);
}
@ -1190,7 +1192,8 @@ void AppMgrServiceInner::StateChangedNotifyObserver(const AbilityStateData abili
}
void AppMgrServiceInner::StartProcess(const std::string &appName, const std::string &processName, uint32_t startFlags,
const std::shared_ptr<AppRunningRecord> &appRecord, const int uid, const std::string &bundleName)
const std::shared_ptr<AppRunningRecord> &appRecord, const int uid,
const std::string &bundleName, const int32_t bundleIndex)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
if (!remoteClientManager_->GetSpawnClient() || !appRecord) {
@ -1230,6 +1233,7 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str
startMsg.bundleName = bundleName;
startMsg.renderParam = RENDER_PARAM;
startMsg.flags = startFlags;
startMsg.bundleIndex = bundleIndex;
HILOG_DEBUG("Start process, apl is %{public}s, bundleName is %{public}s, startFlags is %{public}d.",
startMsg.apl.c_str(), bundleName.c_str(), startFlags);
@ -1594,7 +1598,7 @@ void AppMgrServiceInner::StartEmptyResidentProcess(
return;
}
StartProcess(appInfo->name, processName, 0, appRecord, appInfo->uid, appInfo->bundleName);
StartProcess(appInfo->name, processName, 0, appRecord, appInfo->uid, appInfo->bundleName, 0);
// If it is empty, the startup failed
if (!appRecord) {
@ -1843,7 +1847,8 @@ int AppMgrServiceInner::StartEmptyProcess(const AAFwk::Want &want, const sptr<IR
testRecord->userId = userId;
appRecord->SetUserTestInfo(testRecord);
StartProcess(appInfo->name, processName, 0, appRecord, appInfo->uid, appInfo->bundleName);
int32_t bundleIndex = want.GetIntParam(DLP_PARAMS_INDEX, 0);
StartProcess(appInfo->name, processName, 0, appRecord, appInfo->uid, appInfo->bundleName, bundleIndex);
// If it is empty, the startup failed
if (!appRecord) {
@ -1961,7 +1966,8 @@ void AppMgrServiceInner::StartSpecifiedAbility(const AAFwk::Want &want, const Ap
appRecord->SendEventForSpecifiedAbility(AMSEventHandler::START_PROCESS_SPECIFIED_ABILITY_TIMEOUT_MSG,
AMSEventHandler::START_PROCESS_SPECIFIED_ABILITY_TIMEOUT);
uint32_t startFlags = BuildStartFlags(want, abilityInfo);
StartProcess(appInfo->name, processName, startFlags, appRecord, appInfo->uid, appInfo->bundleName);
int32_t bundleIndex = want.GetIntParam(DLP_PARAMS_INDEX, 0);
StartProcess(appInfo->name, processName, startFlags, appRecord, appInfo->uid, appInfo->bundleName, bundleIndex);
appRecord->SetSpecifiedAbilityFlagAndWant(true, want, hapModuleInfo.moduleName);
appRecord->AddModules(appInfo, hapModules);
@ -2473,7 +2479,7 @@ uint32_t AppMgrServiceInner::BuildStartFlags(const AAFwk::Want &want, const Abil
startFlags = startFlags | (AppSpawn::ClientSocket::APPSPAWN_COLD_BOOT << StartFlags::COLD_START);
}
if (want.GetIntParam("ohos.dlp.params.index", 0) != 0) {
if (want.GetIntParam(DLP_PARAMS_INDEX, 0) != 0) {
startFlags = startFlags | (AppSpawn::ClientSocket::APPSPAWN_COLD_BOOT << StartFlags::DLP_MANAGER);
}

View File

@ -47,6 +47,7 @@ bool AppSpawnMsgWrapper::AssembleMsg(const AppSpawnStartMsg &startMsg)
msg_->uid = startMsg.uid;
msg_->gid = startMsg.gid;
msg_->gidCount = startMsg.gids.size();
msg_->bundleIndex = startMsg.bundleIndex;
for (uint32_t i = 0; i < msg_->gidCount; ++i) {
msg_->gidTable[i] = startMsg.gids[i];
}

View File

@ -146,7 +146,7 @@ TestApplicationPreRecord AmsWorkFlowTest::CreateTestApplicationRecord(const std:
appInfo->name,
false, appRecord,
abilityInfo->applicationInfo.uid,
abilityInfo->applicationInfo.bundleName);
abilityInfo->applicationInfo.bundleName, 0);
} else {
appRecord->AddModule(appInfo, abilityInfo, token, hapModuleInfo, nullptr);
}

View File

@ -1142,7 +1142,7 @@ HWTEST_F(AmsServiceLoadAbilityProcessTest, StartProcess001, TestSize.Level1)
GetTestAppName(),
false, record,
abilityInfo->applicationInfo.uid,
abilityInfo->applicationInfo.bundleName);
abilityInfo->applicationInfo.bundleName, 0);
const auto &recordMap = service_->GetRecordMap();
EXPECT_EQ(recordMap.size(), (uint32_t)1);
@ -1193,7 +1193,7 @@ HWTEST_F(AmsServiceLoadAbilityProcessTest, StartProcess002, TestSize.Level1)
GetTestAppName(),
false, record,
abilityInfo->applicationInfo.uid,
abilityInfo->applicationInfo.bundleName);
abilityInfo->applicationInfo.bundleName, 0);
const auto &recordMap = service_->GetRecordMap();
EXPECT_EQ(recordMap.size(), (uint32_t)1);
@ -1237,7 +1237,7 @@ HWTEST_F(AmsServiceLoadAbilityProcessTest, StartProcess003, TestSize.Level1)
GetTestAppName(),
false, nullptr,
abilityInfo->applicationInfo.uid,
abilityInfo->applicationInfo.bundleName);
abilityInfo->applicationInfo.bundleName, 0);
const auto &recordMap = service_->GetRecordMap();
EXPECT_EQ(recordMap.size(), (uint32_t)1);
@ -1290,10 +1290,10 @@ HWTEST_F(AmsServiceLoadAbilityProcessTest, StartProcess004, TestSize.Level1)
GetTestAppName(),
false, record,
abilityInfo->applicationInfo.uid,
abilityInfo->applicationInfo.bundleName);
abilityInfo->applicationInfo.bundleName, 0);
auto record1 = service_->GetAppRunningRecordByAppRecordId(record->GetRecordId());
EXPECT_EQ(record1, nullptr);
HILOG_INFO("AmsServiceLoadAbilityProcessTest StartProcess004 end");
}
} // namespace AppExecFwk
} // namespace OHOS
} // namespace OHOS