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