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_I_SERVICE_H 17 #define OHOS_FILEMGMT_BACKUP_I_SERVICE_H 18 19 #include <string> 20 #include <tuple> 21 22 #include <unique_fd.h> 23 24 #include "b_file_info.h" 25 #include "b_incremental_data.h" 26 #include "i_service_ipc_interface_code.h" 27 #include "i_service_reverse.h" 28 #include "iremote_broker.h" 29 30 namespace OHOS::FileManagement::Backup { 31 const int DEFAULT_INVAL_VALUE = -1; 32 33 typedef enum TypeRestoreTypeEnum { 34 RESTORE_DATA_WAIT_SEND = 0, 35 RESTORE_DATA_READDY = 1, 36 } RestoreTypeEnum; 37 38 class IService : public IRemoteBroker { 39 public: 40 virtual ErrCode InitRestoreSession(sptr<IServiceReverse> remote) = 0; 41 virtual ErrCode InitBackupSession(sptr<IServiceReverse> remote) = 0; 42 virtual ErrCode Start() = 0; 43 virtual UniqueFd GetLocalCapabilities() = 0; 44 virtual ErrCode PublishFile(const BFileInfo &fileInfo) = 0; 45 virtual ErrCode AppFileReady(const std::string &fileName, UniqueFd fd) = 0; 46 virtual ErrCode AppDone(ErrCode errCode) = 0; 47 virtual ErrCode GetFileHandle(const std::string &bundleName, const std::string &fileName) = 0; 48 virtual ErrCode AppendBundlesRestoreSession(UniqueFd fd, 49 const std::vector<BundleName> &bundleNames, 50 RestoreTypeEnum restoreType = RestoreTypeEnum::RESTORE_DATA_WAIT_SEND, 51 int32_t userId = DEFAULT_INVAL_VALUE) = 0; 52 virtual ErrCode AppendBundlesBackupSession(const std::vector<BundleName> &bundleNames) = 0; 53 virtual ErrCode Finish() = 0; 54 virtual ErrCode Release() = 0; 55 virtual UniqueFd GetLocalCapabilitiesIncremental(const std::vector<BIncrementalData> &bundleNames) = 0; 56 virtual ErrCode InitIncrementalBackupSession(sptr<IServiceReverse> remote) = 0; 57 virtual ErrCode AppendBundlesIncrementalBackupSession(const std::vector<BIncrementalData> &bundlesToBackup) = 0; 58 59 virtual ErrCode PublishIncrementalFile(const BFileInfo &fileInfo) = 0; 60 virtual ErrCode AppIncrementalFileReady(const std::string &fileName, UniqueFd fd, UniqueFd manifestFd) = 0; 61 virtual ErrCode AppIncrementalDone(ErrCode errCode) = 0; 62 virtual ErrCode GetIncrementalFileHandle(const std::string &bundleName, const std::string &fileName) = 0; 63 64 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Filemanagement.Backup.IService") 65 }; 66 } // namespace OHOS::FileManagement::Backup 67 68 #endif // OHOS_FILEMGMT_BACKUP_I_SERVICE_H