!2207 IsOsAccountCompleted错误码判断

Merge pull request !2207 from xuqian0131/onstart
This commit is contained in:
openharmony_ci 2024-10-31 12:49:15 +00:00 committed by Gitee
commit 2977ddf4f4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 10 additions and 6 deletions

View File

@ -290,15 +290,16 @@ void AccountMgrService::OnAddSystemAbility(int32_t systemAbilityId, const std::s
return;
}
bool isAccountCompleted = false;
IInnerOsAccountManager::GetInstance().IsOsAccountCompleted(Constants::START_USER_ID, isAccountCompleted);
if (!isAccountCompleted) {
ErrCode errCode =
IInnerOsAccountManager::GetInstance().IsOsAccountCompleted(Constants::START_USER_ID, isAccountCompleted);
if (errCode == ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR || (errCode == ERR_OK && !isAccountCompleted)) {
if (!isBmsReady_) {
return;
}
IInnerOsAccountManager::GetInstance().Init();
}
if (!isDefaultOsAccountActivated_ && isAmsReady_) {
ErrCode errCode = IInnerOsAccountManager::GetInstance().ActivateDefaultOsAccount();
errCode = IInnerOsAccountManager::GetInstance().ActivateDefaultOsAccount();
if (errCode == ERR_OK) {
isDefaultOsAccountActivated_ = true;
}

View File

@ -537,19 +537,22 @@ ErrCode OsAccountControlFileManager::GetOsAccountInfoById(const int id, OsAccoun
InsertOsAccount(osAccountInfo);
return ERR_OK;
}
return ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR;
return errno == ENOENT ? ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR : ERR_ACCOUNT_COMMON_FILE_READ_FAILED;
}
std::string accountInfoStr;
if (accountFileOperator_->GetFileContentByPath(path, accountInfoStr) != ERR_OK) {
ACCOUNT_LOGE("get content from file %{public}s failed!", path.c_str());
return ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR;
if (GetOsAccountFromDatabase("", id, osAccountInfo) == ERR_OK) {
return ERR_OK;
}
return ERR_ACCOUNT_COMMON_FILE_READ_FAILED;
}
Json osAccountInfoJson = Json::parse(accountInfoStr, nullptr, false);
if (osAccountInfoJson.is_discarded() || !osAccountInfo.FromJson(osAccountInfoJson)) {
ACCOUNT_LOGE("parse os account info json for %{public}d failed", id);
if (GetOsAccountFromDatabase("", id, osAccountInfo) != ERR_OK) {
ACCOUNT_LOGE("GetOsAccountFromDatabase failed id=%{public}d", id);
return ERR_ACCOUNT_COMMON_BAD_JSON_FORMAT_ERROR;
return ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR;
}
}
return ERR_OK;