• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #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)28 int32_t DeviceProfileConnector::HandleDevUnBindEvent(int32_t remoteUserId, const std::string &remoteUdid,
29     const std::string &localUdid)
30 {
31     return DmDeviceProfileConnector::dmDeviceProfileConnector->HandleDevUnBindEvent(remoteUserId, remoteUdid,
32         localUdid);
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 std::string & localUdid,int32_t localUserId,const std::string & peerUdid,int32_t peerUserId)53 bool DeviceProfileConnector::DeleteAclForAccountLogOut(const std::string &localUdid, int32_t localUserId,
54     const std::string &peerUdid, int32_t peerUserId)
55 {
56     return DmDeviceProfileConnector::dmDeviceProfileConnector->DeleteAclForAccountLogOut(localUdid, localUserId,
57         peerUdid, peerUserId);
58 }
59 
HandleAppUnBindEvent(int32_t remoteUserId,const std::string & remoteUdid,int32_t tokenId,const std::string & localUdid)60 OHOS::DistributedHardware::ProcessInfo 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)96 void DeviceProfileConnector::DeleteAclForRemoteUserRemoved(std::string peerUdid, int32_t peerUserId,
97     std::vector<int32_t> &userIds)
98 {
99     return DmDeviceProfileConnector::dmDeviceProfileConnector->DeleteAclForRemoteUserRemoved(peerUdid, peerUserId,
100         userIds);
101 }
102 
HandleAppUnBindEvent(int32_t remoteUserId,const std::string & remoteUdid,int32_t tokenId,const std::string & localUdid,int32_t peerTokenId)103 OHOS::DistributedHardware::ProcessInfo 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(const std::vector<unsigned char> & sessionKeyArray,int32_t & sessionKeyId)128 int32_t DeviceProfileConnector::PutSessionKey(const std::vector<unsigned char> &sessionKeyArray, int32_t &sessionKeyId)
129 {
130     return DmDeviceProfileConnector::dmDeviceProfileConnector->PutSessionKey(sessionKeyArray, sessionKeyId);
131 }
132 
PutLocalServiceInfo(const DistributedDeviceProfile::LocalServiceInfo & localServiceInfo)133 int32_t DeviceProfileConnector::PutLocalServiceInfo(
134     const DistributedDeviceProfile::LocalServiceInfo &localServiceInfo)
135 {
136     return DmDeviceProfileConnector::dmDeviceProfileConnector->PutLocalServiceInfo(localServiceInfo);
137 }
138 
DeleteLocalServiceInfo(const std::string & bundleName,int32_t pinExchangeType)139 int32_t DeviceProfileConnector::DeleteLocalServiceInfo(const std::string &bundleName, int32_t pinExchangeType)
140 {
141     return DmDeviceProfileConnector::dmDeviceProfileConnector->DeleteLocalServiceInfo(bundleName, pinExchangeType);
142 }
143 
UpdateLocalServiceInfo(const DistributedDeviceProfile::LocalServiceInfo & localServiceInfo)144 int32_t DeviceProfileConnector::UpdateLocalServiceInfo(
145     const DistributedDeviceProfile::LocalServiceInfo &localServiceInfo)
146 {
147     return DmDeviceProfileConnector::dmDeviceProfileConnector->UpdateLocalServiceInfo(localServiceInfo);
148 }
149 
CheckAclStatusAndForegroundNotMatch(const std::string & localUdid,const std::vector<int32_t> & foregroundUserIds,const std::vector<int32_t> & backgroundUserIds)150 bool DeviceProfileConnector::CheckAclStatusAndForegroundNotMatch(const std::string &localUdid,
151     const std::vector<int32_t> &foregroundUserIds, const std::vector<int32_t> &backgroundUserIds)
152 {
153     return DmDeviceProfileConnector::dmDeviceProfileConnector->CheckAclStatusAndForegroundNotMatch(localUdid,
154         foregroundUserIds, backgroundUserIds);
155 }
156 
GetDeviceIdAndBindLevel(std::vector<int32_t> userIds,const std::string & localUdid)157 std::map<std::string, int32_t> DeviceProfileConnector::GetDeviceIdAndBindLevel(std::vector<int32_t> userIds,
158     const std::string &localUdid)
159 {
160     return DmDeviceProfileConnector::dmDeviceProfileConnector->GetDeviceIdAndBindLevel(userIds, localUdid);
161 }
162 } // namespace DistributedHardware
163 } // namespace OHOS