!1241 IAMIPC错误码冗余优化

Merge pull request !1241 from liushuling/errorCodebetter
This commit is contained in:
openharmony_ci 2023-06-09 10:49:12 +00:00 committed by Gitee
commit 1e95d04c47
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
10 changed files with 129 additions and 142 deletions

View File

@ -59,15 +59,15 @@ ErrCode IDMCallbackStub::ProcOnAcquireInfo(MessageParcel &data, MessageParcel &r
std::vector<uint8_t> buffer;
if (!data.ReadInt32(module)) {
ACCOUNT_LOGE("failed to read module");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
if (!data.ReadInt32(acquireInfo)) {
ACCOUNT_LOGE("failed to read acquireInfo");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
if (!data.ReadUInt8Vector(&buffer)) {
ACCOUNT_LOGE("failed to read buffer");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
Attributes extraInfo(buffer);
OnAcquireInfo(module, acquireInfo, extraInfo);
@ -79,12 +79,12 @@ ErrCode IDMCallbackStub::ProcOnResult(MessageParcel &data, MessageParcel &reply)
int32_t result;
if (!data.ReadInt32(result)) {
ACCOUNT_LOGE("failed to read result for IDMCallback OnResult");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
std::vector<uint8_t> buffer;
if (!data.ReadUInt8Vector(&buffer)) {
ACCOUNT_LOGE("failed to read result for IDMCallback OnResult");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
Attributes extraInfo(buffer);
OnResult(result, extraInfo);
@ -122,11 +122,11 @@ ErrCode GetCredInfoCallbackStub::ProcOnCredentialInfo(MessageParcel &data, Messa
std::vector<CredentialInfo> infoList;
if (!data.ReadUint32(vectorSize)) {
ACCOUNT_LOGE("read size fail");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
if (vectorSize > MAX_VEC_SIZE) {
ACCOUNT_LOGE("credential info list is oversize, the limit is %{public}d", MAX_VEC_SIZE);
return ERR_ACCOUNT_IAM_KIT_PARAM_INVALID_ERROR;
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
}
for (uint32_t i = 0; i < vectorSize; ++i) {
CredentialInfo info;
@ -134,19 +134,19 @@ ErrCode GetCredInfoCallbackStub::ProcOnCredentialInfo(MessageParcel &data, Messa
int32_t pinType = 0;
if (!data.ReadUint64(info.credentialId)) {
ACCOUNT_LOGE("failed to read credentialId");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
if (!data.ReadInt32(authType)) {
ACCOUNT_LOGE("failed to read authType");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
if (!data.ReadInt32(pinType)) {
ACCOUNT_LOGE("failed to read pinSubType");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
if (!data.ReadUint64(info.templateId)) {
ACCOUNT_LOGE("failed to read templateId");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
info.authType = static_cast<AuthType>(authType);
info.pinType = static_cast<PinSubType>(pinType);
@ -185,12 +185,12 @@ ErrCode GetSetPropCallbackStub::ProcOnResult(MessageParcel &data, MessageParcel
int32_t result;
if (!data.ReadInt32(result)) {
ACCOUNT_LOGE("failed to read result for GetSetPropCallback OnResult");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
std::vector<uint8_t> buffer;
if (!data.ReadUInt8Vector(&buffer)) {
ACCOUNT_LOGE("failed to read result for GetSetPropCallback OnResult");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
Attributes extraInfo(buffer);
OnResult(result, extraInfo);

View File

@ -71,7 +71,7 @@ void AccountIAMClient::AddCredential(
}
if ((userId == 0) && (!GetCurrentUserId(userId))) {
ACCOUNT_LOGE("fail to add credential for invalid userId");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_PARAM_INVALID_ERROR, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_INVALID_PARAMETER, emptyResult);
return;
}
if (credInfo.authType == AuthType::PIN) {
@ -95,7 +95,7 @@ void AccountIAMClient::UpdateCredential(
}
if ((userId == 0) && (!GetCurrentUserId(userId))) {
ACCOUNT_LOGE("fail to update credential for invalid userId");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_PARAM_INVALID_ERROR, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_INVALID_PARAMETER, emptyResult);
return;
}
if (credInfo.authType == AuthType::PIN) {
@ -118,7 +118,7 @@ void AccountIAMClient::DelCred(int32_t userId, uint64_t credentialId, const std:
return;
}
if ((userId == 0) && (!GetCurrentUserId(userId))) {
callback->OnResult(ERR_ACCOUNT_IAM_KIT_PARAM_INVALID_ERROR, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_INVALID_PARAMETER, emptyResult);
return;
}
sptr<IIDMCallback> wrapper = new (std::nothrow) IDMCallbackService(userId, callback);
@ -138,7 +138,7 @@ void AccountIAMClient::DelUser(
return;
}
if ((userId == 0) && (!GetCurrentUserId(userId))) {
callback->OnResult(ERR_ACCOUNT_IAM_KIT_PARAM_INVALID_ERROR, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_INVALID_PARAMETER, emptyResult);
return;
}
sptr<IIDMCallback> wrapper = new (std::nothrow) IDMCallbackService(userId, callback);
@ -239,11 +239,11 @@ int32_t AccountIAMClient::GetAvailableStatus(AuthType authType, AuthTrustLevel a
}
if (authTrustLevel < UserIam::UserAuth::ATL1 || authTrustLevel > UserIam::UserAuth::ATL4) {
ACCOUNT_LOGE("authTrustLevel is not in correct range");
return ERR_ACCOUNT_IAM_KIT_PARAM_INVALID_ERROR;
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
}
if (authType < UserIam::UserAuth::ALL) {
ACCOUNT_LOGE("authType is not in correct range");
return ERR_ACCOUNT_IAM_KIT_PARAM_INVALID_ERROR;
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
}
return proxy_->GetAvailableStatus(authType, authTrustLevel, status);
}

View File

@ -59,7 +59,7 @@ int32_t AccountIAMMgrProxy::OpenSession(int32_t userId, std::vector<uint8_t> &ch
challenge.clear();
MessageParcel data;
if (!WriteCommonData(data, userId)) {
return ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
MessageParcel reply;
int32_t result = SendRequest(IAccountIAM::Message::OPEN_SESSION, data, reply);
@ -68,7 +68,7 @@ int32_t AccountIAMMgrProxy::OpenSession(int32_t userId, std::vector<uint8_t> &ch
}
if (!reply.ReadInt32(result)) {
ACCOUNT_LOGE("failed to read result");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
if (result != ERR_OK) {
ACCOUNT_LOGE("failed to open session, result: %{public}d", result);
@ -76,7 +76,7 @@ int32_t AccountIAMMgrProxy::OpenSession(int32_t userId, std::vector<uint8_t> &ch
}
if (!reply.ReadUInt8Vector(&challenge)) {
ACCOUNT_LOGE("failed to read challenge!");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
return ERR_OK;
}
@ -85,7 +85,7 @@ int32_t AccountIAMMgrProxy::CloseSession(int32_t userId)
{
MessageParcel data;
if (!WriteCommonData(data, userId)) {
return ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
MessageParcel reply;
int32_t result = SendRequest(IAccountIAM::Message::CLOSE_SESSION, data, reply);
@ -94,7 +94,7 @@ int32_t AccountIAMMgrProxy::CloseSession(int32_t userId)
}
if (!reply.ReadInt32(result)) {
ACCOUNT_LOGE("failed to read result");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
return result;
}
@ -109,28 +109,28 @@ void AccountIAMMgrProxy::AddOrUpdateCredential(
Attributes emptyResult;
MessageParcel data;
if (!WriteCommonData(data, userId)) {
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteInt32(credInfo.authType)) {
ACCOUNT_LOGE("failed to write authType");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
PinSubType pinType = credInfo.pinType.value_or(PinSubType::PIN_MAX);
if (!data.WriteInt32(pinType)) {
ACCOUNT_LOGE("failed to write pinType");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteUInt8Vector(credInfo.token)) {
ACCOUNT_LOGE("failed to write token");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
ACCOUNT_LOGE("failed to write callback");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
MessageParcel reply;
@ -161,7 +161,7 @@ int32_t AccountIAMMgrProxy::Cancel(int32_t userId)
{
MessageParcel data;
if (!WriteCommonData(data, userId)) {
return ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
MessageParcel reply;
int32_t result = SendRequest(IAccountIAM::Message::CANCEL, data, reply);
@ -170,7 +170,7 @@ int32_t AccountIAMMgrProxy::Cancel(int32_t userId)
}
if (!reply.ReadInt32(result)) {
ACCOUNT_LOGE("failed to read result");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
return result;
}
@ -185,22 +185,22 @@ void AccountIAMMgrProxy::DelCred(
Attributes emptyResult;
MessageParcel data;
if (!WriteCommonData(data, userId)) {
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteUint64(credentialId)) {
ACCOUNT_LOGE("failed to write userId");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteUInt8Vector(authToken)) {
ACCOUNT_LOGE("failed to write token for DelCred");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
ACCOUNT_LOGE("failed to write callback for DelCred");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
MessageParcel reply;
@ -220,17 +220,17 @@ void AccountIAMMgrProxy::DelUser(
Attributes emptyResult;
MessageParcel data;
if (!WriteCommonData(data, userId)) {
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteUInt8Vector(authToken)) {
ACCOUNT_LOGE("failed to write token for DelUser");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
ACCOUNT_LOGE("failed to write callback for DelUser");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
MessageParcel reply;
@ -249,15 +249,15 @@ int32_t AccountIAMMgrProxy::GetCredentialInfo(
}
MessageParcel data;
if (!WriteCommonData(data, userId)) {
return ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
if (!data.WriteInt32(authType)) {
ACCOUNT_LOGE("failed to write authType");
return ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
ACCOUNT_LOGE("failed to write callback");
return ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
MessageParcel reply;
int32_t result = SendRequest(IAccountIAM::Message::GET_CREDENTIAL_INFO, data, reply);
@ -266,7 +266,7 @@ int32_t AccountIAMMgrProxy::GetCredentialInfo(
}
if (!reply.ReadInt32(result)) {
ACCOUNT_LOGE("failed to read result");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
return result;
}
@ -320,11 +320,11 @@ int32_t AccountIAMMgrProxy::CancelAuth(uint64_t contextId)
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
ACCOUNT_LOGE("failed to write descriptor");
return ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
if (!data.WriteUint64(contextId)) {
ACCOUNT_LOGE("failed to write contextId");
return ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
MessageParcel reply;
int32_t result = SendRequest(IAccountIAM::Message::CANCEL_AUTH, data, reply);
@ -333,7 +333,7 @@ int32_t AccountIAMMgrProxy::CancelAuth(uint64_t contextId)
}
if (!reply.ReadInt32(result)) {
ACCOUNT_LOGE("failed to read result");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
return result;
}
@ -344,15 +344,15 @@ int32_t AccountIAMMgrProxy::GetAvailableStatus(const AuthType authType, const Au
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
ACCOUNT_LOGE("failed to write descriptor");
return ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
if (!data.WriteInt32(authType)) {
ACCOUNT_LOGE("failed to write authType");
return ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
if (!data.WriteUint32(authTrustLevel)) {
ACCOUNT_LOGE("failed to write authTrustLevel");
return ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
MessageParcel reply;
int32_t res = SendRequest(IAccountIAM::Message::GET_AVAILABLE_STATUS, data, reply);
@ -361,7 +361,7 @@ int32_t AccountIAMMgrProxy::GetAvailableStatus(const AuthType authType, const Au
}
if (!reply.ReadInt32(res)) {
ACCOUNT_LOGE("failed to read result");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
if (res != ERR_OK) {
ACCOUNT_LOGE("failed to get available status, result: %{public}d", res);
@ -369,7 +369,7 @@ int32_t AccountIAMMgrProxy::GetAvailableStatus(const AuthType authType, const Au
}
if (!reply.ReadInt32(status)) {
ACCOUNT_LOGE("failed to read status");
return ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
return ERR_OK;
}
@ -384,12 +384,12 @@ void AccountIAMMgrProxy::GetProperty(
Attributes emptyResult;
MessageParcel data;
if (!WriteCommonData(data, userId)) {
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteInt32(request.authType)) {
ACCOUNT_LOGE("failed to write authType for GetProperty");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
std::vector<uint32_t> attrKeys;
@ -398,12 +398,12 @@ void AccountIAMMgrProxy::GetProperty(
if (!data.WriteUInt32Vector(attrKeys)) {
ACCOUNT_LOGE("failed to write keys");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
ACCOUNT_LOGE("failed to write callback");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
MessageParcel reply;
@ -423,23 +423,23 @@ void AccountIAMMgrProxy::SetProperty(
Attributes emptyResult;
MessageParcel data;
if (!WriteCommonData(data, userId)) {
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteInt32(request.authType)) {
ACCOUNT_LOGE("failed to write authType for SetProperty");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
auto buffer = request.attrs.Serialize();
if (!data.WriteUInt8Vector(buffer)) {
ACCOUNT_LOGE("failed to write attributes");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
if (!data.WriteRemoteObject(callback->AsObject())) {
ACCOUNT_LOGE("failed to write callback");
callback->OnResult(ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR, emptyResult);
return;
}
MessageParcel reply;

View File

@ -351,7 +351,7 @@ HWTEST_F(AccountIAMClientTest, AccountIAMClient_GetAvailableStatus_0200, TestSiz
int32_t status;
AuthTrustLevel level = static_cast<AuthTrustLevel>(0);
int32_t ret = AccountIAMClient::GetInstance().GetAvailableStatus(AuthType::FACE, level, status);
EXPECT_EQ(ERR_ACCOUNT_IAM_KIT_PARAM_INVALID_ERROR, ret);
EXPECT_EQ(ERR_ACCOUNT_COMMON_INVALID_PARAMETER, ret);
}
/**

View File

@ -468,9 +468,6 @@ constexpr ErrCode ACCOUNT_IAM_KIT_ERR_OFFSET =
enum {
ERR_ACCOUNT_IAM_KIT_SEND_REQUEST = ACCOUNT_IAM_KIT_ERR_OFFSET + 0x0001,
ERR_ACCOUNT_IAM_KIT_PROXY_ERROR,
ERR_ACCOUNT_IAM_KIT_WRITE_PARCEL_FAIL,
ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL,
ERR_ACCOUNT_IAM_KIT_PARAM_INVALID_ERROR,
ERR_ACCOUNT_IAM_KIT_INPUTER_ALREADY_REGISTERED,
ERR_ACCOUNT_IAM_KIT_INPUTER_NOT_REGISTERED,
ERR_ACCOUNT_IAM_KIT_GET_USERID_FAIL,
@ -482,11 +479,7 @@ constexpr ErrCode ACCOUNT_IAM_SERVICE_ERR_OFFSET =
ErrCodeOffset(SUBSYS_ACCOUNT, ACCOUNT_MODULE_ACCOUNT_IAM_SERVICE);
enum {
ERR_ACCOUNT_IAM_SERVICE_PERMISSION_DENIED = ACCOUNT_IAM_SERVICE_ERR_OFFSET + 0x0001,
ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR,
ERR_ACCOUNT_IAM_SERVICE_GET_STORAGE_SYSTEM_ABILITY,
ERR_ACCOUNT_IAM_SERVICE_REMOTE_IS_NULLPTR,
ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL,
ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL
};
// Error code for OHOSACCOUNT_KIT

View File

@ -69,15 +69,9 @@ int32_t AccountIAMConvertToJSErrCode(int32_t errCode)
{
if (errCode == ERR_ACCOUNT_COMMON_NOT_SYSTEM_APP_ERROR) {
return ERR_JS_IS_NOT_SYSTEM_APP;
}
if ((errCode >= ERR_ACCOUNT_IAM_KIT_SEND_REQUEST && errCode <= ERR_ACCOUNT_IAM_KIT_READ_PARCEL_FAIL) ||
(errCode >= ERR_ACCOUNT_IAM_SERVICE_GET_STORAGE_SYSTEM_ABILITY &&
errCode <= ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL)) {
return ERR_JS_SYSTEM_SERVICE_EXCEPTION;
} else if (errCode == ERR_ACCOUNT_IAM_SERVICE_PERMISSION_DENIED || errCode == ERR_IAM_CHECK_PERMISSION_FAILED) {
return ERR_JS_PERMISSION_DENIED;
} else if (errCode == ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR ||
errCode == ERR_ACCOUNT_IAM_KIT_PARAM_INVALID_ERROR) {
} else if (errCode == ERR_ACCOUNT_COMMON_INVALID_PARAMETER) {
return ERR_JS_INVALID_PARAMETER;
}
return AccountIAMConvertOtherToJSErrCode(errCode);

View File

@ -164,18 +164,18 @@ ErrCode AccountIAMMgrStub::ProcOpenSession(MessageParcel &data, MessageParcel &r
int32_t userId;
if (!data.ReadInt32(userId)) {
ACCOUNT_LOGE("failed to read userId");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
std::vector<uint8_t> challenge;
int32_t result = OpenSession(userId, challenge);
if (!reply.WriteInt32(result)) {
ACCOUNT_LOGE("failed to write result");
return ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
if (result == ERR_OK) {
if (!reply.WriteUInt8Vector(challenge)) {
ACCOUNT_LOGE("failed to write challenge");
return ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
}
return ERR_NONE;
@ -189,12 +189,12 @@ ErrCode AccountIAMMgrStub::ProcCloseSession(MessageParcel &data, MessageParcel &
int32_t userId;
if (!data.ReadInt32(userId)) {
ACCOUNT_LOGE("failed to read userId");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
int32_t result = CloseSession(userId);
if (!reply.WriteInt32(result)) {
ACCOUNT_LOGE("failed to write result");
return ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
return ERR_NONE;
}
@ -203,11 +203,11 @@ ErrCode AccountIAMMgrStub::ReadUserIdAndAuthType(MessageParcel &data, int32_t &u
{
if (!data.ReadInt32(userId)) {
ACCOUNT_LOGE("failed to read userId");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
if (!data.ReadInt32(authType)) {
ACCOUNT_LOGE("failed to read authType");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
return ERR_OK;
}
@ -226,17 +226,17 @@ ErrCode AccountIAMMgrStub::AddOrUpdateCredential(MessageParcel &data, MessagePar
int32_t authSubType;
if (!data.ReadInt32(authSubType)) {
ACCOUNT_LOGE("failed to read authSubType");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
CredentialParameters credParams;
if (!data.ReadUInt8Vector(&credParams.token)) {
ACCOUNT_LOGE("failed to read token");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
sptr<IIDMCallback> callback = iface_cast<IIDMCallback>(data.ReadRemoteObject());
if (callback == nullptr) {
ACCOUNT_LOGE("callback is nullptr");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
credParams.authType = static_cast<AuthType>(authType);
credParams.pinType = static_cast<PinSubType>(authSubType);
@ -266,22 +266,22 @@ ErrCode AccountIAMMgrStub::ProcDelCred(MessageParcel &data, MessageParcel &reply
int32_t userId;
if (!data.ReadInt32(userId)) {
ACCOUNT_LOGE("failed to read userId");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
uint64_t credentialId;
if (!data.ReadUint64(credentialId)) {
ACCOUNT_LOGE("failed to read credentialId");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
std::vector<uint8_t> authToken;
if (!data.ReadUInt8Vector(&authToken)) {
ACCOUNT_LOGE("failed to read authToken for delCred");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
sptr<IIDMCallback> callback = iface_cast<IIDMCallback>(data.ReadRemoteObject());
if (callback == nullptr) {
ACCOUNT_LOGE("callback is nullptr");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
DelCred(userId, credentialId, authToken, callback);
return ERR_NONE;
@ -295,17 +295,17 @@ ErrCode AccountIAMMgrStub::ProcDelUser(MessageParcel &data, MessageParcel &reply
int32_t userId;
if (!data.ReadInt32(userId)) {
ACCOUNT_LOGE("failed to read userId");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
std::vector<uint8_t> authToken;
if (!data.ReadUInt8Vector(&authToken)) {
ACCOUNT_LOGE("failed to read authToken for delUser");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
sptr<IIDMCallback> callback = iface_cast<IIDMCallback>(data.ReadRemoteObject());
if (callback == nullptr) {
ACCOUNT_LOGE("callback is nullptr");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
DelUser(userId, authToken, callback);
return ERR_NONE;
@ -319,12 +319,12 @@ ErrCode AccountIAMMgrStub::ProcCancel(MessageParcel &data, MessageParcel &reply)
int32_t userId;
if (!data.ReadInt32(userId)) {
ACCOUNT_LOGE("failed to read userId");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
int32_t result = Cancel(userId);
if (!reply.WriteInt32(result)) {
ACCOUNT_LOGE("failed to write result");
return ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
return ERR_NONE;
}
@ -343,12 +343,12 @@ ErrCode AccountIAMMgrStub::ProcGetCredentialInfo(MessageParcel &data, MessagePar
sptr<IGetCredInfoCallback> callback = iface_cast<IGetCredInfoCallback>(data.ReadRemoteObject());
if (callback == nullptr) {
ACCOUNT_LOGE("callback is nullptr");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
int result = GetCredentialInfo(userId, static_cast<AuthType>(authType), callback);
if (!reply.WriteInt32(result)) {
ACCOUNT_LOGE("failed to write result");
return ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
return ERR_NONE;
}
@ -361,39 +361,39 @@ ErrCode AccountIAMMgrStub::ProcAuthUser(MessageParcel &data, MessageParcel &repl
int32_t userId;
if (!data.ReadInt32(userId)) {
ACCOUNT_LOGE("failed to read userId");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
AuthParam authParam;
if (!data.ReadUInt8Vector(&authParam.challenge)) {
ACCOUNT_LOGE("failed to read challenge");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
int32_t authType;
if (!data.ReadInt32(authType)) {
ACCOUNT_LOGE("failed to read authType for AuthUser");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
authParam.authType = static_cast<AuthType>(authType);
uint32_t authTrustLevel;
if (!data.ReadUint32(authTrustLevel)) {
ACCOUNT_LOGE("failed to read authTrustLevel for AuthUser");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
authParam.authTrustLevel = static_cast<AuthTrustLevel>(authTrustLevel);
sptr<IIDMCallback> callback = iface_cast<IIDMCallback>(data.ReadRemoteObject());
if (callback == nullptr) {
ACCOUNT_LOGE("UserAuthCallbackInterface is nullptr");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
uint64_t contextId = 0;
ErrCode result = AuthUser(userId, authParam, callback, contextId);
if (!reply.WriteInt32(result)) {
ACCOUNT_LOGE("failed to write result");
return ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
if (!reply.WriteUint64(contextId)) {
ACCOUNT_LOGE("failed to write contextId");
return ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
return ERR_NONE;
}
@ -406,12 +406,12 @@ ErrCode AccountIAMMgrStub::ProcCancelAuth(MessageParcel &data, MessageParcel &re
uint64_t contextId;
if (!data.ReadUint64(contextId)) {
ACCOUNT_LOGE("failed to read contextId");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
int32_t result = CancelAuth(contextId);
if (!reply.WriteInt32(result)) {
ACCOUNT_LOGE("failed to write result");
return ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
return ERR_NONE;
}
@ -424,24 +424,24 @@ ErrCode AccountIAMMgrStub::ProcGetAvailableStatus(MessageParcel &data, MessagePa
int32_t authType;
if (!data.ReadInt32(authType)) {
ACCOUNT_LOGE("failed to read authType for GetAvailableStatus");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
uint32_t authTrustLevel;
if (!data.ReadUint32(authTrustLevel)) {
ACCOUNT_LOGE("failed to read authTrustLevel for GetAvailableStatus");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
int32_t status;
int32_t result =
GetAvailableStatus(static_cast<AuthType>(authType), static_cast<AuthTrustLevel>(authTrustLevel), status);
if (!reply.WriteInt32(result)) {
ACCOUNT_LOGE("failed to write result");
return ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
if (result == ERR_OK) {
if (!reply.WriteInt32(status)) {
ACCOUNT_LOGE("failed to write status");
return ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
}
return ERR_NONE;
@ -455,17 +455,17 @@ ErrCode AccountIAMMgrStub::ProcGetProperty(MessageParcel &data, MessageParcel &r
int32_t userId;
int32_t authType;
if (ReadUserIdAndAuthType(data, userId, authType) != ERR_OK) {
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
std::vector<uint32_t> keys;
if (!data.ReadUInt32Vector(&keys)) {
ACCOUNT_LOGE("failed to read attribute keys");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
sptr<IGetSetPropCallback> callback = iface_cast<IGetSetPropCallback>(data.ReadRemoteObject());
if (callback == nullptr) {
ACCOUNT_LOGE("IGetSetPropCallback is nullptr");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
GetPropertyRequest request;
request.authType = static_cast<AuthType>(authType);
@ -484,17 +484,17 @@ ErrCode AccountIAMMgrStub::ProcSetProperty(MessageParcel &data, MessageParcel &r
int32_t userId;
int32_t authType;
if (ReadUserIdAndAuthType(data, userId, authType) != ERR_OK) {
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
std::vector<uint8_t> attr;
if (!data.ReadUInt8Vector(&attr)) {
ACCOUNT_LOGE("failed to read attributes");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
sptr<IGetSetPropCallback> callback = iface_cast<IGetSetPropCallback>(data.ReadRemoteObject());
if (callback == nullptr) {
ACCOUNT_LOGE("SetExecutorPropertyCallbackInterface is nullptr");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
SetPropertyRequest request = {
.authType = static_cast<AuthType>(authType),
@ -509,12 +509,12 @@ ErrCode AccountIAMMgrStub::ProcGetAccountState(MessageParcel &data, MessageParce
int32_t userId;
if (!data.ReadInt32(userId)) {
ACCOUNT_LOGE("failed to read userId");
return ERR_ACCOUNT_IAM_SERVICE_READ_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_READ_PARCEL_ERROR;
}
IAMState state = GetAccountState(userId);
if (!reply.WriteInt32(state)) {
ACCOUNT_LOGE("failed to write state");
return ERR_ACCOUNT_IAM_SERVICE_WRITE_PARCEL_FAIL;
return ERR_ACCOUNT_COMMON_WRITE_PARCEL_ERROR;
}
return ERR_NONE;
}

View File

@ -32,7 +32,7 @@ AccountIAMService::~AccountIAMService()
int32_t AccountIAMService::OpenSession(int32_t userId, std::vector<uint8_t> &challenge)
{
if ((userId == 0) && (!GetCurrentUserId(userId))) {
return ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR;
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
}
InnerAccountIAMManager::GetInstance().OpenSession(userId, challenge);
return ERR_OK;
@ -41,7 +41,7 @@ int32_t AccountIAMService::OpenSession(int32_t userId, std::vector<uint8_t> &cha
int32_t AccountIAMService::CloseSession(int32_t userId)
{
if ((userId == 0) && (!GetCurrentUserId(userId))) {
return ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR;
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
}
InnerAccountIAMManager::GetInstance().CloseSession(userId);
return ERR_OK;
@ -52,7 +52,7 @@ void AccountIAMService::AddCredential(
{
Attributes emptyResult;
if ((userId == 0) && (!GetCurrentUserId(userId))) {
callback->OnResult(ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_INVALID_PARAMETER, emptyResult);
return;
}
InnerAccountIAMManager::GetInstance().AddCredential(userId, credInfo, callback);
@ -63,7 +63,7 @@ void AccountIAMService::UpdateCredential(int32_t userId, const CredentialParamet
{
Attributes emptyResult;
if ((userId == 0) && (!GetCurrentUserId(userId))) {
callback->OnResult(ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_INVALID_PARAMETER, emptyResult);
return;
}
InnerAccountIAMManager::GetInstance().UpdateCredential(userId, credInfo, callback);
@ -72,7 +72,7 @@ void AccountIAMService::UpdateCredential(int32_t userId, const CredentialParamet
int32_t AccountIAMService::Cancel(int32_t userId)
{
if ((userId == 0) && (!GetCurrentUserId(userId))) {
return ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR;
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
}
return InnerAccountIAMManager::GetInstance().Cancel(userId);
}
@ -82,7 +82,7 @@ void AccountIAMService::DelCred(
{
Attributes emptyResult;
if ((userId == 0) && (!GetCurrentUserId(userId))) {
callback->OnResult(ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_INVALID_PARAMETER, emptyResult);
return;
}
InnerAccountIAMManager::GetInstance().DelCred(userId, credentialId, authToken, callback);
@ -93,7 +93,7 @@ void AccountIAMService::DelUser(
{
Attributes emptyResult;
if ((userId == 0) && (!GetCurrentUserId(userId))) {
callback->OnResult(ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_INVALID_PARAMETER, emptyResult);
return;
}
InnerAccountIAMManager::GetInstance().DelUser(userId, authToken, callback);
@ -103,7 +103,7 @@ int32_t AccountIAMService::GetCredentialInfo(
int32_t userId, AuthType authType, const sptr<IGetCredInfoCallback> &callback)
{
if ((userId == 0) && (!GetCurrentUserId(userId))) {
return ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR;
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
}
InnerAccountIAMManager::GetInstance().GetCredentialInfo(userId, authType, callback);
return ERR_OK;
@ -113,7 +113,7 @@ int32_t AccountIAMService::AuthUser(
int32_t userId, const AuthParam &authParam, const sptr<IIDMCallback> &callback, uint64_t &contextId)
{
if ((userId == 0) && (!GetCurrentUserId(userId))) {
return ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR;
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
}
return InnerAccountIAMManager::GetInstance().AuthUser(userId, authParam, callback, contextId);
}
@ -127,11 +127,11 @@ int32_t AccountIAMService::GetAvailableStatus(AuthType authType, AuthTrustLevel
{
if (authTrustLevel < UserIam::UserAuth::ATL1 || authTrustLevel > UserIam::UserAuth::ATL4) {
ACCOUNT_LOGE("authTrustLevel is not in correct range");
return ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR;
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
}
if (authType < UserIam::UserAuth::ALL) {
ACCOUNT_LOGE("authType is not in correct range");
return ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR;
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
}
return InnerAccountIAMManager::GetInstance().GetAvailableStatus(authType, authTrustLevel, status);
}
@ -141,7 +141,7 @@ void AccountIAMService::GetProperty(
{
Attributes emptyResult;
if ((userId == 0) && (!GetCurrentUserId(userId))) {
callback->OnResult(ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_INVALID_PARAMETER, emptyResult);
return;
}
return InnerAccountIAMManager::GetInstance().GetProperty(userId, request, callback);
@ -152,7 +152,7 @@ void AccountIAMService::SetProperty(
{
Attributes emptyResult;
if ((userId == 0) && (!GetCurrentUserId(userId))) {
callback->OnResult(ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR, emptyResult);
callback->OnResult(ERR_ACCOUNT_COMMON_INVALID_PARAMETER, emptyResult);
return;
}
InnerAccountIAMManager::GetInstance().SetProperty(userId, request, callback);

View File

@ -460,7 +460,7 @@ ErrCode InnerAccountIAMManager::GetStorageManagerProxy()
auto systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (systemAbilityManager == nullptr) {
ACCOUNT_LOGE("failed to get system ability mgr");
return ERR_ACCOUNT_IAM_SERVICE_GET_STORAGE_SYSTEM_ABILITY;
return ERR_ACCOUNT_COMMON_GET_SYSTEM_ABILITY_MANAGER;
}
auto remote = systemAbilityManager->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
if (remote == nullptr) {

View File

@ -106,7 +106,7 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_OpenSession_0100, TestSize.Lev
{
std::vector<uint8_t> challenge;
int32_t res = accountIAMService_->OpenSession(0, challenge);
EXPECT_EQ(res, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(res, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
/**
@ -118,7 +118,7 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_OpenSession_0100, TestSize.Lev
HWTEST_F(AccountIamServiceTest, AccountIAMService_CloseSession_0100, TestSize.Level0)
{
int32_t res = accountIAMService_->CloseSession(0);
EXPECT_EQ(res, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(res, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
/**
@ -133,7 +133,7 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_AddCredential_0100, TestSize.L
sptr<MockIIDMCallback> callback = new (std::nothrow) MockIIDMCallback();
ASSERT_NE(callback, nullptr);
accountIAMService_->AddCredential(0, creInfo, callback);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
/**
@ -148,7 +148,7 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_UpdateCredential_0100, TestSiz
sptr<MockIIDMCallback> callback = new (std::nothrow) MockIIDMCallback();
ASSERT_NE(callback, nullptr);
accountIAMService_->UpdateCredential(0, creInfo, callback);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
/**
@ -160,7 +160,7 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_UpdateCredential_0100, TestSiz
HWTEST_F(AccountIamServiceTest, AccountIAMService_Cancel_0100, TestSize.Level0)
{
int32_t res = accountIAMService_->Cancel(0);
EXPECT_EQ(res, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(res, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
/**
@ -175,7 +175,7 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_DelCred_0100, TestSize.Level0)
sptr<MockIIDMCallback> callback = new (std::nothrow) MockIIDMCallback();
ASSERT_NE(callback, nullptr);
accountIAMService_->DelCred(0, 0, token, callback);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
/**
@ -190,7 +190,7 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_DelUser_0100, TestSize.Level0)
sptr<MockIIDMCallback> callback = new (std::nothrow) MockIIDMCallback();
ASSERT_NE(callback, nullptr);
accountIAMService_->DelUser(0, token, callback);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
/**
@ -204,7 +204,7 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_GetCredentialInfo_0100, TestSi
sptr<MockGetCredInfoCallback> callback = new (std::nothrow) MockGetCredInfoCallback();
ASSERT_NE(callback, nullptr);
int32_t res = accountIAMService_->GetCredentialInfo(0, AuthType::PIN, callback);
EXPECT_EQ(res, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(res, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
/**
@ -225,7 +225,7 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_AuthUser_0100, TestSize.Level0
};
uint64_t contextId = 0;
ErrCode res = accountIAMService_->AuthUser(0, authParam, callback, contextId);
EXPECT_EQ(res, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(res, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
/**
@ -238,9 +238,9 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_GetAvailableStatus_0100, TestS
{
int32_t status;
int32_t res = accountIAMService_->GetAvailableStatus(static_cast<AuthType>(-1), AuthTrustLevel::ATL1, status);
EXPECT_EQ(res, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(res, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
res = accountIAMService_->GetAvailableStatus(AuthType::PIN, static_cast<AuthTrustLevel>(0), status);
EXPECT_EQ(res, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(res, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
/**
@ -255,7 +255,7 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_GetProperty_0100, TestSize.Lev
sptr<MockGetSetPropCallback> callback = new (std::nothrow) MockGetSetPropCallback();
ASSERT_NE(callback, nullptr);
accountIAMService_->GetProperty(0, request, callback);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
/**
@ -270,7 +270,7 @@ HWTEST_F(AccountIamServiceTest, AccountIAMService_SetProperty_0100, TestSize.Lev
sptr<MockGetSetPropCallback> callback = new (std::nothrow) MockGetSetPropCallback();
ASSERT_NE(callback, nullptr);
accountIAMService_->SetProperty(0, request, callback);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_IAM_SERVICE_PARAM_INVALID_ERROR);
EXPECT_EQ(callback->result_, ERR_ACCOUNT_COMMON_INVALID_PARAMETER);
}
} // namespace AccountTest
} // namespace OHOS