• 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_ABILILTY_INFO_H
17 #define ACCESSIBILITY_ABILILTY_INFO_H
18 
19 #include <cstdint>
20 #include <vector>
21 #include <string>
22 
23 #include "accessibility_event_info.h"
24 #include "extension_ability_info.h"
25 #include "parcel.h"
26 
27 namespace OHOS {
28 namespace Accessibility {
29 // The capability types of the accessible ability.
30 enum Capability : uint32_t {
31     CAPABILITY_RETRIEVE = 0x0001,
32     CAPABILITY_TOUCH_GUIDE = 0x0002,
33     CAPABILITY_GESTURE = 0x0004,
34     CAPABILITY_KEY_EVENT_OBSERVER = 0x0008,
35     CAPABILITY_ZOOM = 0x0010,
36 };
37 
38 // The accessibility ability types for feedbacks.
39 enum AccessibilityAbilityTypes : uint32_t {
40     ACCESSIBILITY_ABILITY_TYPE_INVALID = 0x00000000,
41     ACCESSIBILITY_ABILITY_TYPE_SPOKEN = 0x00000001,
42     ACCESSIBILITY_ABILITY_TYPE_HAPTIC = 0x00000002,
43     ACCESSIBILITY_ABILITY_TYPE_AUDIBLE = 0x00000004,
44     ACCESSIBILITY_ABILITY_TYPE_VISUAL = 0x00000008,
45     ACCESSIBILITY_ABILITY_TYPE_GENERIC = 0x00000010,
46     ACCESSIBILITY_ABILITY_TYPE_ALL = 0xFFFFFFFF,
47 };
48 
49 class AccessibilityAbilityInfo : public Parcelable {
50 public:
51     AccessibilityAbilityInfo() = default;
52     ~AccessibilityAbilityInfo() = default;
53 
54     AccessibilityAbilityInfo(const AppExecFwk::ExtensionAbilityInfo &abilityInfo);
55 
56     /**
57      * @brief Obtains the types of the accessible ability.
58      * @param
59      * @return Return the type of the accessible ability.
60      */
61     uint32_t GetAccessibilityAbilityType();
62 
63     /**
64      * @brief Obtains the types of the capabilities.
65      * @param
66      * @return Return the types of the capabilities.
67      */
68     uint32_t GetCapabilityValues();
69 
70     /**
71      * @brief Obtains the description of the accessible ability.
72      * @param
73      * @return Return the description of the accessible ability.
74      */
75     std::string GetDescription();
76 
77     /**
78      * @brief Obtains the type of the accessible events.
79      * @param
80      * @return Return the type of the accessible events.
81      */
82     uint32_t GetEventTypes();
83 
84     /**
85      * @brief Obtains the id of the accessible ability.
86      * @param
87      * @return Return the id of the accessible ability.
88      */
89     std::string GetId();
90 
91     /**
92      * @brief Obtains the name of the accessible ability.
93      * @param
94      * @return Return the name of the accessible ability.
95      */
96     std::string GetName();
97 
98     /**
99      * @brief Obtains the package name of the accessible ability.
100      * @param
101      * @return Return the package name of the accessible ability.
102      */
103     std::string GetPackageName();
104 
105     void SetPackageName(std::string bundleName);
106 
107     /**
108      * @brief Obtains the target bundles's name that you are listening on.
109      * @param
110      * @return Return the target bundles's name that you are listening on.
111      */
112     std::vector<std::string> GetFilterBundleNames();
113 
114     /**
115      * @brief Obtains the setting ability of the accessible ability.
116      * @param
117      * @return Return the setting ability of the accessible ability.
118      */
119     std::string GetSettingsAbility();
120 
121     /**
122      * @brief read this sequenceable object from a Parcel.
123      * @param parcel Indicates the Parcel object into which the sequenceable object has been marshaled.
124      * @return Return true if read successfully, else return false.
125      */
126     bool ReadFromParcel(Parcel &parcel);
127 
128     /**
129      * @brief Marshals this sequenceable object into a Parcel.
130      * @param parcel Indicates the Parcel object to which the sequenceable object will be marshaled.
131      * @return Return true if Marshal successfully, else return false.
132      */
133     virtual bool Marshalling(Parcel &parcel) const override;
134 
135     /**
136      * @brief Unmarshals this sequenceable object from a Parcel.
137      * @param parcel Indicates the Parcel object into which the sequenceable object has been marshaled.
138      * @return Return a sequenceable object of AccessibilityAbilityInfo.
139      */
140     static AccessibilityAbilityInfo *Unmarshalling(Parcel &parcel);
141 
142     /**
143      * @brief Set the types of the capabilities.
144      * @param capabilities the capabilities to set.
145      * @return
146      */
SetCapabilityValues(uint32_t capabilities)147     inline void SetCapabilityValues(uint32_t capabilities)
148     {
149         capabilities_ = capabilities;
150     }
151 
152     /**
153      * @brief Set the types of the ability.
154      * @param abilityTypes the ability to set.
155      * @return
156      */
SetAccessibilityAbilityType(uint32_t abilityTypes)157     inline void SetAccessibilityAbilityType(uint32_t abilityTypes)
158     {
159         abilityTypes_ = abilityTypes;
160     }
161 
162     /**
163      * @brief Set the types of the event.
164      * @param eventTypes the event to set.
165      * @return
166      */
SetEventTypes(uint32_t eventTypes)167     inline void SetEventTypes(uint32_t eventTypes)
168     {
169         eventTypes_ = eventTypes;
170     }
171 
172 private:
173     /**
174      * @brief Parse config files of the accessible ability.
175      * @param
176      * @return Return true if parses config files successfully, else return false.
177      */
178     bool ParseAAConfig(std::string &config);
179 
180     std::string bundleName_;
181     std::string moduleName_;
182     std::string name_;
183     std::string description_;
184 
185     uint32_t capabilities_ = 0;
186     std::string rationale_ = "";
187 
188     uint32_t abilityTypes_ = ACCESSIBILITY_ABILITY_TYPE_INVALID;
189     uint32_t eventTypes_ = EventType::TYPE_VIEW_INVALID;
190     std::string settingsAbility_;
191     std::vector<std::string> targetBundleNames_;
192 };
193 } // namespace Accessibility
194 } // namespace OHOS
195 #endif // ACCESSIBILITY_ABILITY_INFO_H