• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_IOS_ACCOUNT_H
16 #define OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_IOS_ACCOUNT_H
17 #include <string>
18 #include "iremote_broker.h"
19 #include "iremote_object.h"
20 #include "os_account_info.h"
21 #include "account_error_no.h"
22 #include "os_account_constants.h"
23 #include "os_account_event_listener.h"
24 namespace OHOS {
25 namespace AccountSA {
26 class IOsAccount : public IRemoteBroker {
27 public:
28     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accountfwk.IOsAccount");
29 
30     virtual ErrCode CreateOsAccount(
31         const std::string &name, const OsAccountType &type, OsAccountInfo &osAccountInfo) = 0;
32     virtual ErrCode CreateOsAccountForDomain(
33         const OsAccountType &type, const DomainAccountInfo &domainInfo, OsAccountInfo &osAccountInfo) = 0;
34     virtual ErrCode RemoveOsAccount(const int id) = 0;
35     virtual ErrCode IsOsAccountExists(const int id, bool &isOsAccountExists) = 0;
36     virtual ErrCode IsOsAccountActived(const int id, bool &isOsAccountActived) = 0;
37     virtual ErrCode IsOsAccountConstraintEnable(
38         const int id, const std::string &constraint, bool &isConstraintEnable) = 0;
39     virtual ErrCode IsOsAccountVerified(const int id, bool &isVerified) = 0;
40     virtual ErrCode GetCreatedOsAccountsCount(unsigned int &osAccountsCount) = 0;
41     virtual ErrCode GetOsAccountLocalIdFromProcess(int &id) = 0;
42     virtual ErrCode GetOsAccountLocalIdFromDomain(const DomainAccountInfo &domainInfo, int &id) = 0;
43     virtual ErrCode QueryMaxOsAccountNumber(int &maxOsAccountNumber) = 0;
44     virtual ErrCode GetOsAccountAllConstraints(const int id, std::vector<std::string> &constraints) = 0;
45     virtual ErrCode QueryAllCreatedOsAccounts(std::vector<OsAccountInfo> &osAccountInfos) = 0;
46     virtual ErrCode QueryCurrentOsAccount(OsAccountInfo &osAccountInfo) = 0;
47     virtual ErrCode QueryOsAccountById(const int id, OsAccountInfo &osAccountInfo) = 0;
48     virtual ErrCode GetOsAccountTypeFromProcess(OsAccountType &type) = 0;
49     virtual ErrCode GetOsAccountProfilePhoto(const int id, std::string &photo) = 0;
50     virtual ErrCode IsMultiOsAccountEnable(bool &isMultiOsAccountEnable) = 0;
51     virtual ErrCode SetOsAccountName(const int id, const std::string &localName) = 0;
52     virtual ErrCode SetOsAccountConstraints(
53         const int id, const std::vector<std::string> &constraints, const bool enable) = 0;
54     virtual ErrCode SetOsAccountProfilePhoto(const int id, const std::string &photo) = 0;
55     virtual ErrCode ActivateOsAccount(const int id) = 0;
56     virtual ErrCode StartOsAccount(const int id) = 0;
57     virtual ErrCode StopOsAccount(const int id) = 0;
58     virtual ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id) = 0;
59     virtual ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber) = 0;
60     virtual ErrCode SubscribeOsAccount(
61         const OsAccountSubscribeInfo &subscribeInfo, const sptr<IRemoteObject> &eventListener) = 0;
62     virtual ErrCode UnsubscribeOsAccount(const sptr<IRemoteObject> &eventListener) = 0;
63     virtual OS_ACCOUNT_SWITCH_MOD GetOsAccountSwitchMod() = 0;
64     virtual ErrCode IsCurrentOsAccountVerified(bool &isVerified) = 0;
65     virtual ErrCode IsOsAccountCompleted(const int id, bool &isOsAccountCompleted) = 0;
66     virtual ErrCode SetCurrentOsAccountIsVerified(const bool isVerified) = 0;
67     virtual ErrCode SetOsAccountIsVerified(const int id, const bool isVerified) = 0;
68     virtual ErrCode DumpState(const int &id, std::vector<std::string> &state) = 0;
69 
70     virtual void CreateBasicAccounts() = 0;
71     virtual ErrCode GetCreatedOsAccountNumFromDatabase(const std::string& storeID,
72         int &createdOsAccountNum) = 0;
73     virtual ErrCode GetSerialNumberFromDatabase(const std::string& storeID, int64_t &serialNumber) = 0;
74     virtual ErrCode GetMaxAllowCreateIdFromDatabase(const std::string& storeID, int &id) = 0;
75     virtual ErrCode GetOsAccountFromDatabase(const std::string& storeID, const int id,
76         OsAccountInfo &osAccountInfo) = 0;
77     virtual ErrCode GetOsAccountListFromDatabase(const std::string& storeID,
78         std::vector<OsAccountInfo> &osAccountList) = 0;
79     virtual ErrCode QueryActiveOsAccountIds(std::vector<int32_t>& ids) = 0;
80 
81     enum class Message {
82         CREATE_OS_ACCOUNT = 0,
83         CREATE_OS_ACCOUNT_FOR_DOMAIN,
84         REMOVE_OS_ACCOUNT,
85         IS_OS_ACCOUNT_EXISTS,
86         IS_OS_ACCOUNT_ACTIVED,
87         IS_OS_ACCOUNT_CONSTRAINT_ENABLE,
88         IS_OS_ACCOUNT_VERIFIED,
89         GET_CREATED_OS_ACCOUNT_COUNT,
90         GET_OS_ACCOUNT_LOCAL_ID_FROM_PROCESS,
91         GET_OS_ACCOUNT_LOCAL_ID_FROM_DOMAIN,
92         QUERY_MAX_OS_ACCOUNT_NUMBER,
93         GET_OS_ACCOUNT_ALL_CONSTRAINTS,
94         QUERY_ALL_CREATED_OS_ACCOUNTS,
95         QUERY_CURRENT_OS_ACCOUNT,
96         QUERY_OS_ACCOUNT_BY_ID,
97         GET_OS_ACCOUNT_TYPE_FROM_PROCESS,
98         GET_OS_ACCOUNT_PROFILE_PHOTO,
99         IS_MULTI_OS_ACCOUNT_ENABLE,
100         SET_OS_ACCOUNT_NAME,
101         SET_OS_ACCOUNT_CONSTRAINTS,
102         SET_OS_ACCOUNT_PROFILE_PHOTO,
103         ACTIVATE_OS_ACCOUNT,
104         START_OS_ACCOUNT,
105         STOP_OS_ACCOUNT,
106         SUBSCRIBE_ACCOUNT,
107         UNSUBSCRIBE_ACCOUNT,
108         GET_OS_ACCOUNT_LOCAL_ID_FOR_SERIAL_NUMBER,
109         GET_SERIAL_NUMBER_FOR_OS_ACCOUNT,
110         GET_OS_ACCOUNT_SWITCH_MOD,
111         IS_CURRENT_OS_ACCOUNT_VERIFIED,
112         IS_OS_ACCOUNT_COMPLETED,
113         SET_CURRENT_OS_ACCOUNT_IS_VERIFIED,
114         SET_OS_ACCOUNT_IS_VERIFIED,
115         DUMP_STATE,
116         GET_CREATED_OS_ACCOUNT_NUM_FROM_DATABASE,
117         GET_SERIAL_NUM_FROM_DATABASE,
118         GET_MAX_ALLOW_CREATE_ID_FROM_DATABASE,
119         GET_OS_ACCOUNT_FROM_DATABASE,
120         GET_OS_ACCOUNT_LIST_FROM_DATABASE,
121         QUERY_ACTIVE_OS_ACCOUNT_IDS,
122     };
123 };
124 }  // namespace AccountSA
125 }  // namespace OHOS
126 #endif  // OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_IOS_ACCOUNT_H
127