mirror of
https://gitee.com/openharmony/account_os_account
synced 2024-11-23 10:10:11 +00:00
commit
2f13af0102
@ -45,6 +45,7 @@ constexpr uint32_t APP_INDEX = 0;
|
||||
constexpr uint32_t MAX_TOKEN_NUMBER = 128;
|
||||
constexpr uint32_t MAX_OAUTH_LIST_SIZE = 512;
|
||||
constexpr uint32_t MAX_ASSOCIATED_DATA_NUMBER = 1024;
|
||||
constexpr uint32_t MAX_APP_AUTH_LIST_SIZE = 1024;
|
||||
#ifdef HAS_ASSET_PART
|
||||
constexpr uint32_t HASH_LENGTH = 32;
|
||||
constexpr uint32_t WIDTH_FOR_HEX = 2;
|
||||
@ -158,6 +159,12 @@ ErrCode AppAccountInfo::EnableAppAccess(const std::string &authorizedApp, const
|
||||
if (!it.second && apiVersion < Constants::API_VERSION9) {
|
||||
return ERR_APPACCOUNT_SERVICE_ENABLE_APP_ACCESS_ALREADY_EXISTS;
|
||||
}
|
||||
if (authorizedApps_.size() > MAX_APP_AUTH_LIST_SIZE) {
|
||||
ACCOUNT_LOGE("the authorization list is too large, whose capacity for each authType is %{public}d",
|
||||
MAX_OAUTH_LIST_SIZE);
|
||||
authorizedApps_.erase(authorizedApp);
|
||||
return ERR_APPACCOUNT_SERVICE_OAUTH_LIST_MAX_SIZE;
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -351,10 +351,9 @@ ErrCode AppAccountControlManager::EnableAppAccess(const std::string &name, const
|
||||
|
||||
result = appAccountInfo.EnableAppAccess(authorizedApp, apiVersion);
|
||||
if (result != ERR_OK) {
|
||||
ACCOUNT_LOGE("failed to enable app access, result %{public}d.", result);
|
||||
return ERR_APPACCOUNT_SERVICE_ENABLE_APP_ACCESS_ALREADY_EXISTS;
|
||||
ACCOUNT_LOGE("Failed to enable app access, result=%{public}d.", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = SaveAccountInfoIntoDataStorage(appAccountInfo, dataStoragePtr, appAccountCallingInfo.callingUid);
|
||||
if (result != ERR_OK) {
|
||||
ACCOUNT_LOGE("failed to save account info into data storage, result %{public}d.", result);
|
||||
@ -364,7 +363,7 @@ ErrCode AppAccountControlManager::EnableAppAccess(const std::string &name, const
|
||||
// save authorized account into data storage
|
||||
result = SaveAuthorizedAccount(authorizedApp, appAccountInfo, dataStoragePtr, appAccountCallingInfo.callingUid);
|
||||
if (result != ERR_OK) {
|
||||
ACCOUNT_LOGE("failed to save authorized account into data storage, result %{public}d.", result);
|
||||
ACCOUNT_LOGE("Failed to save authorized account into data storage, result=%{public}d.", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -153,16 +153,9 @@ ErrCode AppAccountManagerService::EnableAppAccess(
|
||||
if (result != ERR_OK) {
|
||||
return result;
|
||||
}
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
int32_t userId = appAccountCallingInfo.callingUid / UID_TRANSFORM_DIVISOR;
|
||||
bool bundleRet = BundleManagerAdapter::GetInstance()->GetBundleInfo(
|
||||
authorizedApp, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, userId);
|
||||
if (!bundleRet) {
|
||||
ACCOUNT_LOGE("failed to get bundle info");
|
||||
return ERR_APPACCOUNT_SERVICE_GET_BUNDLE_INFO;
|
||||
}
|
||||
|
||||
if (authorizedApp == appAccountCallingInfo.bundleName) {
|
||||
ACCOUNT_LOGE("authorizedApp is the same to owner");
|
||||
ACCOUNT_LOGE("AuthorizedApp is the same to owner.");
|
||||
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -178,21 +171,10 @@ ErrCode AppAccountManagerService::DisableAppAccess(
|
||||
if (ret != ERR_OK) {
|
||||
return ret;
|
||||
}
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
|
||||
int32_t userId = appAccountCallingInfo.callingUid / UID_TRANSFORM_DIVISOR;
|
||||
bool bundleRet = BundleManagerAdapter::GetInstance()->GetBundleInfo(
|
||||
authorizedApp, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, userId);
|
||||
if (!bundleRet) {
|
||||
ACCOUNT_LOGE("failed to get bundle info");
|
||||
return ERR_APPACCOUNT_SERVICE_GET_BUNDLE_INFO;
|
||||
}
|
||||
|
||||
if (authorizedApp == appAccountCallingInfo.bundleName) {
|
||||
ACCOUNT_LOGE("authorizedApp is the same to owner");
|
||||
ACCOUNT_LOGE("AuthorizedApp is the same to owner.");
|
||||
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return innerManager_->DisableAppAccess(name, authorizedApp, appAccountCallingInfo);
|
||||
}
|
||||
|
||||
@ -208,23 +190,14 @@ ErrCode AppAccountManagerService::SetAppAccess(
|
||||
|
||||
if (authorizedApp == appAccountCallingInfo.bundleName) {
|
||||
if (isAccessible) {
|
||||
ACCOUNT_LOGI("authorizedApp name is the self, invalid operate.");
|
||||
ACCOUNT_LOGI("AuthorizedApp name is the self, invalid operate.");
|
||||
return ERR_OK;
|
||||
} else {
|
||||
ACCOUNT_LOGE("authorizedApp is the same to owner");
|
||||
ACCOUNT_LOGE("AuthorizedApp is the same to owner.");
|
||||
return ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if (isAccessible) {
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
int32_t userId = appAccountCallingInfo.callingUid / UID_TRANSFORM_DIVISOR;
|
||||
bool bundleRet = BundleManagerAdapter::GetInstance()->GetBundleInfo(
|
||||
authorizedApp, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, userId);
|
||||
if (!bundleRet) {
|
||||
ACCOUNT_LOGE("failed to get bundle info");
|
||||
return ERR_APPACCOUNT_SERVICE_GET_BUNDLE_INFO;
|
||||
}
|
||||
return innerManager_->EnableAppAccess(name, authorizedApp, appAccountCallingInfo, Constants::API_VERSION9);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user