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
16 #include "softbus_handler_asset_mock.h"
17
18 namespace OHOS {
19 namespace Storage {
20 namespace DistributedFile {
21 SoftBusHandlerAsset::SoftBusHandlerAsset() = default;
22 SoftBusHandlerAsset::~SoftBusHandlerAsset() = default;
23
GetInstance()24 SoftBusHandlerAsset &SoftBusHandlerAsset::GetInstance()
25 {
26 static SoftBusHandlerAsset assetHandle;
27 return assetHandle;
28 }
29
CreateAssetLocalSessionServer()30 void SoftBusHandlerAsset::CreateAssetLocalSessionServer()
31 {
32 return;
33 }
34
DeleteAssetLocalSessionServer()35 void SoftBusHandlerAsset::DeleteAssetLocalSessionServer()
36 {
37 return;
38 }
39
AssetBind(const std::string & dstNetworkId,int32_t & socketId)40 int32_t SoftBusHandlerAsset::AssetBind(const std::string &dstNetworkId, int32_t &socketId)
41 {
42 if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
43 return -1;
44 }
45 return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->AssetBind(dstNetworkId, socketId);
46 }
47
AssetSendFile(int32_t socketId,const std::string & sendFile,bool isSingleFile)48 int32_t SoftBusHandlerAsset::AssetSendFile(int32_t socketId, const std::string &sendFile, bool isSingleFile)
49 {
50 if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
51 return -1;
52 }
53 return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->AssetSendFile(socketId, sendFile, isSingleFile);
54 }
55
closeAssetBind(int32_t socketId)56 void SoftBusHandlerAsset::closeAssetBind(int32_t socketId)
57 {
58 return;
59 }
60
OnAssetRecvBind(int32_t socketId,const std::string & srcNetWorkId)61 void SoftBusHandlerAsset::OnAssetRecvBind(int32_t socketId, const std::string &srcNetWorkId)
62 {
63 return;
64 }
65
GetSocketIdFromAssetObj(const std::string & peerNetworkId)66 std::vector<int32_t> GetSocketIdFromAssetObj(const std::string &peerNetworkId)
67 {
68 return {};
69 }
GetSocketIdFromClientInfo(const std::string & peerNetworkId)70 std::vector<int32_t> GetSocketIdFromClientInfo(const std::string &peerNetworkId)
71 {
72 return {};
73 }
74
GetClientInfo(int32_t socketId)75 std::string SoftBusHandlerAsset::GetClientInfo(int32_t socketId)
76 {
77 if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
78 return "";
79 }
80 return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->GetClientInfo(socketId);
81 }
82
RemoveClientInfo(int32_t socketId)83 void SoftBusHandlerAsset::RemoveClientInfo(int32_t socketId)
84 {
85 return;
86 }
87
AddAssetObj(int32_t socketId,const sptr<AssetObj> & assetObj)88 void SoftBusHandlerAsset::AddAssetObj(int32_t socketId, const sptr<AssetObj> &assetObj)
89 {
90 return;
91 }
92
GetAssetObj(int32_t socketId)93 sptr<AssetObj> SoftBusHandlerAsset::GetAssetObj(int32_t socketId)
94 {
95 if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
96 return nullptr;
97 }
98 return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->GetAssetObj(socketId);
99 }
100
RemoveAssetObj(int32_t socketId)101 void SoftBusHandlerAsset::RemoveAssetObj(int32_t socketId)
102 {
103 return;
104 }
105
GenerateAssetObjInfo(int32_t socketId,const std::string & fileName,const sptr<AssetObj> & assetObj)106 int32_t SoftBusHandlerAsset::GenerateAssetObjInfo(int32_t socketId,
107 const std::string &fileName,
108 const sptr<AssetObj> &assetObj)
109 {
110 if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
111 return -1;
112 }
113 return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->GenerateAssetObjInfo(socketId, fileName, assetObj);
114 }
115
IsSameAccount(const std::string & networkId)116 bool SoftBusHandlerAsset::IsSameAccount(const std::string &networkId)
117 {
118 return true;
119 }
120
GetDstFile(const std::string & file,const std::string & srcBundleName,const std::string & dstBundleName,const std::string & sessionId,bool isSingleFile)121 std::string SoftBusHandlerAsset::GetDstFile(const std::string &file,
122 const std::string &srcBundleName,
123 const std::string &dstBundleName,
124 const std::string &sessionId,
125 bool isSingleFile)
126 {
127 return "test";
128 }
129
GenerateUris(const std::vector<std::string> & fileList,const std::string & dstBundleName,bool isSingleFile)130 std::vector<std::string> SoftBusHandlerAsset::GenerateUris(const std::vector<std::string> &fileList,
131 const std::string &dstBundleName,
132 bool isSingleFile)
133 {
134 if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
135 return {};
136 }
137 return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->GenerateUris(fileList, dstBundleName, isSingleFile);
138 }
139
CompressFile(const std::vector<std::string> & fileList,const std::string & relativePath,const std::string & zipFileName)140 int32_t SoftBusHandlerAsset::CompressFile(const std::vector<std::string> &fileList,
141 const std::string &relativePath,
142 const std::string &zipFileName)
143 {
144 if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
145 return -1;
146 }
147 return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->CompressFile(fileList, relativePath, zipFileName);
148 }
149
DecompressFile(const std::string & unZipFileName,const std::string & relativePath)150 std::vector<std::string> SoftBusHandlerAsset::DecompressFile(const std::string &unZipFileName,
151 const std::string &relativePath)
152 {
153 if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
154 return {};
155 }
156 return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->DecompressFile(unZipFileName, relativePath);
157 }
158
GetLocalNetworkId()159 std::string SoftBusHandlerAsset::GetLocalNetworkId()
160 {
161 return "test";
162 }
163
MkDir(const std::string & path,mode_t mode)164 int32_t SoftBusHandlerAsset::MkDir(const std::string &path, mode_t mode)
165 {
166 return 0;
167 }
168
MkDirRecurse(const std::string & path,mode_t mode)169 bool SoftBusHandlerAsset::MkDirRecurse(const std::string &path, mode_t mode)
170 {
171 if (ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_ == nullptr) {
172 return -1;
173 }
174 return ISoftBusHandlerAssetMock::iSoftBusHandlerAssetMock_->MkDirRecurse(path, mode);
175 }
176
IsDir(const std::string & path)177 bool SoftBusHandlerAsset::IsDir(const std::string &path)
178 {
179 return true;
180 }
181
ExtractFile(unzFile unZipFile,const std::string & dir)182 std::string SoftBusHandlerAsset::ExtractFile(unzFile unZipFile, const std::string &dir)
183 {
184 return "test";
185 }
186
RemoveFile(const std::string & path,bool isRemove)187 void SoftBusHandlerAsset::RemoveFile(const std::string &path, bool isRemove)
188 {
189 return;
190 }
191 } // namespace DistributedFile
192 } // namespace Storage
193 } // namespace OHOS