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 class OsAccountInfo : public IAccountInfo, public Parcelable { 44 public: 45 OsAccountInfo(); 46 47 OsAccountInfo(int localId, const std::string localName, OsAccountType type, int64_t serialNumber); 48 49 int GetLocalId() const; 50 51 void SetLocalId(int localId); 52 53 std::string GetLocalName() const; 54 55 void SetLocalName(const std::string localName); 56 57 OsAccountType GetType() const; 58 59 void SetType(OsAccountType type); 60 61 std::vector<std::string> GetConstraints() const; 62 63 void SetConstraints(const std::vector<std::string> constraints); 64 65 bool GetIsVerified() const; 66 67 void SetIsVerified(bool isVerified); 68 69 std::string GetPhoto() const; 70 71 void SetPhoto(const std::string photo); 72 73 int64_t GetCreateTime() const; 74 75 void SetCreateTime(const int64_t createTime); 76 77 int64_t GetLastLoginTime() const; 78 79 void SetLastLoginTime(const int64_t lastLoginTime); 80 81 Json ToJson() const override; 82 83 void FromJson(const Json &jsonObject) override; 84 85 bool Marshalling(Parcel &parcel) const override; 86 87 bool ReadFromParcel(Parcel &parcel); 88 89 std::string ToString() const override; 90 91 std::string GetPrimeKey() const override; 92 93 static OsAccountInfo *Unmarshalling(Parcel &parcel); 94 95 int64_t GetSerialNumber() const; 96 97 void SetSerialNumber(const int64_t serialNumber); 98 99 bool GetIsActived() const; 100 101 void SetIsActived(const bool isActivated); 102 103 bool GetIsCreateCompleted() const; 104 105 void SetIsCreateCompleted(const bool isCreateCompleted); 106 107 bool SetDomainInfo(const DomainAccountInfo &domainInfo); 108 109 void GetDomainInfo(DomainAccountInfo &domainInfo) const; 110 111 bool GetToBeRemoved() const; 112 113 void SetToBeRemoved(bool toBeRemoved); 114 115 bool GetIsCreateSecret() const; 116 117 void SetIsCreateSecret(bool isCreateSecret); 118 119 private: 120 int localId_; 121 std::string localName_; 122 OsAccountType type_; 123 std::vector<std::string> constraints_; 124 bool isVerified_; 125 std::string photo_; 126 int64_t createTime_; 127 int64_t lastLoginTime_; 128 int64_t serialNumber_; 129 bool isActivated_; 130 bool isCreateCompleted_; 131 DomainAccountInfo domainInfo_; 132 bool toBeRemoved_; 133 bool isCreateSecret_; 134 }; 135 typedef enum { 136 ERROR_MOD = 0, 137 HOT_SWITCH, 138 COLD_SWITCH, 139 } OS_ACCOUNT_SWITCH_MOD; 140 } // namespace AccountSA 141 } // namespace OHOS 142 143 #endif // OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_INFO_H 144