1 /*
2  * Copyright (C) 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 
16 #include "os_account_manager.h"
17 
18 namespace OHOS {
19 namespace AccountSA {
20 const int32_t accountId = 100;
21 std::vector<int> g_accountIds;
22 bool g_enableMockIds = false;
23 ErrCode g_queryRet = ERR_OK;
QueryActiveOsAccountIds(std::vector<int32_t> & accountIds)24 ErrCode OsAccountManager::QueryActiveOsAccountIds(std::vector<int32_t>& accountIds)
25 {
26     if (g_enableMockIds) {
27         accountIds = g_accountIds;
28     } else {
29         accountIds.push_back(accountId);
30     }
31     return g_queryRet;
32 }
33 
SubscribeOsAccount(const std::shared_ptr<OsAccountSubscriber> & subscriberAccount)34 ErrCode OsAccountManager::SubscribeOsAccount(const std::shared_ptr<OsAccountSubscriber>& subscriberAccount)
35 {
36     (void)subscriberAccount;
37     return ERR_OK;
38 }
39 
OsAccountSubscriber()40 OsAccountSubscriber::OsAccountSubscriber()
41 {
42 }
43 
OsAccountSubscriber(const OsAccountSubscribeInfo & subscribeInfo)44 OsAccountSubscriber::OsAccountSubscriber(const OsAccountSubscribeInfo& subscribeInfo) : subscribeInfo_(subscribeInfo)
45 {
46 }
47 
~OsAccountSubscriber()48 OsAccountSubscriber::~OsAccountSubscriber()
49 {
50 }
51 
GetSubscribeInfo(OsAccountSubscribeInfo & info) const52 void OsAccountSubscriber::GetSubscribeInfo(OsAccountSubscribeInfo& info) const
53 {
54     info = subscribeInfo_;
55 }
56 
OsAccountSubscribeInfo()57 OsAccountSubscribeInfo::OsAccountSubscribeInfo() : osAccountSubscribeType_(ACTIVATING), name_("")
58 {
59 }
60 
OsAccountSubscribeInfo(const OS_ACCOUNT_SUBSCRIBE_TYPE & osAccountSubscribeType,const std::string & name)61 OsAccountSubscribeInfo::OsAccountSubscribeInfo(
62     const OS_ACCOUNT_SUBSCRIBE_TYPE& osAccountSubscribeType, const std::string& name)
63     : osAccountSubscribeType_(osAccountSubscribeType), name_(name)
64 {
65     (void)osAccountSubscribeType;
66 }
67 
~OsAccountSubscribeInfo()68 OsAccountSubscribeInfo::~OsAccountSubscribeInfo()
69 {
70 }
71 
GetOsAccountSubscribeType(OS_ACCOUNT_SUBSCRIBE_TYPE & subscribetype) const72 void OsAccountSubscribeInfo::GetOsAccountSubscribeType(OS_ACCOUNT_SUBSCRIBE_TYPE& subscribetype) const
73 {
74     subscribetype = osAccountSubscribeType_;
75 }
76 
SetOsAccountSubscribeType(const OS_ACCOUNT_SUBSCRIBE_TYPE & subscribetype)77 void OsAccountSubscribeInfo::SetOsAccountSubscribeType(const OS_ACCOUNT_SUBSCRIBE_TYPE& subscribetype)
78 {
79     osAccountSubscribeType_ = subscribetype;
80 }
81 
GetName(std::string & subscribeName) const82 void OsAccountSubscribeInfo::GetName(std::string& subscribeName) const
83 {
84     subscribeName = name_;
85 }
86 
SetName(const std::string & subscribeName)87 void OsAccountSubscribeInfo::SetName(const std::string& subscribeName)
88 {
89     name_ = subscribeName;
90 }
91 
Marshalling(Parcel & parcel) const92 bool OsAccountSubscribeInfo::Marshalling(Parcel& parcel) const
93 {
94     (void)parcel;
95     return false;
96 }
97 
Unmarshalling(Parcel & parcel)98 OsAccountSubscribeInfo* OsAccountSubscribeInfo::Unmarshalling(Parcel& parcel)
99 {
100     (void)parcel;
101     return nullptr;
102 }
103 
ReadFromParcel(Parcel & parcel)104 bool OsAccountSubscribeInfo::ReadFromParcel(Parcel& parcel)
105 {
106     (void)parcel;
107     return false;
108 }
109 }  // AccountSA
110 }  // OHOS