• 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 
16 #ifndef OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_INFO_H
17 #define OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_INFO_H
18 #include <vector>
19 #include "domain_account_common.h"
20 #include "iaccount_info.h"
21 #include "parcel.h"
22 namespace OHOS {
23 namespace AccountSA {
24 typedef enum {
25     ADMIN = 0,
26     NORMAL,
27     GUEST,
28     END, // the upper bound of OsAccountType.
29 } OsAccountType;
30 
31 typedef enum {
32     CONSTRAINT_NOT_EXIST = 0,
33     CONSTRAINT_TYPE_BASE,
34     CONSTRAINT_TYPE_DEVICE_OWNER,
35     CONSTRAINT_TYPE_PROFILE_OWNER,
36 } ConstraintSourceType;
37 
38 struct ConstraintSourceTypeInfo {
39     int32_t localId;
40     ConstraintSourceType typeInfo;
41 };
42 
43 struct CreateOsAccountOptions: public Parcelable {
44     std::vector<std::string> disallowedHapList = {};
45     bool ReadFromParcel(Parcel &parcel);
46     bool Marshalling(Parcel &parcel) const override;
47     static CreateOsAccountOptions *Unmarshalling(Parcel &parcel);
48 };
49 
50 class OsAccountInfo : public IAccountInfo, public Parcelable {
51 public:
52     OsAccountInfo();
53 
54     OsAccountInfo(int localId, const std::string localName, OsAccountType type, int64_t serialNumber);
55 
56     OsAccountInfo(int localId, const std::string localName, const std::string shortName, OsAccountType type,
57         int64_t serialNumber);
58 
59     int GetLocalId() const;
60 
61     void SetLocalId(int localId);
62 
63     std::string GetLocalName() const;
64 
65     void SetLocalName(const std::string localName);
66 
67     std::string GetShortName() const;
68 
69     void SetShortName(const std::string &shortName);
70 
71     OsAccountType GetType() const;
72 
73     void SetType(OsAccountType type);
74 
75     std::vector<std::string> GetConstraints() const;
76 
77     void SetConstraints(const std::vector<std::string> constraints);
78 
79     bool GetIsVerified() const;
80 
81     void SetIsVerified(bool isVerified);
82 
83     std::string GetPhoto() const;
84 
85     void SetPhoto(const std::string photo);
86 
87     int64_t GetCreateTime() const;
88 
89     void SetCreateTime(const int64_t createTime);
90 
91     int64_t GetLastLoginTime() const;
92 
93     void SetLastLoginTime(const int64_t lastLoginTime);
94 
95     Json ToJson() const override;
96 
97     void FromJson(const Json &jsonObject) override;
98 
99     bool Marshalling(Parcel &parcel) const override;
100 
101     bool ReadFromParcel(Parcel &parcel);
102 
103     std::string ToString() const override;
104 
105     std::string GetPrimeKey() const override;
106 
107     static OsAccountInfo *Unmarshalling(Parcel &parcel);
108 
109     int64_t GetSerialNumber() const;
110 
111     void SetSerialNumber(const int64_t serialNumber);
112 
113     bool GetIsActived() const;
114 
115     void SetIsActived(const bool isActivated);
116 
117     bool GetIsCreateCompleted() const;
118 
119     void SetIsCreateCompleted(const bool isCreateCompleted);
120 
121     bool SetDomainInfo(const DomainAccountInfo &domainInfo);
122 
123     void GetDomainInfo(DomainAccountInfo &domainInfo) const;
124 
125     bool GetToBeRemoved() const;
126 
127     void SetToBeRemoved(bool toBeRemoved);
128 
129     uint64_t GetCredentialId() const;
130 
131     void SetCredentialId(uint64_t credentialId);
132 
133     ErrCode ParamCheck();
134 
135 private:
136     int localId_ = -1;
137     std::string localName_;
138     std::string shortName_;
139     OsAccountType type_ = OsAccountType::ADMIN;
140     std::vector<std::string> constraints_;
141     std::string photo_;
142     int64_t createTime_ = 0;
143     int64_t lastLoginTime_ = 0;
144     int64_t serialNumber_ = 0;
145     uint64_t credentialId_ = 0;
146     bool isVerified_ = false;
147     bool isActivated_ = false;
148     bool isCreateCompleted_ = false;
149     bool toBeRemoved_ = false;
150     DomainAccountInfo domainInfo_;
151 };
152 typedef enum {
153     ERROR_MOD = 0,
154     HOT_SWITCH,
155     COLD_SWITCH,
156 } OS_ACCOUNT_SWITCH_MOD;
157 }  // namespace AccountSA
158 }  // namespace OHOS
159 
160 #endif  // OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_INFO_H
161