1 /* 2 * Copyright (C) 2022-2023 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 ACCESSIBLE_ABILITY_CLIENT_IMPL_H 17 #define ACCESSIBLE_ABILITY_CLIENT_IMPL_H 18 19 #include <atomic> 20 #include <deque> 21 #include <memory> 22 #include "accessible_ability_channel_client.h" 23 #include "accessible_ability_client.h" 24 #include "accessible_ability_client_stub.h" 25 #include "ffrt.h" 26 #include "ffrt_inner.h" 27 #include "iaccessible_ability_manager_service.h" 28 #include "refbase.h" 29 #include "system_ability_load_callback_stub.h" 30 #include "system_ability_status_change_stub.h" 31 #include "safe_map.h" 32 33 namespace OHOS { 34 namespace Accessibility { 35 36 constexpr int32_t SCENE_BOARD_WINDOW_ID = 1; // default scene board window id 1 37 constexpr int32_t INVALID_SCENE_BOARD_INNER_WINDOW_ID = -1; // invalid scene board window id -1 38 constexpr int64_t INVALID_SCENE_BOARD_ELEMENT_ID = -1; // invalid scene board element id -1 39 constexpr int32_t MAX_CACHE_WINDOW_SIZE = 5; 40 41 class AccessibleAbilityClientImpl : public AccessibleAbilityClient, public AccessibleAbilityClientStub { 42 public: 43 /** 44 * @brief The constructor of AccessibleAbilityClientImpl. 45 */ 46 AccessibleAbilityClientImpl(); 47 48 /** 49 * @brief The deconstructor of AccessibleAbilityClientImpl. 50 */ 51 ~AccessibleAbilityClientImpl(); 52 53 /** 54 * @brief Get the implement of accessibility ability client. 55 */ 56 static sptr<AccessibleAbilityClientImpl> GetAbilityClientImplement(); 57 58 /** 59 * @brief Gets remote object. 60 * @return Remote object. 61 */ 62 virtual sptr<IRemoteObject> GetRemoteObject() override; 63 64 /** 65 * @brief Check the permission of the extension ability. 66 * @return Return RET_OK if the ability has the permission. 67 */ 68 virtual RetError CheckExtensionAbilityPermission() override; 69 70 /** 71 * @brief Register ability listener. 72 * @param listener The listener to add. 73 * @return Return RET_OK if registers listener successfully, otherwise refer to the RetError for the failure. 74 */ 75 virtual RetError RegisterAbilityListener(const std::shared_ptr<AccessibleAbilityListener> &listener) override; 76 77 /** 78 * @brief Init accessible ability. 79 * @param channel The object of IAccessibleAbilityChannel. 80 * @param channelId The id of channel. 81 */ 82 virtual void Init(const sptr<IAccessibleAbilityChannel> &channel, const int32_t channelId) override; 83 84 /** 85 * @brief Disconnect accessible ability. 86 * @param channelId The id of channel. 87 */ 88 virtual void Disconnect(const int32_t channelId) override; 89 90 /** 91 * @brief Called when an accessibility event occurs. 92 * @param eventInfo The information of accessible event. 93 */ 94 virtual void OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo) override; 95 96 /** 97 * @brief Called when a key event occurs. 98 * @param keyEvent Indicates the key event to send. 99 * @param sequence The sequence of the key event. 100 */ 101 virtual void OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int32_t sequence) override; 102 103 /** 104 * @brief Obtains elementInfo of focus. 105 * @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY. 106 * @param elementInfo The accessibilityElementInfo of focus. 107 * @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure. 108 */ 109 virtual RetError GetFocus( 110 const int32_t focusType, AccessibilityElementInfo& elementInfo, bool systemApi = false) override; 111 112 /** 113 * @brief Obtains elementInfo of focus. 114 * @param sourceInfo The source info to get focus. 115 * @param focusType The type of focus. It contains FOCUS_TYPE_INPUT and FOCUS_TYPE_ACCESSIBILITY. 116 * @param elementInfo The accessibilityElementInfo of focus. 117 * @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure. 118 */ 119 virtual RetError GetFocusByElementInfo(const AccessibilityElementInfo &sourceInfo, const int32_t focusType, 120 AccessibilityElementInfo &elementInfo) override; 121 122 /** 123 * @brief Sends simulate gestures to the screen. 124 * @param gesturePath The gesture which need to send. 125 * @return Return RET_OK if the gesture sends successfully, otherwise refer to the RetError for the failure. 126 */ 127 virtual RetError InjectGesture(const std::shared_ptr<AccessibilityGestureInjectPath> &gesturePath) override; 128 129 /** 130 * @brief Obtains elementInfo of the accessible root node. 131 * @param elementInfo The elementInfo of the accessible root node. 132 * @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure. 133 */ 134 virtual RetError GetRoot(AccessibilityElementInfo &elementInfo, bool systemApi = false) override; 135 136 /** 137 * @brief Obtains elementInfo of the accessible root node. 138 * @param windowInfo The source window info to get root. 139 * @param elementInfo The elementInfo of the accessible root node. 140 * @return Return RET_OK if obtains elementInfo successfully, otherwise refer to the RetError for the failure. 141 */ 142 virtual RetError GetRootByWindow(const AccessibilityWindowInfo &windowInfo, 143 AccessibilityElementInfo &elementInfo, bool systemApi = false) override; 144 145 /** 146 * @brief Obtains elementInfos of the accessible root node in batchs. 147 * @param elementInfos ElementInfos of the accessible root node and its recursive subnodes. 148 * @return Return RET_OK if obtains elementInfos successfully, otherwise refer to the RetError for the failure. 149 */ 150 virtual RetError GetRootBatch(std::vector<AccessibilityElementInfo>& elementInfos) override; 151 152 /** 153 * @brief Obtains elementInfos of the accessible root node in batchs. 154 * @param windowInfo The source window info to get root. 155 * @param elementInfos ElementInfos of the accessible root node and its recursive subnodes. 156 * @param isFilter Indicates whether to filter nodes. 157 * @param needCut Indicates whether to remove invisible nodes. 158 * @return Return RET_OK if obtains elementInfos successfully, otherwise refer to the RetError for the failure. 159 */ 160 virtual RetError GetRootByWindowBatch(const AccessibilityWindowInfo &windowInfo, 161 std::vector<AccessibilityElementInfo>& elementInfos, bool isFilter, bool needCut) override; 162 163 /** 164 * @brief Get the window information related with the event 165 * @param windowId The window id. 166 * @param windowInfo The window information. 167 * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure. 168 */ 169 virtual RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override; 170 171 /** 172 * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users. 173 * @param windows The information of windows. 174 * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure. 175 */ 176 virtual RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows, bool systemApi = false) override; 177 178 /** 179 * @brief Obtains the list of interactive windows on the device, in the layers they are visible to users. 180 * @param displayId the id of display 181 * @param windows The information of windows. 182 * @return Return RET_OK if obtains windowInfo successfully, otherwise refer to the RetError for the failure. 183 */ 184 virtual RetError GetWindows( 185 const uint64_t displayId, std::vector<AccessibilityWindowInfo>& windows, bool systemApi = false) override; 186 187 /** 188 * @brief Gets the next focused node in the specified direction of the currently focused node. 189 * @param elementInfo The source info to get next info. 190 * @param direction Indicates the direction to obtain the next focused node. Refer to FocusMoveDirection 191 * @param nextElementInfo The info of next element. 192 * @return Return RET_OK if gets next elementInfo successfully, otherwise refer to the RetError for the failure. 193 */ 194 virtual RetError GetNext(const AccessibilityElementInfo &elementInfo, const FocusMoveDirection direction, 195 AccessibilityElementInfo &nextElementInfo, bool systemApi = false) override; 196 197 /** 198 * @brief Get the child node information by childId 199 * @param index The index of the child. 200 * @param parent The parent info to get child. 201 * @param child The element info of child. 202 * @return Return RET_OK if gets child elementInfo successfully, otherwise refer to the RetError for the failure. 203 */ 204 virtual RetError GetChildElementInfo(const int32_t index, const AccessibilityElementInfo &parent, 205 AccessibilityElementInfo &child) override; 206 207 /** 208 * @brief Get the child node information 209 * @param parent The parent info to get child. 210 * @param children The element info of children. 211 * @return Return RET_OK if gets child elementInfo successfully, otherwise refer to the RetError for the failure. 212 */ 213 virtual RetError GetChildren(const AccessibilityElementInfo &parent, 214 std::vector<AccessibilityElementInfo> &children, bool systemApi = false) override; 215 216 /** 217 * @brief Searches for node information based on the specified content. 218 * @param elementInfo The source info. 219 * @param text specified content 220 * @param elementInfos The element infos of specified content. 221 * @return Return RET_OK if gets elementInfos successfully, otherwise refer to the RetError for the failure. 222 */ 223 virtual RetError GetByContent(const AccessibilityElementInfo &elementInfo, const std::string &text, 224 std::vector<AccessibilityElementInfo> &elementInfos, bool systemApi = false) override; 225 226 /** 227 * @brief Get the node information related with the event 228 * @param eventInfo The source info to get source. 229 * @param elementInfo The element info of source. 230 * @return Return RET_OK if gets elementInfos successfully, otherwise refer to the RetError for the failure. 231 */ 232 virtual RetError GetSource(const AccessibilityEventInfo &eventInfo, 233 AccessibilityElementInfo &elementInfo) override; 234 235 /** 236 * @brief Get Parent node information 237 * @param child The child element info to get parent. 238 * @param parent The parent element info. 239 * @return Return RET_OK if gets info successfully, otherwise refer to the RetError for the failure. 240 */ 241 virtual RetError GetParentElementInfo(const AccessibilityElementInfo &child, 242 AccessibilityElementInfo &parent, bool systemApi = false) override; 243 244 /** 245 * @brief Get node information based on element id in active window. 246 * @param elementId The target element id. 247 * @param windowId The target window id. 248 * @param targetElementInfo The element info of specified content. 249 * @return Return RET_OK if gets info successfully, otherwise refer to the RetError for the failure. 250 */ 251 virtual RetError GetByElementId(const int64_t elementId, const int32_t windowId, 252 AccessibilityElementInfo &targetElementInfo, bool systemApi = false) override; 253 254 /** 255 * @brief Get node information based on inspectorKey in active window. 256 * @param inspectorKey The target inspectorKey. 257 * @param elementInfo The element info of specified content. 258 * @return Return RET_OK if gets info successfully, otherwise refer to the RetError for the failure. 259 */ 260 virtual RetError SearchElementInfoByInspectorKey(const std::string &inspectorKey, 261 AccessibilityElementInfo &elementInfo) override; 262 263 /** 264 * @brief Executes a specified action. 265 * @param elementInfo The source info to execute action. 266 * @param action: the action type 267 * @param actionArguments: The parameter for action type. such as: 268 * action: ACCESSIBILITY_ACTION_NEXT_HTML_ITEM, 269 * actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType) 270 * action: ACCESSIBILITY_ACTION_PREVIOUS_HTML_ITEM, 271 * actionArguments(ACTION_ARGU_HTML_ELEMENT,HtmlItemType) 272 * action: ACCESSIBILITY_ACTION_NEXT_TEXT, 273 * actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX) 274 * action: ACCESSIBILITY_ACTION_PREVIOUS_TEXT, 275 * actionArguments(ACTION_ARGU_MOVE_UNIT,MOVE_UNIT_XXX) 276 * action: ACCESSIBILITY_ACTION_SET_SELECTION, 277 * actionArguments({ACTION_ARGU_SELECT_TEXT_START,"1"(start location)}, 278 * {ACTION_ARGU_SELECT_TEXT_END,"10"(end location)}) 279 * action: ACCESSIBILITY_ACTION_SET_TEXT, 280 * actionArguments(ACTION_ARGU_SET_TEXT,"the text of setted") 281 * @return Return RET_OK if performs action succeed, otherwise refer to the RetError for the failure. 282 */ 283 virtual RetError ExecuteAction(const AccessibilityElementInfo &elementInfo, const ActionType action, 284 const std::map<std::string, std::string> &actionArguments) override; 285 286 /** 287 * @brief Curtain screen ability. 288 * @param isEnable Flag bits for opening or closing. 289 */ 290 virtual RetError EnableScreenCurtain(bool isEnable) override; 291 292 /** 293 * @brief Hold running lock to prevent screen turning off automatically. 294 * @param null. 295 * @return Return RET_OK if hold running lock successfully, otherwise refer to the RetError for the failure. 296 */ 297 virtual RetError HoldRunningLock() override; 298 299 /** 300 * @brief Unhold running lock to prevent screen turning off automatically 301 * @param null. 302 * @return Return RET_OK if Unhold running lock successfully, otherwise refer to the RetError for the failure. 303 */ 304 virtual RetError UnholdRunningLock() override; 305 306 /** 307 * @brief To return the result of cursor position. 308 * @param elementInfo The source info to cursor position. 309 * @param position: The position of the cursor to get. 310 * @return Return RET_OK if performs action succeed, otherwise refer to the RetError for the failure. 311 */ 312 virtual RetError GetCursorPosition(const AccessibilityElementInfo &elementInfo, int32_t &position) override; 313 314 /** 315 * @brief Set target bundle names. 316 * @param targetBundleNames The target bundle name 317 * @return Return RET_OK if sets target bundle names successfully, otherwise refer to the RetError for the failure. 318 */ 319 virtual RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override; 320 321 /** 322 * @brief Set cache mode. 323 * The mode is used for functions: GetRoot, GetRootByWindow, GetChildElementInfo, 324 * GetChildren, GetSource, GetParentElementInfo. 325 * @param cacheMode The cache mode. It includes: 326 * PREFETCH_PREDECESSORS: cache the parent node info also. 327 * PREFETCH_SIBLINGS: cache the sister/brothers node info also. 328 * PREFETCH_CHILDREN: cache the child node info also. 329 * otherwise: no cache. 330 * @return Return RET_OK if sets cache mode successfully, otherwise refer to the RetError for the failure. 331 */ 332 virtual RetError SetCacheMode(const int32_t cacheMode) override; 333 334 /** 335 * @brief Search all child nodes 336 * @param windowId The target window id. 337 * @param elementId The target element id. 338 * @param elementInfos The element infos of specified content. 339 * @return Return RET_OK if gets all child nodes successfully, otherwise refer to the RetError for the failure. 340 */ 341 virtual RetError GetElements(const int32_t windowId, const int64_t elementId, 342 std::vector<AccessibilityElementInfo> &elementInfos) override; 343 344 /** 345 * @brief Search all child nodes 346 * @param windowId The target window id. 347 * @param elementInfos The element infos of specified content. 348 * @return Return RET_OK if gets all child nodes successfully, otherwise refer to the RetError for the failure. 349 */ 350 virtual RetError GetDefaultFocusedElementIds(const int32_t windowId, 351 std::vector<AccessibilityElementInfo> &elementInfos) override; 352 353 /** 354 * @brief register disconnect callback 355 * @param callback The disconnect callback. 356 * @return Return RET_OK if register callback successfully, otherwise refer to the RetError for the failure. 357 */ 358 virtual RetError RegisterDisconnectCallback(std::shared_ptr<DisconnectCallback> &callback) override; 359 360 /** 361 * @brief unRegister disconnect callback 362 * @return Return RET_OK if unRegister callback successfully, otherwise refer to the RetError for the failure. 363 */ 364 virtual RetError UnRegisterDisconnectCallback(std::shared_ptr<DisconnectCallback> &callback) override; 365 366 /** 367 * @brief notify disconnect 368 * @return Return RET_OK if notify disconnect successfully, otherwise refer to the RetError for the failure. 369 */ 370 virtual RetError NotifyDisconnect() override; 371 372 /** 373 * @brief Clean data. 374 * @param remote The object access to AAMS. 375 */ 376 void ResetAAClient(const wptr<IRemoteObject> &remote); 377 378 /** 379 * @brief Notify AA client and clean data when service is died. 380 * @param remote The object access to AAMS. 381 */ 382 void NotifyServiceDied(const wptr<IRemoteObject> &remote); 383 384 /** 385 * @brief Connect to AAMS. For UI test. 386 * @return Return RET_OK if the command of connection is sent successfully, 387 * otherwise refer to the RetError for the failure. 388 */ 389 RetError Connect(); 390 391 /** 392 * @brief disconnect to AAMS. For UI test. 393 * @return Return RET_OK if the command of disconnect is sent successfully, 394 * otherwise refer to the RetError for the failure. 395 */ 396 RetError Disconnect(); 397 398 /** 399 * @brief Set connection state. 400 * @param state Connnection state. 401 */ 402 void SetConnectionState(bool state); 403 404 /** 405 * @brief Config need events. 406 * @param needEvents The need events. 407 * @return Return RET_OK if config need events successfully, otherwise refer to the RetError for the failure. 408 */ 409 RetError ConfigureEvents(const std::vector<uint32_t> needEvents) override; 410 411 /** 412 * @brief Find the node information by accessibility ID. 413 * @param accessibilityWindowId The window id that the component belongs to. 414 * @param elementId: The unique id of the component ID. 415 * @param mode PREFETCH_PREDECESSORS: Need to make the parent node info also. 416 * PREFETCH_SIBLINGS: Need to make the sister/brothers node info also. 417 * PREFETCH_CHILDREN: Need to make the child node info also. 418 * otherwise: Make the node information by elementId only. 419 * @param info[out] The components information matched conditions searched. 420 * @return Return RET_OK if search element info successfully, otherwise refer to the RetError for the failure. 421 */ 422 RetError SearchElementInfoByAccessibilityId(const int32_t windowId, const int64_t elementId, 423 const uint32_t mode, AccessibilityElementInfo &info, bool isFilter = false) override; 424 425 void AddWindowElementMapByWMS(int32_t windowId, int64_t elementId); 426 void AddWindowElementMapByAce(int32_t windowId, int64_t elementId); 427 RetError GetElementInfoFromCache(int32_t windowId, int64_t elementId, 428 std::vector<AccessibilityElementInfo> &elementInfos); 429 RetError SearchElementInfoRecursive(int32_t windowId, int64_t elementId, uint32_t mode, 430 std::vector<AccessibilityElementInfo> &elementInfos, bool isFilter = false); 431 RetError SearchElementInfoRecursiveByWinid(const int32_t windowId, const int64_t elementId, 432 uint32_t mode, std::vector<AccessibilityElementInfo> &elementInfos, int32_t treeId, bool isFilter = false, 433 uint64_t parentIndex = 0, bool systemApi = false); 434 RetError SearchElementInfoRecursiveByContent(const int32_t windowId, const int64_t elementId, 435 uint32_t mode, std::vector<AccessibilityElementInfo> &elementInfos, const std::string text, int32_t treeId, 436 bool isFilter = false, bool systemApi = false); 437 void RemoveCacheData(const AccessibilityEventInfo &eventInfo); 438 void AddCacheByWMS(int32_t windowId, int64_t elementId, std::vector<AccessibilityElementInfo>& elementInfos); 439 void AddCacheByAce(int32_t windowId, int64_t elementId, std::vector<AccessibilityElementInfo>& elementInfos); 440 void SortElementInfosIfNecessary(std::vector<AccessibilityElementInfo> &elementInfos); 441 442 bool LoadAccessibilityService(); 443 void LoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject); 444 void LoadSystemAbilityFail(); 445 RetError GetChildrenWork(const int32_t windowId, std::vector<int64_t> childIds, 446 std::vector<AccessibilityElementInfo> &children, bool systemApi = false); 447 RetError SearchElementInfoRecursiveBySpecificProperty(const int32_t windowId, const int64_t elementId, 448 std::vector<AccessibilityElementInfo> &elementInfos, int32_t treeId, uint64_t parentIndex = 0, 449 const SpecificPropertyParam& param = {}); 450 451 private: 452 class ElementCacheInfo { 453 public: 454 ElementCacheInfo() = default; 455 ~ElementCacheInfo() = default; 456 void RemoveElementByWindowId(const int32_t windowId); 457 bool GetElementByWindowId(const int32_t windowId, const int64_t elementId, 458 std::vector<AccessibilityElementInfo>& elementInfos); 459 bool GetElementByWindowIdBFS(const int64_t elementId, std::vector<AccessibilityElementInfo>& elementInfos, 460 std::map<int32_t, std::shared_ptr<AccessibilityElementInfo>>& cache); 461 void AddElementCache(int32_t windowId, const std::vector<AccessibilityElementInfo>& elementInfos); 462 bool IsExistWindowId(int32_t windowId); 463 private: 464 std::map<int32_t, std::map<int32_t, std::shared_ptr<AccessibilityElementInfo>>> elementCache_; 465 std::deque<int32_t> windowIdSet_; 466 ffrt::mutex elementCacheMutex_; 467 }; 468 469 class SceneBoardWindowElementMap { 470 public: 471 SceneBoardWindowElementMap() = default; 472 ~SceneBoardWindowElementMap() = default; 473 bool IsExistWindowId(int32_t windowId); 474 void AddWindowElementIdPair(int32_t windowId, int64_t elementId); 475 std::vector<int32_t> GetWindowIdList(); 476 int32_t GetWindowIdByElementId(int64_t elementId); 477 void RemovePairByWindowIdList(std::vector<int32_t>& windowIdList); 478 void RemovePairByWindowId(int32_t windowId); 479 private: 480 std::map<int32_t, int64_t> windowElementMap_; 481 ffrt::mutex mapMutex_; 482 }; 483 484 class AccessibleAbilityDeathRecipient final : public IRemoteObject::DeathRecipient { 485 public: AccessibleAbilityDeathRecipient(AccessibleAbilityClientImpl & client)486 AccessibleAbilityDeathRecipient(AccessibleAbilityClientImpl &client) : client_(client) {} 487 ~AccessibleAbilityDeathRecipient() = default; 488 DISALLOW_COPY_AND_MOVE(AccessibleAbilityDeathRecipient); 489 490 void OnRemoteDied(const wptr<IRemoteObject> &remote); 491 private: 492 AccessibleAbilityClientImpl &client_; 493 }; 494 495 class AccessibilityServiceDeathRecipient final : public IRemoteObject::DeathRecipient { 496 public: AccessibilityServiceDeathRecipient(AccessibleAbilityClientImpl & client)497 AccessibilityServiceDeathRecipient(AccessibleAbilityClientImpl &client) : client_(client) {} 498 ~AccessibilityServiceDeathRecipient() = default; 499 DISALLOW_COPY_AND_MOVE(AccessibilityServiceDeathRecipient); 500 501 void OnRemoteDied(const wptr<IRemoteObject> &remote); 502 private: 503 AccessibleAbilityClientImpl &client_; 504 }; 505 506 class AccessibilityLoadCallback : public SystemAbilityLoadCallbackStub { 507 public: 508 void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, 509 const sptr<IRemoteObject> &remoteObject) override; 510 void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; 511 }; 512 513 bool GetCacheElementInfo(const int32_t windowId, 514 const int64_t elementId, AccessibilityElementInfo &elementInfo); 515 void SetCacheElementInfo(const int32_t windowId, 516 const std::vector<OHOS::Accessibility::AccessibilityElementInfo> &elementInfos); 517 RetError SearchElementInfoByElementId(const int32_t windowId, const int64_t elementId, 518 const uint32_t mode, AccessibilityElementInfo &info, int32_t treeId, bool systemApi = false); 519 RetError SearchElementInfoFromAce(const int32_t windowId, const int64_t elementId, 520 const uint32_t mode, AccessibilityElementInfo &info, bool systemApi = false); 521 bool InitAccessibilityServiceProxy(); 522 static void OnParameterChanged(const char *key, const char *value, void *context); 523 bool CheckServiceProxy(); // should be used in mutex 524 RetError CheckConnection(); // should be used in mutex, to check isConnected_ and channelClient_ 525 526 sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr; 527 sptr<IRemoteObject::DeathRecipient> accessibilityServiceDeathRecipient_ = nullptr; 528 sptr<IAccessibleAbilityManagerService> serviceProxy_ = nullptr; 529 std::shared_ptr<AccessibleAbilityListener> listener_ = nullptr; 530 std::shared_ptr<AccessibleAbilityChannelClient> channelClient_ = nullptr; 531 uint32_t cacheMode_ = 0; 532 int32_t cacheWindowId_ = -1; 533 SafeMap<int64_t, AccessibilityElementInfo> cacheElementInfos_; 534 ffrt::mutex mutex_; 535 std::atomic<bool> isConnected_ = false; 536 // used for query element info in batch 537 ElementCacheInfo elementCacheInfo_; 538 SceneBoardWindowElementMap windowElementMap_; 539 540 ffrt::condition_variable proxyConVar_; 541 ffrt::mutex conVarMutex_; 542 ffrt::shared_mutex rwLock_; 543 std::list<std::shared_ptr<DisconnectCallback>> callbackList_; 544 bool isDisconnectCallbackExecute_ = false; 545 ffrt::mutex callbackListMutex_; 546 }; 547 } // namespace Accessibility 548 } // namespace OHOS 549 #endif // ACCESSIBLE_ABILITY_CLIENT_IMPL_H