• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "feature/feature_system.h"
17 namespace OHOS {
18 namespace DistributedData {
GetInstance()19 FeatureSystem &FeatureSystem::GetInstance()
20 {
21     static FeatureSystem instance;
22     return instance;
23 }
24 
RegisterCreator(const std::string & name,Creator creator,int32_t flag)25 int32_t FeatureSystem::RegisterCreator(const std::string &name, Creator creator, int32_t flag)
26 {
27     creators_.InsertOrAssign(name, std::pair{ std::move(creator), flag });
28     return E_OK;
29 }
30 
GetCreator(const std::string & name)31 FeatureSystem::Creator FeatureSystem::GetCreator(const std::string &name)
32 {
33     auto [success, pair] = creators_.Find(name);
34     if (!success) {
35         return nullptr;
36     }
37     auto [creator, flag] = std::move(pair);
38     return creator;
39 }
40 
GetFeatureName(int32_t flag)41 std::vector<std::string> FeatureSystem::GetFeatureName(int32_t flag)
42 {
43     std::vector<std::string> features;
44     creators_.ForEach([flag, &features](const std::string &key, auto &pair) -> bool {
45         auto &[creator, bindFlag] = pair;
46         if (bindFlag == flag) {
47             features.push_back(key);
48         }
49         return false;
50     });
51     return features;
52 }
53 
~Feature()54 FeatureSystem::Feature::~Feature()
55 {
56 }
57 
OnInitialize()58 int32_t FeatureSystem::Feature::OnInitialize()
59 {
60     return E_OK;
61 }
62 
OnAppExit(pid_t uid,pid_t pid,uint32_t tokenId,const std::string & bundleName)63 int32_t FeatureSystem::Feature::OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &bundleName)
64 {
65     return E_OK;
66 }
67 
OnAppUninstall(const std::string & bundleName,int32_t user,int32_t index)68 int32_t FeatureSystem::Feature::OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index)
69 {
70     return E_OK;
71 }
72 
OnAppUpdate(const std::string & bundleName,int32_t user,int32_t index)73 int32_t FeatureSystem::Feature::OnAppUpdate(const std::string &bundleName, int32_t user, int32_t index)
74 {
75     return E_OK;
76 }
77 
ResolveAutoLaunch(const std::string & identifier,DistributedDB::AutoLaunchParam & param)78 int32_t FeatureSystem::Feature::ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam &param)
79 {
80     return E_OK;
81 }
82 
OnUserChange(uint32_t code,const std::string & user,const std::string & account)83 int32_t FeatureSystem::Feature::OnUserChange(uint32_t code, const std::string &user, const std::string &account)
84 {
85     return E_OK;
86 }
87 
Online(const std::string & device)88 int32_t FeatureSystem::Feature::Online(const std::string &device)
89 {
90     return E_OK;
91 }
92 
Offline(const std::string & device)93 int32_t FeatureSystem::Feature::Offline(const std::string &device)
94 {
95     return E_OK;
96 }
97 
OnReady(const std::string & device)98 int32_t FeatureSystem::Feature::OnReady(const std::string &device)
99 {
100     return E_OK;
101 }
102 
OnBind(const FeatureSystem::Feature::BindInfo & bindInfo)103 int32_t FeatureSystem::Feature::OnBind(const FeatureSystem::Feature::BindInfo &bindInfo)
104 {
105     return E_OK;
106 }
107 } // namespace DistributedData
108 } // namespace OHOS