mirror of
https://gitee.com/openharmony/account_os_account
synced 2024-11-23 02:00:01 +00:00
Merge branch 'master' of gitee.com:openharmony/account_os_account into master
Signed-off-by: lichenchen <lichenchen22@huawei.com>
This commit is contained in:
commit
81cea1e017
@ -96,7 +96,7 @@ public:
|
||||
ErrCode SetAuthenticatorProperties(const std::string &owner, const SetPropertiesOptions &options,
|
||||
const sptr<IAppAccountAuthenticatorCallback> &callback) override;
|
||||
ErrCode SubscribeAppAccount(
|
||||
const AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) override;
|
||||
AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) override;
|
||||
ErrCode UnsubscribeAppAccount(const sptr<IRemoteObject> &eventListener) override;
|
||||
|
||||
private:
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
const sptr<IAppAccountAuthenticatorCallback> &callback) = 0;
|
||||
|
||||
virtual ErrCode SubscribeAppAccount(
|
||||
const AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) = 0;
|
||||
AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) = 0;
|
||||
virtual ErrCode UnsubscribeAppAccount(const sptr<IRemoteObject> &eventListener) = 0;
|
||||
};
|
||||
} // namespace AccountSA
|
||||
|
@ -1071,7 +1071,7 @@ ErrCode AppAccountProxy::SetAuthenticatorProperties(const std::string &owner,
|
||||
}
|
||||
|
||||
ErrCode AppAccountProxy::SubscribeAppAccount(
|
||||
const AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener)
|
||||
AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
const sptr<IAppAccountAuthenticatorCallback> &callback) override;
|
||||
|
||||
ErrCode SubscribeAppAccount(
|
||||
const AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) override;
|
||||
AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) override;
|
||||
ErrCode UnsubscribeAppAccount(const sptr<IRemoteObject> &eventListener) override;
|
||||
|
||||
virtual ErrCode OnPackageRemoved(const uid_t &uid, const std::string &bundleName, const uint32_t &appIndex);
|
||||
|
@ -665,7 +665,7 @@ ErrCode AppAccountManagerService::SetAuthenticatorProperties(const std::string &
|
||||
}
|
||||
|
||||
ErrCode AppAccountManagerService::SubscribeAppAccount(
|
||||
const AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener)
|
||||
AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener)
|
||||
{
|
||||
int32_t callingUid = -1;
|
||||
std::string bundleName;
|
||||
@ -683,16 +683,22 @@ ErrCode AppAccountManagerService::SubscribeAppAccount(
|
||||
}
|
||||
|
||||
int32_t userId = callingUid / UID_TRANSFORM_DIVISOR;
|
||||
std::vector<std::string> existOwners;
|
||||
for (auto owner : owners) {
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
bool bundleRet = BundleManagerAdapter::GetInstance()->GetBundleInfo(owner,
|
||||
AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, userId);
|
||||
if (!bundleRet) {
|
||||
ACCOUNT_LOGE("failed to get bundle info");
|
||||
return ERR_OK;
|
||||
ACCOUNT_LOGE("Failed to get bundle info, name=%{public}s", owner.c_str());
|
||||
continue;
|
||||
}
|
||||
existOwners.push_back(owner);
|
||||
}
|
||||
|
||||
if (existOwners.size() == 0) {
|
||||
ACCOUNT_LOGI("ExistOwners is empty.");
|
||||
return ERR_OK;
|
||||
}
|
||||
subscribeInfo.SetOwners(existOwners);
|
||||
return innerManager_->SubscribeAppAccount(subscribeInfo, eventListener, callingUid, bundleName, appIndex);
|
||||
}
|
||||
|
||||
|
@ -1865,6 +1865,7 @@ ErrCode IInnerOsAccountManager::DeactivateOsAccount(const int id, bool isStopSto
|
||||
OsAccountInterface::PublishCommonEvent(osAccountInfo, OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_STOPPED,
|
||||
Constants::OPERATION_STOP);
|
||||
subscribeManager_.Publish(id, OS_ACCOUNT_SUBSCRIBE_TYPE::STOPPED);
|
||||
ReportOsAccountLifeCycle(id, Constants::OPERATION_STOP);
|
||||
|
||||
RemoveLocalIdToOperating(id);
|
||||
ACCOUNT_LOGI("IInnerOsAccountManager DeactivateOsAccount end");
|
||||
@ -1878,6 +1879,7 @@ ErrCode IInnerOsAccountManager::SendMsgForAccountActivate(OsAccountInfo &osAccou
|
||||
int32_t oldId = -1;
|
||||
bool oldIdExist = foregroundAccountMap_.Find(displayId, oldId);
|
||||
int32_t localId = static_cast<int32_t>(osAccountInfo.GetLocalId());
|
||||
bool preActivated = osAccountInfo.GetIsActived();
|
||||
if (oldId != localId) {
|
||||
subscribeManager_.Publish(localId, oldId, OS_ACCOUNT_SUBSCRIBE_TYPE::SWITCHING);
|
||||
}
|
||||
@ -1912,6 +1914,9 @@ ErrCode IInnerOsAccountManager::SendMsgForAccountActivate(OsAccountInfo &osAccou
|
||||
subscribeManager_.Publish(localId, oldId, OS_ACCOUNT_SUBSCRIBE_TYPE::SWITCHED);
|
||||
ReportOsAccountSwitch(localId, oldId);
|
||||
}
|
||||
if (!preActivated) {
|
||||
ReportOsAccountLifeCycle(defaultActivatedId_, Constants::OPERATION_ACTIVATE);
|
||||
}
|
||||
ACCOUNT_LOGI("SendMsgForAccountActivate ok");
|
||||
return errCode;
|
||||
}
|
||||
@ -1936,6 +1941,7 @@ ErrCode IInnerOsAccountManager::SendToStorageAccountStart(OsAccountInfo &osAcco
|
||||
OsAccountInterface::PublishCommonEvent(osAccountInfo,
|
||||
OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_UNLOCKED, Constants::OPERATION_UNLOCK);
|
||||
subscribeManager_.Publish(localId, OS_ACCOUNT_SUBSCRIBE_TYPE::UNLOCKED);
|
||||
ReportOsAccountLifeCycle(localId, Constants::OPERATION_UNLOCK);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -2088,6 +2094,7 @@ ErrCode IInnerOsAccountManager::SetOsAccountIsVerified(const int id, const bool
|
||||
OsAccountInterface::PublishCommonEvent(osAccountInfo,
|
||||
OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_UNLOCKED, Constants::OPERATION_UNLOCK);
|
||||
subscribeManager_.Publish(id, OS_ACCOUNT_SUBSCRIBE_TYPE::UNLOCKED);
|
||||
ReportOsAccountLifeCycle(id, Constants::OPERATION_UNLOCK);
|
||||
|
||||
CleanGarbageOsAccountsAsync();
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ ErrCode OsAccountInterface::SendToStorageAccountCreate(OsAccountInfo &osAccountI
|
||||
int32_t retryTimes = 0;
|
||||
while (retryTimes < MAX_RETRY_TIMES) {
|
||||
errCode = InnerSendToStorageAccountCreate(osAccountInfo);
|
||||
if (errCode == ERR_OK) {
|
||||
if (errCode != Constants::E_IPC_ERROR && errCode != Constants::E_IPC_SA_DIED) {
|
||||
break;
|
||||
}
|
||||
ACCOUNT_LOGE("Fail to SendToStorageAccountCreate,id=%{public}d, errCode %{public}d.",
|
||||
@ -343,7 +343,7 @@ ErrCode OsAccountInterface::SendToStorageAccountCreate(OsAccountInfo &osAccountI
|
||||
}
|
||||
|
||||
#ifdef HAS_STORAGE_PART
|
||||
static ErrCode PrepareAddUser(sptr<StorageManager::IStorageManager> &proxy, int32_t userId)
|
||||
static ErrCode PrepareAddUser(const sptr<StorageManager::IStorageManager> &proxy, int32_t userId)
|
||||
{
|
||||
ErrCode err = proxy->PrepareAddUser(userId, CRYPTO_FLAG_EL1 | CRYPTO_FLAG_EL2);
|
||||
if (err == 0) {
|
||||
@ -383,18 +383,20 @@ ErrCode OsAccountInterface::InnerSendToStorageAccountCreate(OsAccountInfo &osAcc
|
||||
return ERR_ACCOUNT_COMMON_GET_SYSTEM_ABILITY_MANAGER;
|
||||
}
|
||||
StartTraceAdapter("StorageManager PrepareAddUser");
|
||||
|
||||
ErrCode err = PrepareAddUser(proxy, localId);
|
||||
if (err == ERR_OK) {
|
||||
FinishTraceAdapter();
|
||||
return ERR_OK;
|
||||
}
|
||||
ACCOUNT_LOGI("PrepareAddUser Failed, start check and clear accounts.");
|
||||
|
||||
ACCOUNT_LOGI("PrepareAddUser Failed, start check and clean accounts.");
|
||||
auto &osAccountManager = IInnerOsAccountManager::GetInstance();
|
||||
if (osAccountManager.CleanGarbageOsAccounts(localId) <= 0) {
|
||||
FinishTraceAdapter();
|
||||
return err;
|
||||
}
|
||||
ACCOUNT_LOGI("Clean garbage account data, Retry storage PrepareAddUser.");
|
||||
ACCOUNT_LOGI("Clean garbage account data, Retry Storage PrepareAddUser.");
|
||||
err = PrepareAddUser(proxy, localId);
|
||||
FinishTraceAdapter();
|
||||
return err;
|
||||
|
@ -1155,6 +1155,14 @@ ErrCode OsAccountManagerService::GetBackgroundOsAccountLocalIds(std::vector<int3
|
||||
|
||||
ErrCode OsAccountManagerService::SetOsAccountToBeRemoved(int32_t localId, bool toBeRemoved)
|
||||
{
|
||||
ErrCode res = CheckLocalId(localId);
|
||||
if (res != ERR_OK) {
|
||||
return res;
|
||||
}
|
||||
if ((localId == Constants::START_USER_ID) || (localId == Constants::ADMIN_LOCAL_ID)) {
|
||||
ACCOUNT_LOGE("Cannot remove system preinstalled user.");
|
||||
return ERR_OSACCOUNT_SERVICE_MANAGER_ID_ERROR;
|
||||
}
|
||||
if (!PermissionCheck(MANAGE_LOCAL_ACCOUNTS, "")) {
|
||||
ACCOUNT_LOGE("Permission denied.");
|
||||
return ERR_ACCOUNT_COMMON_PERMISSION_DENIED;
|
||||
|
@ -364,7 +364,7 @@ ErrCode MockAppAccountStub::SetAuthenticatorProperties(const std::string &owner,
|
||||
}
|
||||
|
||||
ErrCode MockAppAccountStub::SubscribeAppAccount(
|
||||
const AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener)
|
||||
AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener)
|
||||
{
|
||||
ACCOUNT_LOGI("mock enter");
|
||||
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
const sptr<IAppAccountAuthenticatorCallback> &callback) override;
|
||||
|
||||
ErrCode SubscribeAppAccount(
|
||||
const AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) override;
|
||||
AppAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) override;
|
||||
ErrCode UnsubscribeAppAccount(const sptr<IRemoteObject> &eventListener) override;
|
||||
};
|
||||
} // namespace AccountSA
|
||||
|
Loading…
Reference in New Issue
Block a user