• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 EXT_BACKUP_ANI_H
17 #define EXT_BACKUP_ANI_H
18 
19 #include "ext_backup_context.h"
20 #include "ext_backup.h"
21 #include "runtime.h"
22 #include "ets_native_reference.h"
23 #include "ets_runtime.h"
24 
25 namespace OHOS::FileManagement::Backup {
26 
27 class ExtBackupAni : public ExtBackup {
28 public:
29     void Init(const std::shared_ptr<AppExecFwk::AbilityLocalRecord> &record,
30               const std::shared_ptr<AppExecFwk::OHOSApplication> &application,
31               std::shared_ptr<AppExecFwk::AbilityHandler> &handler,
32               const sptr<IRemoteObject> &token) override;
33 
34 public:
35     static ExtBackupAni *Create(const std::unique_ptr<AbilityRuntime::Runtime> &runtime);
36 
37     ErrCode OnBackup(std::function<void(ErrCode, std::string)> callback,
38                      std::function<void(ErrCode, const std::string)> callbackEx) override;
39 
40     ErrCode OnRestore(std::function<void(ErrCode, std::string)> callback,
41                       std::function<void(ErrCode, const std::string)> callbackEx) override;
42 
43 public:
44     explicit ExtBackupAni(AbilityRuntime::Runtime &runtime);
45     virtual ~ExtBackupAni() override;
46 
47 private:
48     ErrCode CallEtsOnBackup();
49     ErrCode CallEtsOnRestore();
50 
51 private:
52     AbilityRuntime::ETSRuntime &stsRuntime_;
53     std::unique_ptr<AppExecFwk::ETSNativeReference> etsObj_;
54 };
55 
56 } // namespace OHOS::FileManagement::Backup
57 
58 #endif // EXT_BACKUP_ANI_H