mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2025-01-02 05:09:34 +00:00
IssueNo:#I5LMJ8:'keepalive' parameter should be used with 'process' parameter
Description:'keepalive' parameter should be used with 'process' parameter Sig:SIG_ApplicationFramework Feature or Bugfix:Feature Binary Source:No Signed-off-by: zhoujun62 <zhoujun62@huawei.com> Change-Id: Ic383aa73872cec5db9bef09cdd91593ef25cb43e
This commit is contained in:
parent
f1af1c7911
commit
c63170aaaf
@ -32,8 +32,8 @@ public:
|
||||
void StartResidentProcess(const std::vector<AppExecFwk::BundleInfo> &bundleInfos);
|
||||
void StartResidentProcessWithMainElement(std::vector<AppExecFwk::BundleInfo> &bundleInfos);
|
||||
private:
|
||||
bool CheckMainElement(const AppExecFwk::HapModuleInfo &hapModuleInfo, std::string &mainElement,
|
||||
std::set<uint32_t> &needEraseIndexSet, size_t bundleInfoIndex);
|
||||
bool CheckMainElement(const AppExecFwk::HapModuleInfo &hapModuleInfo, const std::string &processName,
|
||||
std::string &mainElement, std::set<uint32_t> &needEraseIndexSet, size_t bundleInfoIndex);
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -1049,22 +1049,37 @@ bool AbilityConnectManager::IsAbilityNeedRestart(const std::shared_ptr<AbilityRe
|
||||
return false;
|
||||
}
|
||||
|
||||
auto GetKeepAliveAbilities = [&bundleInfos](std::vector<std::pair<std::string, std::string>> &keepAliveAbilities) {
|
||||
auto CheckIsAbilityKeepAlive = [](const AppExecFwk::HapModuleInfo &hapModuleInfo,
|
||||
const std::string processName, std::string &mainElement) {
|
||||
if (!hapModuleInfo.isModuleJson) {
|
||||
// old application model
|
||||
mainElement = hapModuleInfo.mainAbility;
|
||||
for (auto abilityInfo : hapModuleInfo.abilityInfos) {
|
||||
if (abilityInfo.process == processName && abilityInfo.name == mainElement) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// new application model
|
||||
if (hapModuleInfo.process == processName) {
|
||||
mainElement = hapModuleInfo.mainElementName;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
auto GetKeepAliveAbilities = [&](std::vector<std::pair<std::string, std::string>> &keepAliveAbilities) {
|
||||
for (size_t i = 0; i < bundleInfos.size(); i++) {
|
||||
if (!bundleInfos[i].isKeepAlive) {
|
||||
std::string processName = bundleInfos[i].applicationInfo.process;
|
||||
if (!bundleInfos[i].isKeepAlive || processName.empty()) {
|
||||
continue;
|
||||
}
|
||||
std::string bundleName = bundleInfos[i].name;
|
||||
for (auto hapModuleInfo : bundleInfos[i].hapModuleInfos) {
|
||||
std::string mainElement;
|
||||
if (!hapModuleInfo.isModuleJson) {
|
||||
// old application model
|
||||
mainElement = hapModuleInfo.mainAbility;
|
||||
} else {
|
||||
// new application model
|
||||
mainElement = hapModuleInfo.mainElementName;
|
||||
}
|
||||
if (!mainElement.empty()) {
|
||||
if (CheckIsAbilityKeepAlive(hapModuleInfo, processName, mainElement) && !mainElement.empty()) {
|
||||
keepAliveAbilities.push_back(std::make_pair(bundleName, mainElement));
|
||||
}
|
||||
}
|
||||
|
@ -1405,7 +1405,7 @@ int AbilityManagerService::ConnectAbility(
|
||||
const Want &want, const sptr<IAbilityConnection> &connect, const sptr<IRemoteObject> &callerToken, int32_t userId)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("Connect ability called.");
|
||||
HILOG_INFO("Connect ability called, element uri: %{public}s.", want.GetElement().GetURI().c_str());
|
||||
CHECK_POINTER_AND_RETURN(connect, ERR_INVALID_VALUE);
|
||||
CHECK_POINTER_AND_RETURN(connect->AsObject(), ERR_INVALID_VALUE);
|
||||
AAFWK::EventInfo eventInfo;
|
||||
|
@ -645,7 +645,7 @@ void DataAbilityManager::RestartDataAbility(const std::shared_ptr<AbilityRecord>
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < bundleInfos.size(); i++) {
|
||||
if (!bundleInfos[i].isKeepAlive) {
|
||||
if (!bundleInfos[i].isKeepAlive || bundleInfos[i].applicationInfo.process.empty()) {
|
||||
continue;
|
||||
}
|
||||
for (auto hapModuleInfo : bundleInfos[i].hapModuleInfos) {
|
||||
@ -655,7 +655,8 @@ void DataAbilityManager::RestartDataAbility(const std::shared_ptr<AbilityRecord>
|
||||
}
|
||||
// old application model, it maybe a data ability
|
||||
std::string mainElement = hapModuleInfo.mainAbility;
|
||||
if (abilityRecord->GetAbilityInfo().name != mainElement) {
|
||||
if (abilityRecord->GetAbilityInfo().name != mainElement ||
|
||||
abilityRecord->GetAbilityInfo().process != bundleInfos[i].applicationInfo.process) {
|
||||
continue;
|
||||
}
|
||||
std::string uriStr;
|
||||
|
@ -36,13 +36,14 @@ void ResidentProcessManager::StartResidentProcessWithMainElement(std::vector<App
|
||||
std::set<uint32_t> needEraseIndexSet;
|
||||
|
||||
for (size_t i = 0; i < bundleInfos.size(); i++) {
|
||||
if (!bundleInfos[i].isKeepAlive) {
|
||||
std::string processName = bundleInfos[i].applicationInfo.process;
|
||||
if (!bundleInfos[i].isKeepAlive || processName.empty()) {
|
||||
needEraseIndexSet.insert(i);
|
||||
continue;
|
||||
}
|
||||
for (auto hapModuleInfo : bundleInfos[i].hapModuleInfos) {
|
||||
std::string mainElement;
|
||||
if (!CheckMainElement(hapModuleInfo, mainElement, needEraseIndexSet, i)) {
|
||||
if (!CheckMainElement(hapModuleInfo, processName, mainElement, needEraseIndexSet, i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -61,7 +62,8 @@ void ResidentProcessManager::StartResidentProcessWithMainElement(std::vector<App
|
||||
}
|
||||
}
|
||||
|
||||
bool ResidentProcessManager::CheckMainElement(const AppExecFwk::HapModuleInfo &hapModuleInfo, std::string &mainElement,
|
||||
bool ResidentProcessManager::CheckMainElement(const AppExecFwk::HapModuleInfo &hapModuleInfo,
|
||||
const std::string &processName, std::string &mainElement,
|
||||
std::set<uint32_t> &needEraseIndexSet, size_t bundleInfoIndex)
|
||||
{
|
||||
if (!hapModuleInfo.isModuleJson) {
|
||||
@ -71,6 +73,18 @@ bool ResidentProcessManager::CheckMainElement(const AppExecFwk::HapModuleInfo &h
|
||||
return false;
|
||||
}
|
||||
|
||||
// old application model, use ability 'process'
|
||||
bool isAbilityKeepAlive = false;
|
||||
for (auto abilityInfo : hapModuleInfo.abilityInfos) {
|
||||
if (abilityInfo.process != processName || abilityInfo.name != mainElement) {
|
||||
continue;
|
||||
}
|
||||
isAbilityKeepAlive = true;
|
||||
}
|
||||
if (!isAbilityKeepAlive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string uriStr;
|
||||
bool getDataAbilityUri = DelayedSingleton<AbilityManagerService>::GetInstance()->GetDataAbilityUri(
|
||||
hapModuleInfo.abilityInfos, mainElement, uriStr);
|
||||
@ -87,6 +101,11 @@ bool ResidentProcessManager::CheckMainElement(const AppExecFwk::HapModuleInfo &h
|
||||
if (mainElement.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// new application model, user model 'process'
|
||||
if (hapModuleInfo.process != processName) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ability need to start, but need to filt page ability
|
||||
|
@ -1639,10 +1639,11 @@ void AppMgrServiceInner::StartResidentProcess(const std::vector<BundleInfo> &inf
|
||||
}
|
||||
|
||||
for (auto &bundle : infos) {
|
||||
auto processName = bundle.applicationInfo.process.empty() ?
|
||||
bundle.applicationInfo.bundleName : bundle.applicationInfo.process;
|
||||
HILOG_INFO("processName = [%{public}s]", processName.c_str());
|
||||
|
||||
HILOG_INFO("processName = [%{public}s]", bundle.applicationInfo.process.c_str());
|
||||
if (bundle.applicationInfo.process.empty()) {
|
||||
continue;
|
||||
}
|
||||
auto processName = bundle.applicationInfo.process;
|
||||
// Inspection records
|
||||
auto appRecord = appRunningManager_->CheckAppRunningRecordIsExist(
|
||||
bundle.applicationInfo.name, processName, bundle.applicationInfo.uid, bundle);
|
||||
|
Loading…
Reference in New Issue
Block a user