/* * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_MANAGER_SERVICE_H #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_MANAGER_SERVICE_H #include #include #include #include "account_permission_manager.h" #include "os_account_stub.h" #include "idomain_account_callback.h" #include "iinner_os_account_manager.h" namespace OHOS { namespace AccountSA { class OsAccountManagerService : public OsAccountStub { public: OsAccountManagerService(); ~OsAccountManagerService() override; ErrCode CreateOsAccount( const std::string &name, const OsAccountType &type, OsAccountInfo &osAccountInfo) override; ErrCode CreateOsAccount(const std::string &localName, const std::string &shortName, const OsAccountType &type, OsAccountInfo &osAccountInfo, const CreateOsAccountOptions &options = {}) override; ErrCode CreateOsAccountForDomain(const OsAccountType &type, const DomainAccountInfo &domainInfo, const sptr &callback, const CreateOsAccountForDomainOptions &options = {}) override; ErrCode CreateOsAccountWithFullInfo(OsAccountInfo &osAccountInfo, const CreateOsAccountOptions &options = {}) override; ErrCode UpdateOsAccountWithFullInfo(OsAccountInfo &osAccountInfo) override; ErrCode RemoveOsAccount(const int id) override; ErrCode IsOsAccountExists(const int id, bool &isOsAccountExists) override; ErrCode IsOsAccountActived(const int id, bool &isOsAccountActived) override; ErrCode IsOsAccountConstraintEnable( const int id, const std::string &constraint, bool &isConstraintEnable) override; ErrCode CheckOsAccountConstraintEnabled( const int id, const std::string &constraint, bool &isEnabled) override; ErrCode IsOsAccountVerified(const int id, bool &isVerified) override; ErrCode IsOsAccountDeactivating(const int id, bool &isDeactivating) override; ErrCode GetCreatedOsAccountsCount(unsigned int &osAccountsCount) override; ErrCode GetOsAccountLocalIdFromProcess(int &id) override; ErrCode IsMainOsAccount(bool &isMainOsAccount) override; ErrCode GetOsAccountLocalIdFromDomain(const DomainAccountInfo &domainInfo, int &id) override; ErrCode QueryMaxOsAccountNumber(uint32_t &maxOsAccountNumber) override; ErrCode QueryMaxLoggedInOsAccountNumber(uint32_t &maxNum) override; ErrCode GetOsAccountAllConstraints(const int id, std::vector &constraints) override; ErrCode QueryAllCreatedOsAccounts(std::vector &osAccountInfos) override; ErrCode QueryCurrentOsAccount(OsAccountInfo &osAccountInfo) override; ErrCode QueryOsAccountById(const int id, OsAccountInfo &osAccountInfo) override; ErrCode GetOsAccountTypeFromProcess(OsAccountType& type) override; ErrCode GetOsAccountType(const int id, OsAccountType& type) override; ErrCode GetOsAccountProfilePhoto(const int id, std::string &photo) override; ErrCode IsMultiOsAccountEnable(bool &isMultiOsAccountEnable) override; ErrCode SetOsAccountName(const int id, const std::string &name) override; ErrCode SetOsAccountConstraints( const int id, const std::vector &constraints, const bool enable) override; ErrCode SetOsAccountProfilePhoto(const int id, const std::string &photo) override; ErrCode ActivateOsAccount(const int id) override; ErrCode DeactivateOsAccount(const int id) override; ErrCode DeactivateAllOsAccounts() override; ErrCode StartOsAccount(const int id) override; ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id) override; ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber) override; ErrCode SubscribeOsAccount( const OsAccountSubscribeInfo &subscribeInfo, const sptr &eventListener) override; ErrCode UnsubscribeOsAccount(const sptr &eventListener) override; OS_ACCOUNT_SWITCH_MOD GetOsAccountSwitchMod() override; ErrCode IsCurrentOsAccountVerified(bool &isVerified) override; ErrCode IsOsAccountCompleted(const int id, bool &isOsAccountCompleted) override; ErrCode SetCurrentOsAccountIsVerified(const bool isVerified) override; ErrCode SetOsAccountIsVerified(const int id, const bool isVerified) override; ErrCode DumpState(const int &id, std::vector &state) override; ErrCode DumpOsAccountInfo(std::vector &state); ErrCode GetCreatedOsAccountNumFromDatabase(const std::string& storeID, int &createdOsAccountNum) override; ErrCode GetSerialNumberFromDatabase(const std::string& storeID, int64_t &serialNumber) override; ErrCode GetMaxAllowCreateIdFromDatabase(const std::string& storeID, int &id) override; ErrCode GetOsAccountFromDatabase(const std::string& storeID, const int id, OsAccountInfo &osAccountInfo) override; ErrCode GetOsAccountListFromDatabase(const std::string& storeID, std::vector &osAccountList) override; ErrCode QueryActiveOsAccountIds(std::vector& ids) override; ErrCode QueryOsAccountConstraintSourceTypes(const int32_t id, const std::string &constraint, std::vector &constraintSourceTypeInfos) override; ErrCode SetGlobalOsAccountConstraints(const std::vector &constraints, const bool enable, const int32_t enforcerId, const bool isDeviceOwner) override; ErrCode SetSpecificOsAccountConstraints(const std::vector &constraints, const bool enable, const int32_t targetId, const int32_t enforcerId, const bool isDeviceOwner) override; ErrCode SetDefaultActivatedOsAccount(const int32_t id) override; ErrCode GetDefaultActivatedOsAccount(int32_t &id) override; ErrCode GetOsAccountShortName(std::string &shortName) override; ErrCode GetOsAccountName(std::string &name) override; ErrCode GetOsAccountShortNameById(const int32_t id, std::string &shortName) override; ErrCode IsOsAccountForeground(const int32_t localId, const uint64_t displayId, bool &isForeground) override; ErrCode GetForegroundOsAccountLocalId(const uint64_t displayId, int32_t &localId) override; ErrCode GetForegroundOsAccounts(std::vector &accounts) override; ErrCode GetBackgroundOsAccountLocalIds(std::vector &localIds) override; ErrCode SetOsAccountToBeRemoved(int32_t localId, bool toBeRemoved) override; private: virtual ErrCode DumpStateByAccounts( const std::vector &osAccountInfos, std::vector &state); bool PermissionCheck(const std::string& permissionName, const std::string& constraintName); bool CheckCreateOsAccountWhiteList(); ErrCode ValidateShortName(const std::string &shortName); void GetCurrentLocalId(int32_t &localId); ErrCode GetOsAccountShortNameCommon(const int32_t id, std::string &shortName); ErrCode ValidateAccountCreateParamAndPermission(const std::string &localName, const OsAccountType &type); private: IInnerOsAccountManager &innerManager_; DISALLOW_COPY_AND_MOVE(OsAccountManagerService); }; } // namespace AccountSA } // namespace OHOS #endif // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_MANAGER_SERVICE_H