• 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_WINDOW_CONNECTION_H
17 #define ACCESSIBILITY_WINDOW_CONNECTION_H
18 
19 #include "i_accessibility_element_operator.h"
20 #include "hilog_wrapper.h"
21 #include "ffrt.h"
22 #include "safe_map.h"
23 
24 namespace OHOS {
25 namespace Accessibility {
26 class AccessibilityWindowConnection : public RefBase {
27 public:
28     AccessibilityWindowConnection(const int32_t windowId, const sptr<IAccessibilityElementOperator> &connection,
29         const int32_t accountId);
30     AccessibilityWindowConnection(const int32_t windowId, const int32_t treeId,
31         const sptr<IAccessibilityElementOperator> &connection, const int32_t accountId);
32     ~AccessibilityWindowConnection();
33 
GetProxy()34     inline sptr<IAccessibilityElementOperator> GetProxy()
35     {
36         return proxy_;
37     }
38 
SetProxy(sptr<IAccessibilityElementOperator> proxy)39     inline void SetProxy(sptr<IAccessibilityElementOperator> proxy)
40     {
41         proxy_ = proxy;
42     }
43 
GetCardProxySize()44     inline int GetCardProxySize()
45     {
46         return cardProxy_.Size();
47     }
48 
49     sptr<IAccessibilityElementOperator> GetCardProxy(const int32_t treeId);
50 
51     RetError SetCardProxy(const int32_t treeId, sptr<IAccessibilityElementOperator> operation);
52 
53     uint32_t GetTokenIdMap(const int32_t treeId);
54 
55     RetError SetTokenIdMap(const int32_t treeId, const uint32_t tokenId);
56 
57     void GetAllTreeId(std::vector<int32_t> &treeIds);
58 
59     RetError GetRootParentId(int32_t treeId, int64_t &elementId);
60 
61     RetError SetRootParentId(const int32_t treeId, const int64_t elementId);
62 
63     void EraseProxy(const int32_t treeId);
64 
65 private:
66     int32_t windowId_;
67     int32_t accountId_;
68     int32_t treeId_ = 0;
69     SafeMap<int32_t, sptr<IAccessibilityElementOperator>> cardProxy_;
70     sptr<IAccessibilityElementOperator> proxy_;
71     SafeMap<int32_t, uint32_t> tokenIdMap_;
72     SafeMap<int32_t, int64_t> treeIdParentId_;
73 };
74 } // namespace Accessibility
75 } // namespace OHOS
76 #endif // ACCESSIBILITY_WINDOW_CONNECTION_H