codecheck

Signed-off-by: MisterE <smart_e@126.com>
This commit is contained in:
MisterE 2024-11-12 17:54:06 +08:00
commit 1a74b8412d
2 changed files with 27 additions and 21 deletions

View File

@ -525,6 +525,10 @@ enum {
* Result(29360237) for not get mgr. * Result(29360237) for not get mgr.
*/ */
DMS_NOT_GET_MANAGER = 29360237, DMS_NOT_GET_MANAGER = 29360237,
/**
* Result(29360238) for BMS can not find the specified module.
*/
CAN_NOT_FOUND_MODULE_ERR = 29360238,
}; };
} // namespace DistributedSchedule } // namespace DistributedSchedule
} // namespace OHOS } // namespace OHOS

View File

@ -390,9 +390,6 @@ int32_t DSchedContinue::OnContinueDataCmd(std::shared_ptr<DSchedContinueDataCmd>
int32_t DSchedContinue::PostContinueDataTask(std::shared_ptr<DSchedContinueDataCmd> cmd) int32_t DSchedContinue::PostContinueDataTask(std::shared_ptr<DSchedContinueDataCmd> cmd)
{ {
DSchedContinueEventType eventType = DSCHED_CONTINUE_DATA_EVENT; DSchedContinueEventType eventType = DSCHED_CONTINUE_DATA_EVENT;
if (UpdateElementInfo(cmd) != ERR_OK) {
return INVALID_PARAMETERS_ERR;
}
HILOGI("PostContinueDataTask %{public}d, continueInfo %{public}s; ", eventType, continueInfo_.toString().c_str()); HILOGI("PostContinueDataTask %{public}d, continueInfo %{public}s; ", eventType, continueInfo_.toString().c_str());
if (eventHandler_ == nullptr) { if (eventHandler_ == nullptr) {
HILOGE("PostContinueDataTask eventHandler is nullptr"); HILOGE("PostContinueDataTask eventHandler is nullptr");
@ -415,7 +412,7 @@ int32_t DSchedContinue::UpdateElementInfo(std::shared_ptr<DSchedContinueDataCmd>
cmd->dstDeviceId_, cmd->dstBundleName_, distributedBundleInfo)) { cmd->dstDeviceId_, cmd->dstBundleName_, distributedBundleInfo)) {
HILOGE("UpdateElementInfo can not found bundle info for bundle name: %{public}s", HILOGE("UpdateElementInfo can not found bundle info for bundle name: %{public}s",
cmd->dstBundleName_.c_str()); cmd->dstBundleName_.c_str());
return INVALID_PARAMETERS_ERR; return CAN_NOT_FOUND_MODULE_ERR;
} }
std::vector<DmsAbilityInfo> dmsAbilityInfos = distributedBundleInfo.dmsAbilityInfos; std::vector<DmsAbilityInfo> dmsAbilityInfos = distributedBundleInfo.dmsAbilityInfos;
@ -425,22 +422,23 @@ int32_t DSchedContinue::UpdateElementInfo(std::shared_ptr<DSchedContinueDataCmd>
for (const auto &abilityInfoElement: dmsAbilityInfos) { for (const auto &abilityInfoElement: dmsAbilityInfos) {
std::vector<std::string> continueTypes = abilityInfoElement.continueType; std::vector<std::string> continueTypes = abilityInfoElement.continueType;
for (const auto &continueTypeElement: continueTypes) { for (const auto &continueTypeElement: continueTypes) {
if (continueTypeElement == cmd->continueType_) { if (continueTypeElement != cmd->continueType_) {
if (continueTypeElement == abilityInfoElement.abilityName && continue;
moduleName == abilityInfoElement.moduleName) { }
sameAbilityGot = true; if (continueTypeElement == abilityInfoElement.abilityName &&
result.push_back(abilityInfoElement); moduleName == abilityInfoElement.moduleName) {
break; sameAbilityGot = true;
} else if (continueTypeElement != abilityInfoElement.abilityName && result.push_back(abilityInfoElement);
moduleName == abilityInfoElement.moduleName) { break;
hasSameModule = true; } else if (continueTypeElement != abilityInfoElement.abilityName &&
result.clear(); moduleName == abilityInfoElement.moduleName) {
result.push_back(abilityInfoElement); hasSameModule = true;
break; result.clear();
} else if (continueTypeElement != abilityInfoElement.abilityName) { result.push_back(abilityInfoElement);
result.push_back(abilityInfoElement); break;
break; } else if (continueTypeElement != abilityInfoElement.abilityName) {
} result.push_back(abilityInfoElement);
break;
} }
} }
if (sameAbilityGot || hasSameModule) { if (sameAbilityGot || hasSameModule) {
@ -450,7 +448,7 @@ int32_t DSchedContinue::UpdateElementInfo(std::shared_ptr<DSchedContinueDataCmd>
if (result.empty()) { if (result.empty()) {
HILOGE("UpdateElementInfo can not found bundle info for bundle name: %{public}s", HILOGE("UpdateElementInfo can not found bundle info for bundle name: %{public}s",
cmd->dstBundleName_.c_str()); cmd->dstBundleName_.c_str());
return INVALID_PARAMETERS_ERR; return CAN_NOT_FOUND_MODULE_ERR;
} }
auto element = cmd->want_.GetElement(); auto element = cmd->want_.GetElement();
DmsAbilityInfo finalAbility = result[0]; DmsAbilityInfo finalAbility = result[0];
@ -978,6 +976,10 @@ int32_t DSchedContinue::ExecuteContinueData(std::shared_ptr<DSchedContinueDataCm
return INVALID_PARAMETERS_ERR; return INVALID_PARAMETERS_ERR;
} }
if (UpdateElementInfo(cmd) != ERR_OK) {
return CAN_NOT_FOUND_MODULE_ERR;
}
DurationDumperBeforeStartAbility(cmd); DurationDumperBeforeStartAbility(cmd);
std::string localDeviceId; std::string localDeviceId;