• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 "module_ipc/service.h"
17 
18 #include <algorithm>
19 #include <cerrno>
20 #include <cstring>
21 #include <gtest/gtest.h>
22 
23 #include "b_error/b_error.h"
24 #include "b_resources/b_constants.h"
25 
26 namespace OHOS::FileManagement::Backup {
27 using namespace std;
28 
GetUserIdDefault()29 int32_t Service::GetUserIdDefault()
30 {
31     return 0;
32 }
33 
OnStart()34 void Service::OnStart() {}
35 
OnStop()36 void Service::OnStop() {}
37 
GetLocalCapabilities()38 UniqueFd Service::GetLocalCapabilities()
39 {
40     return UniqueFd(-1);
41 }
42 
GetLocalCapabilitiesForBundleInfos()43 UniqueFd Service::GetLocalCapabilitiesForBundleInfos()
44 {
45     return UniqueFd(-1);
46 }
47 
StopAll(const wptr<IRemoteObject> & obj,bool force)48 void Service::StopAll(const wptr<IRemoteObject> &obj, bool force) {}
49 
VerifyCallerAndGetCallerName(std::string & bundleName)50 ErrCode Service::VerifyCallerAndGetCallerName(std::string &bundleName)
51 {
52     return BError(BError::Codes::OK);
53 }
54 
InitRestoreSession(sptr<IServiceReverse> remote)55 ErrCode Service::InitRestoreSession(sptr<IServiceReverse> remote)
56 {
57     return BError(BError::Codes::OK);
58 }
59 
InitRestoreSession(sptr<IServiceReverse> remote,std::string & errMsg)60 ErrCode Service::InitRestoreSession(sptr<IServiceReverse> remote, std::string &errMsg)
61 {
62     return BError(BError::Codes::OK);
63 }
64 
InitBackupSession(sptr<IServiceReverse> remote)65 ErrCode Service::InitBackupSession(sptr<IServiceReverse> remote)
66 {
67     return BError(BError::Codes::OK);
68 }
69 
InitBackupSession(sptr<IServiceReverse> remote,std::string & errMsg)70 ErrCode Service::InitBackupSession(sptr<IServiceReverse> remote, std::string &errMsg)
71 {
72     return BError(BError::Codes::OK);
73 }
74 
Start()75 ErrCode Service::Start()
76 {
77     return BError(BError::Codes::OK);
78 }
79 
PublishFile(const BFileInfo & fileInfo)80 ErrCode Service::PublishFile(const BFileInfo &fileInfo)
81 {
82     return BError(BError::Codes::OK);
83 }
84 
AppFileReady(const string & fileName,UniqueFd fd,int32_t errCode)85 ErrCode Service::AppFileReady(const string &fileName, UniqueFd fd, int32_t errCode)
86 {
87     return BError(BError::Codes::OK);
88 }
89 
AppDone(ErrCode errCode)90 ErrCode Service::AppDone(ErrCode errCode)
91 {
92     return BError(BError::Codes::OK);
93 }
94 
ServiceResultReport(const std::string restoreRetInfo,BackupRestoreScenario sennario,ErrCode errCode)95 ErrCode Service::ServiceResultReport(const std::string restoreRetInfo,
96     BackupRestoreScenario sennario, ErrCode errCode)
97 {
98     return BError(BError::Codes::OK);
99 }
100 
AppendBundlesRestoreSession(UniqueFd fd,const std::vector<BundleName> & bundleNames,const std::vector<std::string> & detailInfos,RestoreTypeEnum restoreType,int32_t userId)101 ErrCode Service::AppendBundlesRestoreSession(UniqueFd fd, const std::vector<BundleName> &bundleNames,
102     const std::vector<std::string> &detailInfos, RestoreTypeEnum restoreType, int32_t userId)
103 {
104     return BError(BError::Codes::OK);
105 }
106 
AppendBundlesRestoreSession(UniqueFd fd,const std::vector<BundleName> & bundleNames,RestoreTypeEnum restoreType,int32_t userId)107 ErrCode Service::AppendBundlesRestoreSession(UniqueFd fd,
108                                              const std::vector<BundleName> &bundleNames,
109                                              RestoreTypeEnum restoreType,
110                                              int32_t userId)
111 {
112     return BError(BError::Codes::OK);
113 }
114 
AppendBundlesBackupSession(const std::vector<BundleName> & bundleNames)115 ErrCode Service::AppendBundlesBackupSession(const std::vector<BundleName> &bundleNames)
116 {
117     return BError(BError::Codes::OK);
118 }
119 
AppendBundlesDetailsBackupSession(const std::vector<BundleName> & bundleNames,const std::vector<std::string> & bundleInfos)120 ErrCode Service::AppendBundlesDetailsBackupSession(const std::vector<BundleName> &bundleNames,
121     const std::vector<std::string> &bundleInfos)
122 {
123     return BError(BError::Codes::OK);
124 }
125 
Finish()126 ErrCode Service::Finish()
127 {
128     return BError(BError::Codes::OK);
129 }
130 
LaunchBackupExtension(const BundleName & bundleName)131 ErrCode Service::LaunchBackupExtension(const BundleName &bundleName)
132 {
133     return BError(BError::Codes::OK);
134 }
135 
LaunchBackupSAExtension(const BundleName & bundleName)136 ErrCode Service::LaunchBackupSAExtension(const BundleName &bundleName)
137 {
138     return BError(BError::Codes::OK);
139 }
140 
GetFileHandle(const string & bundleName,const string & fileName)141 ErrCode Service::GetFileHandle(const string &bundleName, const string &fileName)
142 {
143     return BError(BError::Codes::OK);
144 }
145 
OnBackupExtensionDied(const string && bundleName,bool isCleanCalled)146 void Service::OnBackupExtensionDied(const string &&bundleName, bool isCleanCalled) {}
147 
ExtConnectDied(const string & callName)148 void Service::ExtConnectDied(const string &callName) {}
149 
ExtStart(const string & bundleName)150 void Service::ExtStart(const string &bundleName) {}
151 
Dump(int fd,const vector<u16string> & args)152 int Service::Dump(int fd, const vector<u16string> &args)
153 {
154     return 0;
155 }
156 
ExtConnectFailed(const string & bundleName,ErrCode ret)157 void Service::ExtConnectFailed(const string &bundleName, ErrCode ret)
158 {
159     GTEST_LOG_(INFO) << "ExtConnectFailed is OK";
160 }
161 
ExtConnectDone(string bundleName)162 void Service::ExtConnectDone(string bundleName) {}
163 
ClearSessionAndSchedInfo(const string & bundleName)164 void Service::ClearSessionAndSchedInfo(const string &bundleName) {}
165 
VerifyCaller()166 ErrCode Service::VerifyCaller()
167 {
168     return BError(BError::Codes::OK);
169 }
170 
VerifyCaller(IServiceReverse::Scenario scenario)171 ErrCode Service::VerifyCaller(IServiceReverse::Scenario scenario)
172 {
173     return BError(BError::Codes::OK);
174 }
175 
OnAllBundlesFinished(ErrCode errCode)176 void Service::OnAllBundlesFinished(ErrCode errCode) {}
177 
OnStartSched()178 void Service::OnStartSched() {}
179 
SendStartAppGalleryNotify(const BundleName & bundleName)180 void Service::SendStartAppGalleryNotify(const BundleName &bundleName) {}
181 
SessionDeactive()182 void Service::SessionDeactive() {}
183 
Release()184 ErrCode Service::Release()
185 {
186     return BError(BError::Codes::OK);
187 }
188 
Cancel(std::string bundleName,int32_t & result)189 ErrCode Service::Cancel(std::string bundleName, int32_t &result)
190 {
191     result = BError(BError::Codes::OK);
192     return BError(BError::Codes::OK);
193 }
194 
GetLocalCapabilitiesIncremental(const std::vector<BIncrementalData> & bundleNames)195 UniqueFd Service::GetLocalCapabilitiesIncremental(const std::vector<BIncrementalData> &bundleNames)
196 {
197     return UniqueFd(-1);
198 }
199 
GetAppLocalListAndDoIncrementalBackup()200 ErrCode Service::GetAppLocalListAndDoIncrementalBackup()
201 {
202     return BError(BError::Codes::OK);
203 }
204 
InitIncrementalBackupSession(sptr<IServiceReverse> remote)205 ErrCode Service::InitIncrementalBackupSession(sptr<IServiceReverse> remote)
206 {
207     return BError(BError::Codes::OK);
208 }
209 
InitIncrementalBackupSession(sptr<IServiceReverse> remote,std::string & errMsg)210 ErrCode Service::InitIncrementalBackupSession(sptr<IServiceReverse> remote, std::string &errMsg)
211 {
212     return BError(BError::Codes::OK);
213 }
214 
AppendBundlesIncrementalBackupSession(const std::vector<BIncrementalData> & bundlesToBackup)215 ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vector<BIncrementalData> &bundlesToBackup)
216 {
217     return BError(BError::Codes::OK);
218 }
219 
AppendBundlesIncrementalBackupSession(const std::vector<BIncrementalData> & bundlesToBackup,const std::vector<std::string> & infos)220 ErrCode Service::AppendBundlesIncrementalBackupSession(const std::vector<BIncrementalData> &bundlesToBackup,
221     const std::vector<std::string> &infos)
222 {
223     return BError(BError::Codes::OK);
224 }
225 
PublishIncrementalFile(const BFileInfo & fileInfo)226 ErrCode Service::PublishIncrementalFile(const BFileInfo &fileInfo)
227 {
228     return BError(BError::Codes::OK);
229 }
230 
PublishSAIncrementalFile(const BFileInfo & fileInfo,UniqueFd fd)231 ErrCode Service::PublishSAIncrementalFile(const BFileInfo &fileInfo, UniqueFd fd)
232 {
233     return BError(BError::Codes::OK);
234 }
235 
AppIncrementalFileReady(const string & fileName,UniqueFd fd,UniqueFd manifestFd,int32_t errCode)236 ErrCode Service::AppIncrementalFileReady(const string &fileName, UniqueFd fd, UniqueFd manifestFd, int32_t errCode)
237 {
238     return BError(BError::Codes::OK);
239 }
240 
AppIncrementalDone(ErrCode errCode)241 ErrCode Service::AppIncrementalDone(ErrCode errCode)
242 {
243     return BError(BError::Codes::OK);
244 }
245 
GetIncrementalFileHandle(const string & bundleName,const string & fileName)246 ErrCode Service::GetIncrementalFileHandle(const string &bundleName, const string &fileName)
247 {
248     return BError(BError::Codes::OK);
249 }
250 
GetBackupInfo(BundleName & bundleName,std::string & result)251 ErrCode Service::GetBackupInfo(BundleName &bundleName, std::string &result)
252 {
253     return BError(BError::Codes::OK);
254 }
255 
StartExtTimer(bool & isExtStart)256 ErrCode Service::StartExtTimer(bool &isExtStart)
257 {
258     return BError(BError::Codes::OK);
259 }
260 
StartFwkTimer(bool & isFwkStart)261 ErrCode Service::StartFwkTimer(bool &isFwkStart)
262 {
263     return BError(BError::Codes::OK);
264 }
265 
StopExtTimer(bool & isExtStop)266 ErrCode Service::StopExtTimer(bool &isExtStop)
267 {
268     return BError(BError::Codes::OK);
269 }
270 
RefreshDataSize(int64_t totalDatasize)271 ErrCode Service::RefreshDataSize(int64_t totalDatasize)
272 {
273     return BError(BError::Codes::OK);
274 }
275 
UpdateTimer(BundleName & bundleName,uint32_t timeout,bool & result)276 ErrCode Service::UpdateTimer(BundleName &bundleName, uint32_t timeout, bool &result)
277 {
278     return BError(BError::Codes::OK);
279 }
280 
UpdateSendRate(std::string & bundleName,int32_t sendRate,bool & result)281 ErrCode Service::UpdateSendRate(std::string &bundleName, int32_t sendRate, bool &result)
282 {
283     return BError(BError::Codes::OK);
284 }
285 
ReportAppProcessInfo(const std::string processInfo,const BackupRestoreScenario sennario)286 ErrCode Service::ReportAppProcessInfo(const std::string processInfo, const BackupRestoreScenario sennario)
287 {
288     return BError(BError::Codes::OK);
289 }
290 
OnSABackup(const std::string & bundleName,const int & fd,const std::string & result,const ErrCode & errCode)291 void Service::OnSABackup(const std::string &bundleName,
292                          const int &fd,
293                          const std::string &result,
294                          const ErrCode &errCode)
295 {
296 }
297 
OnSARestore(const std::string & bundleName,const std::string & result,const ErrCode & errCode)298 void Service::OnSARestore(const std::string &bundleName, const std::string &result, const ErrCode &errCode) {}
299 
ClearResidualBundleData(const std::string & bundleName)300 ErrCode Service::ClearResidualBundleData(const std::string &bundleName)
301 {
302     return BError(BError::Codes::OK);
303 }
304 
GetExtensionMutex(const BundleName & bundleName)305 std::shared_ptr<ExtensionMutexInfo> Service::GetExtensionMutex(const BundleName &bundleName)
306 {
307     return make_shared<ExtensionMutexInfo>(bundleName);
308 }
309 
RemoveExtensionMutex(const BundleName & bundleName)310 void Service::RemoveExtensionMutex(const BundleName &bundleName)
311 {
312 }
313 
OnBundleStarted(BError error,sptr<SvcSessionManager> session,const BundleName & bundleName)314 void Service::OnBundleStarted(BError error, sptr<SvcSessionManager> session, const BundleName &bundleName) {}
315 
HandleExceptionOnAppendBundles(sptr<SvcSessionManager> session,const vector<BundleName> & appendBundleNames,const vector<BundleName> & restoreBundleNames)316 void Service::HandleExceptionOnAppendBundles(sptr<SvcSessionManager> session,
317     const vector<BundleName> &appendBundleNames, const vector<BundleName> &restoreBundleNames) {}
318 
BundleBeginRadarReport(const std::string & bundleName,const ErrCode errCode,const IServiceReverse::Scenario scenario)319 void Service::BundleBeginRadarReport(const std::string &bundleName, const ErrCode errCode,
320     const IServiceReverse::Scenario scenario) {}
321 
BundleEndRadarReport(const std::string & bundleName,ErrCode errCode,const IServiceReverse::Scenario scenario)322 void Service::BundleEndRadarReport(const std::string &bundleName, ErrCode errCode,
323     const IServiceReverse::Scenario scenario) {}
324 
FileReadyRadarReport(const std::string & bundleName,const std::string & fileName,const ErrCode errCode,const IServiceReverse::Scenario scenario)325 void Service::FileReadyRadarReport(const std::string &bundleName, const std::string &fileName, const ErrCode errCode,
326     const IServiceReverse::Scenario scenario) {}
327 
ExtensionConnectFailRadarReport(const std::string & bundleName,const ErrCode errCode,const IServiceReverse::Scenario scenario)328 void Service::ExtensionConnectFailRadarReport(const std::string &bundleName, const ErrCode errCode,
329     const IServiceReverse::Scenario scenario) {}
330 
PermissionCheckFailRadar(const std::string & info,const std::string & func)331 void Service::PermissionCheckFailRadar(const std::string &info, const std::string &func) {}
332 
OnStartResRadarReport(const std::vector<std::string> & bundleNameList,int32_t stage)333 void Service::OnStartResRadarReport(const std::vector<std::string> &bundleNameList, int32_t stage) {}
334 
GetCallerName()335 std::string Service::GetCallerName()
336 {
337     return "";
338 }
339 
IsReportBundleExecFail(const std::string & bundleName)340 bool Service::IsReportBundleExecFail(const std::string &bundleName)
341 {
342     return true;
343 }
344 
ClearBundleRadarReport()345 void Service::ClearBundleRadarReport() {}
346 
UpdateBundleRadarReport(const std::string & bundleName)347 void Service::UpdateBundleRadarReport(const std::string &bundleName) {}
348 
IsReportFileReadyFail(const std::string & bundleName)349 bool Service::IsReportFileReadyFail(const std::string &bundleName)
350 {
351     return true;
352 }
353 
ClearFileReadyRadarReport()354 void Service::ClearFileReadyRadarReport() {}
355 
UpdateFailedBundles(const std::string & bundleName,BundleTaskInfo taskInfo)356 void Service::UpdateFailedBundles(const std::string &bundleName, BundleTaskInfo taskInfo) {}
357 
ClearFailedBundles()358 void Service::ClearFailedBundles() {}
359 
GetOldDeviceBackupVersion()360 void Service::GetOldDeviceBackupVersion() {}
361 
CreateDirIfNotExist(const std::string & path)362 void Service::CreateDirIfNotExist(const std::string &path)
363 {
364 }
365 
StartRunningTimer(const std::string & bundleName)366 void Service::StartRunningTimer(const std::string &bundleName) {}
367 
GetSupportBackupBundleNames(vector<BJsonEntityCaps::BundleInfo> &,bool,const vector<string> &)368 std::vector<std::string> Service::GetSupportBackupBundleNames(vector<BJsonEntityCaps::BundleInfo>&, bool,
369     const vector<string>&)
370 {
371     return {};
372 }
373 
HandleNotSupportBundleNames(const vector<string> &,vector<string> &,bool)374 void Service::HandleNotSupportBundleNames(const vector<string>&, vector<string>&, bool) {}
375 
SetBundleIncDataInfo(const std::vector<BIncrementalData> &,std::vector<std::string> &)376 void Service::SetBundleIncDataInfo(const std::vector<BIncrementalData>&, std::vector<std::string>&) {}
377 
CancelTask(std::string bundleName,wptr<Service> ptr)378 void Service::CancelTask(std::string bundleName, wptr<Service> ptr) {}
379 
SetUserIdAndRestoreType(RestoreTypeEnum restoreType,int32_t userId)380 void SetUserIdAndRestoreType(RestoreTypeEnum restoreType, int32_t userId) {}
381 
CallOnBundleEndByScenario(const std::string & bundleName,BackupRestoreScenario scenario,ErrCode errCode)382 void Service::CallOnBundleEndByScenario(const std::string &bundleName, BackupRestoreScenario scenario,
383     ErrCode errCode) {}
384 
SetUserIdAndRestoreType(RestoreTypeEnum restoreType,int32_t userId)385 void Service::SetUserIdAndRestoreType(RestoreTypeEnum restoreType, int32_t userId) {}
386 
GetBackupDataSize(bool isPreciseScan,vector<BIncrementalData> bundleNameList)387 ErrCode Service::GetBackupDataSize(bool isPreciseScan, vector<BIncrementalData> bundleNameList)
388 {
389     return BError(BError::Codes::OK);
390 }
391 
GetDataSizeStepByStep(bool isPreciseScan,vector<BIncrementalData> bundleNameList,string & scanning)392 void Service::GetDataSizeStepByStep(bool isPreciseScan, vector<BIncrementalData> bundleNameList, string &scanning) {}
393 
GetPresumablySize(vector<BIncrementalData> bundleNameList,string & scanning)394 void Service::GetPresumablySize(vector<BIncrementalData> bundleNameList, string &scanning) {}
395 
GetPrecisesSize(vector<BIncrementalData> bundleNameList,string & scanning)396 void Service::GetPrecisesSize(vector<BIncrementalData> bundleNameList, string &scanning) {}
397 
WriteToList(BJsonUtil::BundleDataSize bundleDataSize)398 void Service::WriteToList(BJsonUtil::BundleDataSize bundleDataSize) {}
399 
DeleteFromList(size_t scannedSize)400 void Service::DeleteFromList(size_t scannedSize) {}
401 
WriteScannedInfoToList(const string & bundleName,int64_t dataSize,int64_t incDataSize)402 void Service::WriteScannedInfoToList(const string &bundleName, int64_t dataSize, int64_t incDataSize) {}
403 
SendScannedInfo(const string & scannendInfos,sptr<SvcSessionManager> session)404 void Service::SendScannedInfo(const string&scannendInfos, sptr<SvcSessionManager> session) {}
405 
CyclicSendScannedInfo(bool isPreciseScan,vector<BIncrementalData> bundleNameList)406 void Service::CyclicSendScannedInfo(bool isPreciseScan, vector<BIncrementalData> bundleNameList) {}
407 
GetScanningInfo(wptr<Service> obj,size_t scannedSize,string & scanning)408 bool Service::GetScanningInfo(wptr<Service> obj, size_t scannedSize, string &scanning)
409 {
410     return true;
411 }
412 
SetScanningInfo(string & scanning,string name)413 void Service::SetScanningInfo(string &scanning, string name) {}
414 } // namespace OHOS::FileManagement::Backup
415