• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "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,IServiceReverse::Scenario scenario) const22 ErrCode SvcSessionManager::VerifyCallerAndScenario(uint32_t clientToken, IServiceReverse::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 IServiceReverse::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 
GetBackupExtName(const string & bundleName)118 string SvcSessionManager::GetBackupExtName(const string &bundleName)
119 {
120     return BackupSvcSessionManager::session->GetBackupExtName(bundleName);
121 }
122 
SetBackupExtInfo(const string & bundleName,const string & extInfo)123 void SvcSessionManager::SetBackupExtInfo(const string &bundleName, const string &extInfo)
124 {
125     BackupSvcSessionManager::session->SetBackupExtInfo(bundleName, extInfo);
126 }
127 
GetBackupExtInfo(const string & bundleName)128 std::string SvcSessionManager::GetBackupExtInfo(const string &bundleName)
129 {
130     return BackupSvcSessionManager::session->GetBackupExtInfo(bundleName);
131 }
132 
SetBackupExtName(const string & bundleName,const string & backupExtName)133 void SvcSessionManager::SetBackupExtName(const string &bundleName, const string &backupExtName)
134 {
135     BackupSvcSessionManager::session->SetBackupExtName(bundleName, backupExtName);
136 }
137 
GetSAExtConnection(const BundleName & bundleName)138 std::weak_ptr<SABackupConnection> SvcSessionManager::GetSAExtConnection(const BundleName &bundleName)
139 {
140     return BackupSvcSessionManager::session->GetSAExtConnection(bundleName);
141 }
142 
GetBundleUserId(const string & bundleName)143 int32_t SvcSessionManager::GetBundleUserId(const string &bundleName)
144 {
145     return BackupSvcSessionManager::session->GetBundleUserId(bundleName);
146 }
147 
SetBundleUserId(const string & bundleName,const int32_t userId)148 void SvcSessionManager::SetBundleUserId(const string &bundleName, const int32_t userId)
149 {
150     BackupSvcSessionManager::session->SetBundleUserId(bundleName, userId);
151 }
152 
AppendBundles(const vector<BundleName> & bundleNames,vector<BundleName> & failedBundles)153 void SvcSessionManager::AppendBundles(const vector<BundleName> &bundleNames, vector<BundleName> &failedBundles)
154 {
155     BackupSvcSessionManager::session->AppendBundles(bundleNames, failedBundles);
156 }
157 
CreateBackupConnection(BundleName & bundleName)158 sptr<SvcBackupConnection> SvcSessionManager::CreateBackupConnection(BundleName &bundleName)
159 {
160     return BackupSvcSessionManager::session->CreateBackupConnection(bundleName);
161 }
162 
Start()163 ErrCode SvcSessionManager::Start()
164 {
165     return BackupSvcSessionManager::session->Start();
166 }
167 
Finish()168 ErrCode SvcSessionManager::Finish()
169 {
170     return BackupSvcSessionManager::session->Finish();
171 }
172 
IsOnAllBundlesFinished()173 bool SvcSessionManager::IsOnAllBundlesFinished()
174 {
175     return BackupSvcSessionManager::session->IsOnAllBundlesFinished();
176 }
177 
IsOnOnStartSched()178 bool SvcSessionManager::IsOnOnStartSched()
179 {
180     return BackupSvcSessionManager::session->IsOnOnStartSched();
181 }
182 
NeedToUnloadService()183 bool SvcSessionManager::NeedToUnloadService()
184 {
185     return BackupSvcSessionManager::session->NeedToUnloadService();
186 }
187 
GetSessionUserId()188 int32_t SvcSessionManager::GetSessionUserId()
189 {
190     return BackupSvcSessionManager::session->GetSessionUserId();
191 }
192 
SetSessionUserId(int32_t userId)193 void SvcSessionManager::SetSessionUserId(int32_t userId)
194 {
195     BackupSvcSessionManager::session->SetSessionUserId(userId);
196 }
197 
GetSessionCallerName()198 string SvcSessionManager::GetSessionCallerName()
199 {
200     return BackupSvcSessionManager::session->GetSessionCallerName();
201 }
202 
GetSessionActiveTime()203 string SvcSessionManager::GetSessionActiveTime()
204 {
205     return BackupSvcSessionManager::session->GetSessionActiveTime();
206 }
207 
SetBundleRestoreType(const std::string & bundleName,RestoreTypeEnum restoreType)208 void SvcSessionManager::SetBundleRestoreType(const std::string &bundleName, RestoreTypeEnum restoreType)
209 {
210     BackupSvcSessionManager::session->SetBundleRestoreType(bundleName, restoreType);
211 }
212 
GetBundleRestoreType(const std::string & bundleName)213 RestoreTypeEnum SvcSessionManager::GetBundleRestoreType(const std::string &bundleName)
214 {
215     return BackupSvcSessionManager::session->GetBundleRestoreType(bundleName);
216 }
217 
SetBundleVersionCode(const std::string & bundleName,int64_t versionCode)218 void SvcSessionManager::SetBundleVersionCode(const std::string &bundleName, int64_t versionCode)
219 {
220     BackupSvcSessionManager::session->SetBundleVersionCode(bundleName, versionCode);
221 }
222 
GetBundleVersionCode(const std::string & bundleName)223 int64_t SvcSessionManager::GetBundleVersionCode(const std::string &bundleName)
224 {
225     return BackupSvcSessionManager::session->GetBundleVersionCode(bundleName);
226 }
227 
SetBundleVersionName(const std::string & bundleName,std::string versionName)228 void SvcSessionManager::SetBundleVersionName(const std::string &bundleName, std::string versionName)
229 {
230     BackupSvcSessionManager::session->SetBundleVersionName(bundleName, versionName);
231 }
232 
GetBundleVersionName(const std::string & bundleName)233 std::string SvcSessionManager::GetBundleVersionName(const std::string &bundleName)
234 {
235     return BackupSvcSessionManager::session->GetBundleVersionName(bundleName);
236 }
237 
SetBundleDataSize(const std::string & bundleName,int64_t dataSize)238 void SvcSessionManager::SetBundleDataSize(const std::string &bundleName, int64_t dataSize)
239 {
240     BackupSvcSessionManager::session->SetBundleDataSize(bundleName, dataSize);
241 }
242 
StartFwkTimer(const std::string & bundleName,const Utils::Timer::TimerCallback & callback)243 bool SvcSessionManager::StartFwkTimer(const std::string &bundleName, const Utils::Timer::TimerCallback &callback)
244 {
245     return BackupSvcSessionManager::session->StartFwkTimer(bundleName, callback);
246 }
247 
StopFwkTimer(const std::string & bundleName)248 bool SvcSessionManager::StopFwkTimer(const std::string &bundleName)
249 {
250     return BackupSvcSessionManager::session->StopFwkTimer(bundleName);
251 }
252 
StartExtTimer(const std::string & bundleName,const Utils::Timer::TimerCallback & callback)253 bool SvcSessionManager::StartExtTimer(const std::string &bundleName, const Utils::Timer::TimerCallback &callback)
254 {
255     return BackupSvcSessionManager::session->StartExtTimer(bundleName, callback);
256 }
257 
StopExtTimer(const std::string & bundleName)258 bool SvcSessionManager::StopExtTimer(const std::string &bundleName)
259 {
260     return BackupSvcSessionManager::session->StopExtTimer(bundleName);
261 }
262 
UpdateTimer(const std::string & bundleName,uint32_t timeout,const Utils::Timer::TimerCallback & callback)263 bool SvcSessionManager::UpdateTimer(const std::string &bundleName, uint32_t timeout,
264     const Utils::Timer::TimerCallback &callback)
265 {
266     return BackupSvcSessionManager::session->UpdateTimer(bundleName, timeout, callback);
267 }
268 
IncreaseSessionCnt(const std::string funcName)269 void SvcSessionManager::IncreaseSessionCnt(const std::string funcName)
270 {
271     BackupSvcSessionManager::session->IncreaseSessionCnt(funcName);
272 }
273 
DecreaseSessionCnt(const std::string funcName)274 void SvcSessionManager::DecreaseSessionCnt(const std::string funcName)
275 {
276     BackupSvcSessionManager::session->DecreaseSessionCnt(funcName);
277 }
278 
GetMemParaCurSize()279 int32_t SvcSessionManager::GetMemParaCurSize()
280 {
281     return BackupSvcSessionManager::session->GetMemParaCurSize();
282 }
283 
SetMemParaCurSize(int32_t size)284 void SvcSessionManager::SetMemParaCurSize(int32_t size)
285 {
286     BackupSvcSessionManager::session->SetMemParaCurSize(size);
287 }
288 
ClearSessionData()289 ErrCode SvcSessionManager::ClearSessionData()
290 {
291     return BackupSvcSessionManager::session->ClearSessionData();
292 }
293 
GetIsIncrementalBackup()294 bool SvcSessionManager::GetIsIncrementalBackup()
295 {
296     return BackupSvcSessionManager::session->GetIsIncrementalBackup();
297 }
298 
ValidRestoreDataType(RestoreTypeEnum restoreDataType)299 bool SvcSessionManager::ValidRestoreDataType(RestoreTypeEnum restoreDataType)
300 {
301     return BackupSvcSessionManager::session->ValidRestoreDataType(restoreDataType);
302 }
303 
GetTimeoutValue(const std::string & bundleName)304 uint32_t SvcSessionManager::GetTimeoutValue(const std::string &bundleName)
305 {
306     return BackupSvcSessionManager::session->GetTimeoutValue(bundleName);
307 }
308 
GetImpl()309 SvcSessionManager::Impl SvcSessionManager::GetImpl()
310 {
311     return BackupSvcSessionManager::session->GetImpl();
312 }
313 
GetSessionCnt()314 int SvcSessionManager::GetSessionCnt()
315 {
316     return BackupSvcSessionManager::session->GetSessionCnt();
317 }
318 
SetClearDataFlag(const std::string & bundleName,bool isNotClear)319 void SvcSessionManager::SetClearDataFlag(const std::string &bundleName, bool isNotClear)
320 {
321     BackupSvcSessionManager::session->SetClearDataFlag(bundleName, isNotClear);
322 }
323 
GetClearDataFlag(const std::string & bundleName)324 bool SvcSessionManager::GetClearDataFlag(const std::string &bundleName)
325 {
326     return BackupSvcSessionManager::session->GetClearDataFlag(bundleName);
327 }
328 
SetIncrementalData(const BIncrementalData & incrementalData)329 void SvcSessionManager::SetIncrementalData(const BIncrementalData &incrementalData)
330 {
331     BackupSvcSessionManager::session->SetIncrementalData(incrementalData);
332 }
333 
GetIncrementalManifestFd(const string & bundleName)334 int32_t SvcSessionManager::GetIncrementalManifestFd(const string &bundleName)
335 {
336     return BackupSvcSessionManager::session->GetIncrementalManifestFd(bundleName);
337 }
338 
GetLastIncrementalTime(const string & bundleName)339 int64_t SvcSessionManager::GetLastIncrementalTime(const string &bundleName)
340 {
341     return BackupSvcSessionManager::session->GetLastIncrementalTime(bundleName);
342 }
343 
CleanAndCheckIfNeedWait(ErrCode & ret,std::vector<std::string> & bundleNameList)344 bool SvcSessionManager::CleanAndCheckIfNeedWait(ErrCode &ret, std::vector<std::string> &bundleNameList)
345 {
346     return false;
347 }
348 
SetPublishFlag(const std::string & bundleName)349 void SvcSessionManager::SetPublishFlag(const std::string &bundleName) {}
350 
SetImplRestoreType(const RestoreTypeEnum restoreType)351 void SvcSessionManager::SetImplRestoreType(const RestoreTypeEnum restoreType) {}
352 
SetIsReadyLaunch(const std::string & bundleName)353 void SvcSessionManager::SetIsReadyLaunch(const std::string &bundleName) {}
354 
SetOldBackupVersion(const std::string & backupVersion)355 void SvcSessionManager::SetOldBackupVersion(const std::string &backupVersion) {}
356 
GetOldBackupVersion()357 std::string SvcSessionManager::GetOldBackupVersion()
358 {
359     return BackupSvcSessionManager::session->GetOldBackupVersion();
360 }
361 } // namespace OHOS::FileManagement::Backup
362