修复当前子类型获取为空问题

Signed-off-by: cy7717 <chenyu301@huawei.com>
This commit is contained in:
cy7717 2024-07-09 09:40:09 +08:00
parent f5656bd6c1
commit 2e0d2f05b7
2 changed files with 11 additions and 3 deletions

View File

@ -444,11 +444,15 @@ int32_t ImeInfoInquirer::GetSubProperty(int32_t userId, const std::string &subNa
const std::vector<OHOS::AppExecFwk::ExtensionAbilityInfo> &extInfos, SubProperty &subProp)
{
IMSA_HILOGD("oldIme, userId: %{public}d", userId);
if (extInfos.empty()) {
IMSA_HILOGE("extInfos is empty");
return ErrorCode::ERROR_PACKAGE_MANAGER;
}
auto extInfo = std::find_if(extInfos.begin(), extInfos.end(),
[&subName](const ExtensionAbilityInfo &info) { return info.name == subName; });
if (extInfo == extInfos.end()) {
IMSA_HILOGE("subtype %{public}s not found", subName.c_str());
return ErrorCode::ERROR_BAD_PARAMETERS;
extInfo = extInfos.begin();
}
subProp.labelId = extInfo->labelId;
subProp.label = GetStringById(extInfo->bundleName, extInfo->moduleName, extInfo->labelId, userId);
@ -496,11 +500,15 @@ int32_t ImeInfoInquirer::GetSubProperty(int32_t userId, const std::string &subNa
IMSA_HILOGE("failed to parse subtype");
return ret;
}
if (subtypes.empty()) {
IMSA_HILOGE("subtypes is empty");
return ErrorCode::ERROR_PACKAGE_MANAGER;
}
auto subtype = std::find_if(
subtypes.begin(), subtypes.end(), [&subName](const Subtype &subtype) { return subtype.id == subName; });
if (subtype == subtypes.end()) {
IMSA_HILOGE("subtype %{public}s not found", subName.c_str());
return ErrorCode::ERROR_BAD_PARAMETERS;
subtype = subtypes.begin();
}
subProp.label = subtype->label;
subProp.name = extInfo.bundleName;

View File

@ -884,7 +884,7 @@ int32_t InputMethodSystemAbility::OnUserStarted(const Message *msg)
int32_t InputMethodSystemAbility::OnUserRemoved(const Message *msg)
{
if (msg != nullptr || msg->msgContent_ == nullptr) {
if (msg == nullptr || msg->msgContent_ == nullptr) {
IMSA_HILOGE("Aborted! Message is nullptr.");
return ErrorCode::ERROR_NULL_POINTER;
}