1 /* 2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_IOS_ACCOUNT_H 17 #define OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_IOS_ACCOUNT_H 18 19 #include <string> 20 #include "iremote_broker.h" 21 #include "iremote_object.h" 22 #include "os_account_info.h" 23 #include "accountmgr_service_ipc_interface_code.h" 24 #include "account_error_no.h" 25 #include "idomain_account_callback.h" 26 #include "os_account_constants.h" 27 #include "os_account_event_listener.h" 28 29 namespace OHOS { 30 namespace AccountSA { 31 class IOsAccount : public IRemoteBroker { 32 public: 33 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accountfwk.IOsAccount"); 34 35 virtual ErrCode CreateOsAccount( 36 const std::string &name, const OsAccountType &type, OsAccountInfo &osAccountInfo) = 0; 37 virtual ErrCode CreateOsAccount(const std::string &localName, const std::string &shortName, 38 const OsAccountType &type, OsAccountInfo &osAccountInfo, const CreateOsAccountOptions &options = {}) = 0; 39 virtual ErrCode CreateOsAccountWithFullInfo(OsAccountInfo &osAccountInfo, 40 const CreateOsAccountOptions &options = {}) = 0; 41 virtual ErrCode UpdateOsAccountWithFullInfo(OsAccountInfo &osAccountInfo) = 0; 42 virtual ErrCode CreateOsAccountForDomain(const OsAccountType &type, const DomainAccountInfo &domainInfo, 43 const sptr<IDomainAccountCallback> &callback, const CreateOsAccountForDomainOptions& options = {}) = 0; 44 virtual ErrCode RemoveOsAccount(const int id) = 0; 45 virtual ErrCode IsOsAccountExists(const int id, bool &isOsAccountExists) = 0; 46 virtual ErrCode IsOsAccountActived(const int id, bool &isOsAccountActived) = 0; 47 virtual ErrCode IsOsAccountConstraintEnable( 48 const int id, const std::string &constraint, bool &isConstraintEnable) = 0; 49 virtual ErrCode CheckOsAccountConstraintEnabled( 50 const int id, const std::string &constraint, bool &isEnabled) = 0; 51 virtual ErrCode IsOsAccountVerified(const int id, bool &isVerified) = 0; 52 virtual ErrCode IsOsAccountDeactivating(const int id, bool &isDeactivating) = 0; 53 virtual ErrCode GetCreatedOsAccountsCount(unsigned int &osAccountsCount) = 0; 54 virtual ErrCode GetOsAccountLocalIdFromProcess(int &id) = 0; 55 virtual ErrCode IsMainOsAccount(bool &isMainOsAccount) = 0; 56 virtual ErrCode GetOsAccountLocalIdFromDomain(const DomainAccountInfo &domainInfo, int &id) = 0; 57 virtual ErrCode QueryMaxOsAccountNumber(uint32_t &maxOsAccountNumber) = 0; 58 virtual ErrCode QueryMaxLoggedInOsAccountNumber(uint32_t &maxNum) = 0; 59 virtual ErrCode GetOsAccountAllConstraints(const int id, std::vector<std::string> &constraints) = 0; 60 virtual ErrCode QueryAllCreatedOsAccounts(std::vector<OsAccountInfo> &osAccountInfos) = 0; 61 virtual ErrCode QueryCurrentOsAccount(OsAccountInfo &osAccountInfo) = 0; 62 virtual ErrCode QueryOsAccountById(const int id, OsAccountInfo &osAccountInfo) = 0; 63 virtual ErrCode GetOsAccountTypeFromProcess(OsAccountType &type) = 0; 64 virtual ErrCode GetOsAccountType(const int id, OsAccountType& type) = 0; 65 virtual ErrCode GetOsAccountProfilePhoto(const int id, std::string &photo) = 0; 66 virtual ErrCode IsMultiOsAccountEnable(bool &isMultiOsAccountEnable) = 0; 67 virtual ErrCode SetOsAccountName(const int id, const std::string &localName) = 0; 68 virtual ErrCode SetOsAccountConstraints( 69 const int id, const std::vector<std::string> &constraints, const bool enable) = 0; 70 virtual ErrCode SetOsAccountProfilePhoto(const int id, const std::string &photo) = 0; 71 virtual ErrCode ActivateOsAccount(const int id) = 0; 72 virtual ErrCode DeactivateOsAccount(const int id) = 0; 73 virtual ErrCode DeactivateAllOsAccounts() = 0; 74 virtual ErrCode StartOsAccount(const int id) = 0; 75 virtual ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id) = 0; 76 virtual ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber) = 0; 77 virtual ErrCode SubscribeOsAccount( 78 const OsAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) = 0; 79 virtual ErrCode UnsubscribeOsAccount(const sptr<IRemoteObject> &eventListener) = 0; 80 virtual OS_ACCOUNT_SWITCH_MOD GetOsAccountSwitchMod() = 0; 81 virtual ErrCode IsCurrentOsAccountVerified(bool &isVerified) = 0; 82 virtual ErrCode IsOsAccountCompleted(const int id, bool &isOsAccountCompleted) = 0; 83 virtual ErrCode SetCurrentOsAccountIsVerified(const bool isVerified) = 0; 84 virtual ErrCode SetOsAccountIsVerified(const int id, const bool isVerified) = 0; 85 virtual ErrCode DumpState(const int &id, std::vector<std::string> &state) = 0; 86 87 virtual ErrCode GetCreatedOsAccountNumFromDatabase(const std::string& storeID, 88 int &createdOsAccountNum) = 0; 89 virtual ErrCode GetSerialNumberFromDatabase(const std::string& storeID, int64_t &serialNumber) = 0; 90 virtual ErrCode GetMaxAllowCreateIdFromDatabase(const std::string& storeID, int &id) = 0; 91 virtual ErrCode GetOsAccountFromDatabase(const std::string& storeID, const int id, 92 OsAccountInfo &osAccountInfo) = 0; 93 virtual ErrCode GetOsAccountListFromDatabase(const std::string& storeID, 94 std::vector<OsAccountInfo> &osAccountList) = 0; 95 virtual ErrCode QueryActiveOsAccountIds(std::vector<int32_t>& ids) = 0; 96 virtual ErrCode QueryOsAccountConstraintSourceTypes(const int32_t id, 97 const std::string &constraint, std::vector<ConstraintSourceTypeInfo> &constraintSourceTypeInfos) = 0; 98 virtual ErrCode SetGlobalOsAccountConstraints(const std::vector<std::string> &constraints, 99 const bool enable, const int32_t enforcerId, const bool isDeviceOwner) = 0; 100 virtual ErrCode SetSpecificOsAccountConstraints(const std::vector<std::string> &constraints, 101 const bool enable, const int32_t targetId, const int32_t enforcerId, const bool isDeviceOwner) = 0; 102 103 virtual ErrCode SetDefaultActivatedOsAccount(const int32_t id) = 0; 104 virtual ErrCode GetDefaultActivatedOsAccount(int32_t &id) = 0; 105 virtual ErrCode GetOsAccountShortName(std::string &shortName) = 0; 106 virtual ErrCode GetOsAccountName(std::string &name) = 0; 107 virtual ErrCode GetOsAccountShortNameById(const int32_t id, std::string &shortName) = 0; 108 virtual ErrCode IsOsAccountForeground(const int32_t localId, const uint64_t displayId, bool &isForeground) = 0; 109 virtual ErrCode GetForegroundOsAccountLocalId(const uint64_t displayId, int32_t &localId) = 0; 110 virtual ErrCode GetForegroundOsAccounts(std::vector<ForegroundOsAccount> &accounts) = 0; 111 virtual ErrCode GetBackgroundOsAccountLocalIds(std::vector<int32_t> &localIds) = 0; 112 virtual ErrCode SetOsAccountToBeRemoved(int32_t localId, bool toBeRemoved) = 0; 113 }; 114 } // namespace AccountSA 115 } // namespace OHOS 116 117 #endif // OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_IOS_ACCOUNT_H 118