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 #include "ext_backup_loader.h"
17 
18 #include "ext_backup.h"
19 #include "filemgmt_libhilog.h"
20 
21 namespace OHOS::FileManagement::Backup {
22 using namespace std;
23 
24 ExtBackupLoader::ExtBackupLoader() = default;
25 ExtBackupLoader::~ExtBackupLoader() = default;
26 
Create(const unique_ptr<AbilityRuntime::Runtime> & runtime) const27 AbilityRuntime::Extension *ExtBackupLoader::Create(const unique_ptr<AbilityRuntime::Runtime> &runtime) const
28 {
29     HILOGI("Create as an BackupExtensionAbility(Loader)");
30     return ExtBackup::Create(runtime);
31 }
32 
GetParams()33 map<string, string> ExtBackupLoader::GetParams()
34 {
35     HILOGI("Register as an extension ability");
36     return {
37         // Type 即为 Extension 类型,定义在 ExtensionAbilityType 这一枚举类中。具体位置见 extension_ability_info.h
38         {"type", "9"},
39         {"name", "BackupExtensionAbility"},
40     };
41 }
42 
OHOS_EXTENSION_GetExtensionModule()43 extern "C" __attribute__((visibility("default"))) void *OHOS_EXTENSION_GetExtensionModule()
44 {
45     HILOGI("Load as a library");
46     return &ExtBackupLoader::GetInstance();
47 }
48 } // namespace OHOS::FileManagement::Backup