• 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 #ifndef ACCESSIBILITY_ABILITY_INFO_H
17 #define ACCESSIBILITY_ABILITY_INFO_H
18 
19 #include <vector>
20 #include "accessibility_def.h"
21 
22 namespace OHOS {
23 namespace Accessibility {
24 struct AccessibilityAbilityInitParams {
25     std::string bundleName = "";
26     std::string description = "";
27     std::string moduleName = "";
28     std::string name = "";
29     std::string rationale = "";
30     std::string settingsAbility = "";
31     std::string label = "";
32     uint32_t staticCapabilities = 0;
33     uint32_t abilityTypes = ACCESSIBILITY_ABILITY_TYPE_INVALID;
34     bool isImportant = false;
35     bool needHide = false;
36     std::vector<uint32_t> eventConfigure;
37 };
38 
39 class AccessibilityAbilityInfo {
40 public:
41     /**
42      * @brief The constructor of AccessibilityAbilityInfo.
43      */
44     AccessibilityAbilityInfo() = default;
45 
46     /**
47      * @brief The deconstructor of AccessibilityAbilityInfo.
48      */
49     ~AccessibilityAbilityInfo() = default;
50 
51     /**
52      * @brief The constructor of AccessibilityAbilityInfo.
53      * @param initParams The params to init AccessibilityAbilityInfo.
54      */
55     AccessibilityAbilityInfo(const AccessibilityAbilityInitParams &initParams);
56 
57     /**
58      * @brief Obtains the types of the accessible ability.
59      * @return Return the types of the accessible ability.
60      */
61     uint32_t GetAccessibilityAbilityType();
62 
63     /**
64      * @brief Obtains the types of the capabilities.
65      * @return Return the types of the capabilities.
66      */
67     uint32_t GetCapabilityValues() const;
68 
69     /**
70      * @brief Obtains the description of the accessible ability.
71      * @return Return the description of the accessible ability.
72      */
73     const std::string &GetDescription() const;
74 
75     /**
76      * @brief Obtains the types of the accessible events.
77      * @return Return the types of the accessible events.
78      */
79     uint32_t GetEventTypes();
80 
81     /**
82      * @brief Obtains the id of the accessible ability.
83      * @return Return the id of the accessible ability.
84      */
85     std::string GetId() const;
86 
87     /**
88      * @brief Obtains the name of the accessible ability.
89      * @return Return the name of the accessible ability.
90      */
91     const std::string &GetName() const;
92 
93     /**
94      * @brief Obtains the package name of the accessible ability.
95      * @return Return the package name of the accessible ability.
96      */
97     const std::string &GetPackageName() const;
98 
99     /**
100      * @brief Obtains the module name of the accessible ability.
101      * @return Return the module name of the accessible ability.
102      */
103     const std::string &GetModuleName() const;
104 
105     /**
106      * @brief Set the package name of the accessible ability.
107      * @param bundleName the package name of the accessible ability
108      */
109     void SetPackageName(const std::string &bundleName);
110 
111     /**
112      * @brief Obtains the target bundles's name that you are listening on.
113      * @return Return the target bundles's name that you are listening on.
114      */
115     const std::vector<std::string> &GetFilterBundleNames() const;
116 
117     /**
118      * @brief Obtains the setting ability of the accessible ability.
119      * @return Return the setting ability of the accessible ability.
120      */
121     const std::string &GetSettingsAbility() const;
122 
123     /**
124      * @brief Set the target bundles's name that you want to listening on.
125      * @param targetBundleNames the target bundle name to set.
126      */
SetFilterBundleNames(const std::vector<std::string> & targetBundleNames)127     inline void SetFilterBundleNames(const std::vector<std::string> &targetBundleNames)
128     {
129         targetBundleNames_ = targetBundleNames;
130     }
131 
132     /**
133      * @brief Set the types of the capabilities.
134      * @param capabilities the capabilities to set.
135      */
SetCapabilityValues(uint32_t capabilities)136     inline void SetCapabilityValues(uint32_t capabilities)
137     {
138         capabilities_ = capabilities;
139     }
140 
141     /**
142      * @brief Set the types of the ability.
143      * @param abilityTypes the ability types to set.
144      */
SetAccessibilityAbilityType(uint32_t abilityTypes)145     inline void SetAccessibilityAbilityType(uint32_t abilityTypes)
146     {
147         abilityTypes_ = abilityTypes;
148     }
149 
150     /**
151      * @brief Set the types of the event.
152      * @param eventTypes the event to set.
153      */
SetEventTypes(uint32_t eventTypes)154     inline void SetEventTypes(uint32_t eventTypes)
155     {
156         eventTypes_ = eventTypes;
157     }
158 
159     /**
160      * @brief Set the ability name of the ability.
161      * @param name the name to set.
162      */
SetName(const std::string & name)163     inline void SetName(const std::string& name)
164     {
165         name_ = name;
166     }
167 
168     /**
169      * @brief Obtains if the ability is important.
170      * @return Return if the ability is important.
171      */
172     bool IsImportant() const;
173 
174     /**
175      * @brief Obtains the capability types of static configuration.
176      * @return Return the capability types of static configuration.
177      */
178     uint32_t GetStaticCapabilityValues() const;
179 
180     /**
181      * @brief Obtains if the ability is need to hide.
182      * @return Return true means hide the ability, return false means show the ability.
183      */
184     bool NeedHide() const;
185 
186     /**
187      * @brief Obtains the label of the accessible ability.
188      * @return Return the label of the accessible ability.
189      */
190     const std::string &GetLabel() const;
191 
192     /**
193      * @brief Get event configure.
194      * @param needEvents
195      * @return Return needEvents.
196      */
197     void GetEventConfigure(std::vector<uint32_t> &needEvents);
198 
199 protected:
200     std::string bundleName_;
201     std::string moduleName_;
202     std::string name_;
203     std::string description_;
204     std::string label_;
205 
206     uint32_t staticCapabilities_ = 0;
207     uint32_t capabilities_ = 0;
208     std::string rationale_ = "";
209     std::string settingsAbility_;
210 
211     uint32_t abilityTypes_ = ACCESSIBILITY_ABILITY_TYPE_INVALID;
212     uint32_t eventTypes_ = EventType::TYPES_ALL_MASK;
213 
214     std::vector<std::string> targetBundleNames_;
215     bool isImportant_ = false;
216     bool needHide_ = false;
217     std::vector<uint32_t> eventConfigure_ = { TYPES_ALL_MASK };
218 };
219 } // namespace Accessibility
220 } // namespace OHOS
221 #endif // ACCESSIBILITY_ABILITY_INFO_H