1 /* 2 * Copyright (c) 2022-2023 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 "i_service_ipc_interface_code.h" 26 #include "i_service_reverse.h" 27 #include "iremote_broker.h" 28 29 namespace OHOS::FileManagement::Backup { 30 const int DEFAULT_INVAL_VALUE = -1; 31 32 typedef enum TypeRestoreTypeEnum { 33 RESTORE_DATA_WAIT_SEND = 0, 34 RESTORE_DATA_READDY = 1, 35 } RestoreTypeEnum; 36 37 class IService : public IRemoteBroker { 38 public: 39 virtual ErrCode InitRestoreSession(sptr<IServiceReverse> remote) = 0; 40 virtual ErrCode InitBackupSession(sptr<IServiceReverse> remote) = 0; 41 virtual ErrCode Start() = 0; 42 virtual UniqueFd GetLocalCapabilities() = 0; 43 virtual ErrCode PublishFile(const BFileInfo &fileInfo) = 0; 44 virtual ErrCode AppFileReady(const std::string &fileName, UniqueFd fd) = 0; 45 virtual ErrCode AppDone(ErrCode errCode) = 0; 46 virtual ErrCode GetFileHandle(const std::string &bundleName, const std::string &fileName) = 0; 47 virtual ErrCode AppendBundlesRestoreSession(UniqueFd fd, 48 const std::vector<BundleName> &bundleNames, 49 RestoreTypeEnum restoreType = RestoreTypeEnum::RESTORE_DATA_WAIT_SEND, 50 int32_t userId = DEFAULT_INVAL_VALUE) = 0; 51 virtual ErrCode AppendBundlesBackupSession(const std::vector<BundleName> &bundleNames) = 0; 52 virtual ErrCode Finish() = 0; 53 54 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Filemanagement.Backup.IService") 55 }; 56 } // namespace OHOS::FileManagement::Backup 57 58 #endif // OHOS_FILEMGMT_BACKUP_I_SERVICE_H