• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "json_utils.h"
21 namespace OHOS {
22 namespace AccountSA {
23 struct OsAccountConfig {
24     uint32_t maxOsAccountNum = 999;
25     uint32_t maxLoggedInOsAccountNum = 999;
26 #ifdef ENABLE_U1_ACCOUNT
27     bool isU1Enable = false;
28     OsAccountType u1AccountType = OsAccountType::ADMIN;
29     std::string u1AccountName;
30     bool isBlockBoot = false;
31 #endif // ENABLE_U1_ACCOUNT
32 };
33 
34 class IOsAccountControl {
35 public:
36     virtual void Init() = 0;
37     virtual ErrCode GetOsAccountConfig(OsAccountConfig &config) = 0;
38     virtual ErrCode GetOsAccountList(std::vector<OsAccountInfo> &osAccountList) = 0;
39     virtual ErrCode GetOsAccountIdList(std::vector<int32_t> &idList) = 0;
40     virtual ErrCode GetOsAccountInfoById(const int id, OsAccountInfo &osAccountInfo) = 0;
41     virtual ErrCode GetConstraintsByType(const OsAccountType type, std::vector<std::string> &constraints) = 0;
42     virtual ErrCode InsertOsAccount(OsAccountInfo &osAccountInfo) = 0;
43     virtual ErrCode DelOsAccount(const int id) = 0;
44     virtual ErrCode UpdateOsAccount(OsAccountInfo &osAccountInfo) = 0;
45     virtual ErrCode GetAccountIndexFromFile(CJsonUnique &accountIndexJson) = 0;
46     virtual ErrCode GetSerialNumber(int64_t &serialNumber) = 0;
47     virtual ErrCode GetAllowCreateId(int &id) = 0;
48     virtual ErrCode IsOsAccountExists(const int id, bool &isExists) = 0;
49     virtual ErrCode GetPhotoById(const int id, std::string &photo) = 0;
50     virtual ErrCode SetPhotoById(const int id, const std::string &photo) = 0;
51     virtual ErrCode GetIsMultiOsAccountEnable(bool &isMultiOsAccountEnable) = 0;
52     virtual bool CheckConstraints(const std::vector<std::string> &constraints) = 0;
53     virtual ErrCode IsAllowedCreateAdmin(bool &isAllowedCreateAdmin) = 0;
54 
55     virtual ErrCode GetCreatedOsAccountNumFromDatabase(const std::string& storeID,
56         int &createdOsAccountNum) = 0;
57     virtual ErrCode GetSerialNumberFromDatabase(const std::string& storeID,
58         int64_t &serialNumber) = 0;
59     virtual ErrCode GetMaxAllowCreateIdFromDatabase(const std::string& storeID, int &id) = 0;
60     virtual ErrCode GetOsAccountFromDatabase(const std::string& storeID,
61         const int id, OsAccountInfo &osAccountInfo) = 0;
62     virtual ErrCode GetOsAccountListFromDatabase(const std::string& storeID,
63         std::vector<OsAccountInfo> &osAccountList) = 0;
64 
65     virtual ErrCode RemoveOAConstraintsInfo(const int32_t id) = 0;
66     virtual ErrCode IsFromBaseOAConstraintsList(const int32_t id, const std::string constraint, bool &isExits) = 0;
67     virtual ErrCode IsFromGlobalOAConstraintsList(const int32_t id, const int32_t deviceOwnerId,
68         const std::string constraint, std::vector<ConstraintSourceTypeInfo> &globalSourceList) = 0;
69     virtual ErrCode IsFromSpecificOAConstraintsList(const int32_t id, const int32_t deviceOwnerId,
70         const std::string constraint, std::vector<ConstraintSourceTypeInfo> &specificSourceList) = 0;
71     virtual ErrCode GetGlobalOAConstraintsList(std::vector<std::string> &constraintsList) = 0;
72     virtual ErrCode GetSpecificOAConstraintsList(const int32_t id, std::vector<std::string> &constraintsList) = 0;
73     virtual ErrCode UpdateBaseOAConstraints(const std::string& idStr,
74         const std::vector<std::string>& ConstraintStr, bool isAdd) = 0;
75     virtual ErrCode UpdateGlobalOAConstraints(const std::string& idStr,
76         const std::vector<std::string>& ConstraintStr, bool isAdd) = 0;
77     virtual ErrCode UpdateSpecificOAConstraints(const std::string& idStr,
78         const std::string& targetIdStr, const std::vector<std::string>& ConstraintStr, bool isAdd) = 0;
79     virtual ErrCode GetDeviceOwnerId(int32_t &deviceOwnerId) = 0;
80     virtual ErrCode UpdateDeviceOwnerId(const int32_t deviceOwnerId) = 0;
81     virtual ErrCode SetDefaultActivatedOsAccount(const int32_t id) = 0;
82     virtual ErrCode GetDefaultActivatedOsAccount(int32_t &id) = 0;
83     virtual ErrCode UpdateAccountIndex(const OsAccountInfo &osAccountInfo, const bool isDelete) = 0;
84     virtual ErrCode SetNextLocalId(const int32_t &nextLocalId) = 0;
85     virtual ErrCode SetDomainBoundFlag(
86         const int32_t localId, const bool flag, const DomainAccountInfo domainInfo = {}) = 0;
87     virtual ErrCode GetDomainBoundFlag(const int32_t localId, bool &flag, DomainAccountInfo &domainInfo) = 0;
88 };
89 }  // namespace AccountSA
90 }  // namespace OHOS
91 
92 #endif  // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_IOS_ACCOUNT_CONTROL_H
93