1 /* 2 * Copyright (c) 2021-2023 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 #ifndef OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_IOS_ACCOUNT_CONTROL_H 16 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_IOS_ACCOUNT_CONTROL_H 17 #include "os_account_info.h" 18 #include "account_error_no.h" 19 #include <stdint.h> 20 namespace OHOS { 21 namespace AccountSA { 22 struct OsAccountConfig { 23 uint32_t maxOsAccountNum = 999; 24 uint32_t maxLoggedInOsAccountNum = 999; 25 }; 26 27 class IOsAccountControl { 28 public: 29 virtual void Init() = 0; 30 virtual ErrCode GetOsAccountConfig(OsAccountConfig &config) = 0; 31 virtual ErrCode GetOsAccountList(std::vector<OsAccountInfo> &osAccountList) = 0; 32 virtual ErrCode GetOsAccountIdList(std::vector<int32_t> &idList) = 0; 33 virtual ErrCode GetOsAccountInfoById(const int id, OsAccountInfo &osAccountInfo) = 0; 34 virtual ErrCode GetConstraintsByType(const OsAccountType type, std::vector<std::string> &constraints) = 0; 35 virtual ErrCode InsertOsAccount(OsAccountInfo &osAccountInfo) = 0; 36 virtual ErrCode DelOsAccount(const int id) = 0; 37 virtual ErrCode UpdateOsAccount(OsAccountInfo &osAccountInfo) = 0; 38 virtual ErrCode GetAccountIndexFromFile(Json &accountIndexJson) = 0; 39 virtual ErrCode GetSerialNumber(int64_t &serialNumber) = 0; 40 virtual ErrCode GetAllowCreateId(int &id) = 0; 41 virtual ErrCode IsOsAccountExists(const int id, bool &isExists) = 0; 42 virtual ErrCode GetPhotoById(const int id, std::string &photo) = 0; 43 virtual ErrCode SetPhotoById(const int id, const std::string &photo) = 0; 44 virtual ErrCode GetIsMultiOsAccountEnable(bool &isMultiOsAccountEnable) = 0; 45 virtual ErrCode CheckConstraintsList(const std::vector<std::string> &constraints, 46 bool &isExists, bool &isOverSize) = 0; 47 virtual ErrCode IsAllowedCreateAdmin(bool &isAllowedCreateAdmin) = 0; 48 49 virtual ErrCode GetCreatedOsAccountNumFromDatabase(const std::string& storeID, 50 int &createdOsAccountNum) = 0; 51 virtual ErrCode GetSerialNumberFromDatabase(const std::string& storeID, 52 int64_t &serialNumber) = 0; 53 virtual ErrCode GetMaxAllowCreateIdFromDatabase(const std::string& storeID, int &id) = 0; 54 virtual ErrCode GetOsAccountFromDatabase(const std::string& storeID, 55 const int id, OsAccountInfo &osAccountInfo) = 0; 56 virtual ErrCode GetOsAccountListFromDatabase(const std::string& storeID, 57 std::vector<OsAccountInfo> &osAccountList) = 0; 58 59 virtual ErrCode RemoveOAConstraintsInfo(const int32_t id) = 0; 60 virtual ErrCode IsFromBaseOAConstraintsList(const int32_t id, const std::string constraint, bool &isExits) = 0; 61 virtual ErrCode IsFromGlobalOAConstraintsList(const int32_t id, const int32_t deviceOwnerId, 62 const std::string constraint, std::vector<ConstraintSourceTypeInfo> &globalSourceList) = 0; 63 virtual ErrCode IsFromSpecificOAConstraintsList(const int32_t id, const int32_t deviceOwnerId, 64 const std::string constraint, std::vector<ConstraintSourceTypeInfo> &specificSourceList) = 0; 65 virtual ErrCode GetGlobalOAConstraintsList(std::vector<std::string> &constraintsList) = 0; 66 virtual ErrCode GetSpecificOAConstraintsList(const int32_t id, std::vector<std::string> &constraintsList) = 0; 67 virtual ErrCode UpdateBaseOAConstraints(const std::string& idStr, 68 const std::vector<std::string>& ConstraintStr, bool isAdd) = 0; 69 virtual ErrCode UpdateGlobalOAConstraints(const std::string& idStr, 70 const std::vector<std::string>& ConstraintStr, bool isAdd) = 0; 71 virtual ErrCode UpdateSpecificOAConstraints(const std::string& idStr, 72 const std::string& targetIdStr, const std::vector<std::string>& ConstraintStr, bool isAdd) = 0; 73 virtual ErrCode GetDeviceOwnerId(int32_t &deviceOwnerId) = 0; 74 virtual ErrCode UpdateDeviceOwnerId(const int32_t deviceOwnerId) = 0; 75 virtual ErrCode SetDefaultActivatedOsAccount(const int32_t id) = 0; 76 virtual ErrCode GetDefaultActivatedOsAccount(int32_t &id) = 0; 77 virtual ErrCode UpdateAccountIndex(const OsAccountInfo &osAccountInfo, const bool isDelete) = 0; 78 virtual ErrCode SetNextLocalId(const int32_t &nextLocalId) = 0; 79 }; 80 } // namespace AccountSA 81 } // namespace OHOS 82 83 #endif // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_IOS_ACCOUNT_CONTROL_H 84