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 
22 namespace OHOS {
23 namespace Accessibility {
24 class AccessibilityWindowConnection : public RefBase {
25 public:
26     AccessibilityWindowConnection(const int32_t windowId, const sptr<IAccessibilityElementOperator> &connection,
27         const int32_t accountId);
28     AccessibilityWindowConnection(const int32_t windowId, const int32_t treeId,
29         const sptr<IAccessibilityElementOperator> &connection, const int32_t accountId);
30     ~AccessibilityWindowConnection();
31 
GetProxy()32     inline sptr<IAccessibilityElementOperator> GetProxy()
33     {
34         return proxy_;
35     }
36 
37     sptr<IAccessibilityElementOperator> GetCardProxy(const int32_t treeId);
38 
39     RetError SetCardProxy(const int32_t treeId, sptr<IAccessibilityElementOperator> operation);
40 
41     uint32_t GetTokenIdMap(const int32_t treeId);
42 
43     RetError SetTokenIdMap(const int32_t treeId, const uint32_t tokenId);
44 
45     void GetAllTreeId(std::vector<int32_t> &treeIds);
46 
47     RetError GetRootParentId(int32_t treeId, int64_t &elementId);
48 
49     RetError SetRootParentId(const int32_t treeId, const int64_t elementId);
50 
51     void EraseProxy(const int32_t treeId);
52 
53 private:
54     int32_t windowId_;
55     int32_t accountId_;
56     int32_t treeId_ = 0;
57     std::map<int32_t, sptr<IAccessibilityElementOperator>> cardProxy_;
58     sptr<IAccessibilityElementOperator> proxy_;
59     std::map<int32_t, uint32_t> tokenIdMap_;
60     std::map<int32_t, int64_t> treeIdParentId_;
61 };
62 } // namespace Accessibility
63 } // namespace OHOS
64 #endif // ACCESSIBILITY_WINDOW_CONNECTION_H