1 /*
2 * Copyright (C) 2024 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 #include "os_account_manager.h"
16
17 #include "mock_other_method.h"
18
19 namespace OHOS {
20 using namespace OHOS::Storage::DistributedFile;
21
22 namespace AccountSA {
23 /**
24 * Interfaces for ohos account subsystem.
25 */
26 class OhosAccountKitsImpl : public OhosAccountKits {
27 public:
QueryOhosAccountInfo()28 std::pair<bool, OhosAccountInfo> QueryOhosAccountInfo()
29 {
30 return {};
31 }
32
33 ErrCode GetOhosAccountInfo(OhosAccountInfo &accountInfo);
34
GetOsAccountDistributedInfo(int32_t localId,OhosAccountInfo & accountInfo)35 ErrCode GetOsAccountDistributedInfo(int32_t localId, OhosAccountInfo &accountInfo)
36 {
37 return 0;
38 }
39
QueryOsAccountDistributedInfo(std::int32_t localId)40 std::pair<bool, OhosAccountInfo> QueryOsAccountDistributedInfo(std::int32_t localId)
41 {
42 return {};
43 }
44
UpdateOhosAccountInfo(const std::string & accountName,const std::string & uid,const std::string & eventStr)45 ErrCode UpdateOhosAccountInfo(const std::string& accountName, const std::string& uid,
46 const std::string& eventStr)
47 {
48 return 0;
49 }
50
SetOhosAccountInfo(const OhosAccountInfo & ohosAccountInfo,const std::string & eventStr)51 ErrCode SetOhosAccountInfo(const OhosAccountInfo &ohosAccountInfo,
52 const std::string &eventStr)
53 {
54 return 0;
55 }
56
SetOsAccountDistributedInfo(const int32_t localId,const OhosAccountInfo & ohosAccountInfo,const std::string & eventStr)57 ErrCode SetOsAccountDistributedInfo(
58 const int32_t localId, const OhosAccountInfo& ohosAccountInfo, const std::string& eventStr)
59 {
60 return 0;
61 }
62
QueryDeviceAccountId(std::int32_t & accountId)63 ErrCode QueryDeviceAccountId(std::int32_t& accountId)
64 {
65 return 0;
66 }
67
GetDeviceAccountIdByUID(std::int32_t & uid)68 std::int32_t GetDeviceAccountIdByUID(std::int32_t& uid)
69 {
70 return 0;
71 }
72
SubscribeDistributedAccountEvent(const DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE type,const std::shared_ptr<DistributedAccountSubscribeCallback> & callback)73 ErrCode SubscribeDistributedAccountEvent(const DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE type,
74 const std::shared_ptr<DistributedAccountSubscribeCallback> &callback)
75 {
76 return 0;
77 }
78
UnsubscribeDistributedAccountEvent(const DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE type,const std::shared_ptr<DistributedAccountSubscribeCallback> & callback)79 ErrCode UnsubscribeDistributedAccountEvent(const DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE type,
80 const std::shared_ptr<DistributedAccountSubscribeCallback> &callback)
81 {
82 return 0;
83 }
84 };
85 } // namespace AccountSA
86
87
QueryActiveOsAccountIds(std::vector<int32_t> & ids)88 ErrCode AccountSA::OsAccountManager::QueryActiveOsAccountIds(std::vector<int32_t>& ids)
89 {
90 if (DfsDeviceOtherMethod::otherMethod == nullptr) {
91 return 0;
92 }
93 return DfsDeviceOtherMethod::otherMethod->QueryActiveOsAccountIds(ids);
94 }
95
GetOhosAccountInfo(AccountSA::OhosAccountInfo & accountInfo)96 ErrCode AccountSA::OhosAccountKitsImpl::GetOhosAccountInfo(AccountSA::OhosAccountInfo &accountInfo)
97 {
98 if (DfsDeviceOtherMethod::otherMethod == nullptr) {
99 return 0;
100 }
101 return DfsDeviceOtherMethod::otherMethod->GetOhosAccountInfo(accountInfo);
102 }
103 } // namespace OHOS
104
105 namespace OHOS::AccountSA {
GetInstance()106 OhosAccountKits &OhosAccountKits::GetInstance()
107 {
108 static OhosAccountKitsImpl test;
109 return test;
110 }
111 }