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