1 /*
2 * Copyright (c) 2023-2025 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 "deviceprofile_connector_mock.h"
17
18 #include "gtest/gtest.h"
19
20 namespace OHOS {
21 namespace DistributedHardware {
22 DM_IMPLEMENT_SINGLE_INSTANCE(DeviceProfileConnector);
GetAllAccessControlProfile()23 std::vector<DistributedDeviceProfile::AccessControlProfile> DeviceProfileConnector::GetAllAccessControlProfile()
24 {
25 return DmDeviceProfileConnector::dmDeviceProfileConnector->GetAllAccessControlProfile();
26 }
27
HandleDevUnBindEvent(int32_t remoteUserId,const std::string & remoteUdid,const std::string & localUdid,DmOfflineParam & offlineParam)28 int32_t DeviceProfileConnector::HandleDevUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid,
29 const std::string &localUdid, DmOfflineParam &offlineParam)
30 {
31 return DmDeviceProfileConnector::dmDeviceProfileConnector->HandleDevUnBindEvent(remoteUserId, remoteUdid,
32 localUdid, offlineParam);
33 }
34
HandleAccountLogoutEvent(int32_t remoteUserId,const std::string & remoteAccountHash,const std::string & remoteUdid,const std::string & localUdid)35 int32_t DeviceProfileConnector::HandleAccountLogoutEvent(int32_t remoteUserId, const std::string &remoteAccountHash,
36 const std::string &remoteUdid, const std::string &localUdid)
37 {
38 return DmDeviceProfileConnector::dmDeviceProfileConnector->HandleAccountLogoutEvent(remoteUserId, remoteAccountHash,
39 remoteUdid, localUdid);
40 }
41
CheckBindType(std::string trustDeviceId,std::string requestDeviceId)42 uint32_t DeviceProfileConnector::CheckBindType(std::string trustDeviceId, std::string requestDeviceId)
43 {
44 return DmDeviceProfileConnector::dmDeviceProfileConnector->CheckBindType(trustDeviceId, requestDeviceId);
45 }
46
GetUserIdAndBindLevel(const std::string & localUdid,const std::string & peerUdid)47 std::map<int32_t, int32_t> DeviceProfileConnector::GetUserIdAndBindLevel(const std::string &localUdid,
48 const std::string &peerUdid)
49 {
50 return DmDeviceProfileConnector::dmDeviceProfileConnector->GetUserIdAndBindLevel(localUdid, peerUdid);
51 }
52
DeleteAclForAccountLogOut(const DMAclQuadInfo & info,const std::string & accountId,DmOfflineParam & offlineParam)53 bool DeviceProfileConnector::DeleteAclForAccountLogOut(const DMAclQuadInfo &info, const std::string &accountId,
54 DmOfflineParam &offlineParam)
55 {
56 return DmDeviceProfileConnector::dmDeviceProfileConnector->DeleteAclForAccountLogOut(info, accountId,
57 offlineParam);
58 }
59
HandleAppUnBindEvent(int32_t remoteUserId,const std::string & remoteUdid,int32_t tokenId,const std::string & localUdid)60 DmOfflineParam DeviceProfileConnector::HandleAppUnBindEvent(int32_t remoteUserId,
61 const std::string &remoteUdid, int32_t tokenId, const std::string &localUdid)
62 {
63 return DmDeviceProfileConnector::dmDeviceProfileConnector->HandleAppUnBindEvent(remoteUserId, remoteUdid,
64 tokenId, localUdid);
65 }
66
GetDevIdAndUserIdByActHash(const std::string & localUdid,const std::string & peerUdid,int32_t peerUserId,const std::string & peerAccountHash)67 std::multimap<std::string, int32_t> DeviceProfileConnector::GetDevIdAndUserIdByActHash(const std::string &localUdid,
68 const std::string &peerUdid, int32_t peerUserId, const std::string &peerAccountHash)
69 {
70 return DmDeviceProfileConnector::dmDeviceProfileConnector->GetDevIdAndUserIdByActHash(localUdid, peerUdid,
71 peerUserId, peerAccountHash);
72 }
73
SyncAclByBindType(std::string pkgName,std::vector<int32_t> bindTypeVec,std::string localDeviceId,std::string targetDeviceId)74 std::vector<int32_t> DeviceProfileConnector::SyncAclByBindType(std::string pkgName, std::vector<int32_t> bindTypeVec,
75 std::string localDeviceId, std::string targetDeviceId)
76 {
77 return DmDeviceProfileConnector::dmDeviceProfileConnector->SyncAclByBindType(pkgName, bindTypeVec,
78 localDeviceId, targetDeviceId);
79 }
80
GetBindTypeByPkgName(std::string pkgName,std::string requestDeviceId,std::string trustUdid)81 std::vector<int32_t> DeviceProfileConnector::GetBindTypeByPkgName(std::string pkgName, std::string requestDeviceId,
82 std::string trustUdid)
83 {
84 return DmDeviceProfileConnector::dmDeviceProfileConnector->GetBindTypeByPkgName(pkgName,
85 requestDeviceId, trustUdid);
86 }
87
DeleteAccessControlList(const std::string & pkgName,const std::string & localDeviceId,const std::string & remoteDeviceId,int32_t bindLevel,const std::string & extra)88 DmOfflineParam DeviceProfileConnector::DeleteAccessControlList(const std::string &pkgName,
89 const std::string &localDeviceId, const std::string &remoteDeviceId,
90 int32_t bindLevel, const std::string &extra)
91 {
92 return DmDeviceProfileConnector::dmDeviceProfileConnector->DeleteAccessControlList(pkgName, localDeviceId,
93 remoteDeviceId, bindLevel, extra);
94 }
95
DeleteAclForRemoteUserRemoved(std::string peerUdid,int32_t peerUserId,std::vector<int32_t> & userIds,DmOfflineParam & offlineParam)96 void DeviceProfileConnector::DeleteAclForRemoteUserRemoved(std::string peerUdid, int32_t peerUserId,
97 std::vector<int32_t> &userIds, DmOfflineParam &offlineParam)
98 {
99 return DmDeviceProfileConnector::dmDeviceProfileConnector->DeleteAclForRemoteUserRemoved(peerUdid, peerUserId,
100 userIds, offlineParam);
101 }
102
HandleAppUnBindEvent(int32_t remoteUserId,const std::string & remoteUdid,int32_t tokenId,const std::string & localUdid,int32_t peerTokenId)103 DmOfflineParam DeviceProfileConnector::HandleAppUnBindEvent(int32_t remoteUserId,
104 const std::string &remoteUdid, int32_t tokenId, const std::string &localUdid, int32_t peerTokenId)
105 {
106 return DmDeviceProfileConnector::dmDeviceProfileConnector->HandleAppUnBindEvent(remoteUserId, remoteUdid,
107 tokenId, localUdid, peerTokenId);
108 }
109
GetAppTrustDeviceList(const std::string & pkgName,const std::string & deviceId)110 std::unordered_map<std::string, DmAuthForm> DeviceProfileConnector::GetAppTrustDeviceList(const std::string &pkgName,
111 const std::string &deviceId)
112 {
113 return DmDeviceProfileConnector::dmDeviceProfileConnector->GetAppTrustDeviceList(pkgName, deviceId);
114 }
115
CheckDeviceInfoPermission(const std::string & localUdid,const std::string & peerDeviceId)116 int32_t DeviceProfileConnector::CheckDeviceInfoPermission(const std::string &localUdid, const std::string &peerDeviceId)
117 {
118 return DmDeviceProfileConnector::dmDeviceProfileConnector->CheckDeviceInfoPermission(localUdid, peerDeviceId);
119 }
120
GetLocalServiceInfoByBundleNameAndPinExchangeType(const std::string & bundleName,int32_t pinExchangeType,DistributedDeviceProfile::LocalServiceInfo & serviceInfo)121 int32_t DeviceProfileConnector::GetLocalServiceInfoByBundleNameAndPinExchangeType(
122 const std::string& bundleName, int32_t pinExchangeType, DistributedDeviceProfile::LocalServiceInfo &serviceInfo)
123 {
124 return DmDeviceProfileConnector::dmDeviceProfileConnector->GetLocalServiceInfoByBundleNameAndPinExchangeType(
125 bundleName, pinExchangeType, serviceInfo);
126 }
127
PutSessionKey(int32_t userId,const std::vector<unsigned char> & sessionKeyArray,int32_t & sessionKeyId)128 int32_t DeviceProfileConnector::PutSessionKey(int32_t userId, const std::vector<unsigned char> &sessionKeyArray,
129 int32_t &sessionKeyId)
130 {
131 return DmDeviceProfileConnector::dmDeviceProfileConnector->PutSessionKey(userId, sessionKeyArray, sessionKeyId);
132 }
133
PutLocalServiceInfo(const DistributedDeviceProfile::LocalServiceInfo & localServiceInfo)134 int32_t DeviceProfileConnector::PutLocalServiceInfo(
135 const DistributedDeviceProfile::LocalServiceInfo &localServiceInfo)
136 {
137 return DmDeviceProfileConnector::dmDeviceProfileConnector->PutLocalServiceInfo(localServiceInfo);
138 }
139
DeleteLocalServiceInfo(const std::string & bundleName,int32_t pinExchangeType)140 int32_t DeviceProfileConnector::DeleteLocalServiceInfo(const std::string &bundleName, int32_t pinExchangeType)
141 {
142 return DmDeviceProfileConnector::dmDeviceProfileConnector->DeleteLocalServiceInfo(bundleName, pinExchangeType);
143 }
144
UpdateLocalServiceInfo(const DistributedDeviceProfile::LocalServiceInfo & localServiceInfo)145 int32_t DeviceProfileConnector::UpdateLocalServiceInfo(
146 const DistributedDeviceProfile::LocalServiceInfo &localServiceInfo)
147 {
148 return DmDeviceProfileConnector::dmDeviceProfileConnector->UpdateLocalServiceInfo(localServiceInfo);
149 }
150
CheckAclStatusAndForegroundNotMatch(const std::string & localUdid,const std::vector<int32_t> & foregroundUserIds,const std::vector<int32_t> & backgroundUserIds)151 bool DeviceProfileConnector::CheckAclStatusAndForegroundNotMatch(const std::string &localUdid,
152 const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds)
153 {
154 return DmDeviceProfileConnector::dmDeviceProfileConnector->CheckAclStatusAndForegroundNotMatch(localUdid,
155 foregroundUserIds, backgroundUserIds);
156 }
157
GetDeviceIdAndBindLevel(std::vector<int32_t> userIds,const std::string & localUdid)158 std::map<std::string, int32_t> DeviceProfileConnector::GetDeviceIdAndBindLevel(std::vector<int32_t> userIds,
159 const std::string &localUdid)
160 {
161 return DmDeviceProfileConnector::dmDeviceProfileConnector->GetDeviceIdAndBindLevel(userIds, localUdid);
162 }
163
DeleteAccessControlById(int64_t accessControlId)164 void DeviceProfileConnector::DeleteAccessControlById(int64_t accessControlId)
165 {
166 return DmDeviceProfileConnector::dmDeviceProfileConnector->DeleteAccessControlById(accessControlId);
167 }
168
GetProcessInfoFromAclByUserId(const std::string & localDeviceId,const std::string & targetDeviceId,int32_t userId)169 std::vector<ProcessInfo> DeviceProfileConnector::GetProcessInfoFromAclByUserId(
170 const std::string &localDeviceId, const std::string &targetDeviceId, int32_t userId)
171 {
172 return DmDeviceProfileConnector::dmDeviceProfileConnector->GetProcessInfoFromAclByUserId(localDeviceId,
173 targetDeviceId, userId);
174 }
175
GetAccessControlProfile()176 std::vector<DistributedDeviceProfile::AccessControlProfile> DeviceProfileConnector::GetAccessControlProfile()
177 {
178 return DmDeviceProfileConnector::dmDeviceProfileConnector->GetAccessControlProfile();
179 }
180
GetAllAclIncludeLnnAcl()181 std::vector<DistributedDeviceProfile::AccessControlProfile> DeviceProfileConnector::GetAllAclIncludeLnnAcl()
182 {
183 return DmDeviceProfileConnector::dmDeviceProfileConnector->GetAllAclIncludeLnnAcl();
184 }
185
GetDeviceIdAndUdidListByTokenId(const std::vector<int32_t> & userIds,const std::string & localUdid,int32_t tokenId)186 std::vector<std::string> DeviceProfileConnector::GetDeviceIdAndUdidListByTokenId(
187 const std::vector<int32_t> &userIds, const std::string &localUdid, int32_t tokenId)
188 {
189 return DmDeviceProfileConnector::dmDeviceProfileConnector->GetDeviceIdAndUdidListByTokenId(userIds, localUdid,
190 tokenId);
191 }
192
CacheAcerAclId(const DistributedDeviceProfile::AccessControlProfile & profile,std::vector<DmAclIdParam> & aclInfos)193 void DeviceProfileConnector::CacheAcerAclId(const DistributedDeviceProfile::AccessControlProfile &profile,
194 std::vector<DmAclIdParam> &aclInfos)
195 {
196 DmDeviceProfileConnector::dmDeviceProfileConnector->CacheAcerAclId(profile, aclInfos);
197 }
198
IsLnnAcl(const DistributedDeviceProfile::AccessControlProfile & profile)199 bool DeviceProfileConnector::IsLnnAcl(const DistributedDeviceProfile::AccessControlProfile &profile)
200 {
201 return DmDeviceProfileConnector::dmDeviceProfileConnector->IsLnnAcl(profile);
202 }
203 } // namespace DistributedHardware
204 } // namespace OHOS