• 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 ACCESSIBLE_ABILITY_CHANNEL_H
17 #define ACCESSIBLE_ABILITY_CHANNEL_H
18 
19 #include <future>
20 #include "accessible_ability_channel_stub.h"
21 #include "event_handler.h"
22 #include "i_accessibility_element_operator.h"
23 
24 namespace OHOS {
25 namespace Accessibility {
26 class AccessibleAbilityConnection;
27 class AccessibleAbilityChannel : public AccessibleAbilityChannelStub {
28 public:
29     AccessibleAbilityChannel(const int32_t accountId, const std::string &clientName);
30     ~AccessibleAbilityChannel() = default;
31     RetError SearchElementInfoByAccessibilityId(const int32_t accessibilityWindowId, const int32_t elementId,
32         const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback,
33         const int32_t mode) override;
34 
35     RetError SearchElementInfosByText(const int32_t accessibilityWindowId, const int32_t elementId,
36         const std::string &text, const int32_t requestId,
37         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
38 
39     RetError FindFocusedElementInfo(const int32_t accessibilityWindowId, const int32_t elementId,
40         const int32_t focusType, const int32_t requestId,
41         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
42 
43     RetError FocusMoveSearch(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t direction,
44         const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) override;
45 
46     RetError ExecuteAction(const int32_t accessibilityWindowId, const int32_t elementId, const int32_t action,
47         const std::map<std::string, std::string> &actionArguments, const int32_t requestId,
48         const sptr<IAccessibilityElementOperatorCallback> &callback) override;
49 
50     RetError GetWindow(const int32_t windowId, AccessibilityWindowInfo &windowInfo) override;
51 
52     RetError GetWindows(std::vector<AccessibilityWindowInfo> &windows) override;
53 
54     RetError GetWindowsByDisplayId(const uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) override;
55 
56     void SetOnKeyPressEventResult(const bool handled, const int32_t sequence) override;
57 
58     RetError SendSimulateGesture(const std::shared_ptr<AccessibilityGestureInjectPath>& gesturePath) override;
59 
60     RetError SetTargetBundleName(const std::vector<std::string> &targetBundleNames) override;
61 
62 private:
63     static sptr<AccessibleAbilityConnection> GetConnection(int32_t accountId, const std::string &clientName);
64     static RetError GetElementOperator(int32_t accountId, int32_t windowId, int32_t focusType,
65         const std::string &clientName, sptr<IAccessibilityElementOperator> &elementOperator);
66     RetError GetWindows(uint64_t displayId, std::vector<AccessibilityWindowInfo> &windows) const;
67 
68     std::string clientName_ = "";
69     int32_t accountId_ = -1;
70     std::shared_ptr<AppExecFwk::EventHandler> eventHandler_ = nullptr;
71 };
72 } // namespace Accessibility
73 } // namespace OHOS
74 #endif // ACCESSIBLE_ABILITY_CHANNEL_H