• 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_INTERFACES_INNERKITS_OS_ACCOUNT_MANAGER_H
16 #define OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_MANAGER_H
17 
18 #include <string>
19 #include <vector>
20 #include "os_account_info.h"
21 #include "os_account_subscriber.h"
22 #include "account_error_no.h"
23 namespace OHOS {
24 namespace AccountSA {
25 class OsAccountManager {
26 public:
27     static ErrCode CreateOsAccount(const std::string &name, const OsAccountType &type, OsAccountInfo &osAccountInfo);
28     static ErrCode CreateOsAccountForDomain(
29         const OsAccountType &type, const DomainAccountInfo &domainInfo, OsAccountInfo &osAccountInfo);
30     static ErrCode RemoveOsAccount(const int id);
31     static ErrCode IsOsAccountExists(const int id, bool &isOsAccountExists);
32     static ErrCode IsOsAccountActived(const int id, bool &isOsAccountActived);
33     static ErrCode IsOsAccountConstraintEnable(const int id, const std::string &constraint, bool &isConstraintEnable);
34     static ErrCode IsOsAccountVerified(const int id, bool &isVerified);
35     static ErrCode GetCreatedOsAccountsCount(unsigned int &osAccountsCount);
36     static ErrCode GetOsAccountLocalIdFromProcess(int &id);
37     static ErrCode GetOsAccountLocalIdFromUid(const int uid, int &id);
38     static ErrCode GetOsAccountLocalIdFromDomain(const DomainAccountInfo &domainInfo, int &id);
39     static ErrCode QueryMaxOsAccountNumber(int &maxOsAccountNumber);
40     static ErrCode GetOsAccountAllConstraints(const int id, std::vector<std::string> &constraints);
41     static ErrCode QueryAllCreatedOsAccounts(std::vector<OsAccountInfo> &osAccountInfos);
42     static ErrCode QueryCurrentOsAccount(OsAccountInfo &osAccountInfo);
43     static ErrCode QueryOsAccountById(const int id, OsAccountInfo &osAccountInfo);
44     static ErrCode GetOsAccountTypeFromProcess(OsAccountType &type);
45     static ErrCode GetOsAccountProfilePhoto(const int id, std::string &photo);
46     static ErrCode IsMultiOsAccountEnable(bool &isMultiOsAccountEnable);
47     static ErrCode SetOsAccountName(const int id, const std::string &localName);
48     static ErrCode SetOsAccountConstraints(
49         const int id, const std::vector<std::string> &constraints, const bool enable);
50     static ErrCode SetOsAccountProfilePhoto(const int id, const std::string &photo);
51     static ErrCode GetDistributedVirtualDeviceId(std::string &deviceId);
52     static ErrCode ActivateOsAccount(const int id);
53     static ErrCode StartOsAccount(const int id);
54     static ErrCode StopOsAccount(const int id);
55     static ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id);
56     static ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber);
57     static ErrCode SubscribeOsAccount(const std::shared_ptr<OsAccountSubscriber> &subscriber);
58     static ErrCode UnsubscribeOsAccount(const std::shared_ptr<OsAccountSubscriber> &subscriber);
59     static OS_ACCOUNT_SWITCH_MOD GetOsAccountSwitchMod();
60     static ErrCode IsCurrentOsAccountVerified(bool &isVerified);
61     static ErrCode IsOsAccountCompleted(const int id, bool &isOsAccountCompleted);
62     static ErrCode SetCurrentOsAccountIsVerified(const bool isVerified);
63     static ErrCode SetOsAccountIsVerified(const int id, const bool isVerified);
64 
65     static ErrCode GetCreatedOsAccountNumFromDatabase(const std::string& storeID, int &createdOsAccountNum);
66     static ErrCode GetSerialNumberFromDatabase(const std::string& storeID, int64_t &serialNumber);
67     static ErrCode GetMaxAllowCreateIdFromDatabase(const std::string& storeID, int &id);
68     static ErrCode GetOsAccountFromDatabase(const std::string& storeID,
69                                             const int id,
70                                             OsAccountInfo &osAccountInfo);
71     static ErrCode GetOsAccountListFromDatabase(const std::string& storeID,
72                                                 std::vector<OsAccountInfo> &osAccountList);
73     static ErrCode QueryActiveOsAccountIds(std::vector<int32_t>& ids);
74 };
75 }  // namespace AccountSA
76 }  // namespace OHOS
77 #endif  // OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_MANAGER_H
78