• 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 #ifndef OHOS_FILEMGMT_BACKUP_SERVICE_H
17 #define OHOS_FILEMGMT_BACKUP_SERVICE_H
18 
19 #include <cstdint>
20 #include <mutex>
21 
22 #include "b_jsonutil/b_jsonutil.h"
23 #include "b_json/b_json_clear_data_config.h"
24 #include "b_json/b_json_entity_caps.h"
25 #include "b_json/b_json_service_disposal_config.h"
26 #include "i_service_reverse.h"
27 #include "iremote_stub.h"
28 #include "module_sched/sched_scheduler.h"
29 #include "service_stub.h"
30 #include "svc_session_manager.h"
31 #include "system_ability.h"
32 #include "thread_pool.h"
33 
34 namespace OHOS::FileManagement::Backup {
35 struct ExtensionMutexInfo {
36     std::string bundleName;
37     std::mutex callbackMutex;
ExtensionMutexInfoExtensionMutexInfo38     ExtensionMutexInfo(std::string bundleName_) : bundleName(bundleName_) {};
39 };
40 
41 struct BundleTaskInfo {
42     std::string reportTime;
43     ErrCode errCode;
44 };
45 
46 class Service : public SystemAbility, public ServiceStub, protected NoCopyable {
47     DECLARE_SYSTEM_ABILITY(Service);
48 
49     // 以下都是IPC接口
50 public:
51     ErrCode InitRestoreSession(sptr<IServiceReverse> remote) override;
52     ErrCode InitRestoreSession(sptr<IServiceReverse> remote, std::string &errMsg) override;
53     ErrCode InitBackupSession(sptr<IServiceReverse> remote) override;
54     ErrCode InitBackupSession(sptr<IServiceReverse> remote, std::string &errMsg) override;
55     ErrCode Start() override;
56     UniqueFd GetLocalCapabilities() override;
57     UniqueFd GetLocalCapabilitiesForBundleInfos() override;
58     ErrCode PublishFile(const BFileInfo &fileInfo) override;
59     ErrCode AppFileReady(const std::string &fileName, UniqueFd fd, int32_t errCode) override;
60     ErrCode AppDone(ErrCode errCode) override;
61     ErrCode ServiceResultReport(const std::string restoreRetInfo,
62         BackupRestoreScenario sennario, ErrCode errCode) override;
63     ErrCode GetFileHandle(const std::string &bundleName, const std::string &fileName) override;
64     ErrCode AppendBundlesRestoreSession(UniqueFd fd,
65                                         const std::vector<BundleName> &bundleNames,
66                                         const std::vector<std::string> &bundleInfos,
67                                         RestoreTypeEnum restoreType = RestoreTypeEnum::RESTORE_DATA_WAIT_SEND,
68                                         int32_t userId = DEFAULT_INVAL_VALUE) override;
69     ErrCode AppendBundlesRestoreSession(UniqueFd fd,
70                                         const std::vector<BundleName> &bundleNames,
71                                         RestoreTypeEnum restoreType = RestoreTypeEnum::RESTORE_DATA_WAIT_SEND,
72                                         int32_t userId = DEFAULT_INVAL_VALUE) override;
73     ErrCode AppendBundlesBackupSession(const std::vector<BundleName> &bundleNames) override;
74     ErrCode AppendBundlesDetailsBackupSession(const std::vector<BundleName> &bundleNames,
75                                               const std::vector<std::string> &bundleInfos) override;
76     ErrCode Finish() override;
77     ErrCode Release() override;
78     ErrCode Cancel(std::string bundleName, int32_t &result) override;
79 
80     UniqueFd GetLocalCapabilitiesIncremental(const std::vector<BIncrementalData> &bundleNames) override;
81     ErrCode GetAppLocalListAndDoIncrementalBackup() override;
82     ErrCode InitIncrementalBackupSession(sptr<IServiceReverse> remote) override;
83     ErrCode InitIncrementalBackupSession(sptr<IServiceReverse> remote, std::string &errMsg) override;
84     ErrCode AppendBundlesIncrementalBackupSession(const std::vector<BIncrementalData> &bundlesToBackup) override;
85     ErrCode AppendBundlesIncrementalBackupSession(const std::vector<BIncrementalData> &bundlesToBackup,
86         const std::vector<std::string> &infos) override;
87 
88     ErrCode PublishIncrementalFile(const BFileInfo &fileInfo) override;
89     ErrCode PublishSAIncrementalFile(const BFileInfo &fileInfo, UniqueFd fd) override;
90     ErrCode AppIncrementalFileReady(const std::string &fileName, UniqueFd fd, UniqueFd manifestFd,
91         int32_t errCode) override;
92     ErrCode AppIncrementalDone(ErrCode errCode) override;
93     ErrCode GetIncrementalFileHandle(const std::string &bundleName, const std::string &fileName) override;
94     ErrCode GetBackupInfo(BundleName &bundleName, std::string &result) override;
95     ErrCode UpdateTimer(BundleName &bundleName, uint32_t timeout, bool &result) override;
96     ErrCode UpdateSendRate(std::string &bundleName, int32_t sendRate, bool &result) override;
97     ErrCode ReportAppProcessInfo(const std::string processInfo, const BackupRestoreScenario sennario) override;
98     ErrCode StartExtTimer(bool &isExtStart) override;
99     ErrCode StartFwkTimer(bool &isFwkStart) override;
100     ErrCode StopExtTimer(bool &isExtStop) override;
101     ErrCode RefreshDataSize(int64_t totalDataSize) override;
102 
103     ErrCode SAResultReport(const std::string bundleName, const std::string resultInfo,
104                            const ErrCode errCode, const BackupRestoreScenario sennario);
105     void StartGetFdTask(std::string bundleName, wptr<Service> ptr);
106 
107     ErrCode GetBackupDataSize(bool isPreciseScan, vector<BIncrementalData> bundleNameList) override;
108 
109     // 以下都是非IPC接口
110 public:
111     void OnStart() override;
112     void OnStop() override;
113     void StopAll(const wptr<IRemoteObject> &obj, bool force = false);
114     int Dump(int fd, const std::vector<std::u16string> &args) override;
115 
116     /**
117      * @brief 执行启动 backup extension
118      *
119      * @param bundleName
120      * @return ErrCode
121      */
122     virtual ErrCode LaunchBackupExtension(const BundleName &bundleName);
123 
124     /**
125      * @brief 执行启动 backup sa extension
126      *
127      * @param bundleName
128      * @return ErrCode
129      */
130     ErrCode LaunchBackupSAExtension(const BundleName &bundleName);
131 
132     /**
133      * @brief backup extension died
134      *
135      * @param bundleName 应用名称
136      */
137     void OnBackupExtensionDied(const std::string &&bundleName, bool isCleanCalled = false);
138 
139     /**
140      * @brief extension启动连接成功
141      *
142      * @param bundleName 应用名称
143      */
144     void ExtConnectDone(std::string bundleName);
145 
146     /**
147      * @brief extension启动连接失败
148      *
149      * @param bundleName 应用名称
150      */
151     void ExtConnectFailed(const std::string &bundleName, ErrCode ret);
152 
153     /**
154      * @brief 执行backup extension 备份恢复流程
155      *
156      * @param bundleName 应用名称
157      */
158     virtual void ExtStart(const std::string &bundleName);
159 
160     /**
161      * @brief 备份恢复开始,设置处置位
162      *
163      * @param bundleName 应用名称
164      *
165      */
166     void SendStartAppGalleryNotify(const std::string &bundleName);
167 
168     /**
169      * @brief 备份恢复结束,清理处置位
170      *
171      * @param bundleName 应用名称
172      *
173      */
174     void SendEndAppGalleryNotify(const std::string &bundleName);
175 
176     /**
177      * @brief 备份恢复异常结束,清理处置位
178      *
179      */
180     void SendErrAppGalleryNotify();
181 
182     /**
183      * @brief SA开始时,清理配置文件中的处置位
184      *
185      */
186     void ClearDisposalOnSaStart();
187 
188     /**
189      * @brief 备份恢复全部结束,删除配置文件
190      *
191      *
192      */
193     void DeleteDisConfigFile();
194 
195     /**
196      * @brief 尝试清理处置
197      *
198      * @param bundleName 应用名称
199      *
200      */
201     void TryToClearDispose(const BundleName &bundleName);
202 
203     /**
204      * @brief 结束会话删除session,卸载服务
205      *
206      */
207     void SessionDeactive();
208 
209     /**
210      * @brief 构造拉起应用所需的want
211      *
212      * @param bundleName 应用名称
213      *
214      */
215     AAFwk::Want CreateConnectWant (BundleName &bundleName);
216 
217     /**
218      * @brief SA backup回调
219      *
220      * @param bundleName 应用名称
221      * @param fd 备份数据
222      * @param result SA备份的结果(异常)
223      * @param errCode backup的错误
224      *
225      */
226     void OnSABackup(const std::string &bundleName, const int &fd, const std::string &result, const ErrCode &errCode);
227 
228     /**
229      * @brief SA restore回调
230      *
231      * @param bundleName 应用名称
232      * @param result SA恢复的结果(异常)
233      * @param errCode restore的错误
234      *
235      */
236     void OnSARestore(const std::string &bundleName, const std::string &result, const ErrCode &errCode);
237 
238     /**
239      * @brief GetBackupInfo extension成功回调
240      *
241      * @param obj 当前对象
242      * @param bundleName 应用名称
243      *
244      */
245     std::function<void(const std::string &&)> GetBackupInfoConnectDone(wptr<Service> obj, std::string &bundleName);
246 
247     /**
248      * @brief GetBackupInfo extension死亡回调
249      *
250      * @param obj 当前对象
251      * @param bundleName 应用名称
252      *
253      */
254     std::function<void(const std::string &&, bool)> GetBackupInfoConnectDied(
255         wptr<Service> obj, std::string &bundleName);
256 
257     /**
258      * @brief timeout callback
259      *
260      * @param ptr 当前对象
261      * @param bundleName 应用名称
262      */
263     std::function<void()> TimeOutCallback(wptr<Service> ptr, std::string bundleName);
264 
265     /**
266      * @brief do timeout
267      *
268      * @param ptr 当前对象
269      * @param bundleName 应用名称
270      */
271     void DoTimeout(wptr<Service> ptr, std::string bundleName);
272 
273     /**
274      * @brief 清理残留数据
275      *
276      * @param bundleName 应用名称
277      *
278      */
279     ErrCode ClearResidualBundleData(const std::string &bundleName);
280 
281     /**
282      * @brief 添加清理记录
283      *
284      * @param bundleName 应用名称
285      *
286      */
287     void AddClearBundleRecord(const std::string &bundleName);
288 
289     /**
290      * @brief 删除清理记录
291      *
292      * @param bundleName 应用名称
293      *
294      */
295     void DelClearBundleRecord(const std::vector<std::string> &bundleNames);
296 
297     /**
298      * @brief 获取extension锁
299      *
300      * @param bundleName 应用名称
301      *
302      */
303     std::shared_ptr<ExtensionMutexInfo> GetExtensionMutex(const BundleName &bundleName);
304 
305     /**
306      * @brief 清理extension锁
307      *
308      * @param bundleName 应用名称
309      *
310      */
311     void RemoveExtensionMutex(const BundleName &bundleName);
312     void StartRunningTimer(const std::string &bundleName);
313     string BundleNameWithUserId(const string& bundleName, const int32_t userId);
314     std::tuple<std::string, int32_t> SplitBundleName(const string& bundleNameWithId);
315     void AppendBundles(const std::vector<std::string> &bundleNames);
316     void ReportOnBundleStarted(IServiceReverse::Scenario scenario, const std::string &bundleName);
317     ErrCode AppIncrementalFileReady(const std::string &bundleName, const std::string &fileName, UniqueFd fd,
318         UniqueFd manifestFd, int32_t errCode);
319 public:
SystemAbility(saID,runOnCreate)320     explicit Service(int32_t saID, bool runOnCreate = false) : SystemAbility(saID, runOnCreate)
321     {
322         threadPool_.Start(BConstants::EXTENSION_THREAD_POOL_COUNT);
323         sendScannendResultThreadPool_.Start(BConstants::SA_THREAD_POOL_COUNT);
324         getDataSizeThreadPool_.Start(BConstants::SA_THREAD_POOL_COUNT);
325         callbackScannedInfoThreadPool_.Start(BConstants::SA_THREAD_POOL_COUNT);
326         session_ = sptr<SvcSessionManager>(new SvcSessionManager(wptr(this)));
327         disposal_ = make_shared<BJsonDisposalConfig>();
328         clearRecorder_ = make_shared<BJsonClearDataConfig>();
329         sched_ = sptr(new SchedScheduler(wptr(this), wptr(session_)));
330     };
~Service()331     ~Service() override
332     {
333         threadPool_.Stop();
334         sendScannendResultThreadPool_.Stop();
335         getDataSizeThreadPool_.Stop();
336         callbackScannedInfoThreadPool_.Stop();
337     };
338 
339 private:
340     /**
341      * @brief 验证调用者
342      *
343      */
344     ErrCode VerifyCaller();
345 
346     /**
347      * @brief 获取调用者名称
348      *
349      * @return std::string
350      */
351     std::string GetCallerName();
352 
353     /**
354      * @brief 获取用户id
355      *
356      * @return int32_t
357      */
358     int32_t GetUserIdDefault();
359 
360     /**
361      * @brief 验证调用者
362      *
363      * @param scenario Scenario状态
364      */
365     ErrCode VerifyCaller(IServiceReverse::Scenario scenario);
366 
367     /**
368      * @brief 验证调用者并返回名称
369      *
370      * @return ErrCode
371      */
372     ErrCode VerifyCallerAndGetCallerName(std::string &bundleName);
373 
374     /**
375      * @brief 清除Session Sched相关资源
376      *
377      * @param bundleName 应用名称
378      */
379     void ClearSessionAndSchedInfo(const std::string &bundleName);
380 
381     /**
382      * @brief 整个备份恢复流程结束
383      *
384      * @param errCode 错误码
385      */
386     void OnAllBundlesFinished(ErrCode errCode);
387 
388     /**
389      * @brief 执行调度器
390      *
391      */
392     void OnStartSched();
393 
394     /**
395      * @brief 通知客户端程序扩展能力处理结果
396      *
397      * @param bundleName 应用名称
398      *
399      */
400     void NoticeClientFinish(const std::string &bundleName, ErrCode errCode);
401 
402     /**
403      * @brief 处理有依赖的应用恢复
404      *
405      * @param bundleName 应用名称
406      *
407      */
408     void HandleRestoreDepsBundle(const std::string &bundleName);
409 
410     /**
411      * @brief 增量备份恢复逻辑处理
412      *
413      * @param bundleName
414      * @return true
415      * @return false
416      */
417     bool IncrementalBackup(const std::string &bundleName);
418 
419     /**
420      * @brief extension连接断开
421      *
422      * @param bundleName
423      */
424     void ExtConnectDied(const std::string &bundleName);
425 
426     /**
427      * @brief 设置当前session的关键信息
428      *
429      * @param restoreBundleInfos 待恢复的应用
430      * @param restoreBundleNames 待恢复的应用包信息
431      * @param bundleNameDetailMap bundle和detail的对应关系
432      * @param isClearDataFlags 清理数据标志集合
433      * @param restoreType 任务类型
434      * @param backupVersion 旧机backupVersion
435      */
436     void SetCurrentSessProperties(std::vector<BJsonEntityCaps::BundleInfo> &restoreBundleInfos,
437         std::vector<std::string> &restoreBundleNames,
438         std::map<std::string, std::vector<BJsonUtil::BundleDetailInfo>> &bundleNameDetailMap,
439         std::map<std::string, bool> &isClearDataFlags, RestoreTypeEnum restoreType, std::string &backupVersion);
440 
441     /**
442      * @brief set session info
443      *
444      * @param restoreBundleInfos: bundles to be restored
445      * @param restoreBundleNames: bundles info to be restored
446      * @param restoreType: retore type
447      * @param backupVersion backupVersion of old device
448      */
449     void SetCurrentSessProperties(std::vector<BJsonEntityCaps::BundleInfo> &restoreBundleInfos,
450         std::vector<std::string> &restoreBundleNames, RestoreTypeEnum restoreType, std::string &backupVersion);
451 
452     void SetCurrentSessProperties(BJsonEntityCaps::BundleInfo &info, std::map<std::string, bool> &isClearDataFlags,
453         const std::string &bundleNameIndexInfo);
454 
455     /**
456      * @brief add useridinfo to  current backup session
457      *
458      * @param bundleNames: bundleNames list
459      * @param userId: userId
460      * @param backupBundleInfos: backupBundleInfos
461      * @param isIncBackup: isIncBackup
462      *
463      */
464     void SetCurrentBackupSessProperties(const std::vector<std::string> &bundleNames, int32_t userId,
465         std::vector<BJsonEntityCaps::BundleInfo> &backupBundleInfos, bool isIncBackup);
466 
467     /**
468      * @brief send userid to app
469      *
470      * @param bundleName: bundleName
471      * @param userId: userId
472      *
473      */
474     void SendUserIdToApp(std::string &bundleName, int32_t userId);
475 
476     /**
477      * @brief 通知权限模块
478      *
479      * @param bundleName 包名称
480      *
481     */
482     void HandleCurBundleEndWork(std::string bundleName, const BackupRestoreScenario sennario);
483 
484     /**
485      * @brief SA 备份恢复结束
486      *
487      * @param bundleName SAID
488      *
489      * @return ErrCode OK if saDone, otherwise saDone failed.
490     */
491     ErrCode SADone(const ErrCode errCode, std::string bundleName);
492 
493     /**
494      * @brief SA备份恢复入口
495      *
496      * @param bundleName SAID
497      *
498      * @return ErrCode OK if backup sa, otherwise backup sa failed.
499     */
500     ErrCode BackupSA(std::string bundleName);
501 
502     /**
503      * @brief 执行通知调用方
504      *
505      * @param errCode 错误码
506      * @param callerName 业务调用方
507      *
508      */
509     void NotifyCallerCurAppDone(ErrCode errCode, const std::string &callerName);
510 
511     /**
512      * @brief 执行通知调用方
513      *
514      * @param errCode 错误码
515      * @param callerName 业务调用方
516      *
517      */
518     void NotifyCallerCurAppIncrementDone(ErrCode errCode, const std::string &callerName);
519 
520     void SetWant(AAFwk::Want &want, const BundleName &bundleName, const BConstants::ExtensionAction &action);
521 
522     /**
523      * @brief GetBackupInfo 任务执行
524      *
525      * @param bundleName 应用名称
526      * @param result 业务结果出参
527      *
528      */
529     ErrCode GetBackupInfoCmdHandle(BundleName &bundleName, std::string &result);
530 
531     /**
532      * @brief 添加需要清理的Session
533      *
534      * @param bundleNames 需要清理的应用包信息
535      *
536      */
537     ErrCode AppendBundlesClearSession(const std::vector<BundleName> &bundleNames);
538 
539     /**
540      * @brief 设置是否自占用Session
541      *
542      * @param isOccupyingSession 框架是否自占用session
543      *
544      */
545     void SetOccupySession(bool isOccupyingSession);
546 
547     void ReportOnExtConnectFailed(const IServiceReverse::Scenario scenario,
548         const std::string &bundleName, const ErrCode ret);
549 
550     void ReleaseOnException();
551 
552     vector<BIncrementalData> MakeDetailList(const vector<BundleName> &bundleNames);
553 
554     vector<string> GetBundleNameByDetails(const std::vector<BIncrementalData> &bundlesToBackup);
555 
556     void HandleCurGroupBackupInfos(vector<BJsonEntityCaps::BundleInfo> &bundleInfos,
557         std::map<std::string, std::vector<BJsonUtil::BundleDetailInfo>> &bundleNameDetailMap,
558         std::map<std::string, bool> &isClearDataFlags);
559 
560     void HandleCurGroupIncBackupInfos(vector<BJsonEntityCaps::BundleInfo> &bundleInfos,
561         std::map<std::string, std::vector<BJsonUtil::BundleDetailInfo>> &bundleNameDetailMap,
562         std::map<std::string, bool> &isClearDataFlags);
563 
564     void TimeoutRadarReport(IServiceReverse::Scenario scenario, std::string &bundleName);
565 
566     void OnBundleStarted(BError error, sptr<SvcSessionManager> session, const BundleName &bundleName);
567 
568     void HandleExceptionOnAppendBundles(sptr<SvcSessionManager> session, const vector<BundleName> &appendBundleNames,
569         const vector<BundleName> &restoreBundleNames);
570 
571     void BundleBeginRadarReport(const std::string &bundleName, const ErrCode errCode,
572         const IServiceReverse::Scenario scenario);
573 
574     void BundleEndRadarReport(const std::string &bundleName, ErrCode errCode,
575         const IServiceReverse::Scenario scenario);
576 
577     void FileReadyRadarReport(const std::string &bundleName, const std::string &fileName, const ErrCode errCode,
578         const IServiceReverse::Scenario scenario);
579 
580     void ExtensionConnectFailRadarReport(const std::string &bundleName, const ErrCode errCode,
581         const IServiceReverse::Scenario scenario);
582 
583     void OnStartResRadarReport(const std::vector<std::string> &bundleNameList, int32_t stage);
584 
585     void PermissionCheckFailRadar(const std::string &info, const std::string &func);
586 
587     bool IsReportBundleExecFail(const std::string &bundleName);
588 
589     void ClearBundleRadarReport();
590 
591     void UpdateBundleRadarReport(const std::string &bundleName);
592 
593     bool IsReportFileReadyFail(const std::string &bundleName);
594 
595     void ClearFileReadyRadarReport();
596 
597     void UpdateFailedBundles(const std::string &bundleName, BundleTaskInfo taskInfo);
598 
599     void ClearFailedBundles();
600     void CreateDirIfNotExist(const std::string &path);
601 
602     void GetOldDeviceBackupVersion();
603 
604     std::vector<std::string> GetSupportBackupBundleNames(vector<BJsonEntityCaps::BundleInfo> &bundleInfos,
605         bool isIncBackup, const vector<std::string> &srcBundleNames);
606 
607     void RefreshBundleDataSize(const vector<BJsonEntityCaps::BundleInfo> &newBundleInfos,
608         std::string bundleName, wptr<Service> ptr);
609 
610     void HandleNotSupportBundleNames(const std::vector<std::string> &srcBundleNames,
611         std::vector<std::string> &supportBundleNames, bool isIncBackup);
612 
613     void SetBundleIncDataInfo(const std::vector<BIncrementalData> &bundlesToBackup,
614         std::vector<std::string> &supportBundleNames);
615 
616     void CancelTask(std::string bundleName, wptr<Service> ptr);
617 
618     void SetUserIdAndRestoreType(RestoreTypeEnum restoreType, int32_t userId);
619 
620     ErrCode VerifySendRateParam();
621 
622     ErrCode HandleCurBundleFileReady(const std::string &bundleName, const std::string &fileName, bool isIncBackup);
623 
624     ErrCode HandleCurAppDone(ErrCode errCode, const std::string &bundleName, bool isIncBackup);
625 
626     void StartCurBundleBackupOrRestore(const std::string &bundleName);
627 
628     void CallOnBundleEndByScenario(const std::string &bundleName, BackupRestoreScenario scenario, ErrCode errCode);
629 
630     void GetDataSizeStepByStep(bool isPreciseScan, vector<BIncrementalData> bundleNameList, string &scanning);
631 
632     void GetPresumablySize(vector<BIncrementalData> bundleNameList, string &scanning);
633 
634     void GetPrecisesSize(vector<BIncrementalData> bundleNameList, string &scanning);
635 
636     void WriteToList(BJsonUtil::BundleDataSize bundleDataSize);
637 
638     void DeleteFromList(size_t scannedSize);
639 
640     void WriteScannedInfoToList(const string &bundleName, int64_t dataSize, int64_t incDataSize);
641 
642     void SendScannedInfo(const string &scannendInfos, sptr<SvcSessionManager> session);
643 
644     void CyclicSendScannedInfo(bool isPreciseScan, vector<BIncrementalData> bundleNameList);
645 
646     bool GetScanningInfo(wptr<Service> obj, size_t scannedSize, string &scanning);
647 
648     void SetScanningInfo(string &scanning, string name);
649 private:
650     static sptr<Service> instance_;
651     static std::mutex instanceLock_;
652     std::mutex getBackupInfoProcLock_;
653     std::mutex getBackupInfoSyncLock_;
654     std::condition_variable getBackupInfoCondition_;
655     static inline std::atomic<uint32_t> seed {1};
656     std::atomic<bool> isConnectDied_ {false};
657     std::atomic<bool> isOccupyingSession_ {false};
658 
659     sptr<SvcSessionManager> session_;
660     sptr<SchedScheduler> sched_;
661     std::shared_ptr<BJsonDisposalConfig> disposal_;
662     std::shared_ptr<BJsonClearDataConfig> clearRecorder_;
663     std::atomic<bool> isInRelease_ {false};
664     std::atomic<bool> isRmConfigFile_ {true};
665     friend class ServiceTest;
666 
667     OHOS::ThreadPool threadPool_;
668     std::mutex bundleExecRadarLock_;
669     std::set<std::string> bundleExecRadarSet_;
670     std::mutex fileReadyRadarLock_;
671     std::map<BundleName, int> fileReadyRadarMap_;
672     std::mutex extensionMutexLock_;
673     std::mutex failedBundlesLock_;
674 
675     std::mutex scannedListLock_;
676     std::mutex getDataSizeLock_;
677     OHOS::ThreadPool callbackScannedInfoThreadPool_;
678     OHOS::ThreadPool getDataSizeThreadPool_;
679     OHOS::ThreadPool sendScannendResultThreadPool_;
680     std::condition_variable getDataSizeCon_;
681     std::atomic<bool> isScannedEnd_ {false};
682     std::atomic<bool> onScanning_ {false};
683 public:
684     std::map<BundleName, std::shared_ptr<ExtensionMutexInfo>> backupExtMutexMap_;
685     std::map<BundleName, BundleTaskInfo> failedBundles_;
686     std::atomic<uint32_t> successBundlesNum_ {0};
687     std::vector<BJsonUtil::BundleDataSize> bundleDataSizeList_;
688     std::string scannedInfo_;
689 };
690 } // namespace OHOS::FileManagement::Backup
691 
692 #endif // OHOS_FILEMGMT_BACKUP_SERVICE_H