• 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_REVERSE_H
17 #define OHOS_FILEMGMT_BACKUP_SERVICE_REVERSE_H
18 
19 #include "b_session_backup.h"
20 #include "b_session_restore.h"
21 #include "b_incremental_backup_session.h"
22 #include "b_incremental_restore_session.h"
23 #include "service_reverse_stub.h"
24 
25 namespace OHOS::FileManagement::Backup {
26 const int DEFAULT_RESTORE_TYPE = 0;
27 const int DEFAULT_USER_ID = -1;
28 
29 class ServiceReverse final : public ServiceReverseStub {
30 public:
31     ErrCode BackupOnFileReady(const std::string &bundleName,
32                               const std::string &fileName,
33                               int fd,
34                               int32_t errCode) override;
35     ErrCode BackupOnFileReadyWithoutFd(const std::string &bundleName,
36                                        const std::string &fileName,
37                                        int32_t errCode) override;
38     ErrCode BackupOnBundleStarted(int32_t errCode, const std::string &bundleName) override;
39     ErrCode BackupOnResultReport(const std::string &result, const std::string &bundleName) override;
40     ErrCode BackupOnBundleFinished(int32_t errCode, const std::string &bundleName) override;
41     ErrCode BackupOnAllBundlesFinished(int32_t errCode) override;
42     ErrCode BackupOnProcessInfo(const std::string &bundleName, const std::string &processInfo) override;
43     ErrCode BackupOnScanningInfo(const std::string &scannedInfo) override;
44 
45     ErrCode RestoreOnBundleStarted(int32_t errCode, const std::string &bundleName) override;
46     ErrCode RestoreOnBundleFinished(int32_t errCode, const std::string &bundleName) override;
47     ErrCode RestoreOnAllBundlesFinished(int32_t errCode) override;
48     ErrCode RestoreOnFileReady(const std::string &bundleName,
49                                const std::string &fileName,
50                                int fd,
51                                int32_t errCode) override;
52     ErrCode RestoreOnFileReadyWithoutFd(const std::string &bundleName,
53                                         const std::string &fileName,
54                                         int32_t errCode) override;
55     ErrCode RestoreOnResultReport(const std::string &result,
56                                   const std::string &bundleName,
57                                   ErrCode errCode = 0) override;
58     ErrCode RestoreOnProcessInfo(const std::string &bundleName, const std::string &processInfo) override;
59 
60     ErrCode IncrementalBackupOnFileReady(const std::string &bundleName,
61                                          const std::string &fileName,
62                                          int fd,
63                                          int manifestFd,
64                                          int32_t errCode) override;
65     ErrCode IncrementalSaBackupOnFileReady(const std::string &bundleName, const std::string &fileName,
66                                            int fd, int32_t errCode) override;
67     ErrCode IncrementalBackupOnFileReadyWithoutFd(const std::string &bundleName,
68                                          const std::string &fileName,
69                                          int32_t errCode) override;
70     ErrCode IncrementalBackupOnBundleStarted(int32_t errCode, const std::string &bundleName) override;
71     ErrCode IncrementalBackupOnResultReport(const std::string &result, const std::string &bundleName) override;
72     ErrCode IncrementalBackupOnBundleFinished(int32_t errCode, const std::string &bundleName) override;
73     ErrCode IncrementalBackupOnAllBundlesFinished(int32_t errCode) override;
74     ErrCode IncrementalBackupOnProcessInfo(const std::string &bundleName, const std::string &processInfo) override;
75     ErrCode IncrementalBackupOnScanningInfo(const std::string &scannedInfo) override;
76 
77     ErrCode IncrementalRestoreOnBundleStarted(int32_t errCode, const std::string &bundleName) override;
78     ErrCode IncrementalRestoreOnBundleFinished(int32_t errCode, const std::string &bundleName) override;
79     ErrCode IncrementalRestoreOnAllBundlesFinished(int32_t errCode) override;
80     ErrCode IncrementalRestoreOnFileReady(const std::string &bundleName,
81                                           const std::string &fileName,
82                                           int fd,
83                                           int manifestFd,
84                                           int32_t errCode) override;
85     ErrCode IncrementalRestoreOnFileReadyWithoutFd(const std::string &bundleName,
86                                                    const std::string &fileName,
87                                                    int32_t errCode) override;
88     ErrCode IncrementalRestoreOnResultReport(const std::string &result,
89                                              const std::string &bundleName,
90                                              ErrCode errCode) override;
91     ErrCode IncrementalRestoreOnProcessInfo(const std::string &bundleName, const std::string &processInfo) override;
92 
93 public:
94     ServiceReverse() = delete;
95     explicit ServiceReverse(BSessionRestore::Callbacks callbacks);
96     explicit ServiceReverse(BSessionBackup::Callbacks callbacks);
97     explicit ServiceReverse(BIncrementalBackupSession::Callbacks callbacks);
98     explicit ServiceReverse(BIncrementalRestoreSession::Callbacks callbacks);
99     ~ServiceReverse() override = default;
100 
101 private:
102     Scenario scenario_ {Scenario::UNDEFINED};
103     BSessionBackup::Callbacks callbacksBackup_;
104     BSessionRestore::Callbacks callbacksRestore_;
105     BIncrementalBackupSession::Callbacks callbacksIncrementalBackup_;
106     BIncrementalRestoreSession::Callbacks callbacksIncrementalRestore_;
107 };
108 } // namespace OHOS::FileManagement::Backup
109 
110 #endif // OHOS_FILEMGMT_BACKUP_SERVICE_REVERSE_H