• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-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 "module_ipc/svc_session_manager.h"
17 #include "svc_session_manager_throw_mock.h"
18 
19 namespace OHOS::FileManagement::Backup {
20 using namespace std;
21 
VerifyCallerAndScenario(uint32_t clientToken,IServiceReverseType::Scenario scenario) const22 ErrCode SvcSessionManager::VerifyCallerAndScenario(uint32_t clientToken, IServiceReverseType::Scenario scenario) const
23 {
24     return BackupSvcSessionManager::session->VerifyCallerAndScenario(clientToken, scenario);
25 }
26 
Active(Impl newImpl,bool force)27 ErrCode SvcSessionManager::Active(Impl newImpl, bool force)
28 {
29     return BackupSvcSessionManager::session->Active(newImpl);
30 }
31 
Deactive(const wptr<IRemoteObject> & remoteInAction,bool force)32 ErrCode SvcSessionManager::Deactive(const wptr<IRemoteObject> &remoteInAction, bool force)
33 {
34     return BackupSvcSessionManager::session->Deactive(remoteInAction, force);
35 }
36 
VerifyBundleName(string & bundleName)37 ErrCode SvcSessionManager::VerifyBundleName(string &bundleName)
38 {
39     return BackupSvcSessionManager::session->VerifyBundleName(bundleName);
40 }
41 
GetServiceReverseProxy()42 sptr<IServiceReverse> SvcSessionManager::GetServiceReverseProxy()
43 {
44     return BackupSvcSessionManager::session->GetServiceReverseProxy();
45 }
46 
GetScenario()47 IServiceReverseType::Scenario SvcSessionManager::GetScenario()
48 {
49     return BackupSvcSessionManager::session->GetScenario();
50 }
51 
OnBundleFileReady(const string & bundleName,const string & fileName)52 bool SvcSessionManager::OnBundleFileReady(const string &bundleName, const string &fileName)
53 {
54     return BackupSvcSessionManager::session->OnBundleFileReady(bundleName, fileName);
55 }
56 
OnBundleExtManageInfo(const string & bundleName,UniqueFd fd)57 UniqueFd SvcSessionManager::OnBundleExtManageInfo(const string &bundleName, UniqueFd fd)
58 {
59     return BackupSvcSessionManager::session->OnBundleExtManageInfo(bundleName, move(fd));
60 }
61 
RemoveExtInfo(const string & bundleName)62 void SvcSessionManager::RemoveExtInfo(const string &bundleName)
63 {
64     BackupSvcSessionManager::session->RemoveExtInfo(bundleName);
65 }
66 
GetExtConnection(const BundleName & bundleName)67 wptr<SvcBackupConnection> SvcSessionManager::GetExtConnection(const BundleName &bundleName)
68 {
69     return BackupSvcSessionManager::session->GetExtConnection(bundleName);
70 }
71 
GetBackupAbilityExt(const string & bundleName)72 sptr<SvcBackupConnection> SvcSessionManager::GetBackupAbilityExt(const string &bundleName)
73 {
74     return BackupSvcSessionManager::session->GetBackupAbilityExt(bundleName);
75 }
76 
DumpInfo(const int fd,const std::vector<std::u16string> & args)77 void SvcSessionManager::DumpInfo(const int fd, const std::vector<std::u16string> &args)
78 {
79     BackupSvcSessionManager::session->DumpInfo(fd, args);
80 }
81 
InitClient(Impl & newImpl)82 ErrCode SvcSessionManager::InitClient(Impl &newImpl)
83 {
84     return BackupSvcSessionManager::session->InitClient(newImpl);
85 }
86 
SetExtFileNameRequest(const string & bundleName,const string & fileName)87 void SvcSessionManager::SetExtFileNameRequest(const string &bundleName, const string &fileName)
88 {
89     BackupSvcSessionManager::session->SetExtFileNameRequest(bundleName, fileName);
90 }
91 
GetExtFileNameRequest(const std::string & bundleName)92 std::set<std::string> SvcSessionManager::GetExtFileNameRequest(const std::string &bundleName)
93 {
94     return BackupSvcSessionManager::session->GetExtFileNameRequest(bundleName);
95 }
96 
GetBackupExtNameMap(const string & bundleName)97 std::tuple<bool, map<BundleName, BackupExtInfo>::iterator> SvcSessionManager::GetBackupExtNameMap(
98     const string &bundleName)
99 {
100     return BackupSvcSessionManager::session->GetBackupExtNameMap(bundleName);
101 }
102 
GetSchedBundleName(string & bundleName)103 bool SvcSessionManager::GetSchedBundleName(string &bundleName)
104 {
105     return BackupSvcSessionManager::session->GetSchedBundleName(bundleName);
106 }
107 
GetServiceSchedAction(const std::string & bundleName)108 BConstants::ServiceSchedAction SvcSessionManager::GetServiceSchedAction(const std::string &bundleName)
109 {
110     return BackupSvcSessionManager::session->GetServiceSchedAction(bundleName);
111 }
112 
SetServiceSchedAction(const string & bundleName,BConstants::ServiceSchedAction action)113 void SvcSessionManager::SetServiceSchedAction(const string &bundleName, BConstants::ServiceSchedAction action)
114 {
115     BackupSvcSessionManager::session->SetServiceSchedAction(bundleName, action);
116 }
117 
UpdateDfxInfo(const std::string & bundleName,uint64_t uniqId)118 void SvcSessionManager::UpdateDfxInfo(const std::string &bundleName, uint64_t uniqId)
119 {
120 }
121 
GetBackupExtName(const string & bundleName)122 string SvcSessionManager::GetBackupExtName(const string &bundleName)
123 {
124     return BackupSvcSessionManager::session->GetBackupExtName(bundleName);
125 }
126 
SetBackupExtInfo(const string & bundleName,const string & extInfo)127 void SvcSessionManager::SetBackupExtInfo(const string &bundleName, const string &extInfo)
128 {
129     BackupSvcSessionManager::session->SetBackupExtInfo(bundleName, extInfo);
130 }
131 
GetBackupExtInfo(const string & bundleName)132 std::string SvcSessionManager::GetBackupExtInfo(const string &bundleName)
133 {
134     return BackupSvcSessionManager::session->GetBackupExtInfo(bundleName);
135 }
136 
SetBackupExtName(const string & bundleName,const string & backupExtName)137 void SvcSessionManager::SetBackupExtName(const string &bundleName, const string &backupExtName)
138 {
139     BackupSvcSessionManager::session->SetBackupExtName(bundleName, backupExtName);
140 }
141 
GetSAExtConnection(const BundleName & bundleName)142 std::weak_ptr<SABackupConnection> SvcSessionManager::GetSAExtConnection(const BundleName &bundleName)
143 {
144     return BackupSvcSessionManager::session->GetSAExtConnection(bundleName);
145 }
146 
GetBundleUserId(const string & bundleName)147 int32_t SvcSessionManager::GetBundleUserId(const string &bundleName)
148 {
149     return BackupSvcSessionManager::session->GetBundleUserId(bundleName);
150 }
151 
SetBundleUserId(const string & bundleName,const int32_t userId)152 void SvcSessionManager::SetBundleUserId(const string &bundleName, const int32_t userId)
153 {
154     BackupSvcSessionManager::session->SetBundleUserId(bundleName, userId);
155 }
156 
AppendBundles(const vector<BundleName> & bundleNames,vector<BundleName> & failedBundles)157 void SvcSessionManager::AppendBundles(const vector<BundleName> &bundleNames, vector<BundleName> &failedBundles)
158 {
159     BackupSvcSessionManager::session->AppendBundles(bundleNames, failedBundles);
160 }
161 
CreateBackupConnection(const BundleName & bundleName)162 sptr<SvcBackupConnection> SvcSessionManager::CreateBackupConnection(const BundleName &bundleName)
163 {
164     return BackupSvcSessionManager::session->CreateBackupConnection(bundleName);
165 }
166 
Start()167 ErrCode SvcSessionManager::Start()
168 {
169     return BackupSvcSessionManager::session->Start();
170 }
171 
Finish()172 ErrCode SvcSessionManager::Finish()
173 {
174     return BackupSvcSessionManager::session->Finish();
175 }
176 
IsOnAllBundlesFinished()177 bool SvcSessionManager::IsOnAllBundlesFinished()
178 {
179     return BackupSvcSessionManager::session->IsOnAllBundlesFinished();
180 }
181 
IsOnOnStartSched()182 bool SvcSessionManager::IsOnOnStartSched()
183 {
184     return BackupSvcSessionManager::session->IsOnOnStartSched();
185 }
186 
NeedToUnloadService()187 bool SvcSessionManager::NeedToUnloadService()
188 {
189     return BackupSvcSessionManager::session->NeedToUnloadService();
190 }
191 
GetSessionUserId()192 int32_t SvcSessionManager::GetSessionUserId()
193 {
194     return BackupSvcSessionManager::session->GetSessionUserId();
195 }
196 
SetSessionUserId(int32_t userId)197 void SvcSessionManager::SetSessionUserId(int32_t userId)
198 {
199     BackupSvcSessionManager::session->SetSessionUserId(userId);
200 }
201 
GetSessionCallerName()202 string SvcSessionManager::GetSessionCallerName()
203 {
204     return BackupSvcSessionManager::session->GetSessionCallerName();
205 }
206 
GetSessionActiveTime()207 string SvcSessionManager::GetSessionActiveTime()
208 {
209     return BackupSvcSessionManager::session->GetSessionActiveTime();
210 }
211 
SetBundleRestoreType(const std::string & bundleName,RestoreTypeEnum restoreType)212 void SvcSessionManager::SetBundleRestoreType(const std::string &bundleName, RestoreTypeEnum restoreType)
213 {
214     BackupSvcSessionManager::session->SetBundleRestoreType(bundleName, restoreType);
215 }
216 
GetBundleRestoreType(const std::string & bundleName)217 RestoreTypeEnum SvcSessionManager::GetBundleRestoreType(const std::string &bundleName)
218 {
219     return BackupSvcSessionManager::session->GetBundleRestoreType(bundleName);
220 }
221 
SetBundleVersionCode(const std::string & bundleName,int64_t versionCode)222 void SvcSessionManager::SetBundleVersionCode(const std::string &bundleName, int64_t versionCode)
223 {
224     BackupSvcSessionManager::session->SetBundleVersionCode(bundleName, versionCode);
225 }
226 
GetBundleVersionCode(const std::string & bundleName)227 int64_t SvcSessionManager::GetBundleVersionCode(const std::string &bundleName)
228 {
229     return BackupSvcSessionManager::session->GetBundleVersionCode(bundleName);
230 }
231 
SetBundleVersionName(const std::string & bundleName,std::string versionName)232 void SvcSessionManager::SetBundleVersionName(const std::string &bundleName, std::string versionName)
233 {
234     BackupSvcSessionManager::session->SetBundleVersionName(bundleName, versionName);
235 }
236 
GetBundleVersionName(const std::string & bundleName)237 std::string SvcSessionManager::GetBundleVersionName(const std::string &bundleName)
238 {
239     return BackupSvcSessionManager::session->GetBundleVersionName(bundleName);
240 }
241 
SetBundleDataSize(const std::string & bundleName,int64_t dataSize)242 void SvcSessionManager::SetBundleDataSize(const std::string &bundleName, int64_t dataSize)
243 {
244     BackupSvcSessionManager::session->SetBundleDataSize(bundleName, dataSize);
245 }
246 
StartFwkTimer(const std::string & bundleName,const Utils::Timer::TimerCallback & callback)247 bool SvcSessionManager::StartFwkTimer(const std::string &bundleName, const Utils::Timer::TimerCallback &callback)
248 {
249     return BackupSvcSessionManager::session->StartFwkTimer(bundleName, callback);
250 }
251 
StopFwkTimer(const std::string & bundleName)252 bool SvcSessionManager::StopFwkTimer(const std::string &bundleName)
253 {
254     return BackupSvcSessionManager::session->StopFwkTimer(bundleName);
255 }
256 
StartExtTimer(const std::string & bundleName,const Utils::Timer::TimerCallback & callback)257 bool SvcSessionManager::StartExtTimer(const std::string &bundleName, const Utils::Timer::TimerCallback &callback)
258 {
259     return BackupSvcSessionManager::session->StartExtTimer(bundleName, callback);
260 }
261 
StopExtTimer(const std::string & bundleName)262 bool SvcSessionManager::StopExtTimer(const std::string &bundleName)
263 {
264     return BackupSvcSessionManager::session->StopExtTimer(bundleName);
265 }
266 
UpdateTimer(const std::string & bundleName,uint32_t timeout,const Utils::Timer::TimerCallback & callback)267 bool SvcSessionManager::UpdateTimer(const std::string &bundleName, uint32_t timeout,
268     const Utils::Timer::TimerCallback &callback)
269 {
270     return BackupSvcSessionManager::session->UpdateTimer(bundleName, timeout, callback);
271 }
272 
IncreaseSessionCnt(const std::string funcName)273 void SvcSessionManager::IncreaseSessionCnt(const std::string funcName)
274 {
275     BackupSvcSessionManager::session->IncreaseSessionCnt(funcName);
276 }
277 
DecreaseSessionCnt(const std::string funcName)278 void SvcSessionManager::DecreaseSessionCnt(const std::string funcName)
279 {
280     BackupSvcSessionManager::session->DecreaseSessionCnt(funcName);
281 }
282 
GetMemParaCurSize()283 int32_t SvcSessionManager::GetMemParaCurSize()
284 {
285     return BackupSvcSessionManager::session->GetMemParaCurSize();
286 }
287 
SetMemParaCurSize(int32_t size)288 void SvcSessionManager::SetMemParaCurSize(int32_t size)
289 {
290     BackupSvcSessionManager::session->SetMemParaCurSize(size);
291 }
292 
ClearSessionData()293 ErrCode SvcSessionManager::ClearSessionData()
294 {
295     return BackupSvcSessionManager::session->ClearSessionData();
296 }
297 
GetIsIncrementalBackup()298 bool SvcSessionManager::GetIsIncrementalBackup()
299 {
300     return BackupSvcSessionManager::session->GetIsIncrementalBackup();
301 }
302 
ValidRestoreDataType(RestoreTypeEnum restoreDataType)303 bool SvcSessionManager::ValidRestoreDataType(RestoreTypeEnum restoreDataType)
304 {
305     return BackupSvcSessionManager::session->ValidRestoreDataType(restoreDataType);
306 }
307 
GetTimeoutValue(const std::string & bundleName)308 uint32_t SvcSessionManager::GetTimeoutValue(const std::string &bundleName)
309 {
310     return BackupSvcSessionManager::session->GetTimeoutValue(bundleName);
311 }
312 
GetImpl()313 SvcSessionManager::Impl SvcSessionManager::GetImpl()
314 {
315     return BackupSvcSessionManager::session->GetImpl();
316 }
317 
GetSessionCnt()318 int SvcSessionManager::GetSessionCnt()
319 {
320     return BackupSvcSessionManager::session->GetSessionCnt();
321 }
322 
SetClearDataFlag(const std::string & bundleName,bool isNotClear)323 void SvcSessionManager::SetClearDataFlag(const std::string &bundleName, bool isNotClear)
324 {
325     BackupSvcSessionManager::session->SetClearDataFlag(bundleName, isNotClear);
326 }
327 
GetClearDataFlag(const std::string & bundleName)328 bool SvcSessionManager::GetClearDataFlag(const std::string &bundleName)
329 {
330     return BackupSvcSessionManager::session->GetClearDataFlag(bundleName);
331 }
332 
SetIncrementalData(const BIncrementalData & incrementalData)333 void SvcSessionManager::SetIncrementalData(const BIncrementalData &incrementalData)
334 {
335     BackupSvcSessionManager::session->SetIncrementalData(incrementalData);
336 }
337 
GetIncrementalManifestFd(const string & bundleName)338 int32_t SvcSessionManager::GetIncrementalManifestFd(const string &bundleName)
339 {
340     return BackupSvcSessionManager::session->GetIncrementalManifestFd(bundleName);
341 }
342 
GetLastIncrementalTime(const string & bundleName)343 int64_t SvcSessionManager::GetLastIncrementalTime(const string &bundleName)
344 {
345     return BackupSvcSessionManager::session->GetLastIncrementalTime(bundleName);
346 }
347 
CleanAndCheckIfNeedWait(ErrCode & ret,std::vector<std::string> & bundleNameList)348 bool SvcSessionManager::CleanAndCheckIfNeedWait(ErrCode &ret, std::vector<std::string> &bundleNameList)
349 {
350     return false;
351 }
352 
SetPublishFlag(const std::string & bundleName)353 void SvcSessionManager::SetPublishFlag(const std::string &bundleName) {}
354 
SetImplRestoreType(const RestoreTypeEnum restoreType)355 void SvcSessionManager::SetImplRestoreType(const RestoreTypeEnum restoreType) {}
356 
SetIsReadyLaunch(const std::string & bundleName)357 void SvcSessionManager::SetIsReadyLaunch(const std::string &bundleName) {}
358 
SetOldBackupVersion(const std::string & backupVersion)359 void SvcSessionManager::SetOldBackupVersion(const std::string &backupVersion) {}
360 
GetOldBackupVersion()361 std::string SvcSessionManager::GetOldBackupVersion()
362 {
363     return BackupSvcSessionManager::session->GetOldBackupVersion();
364 }
365 
HandleOnRelease(sptr<IExtension> proxy)366 void SvcSessionManager::HandleOnRelease(sptr<IExtension> proxy) {}
367 
SetIsRestoreEnd(const std::string & bundleName)368 void SvcSessionManager::SetIsRestoreEnd(const std::string &bundleName)
369 {
370 }
371 
GetIsRestoreEnd(const std::string & bundleName)372 bool SvcSessionManager::GetIsRestoreEnd(const std::string &bundleName)
373 {
374     return false;
375 }
376 } // namespace OHOS::FileManagement::Backup
377