1885b47fbSopenharmony_ci/*
2885b47fbSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3885b47fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4885b47fbSopenharmony_ci * you may not use this file except in compliance with the License.
5885b47fbSopenharmony_ci * You may obtain a copy of the License at
6885b47fbSopenharmony_ci *
7885b47fbSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8885b47fbSopenharmony_ci *
9885b47fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10885b47fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11885b47fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12885b47fbSopenharmony_ci * See the License for the specific language governing permissions and
13885b47fbSopenharmony_ci * limitations under the License.
14885b47fbSopenharmony_ci */
15885b47fbSopenharmony_ci
16885b47fbSopenharmony_ci#ifndef ACCESSIBILITY_MT_HELPER_H
17885b47fbSopenharmony_ci#define ACCESSIBILITY_MT_HELPER_H
18885b47fbSopenharmony_ci
19885b47fbSopenharmony_ci#include <vector>
20885b47fbSopenharmony_ci#include "accessibility_def.h"
21885b47fbSopenharmony_ci#include "ffrt.h"
22885b47fbSopenharmony_ci#include "hilog/log.h"
23885b47fbSopenharmony_ci#include "i_accessible_ability_channel.h"
24885b47fbSopenharmony_ci#include "iremote_object.h"
25885b47fbSopenharmony_ci
26885b47fbSopenharmony_cinamespace OHOS {
27885b47fbSopenharmony_cinamespace Accessibility {
28885b47fbSopenharmony_ciclass AccessibilityHelper {
29885b47fbSopenharmony_cipublic:
30885b47fbSopenharmony_ci    static AccessibilityHelper& GetInstance()
31885b47fbSopenharmony_ci    {
32885b47fbSopenharmony_ci        static AccessibilityHelper helper;
33885b47fbSopenharmony_ci        return helper;
34885b47fbSopenharmony_ci    }
35885b47fbSopenharmony_ci    int32_t GetTestWindowId() const
36885b47fbSopenharmony_ci    {
37885b47fbSopenharmony_ci        return testWindowId_;
38885b47fbSopenharmony_ci    }
39885b47fbSopenharmony_ci    void SetTestWindowId(int32_t windowId)
40885b47fbSopenharmony_ci    {
41885b47fbSopenharmony_ci        testWindowId_ = windowId;
42885b47fbSopenharmony_ci    }
43885b47fbSopenharmony_ci    std::vector<EventType>& GetEventType()
44885b47fbSopenharmony_ci    {
45885b47fbSopenharmony_ci        std::lock_guard<ffrt::mutex> lock(mtx_);
46885b47fbSopenharmony_ci        return mTeventType_;
47885b47fbSopenharmony_ci    }
48885b47fbSopenharmony_ci    EventType GetEventTypeOfTargetIndex(int32_t index)
49885b47fbSopenharmony_ci    {
50885b47fbSopenharmony_ci        std::lock_guard<ffrt::mutex> lock(mtx_);
51885b47fbSopenharmony_ci        int32_t size = static_cast<int32_t>(mTeventType_.size());
52885b47fbSopenharmony_ci        if (size > index) {
53885b47fbSopenharmony_ci            return mTeventType_[index];
54885b47fbSopenharmony_ci        }
55885b47fbSopenharmony_ci        return TYPE_VIEW_INVALID;
56885b47fbSopenharmony_ci    }
57885b47fbSopenharmony_ci    void PushEventType(EventType eventType)
58885b47fbSopenharmony_ci    {
59885b47fbSopenharmony_ci        std::lock_guard<ffrt::mutex> lock(mtx_);
60885b47fbSopenharmony_ci        mTeventType_.push_back(eventType);
61885b47fbSopenharmony_ci    }
62885b47fbSopenharmony_ci    int32_t GetGestureId() const
63885b47fbSopenharmony_ci    {
64885b47fbSopenharmony_ci        return mTgestureId_;
65885b47fbSopenharmony_ci    }
66885b47fbSopenharmony_ci    void SetGestureId(int32_t gestureId)
67885b47fbSopenharmony_ci    {
68885b47fbSopenharmony_ci        mTgestureId_ = gestureId;
69885b47fbSopenharmony_ci    }
70885b47fbSopenharmony_ci    OHOS::sptr<OHOS::Accessibility::IAccessibleAbilityChannel>& GetTestStub()
71885b47fbSopenharmony_ci    {
72885b47fbSopenharmony_ci        return testStub_;
73885b47fbSopenharmony_ci    }
74885b47fbSopenharmony_ci    void SetTestStub(const OHOS::sptr<OHOS::Accessibility::IAccessibleAbilityChannel>& stub)
75885b47fbSopenharmony_ci    {
76885b47fbSopenharmony_ci        testStub_ = stub;
77885b47fbSopenharmony_ci    }
78885b47fbSopenharmony_ci    uint32_t GetTestStateType() const
79885b47fbSopenharmony_ci    {
80885b47fbSopenharmony_ci        return testStateType_;
81885b47fbSopenharmony_ci    }
82885b47fbSopenharmony_ci    void SetTestStateType(uint32_t stateType)
83885b47fbSopenharmony_ci    {
84885b47fbSopenharmony_ci        testStateType_ = stateType;
85885b47fbSopenharmony_ci    }
86885b47fbSopenharmony_ci    int32_t GetTestEventType() const
87885b47fbSopenharmony_ci    {
88885b47fbSopenharmony_ci        return testEventType_;
89885b47fbSopenharmony_ci    }
90885b47fbSopenharmony_ci    void SetTestEventType(int32_t testEventType)
91885b47fbSopenharmony_ci    {
92885b47fbSopenharmony_ci        testEventType_ = testEventType;
93885b47fbSopenharmony_ci    }
94885b47fbSopenharmony_ci    int32_t GetTestWindowChangeTypes() const
95885b47fbSopenharmony_ci    {
96885b47fbSopenharmony_ci        return testWindowChangeTypes_;
97885b47fbSopenharmony_ci    }
98885b47fbSopenharmony_ci    void SetTestWindowChangeTypes(int32_t testWindowChangeTypes)
99885b47fbSopenharmony_ci    {
100885b47fbSopenharmony_ci        testWindowChangeTypes_ = testWindowChangeTypes;
101885b47fbSopenharmony_ci    }
102885b47fbSopenharmony_ci    int32_t GetTestChannalId() const
103885b47fbSopenharmony_ci    {
104885b47fbSopenharmony_ci        return testChannalId_;
105885b47fbSopenharmony_ci    }
106885b47fbSopenharmony_ci    void SetTestChannalId(int32_t testChannalId)
107885b47fbSopenharmony_ci    {
108885b47fbSopenharmony_ci        testChannalId_ = testChannalId;
109885b47fbSopenharmony_ci    }
110885b47fbSopenharmony_ci    int32_t GetTestKeyPressEvent() const
111885b47fbSopenharmony_ci    {
112885b47fbSopenharmony_ci        return testKeyPressEvent_;
113885b47fbSopenharmony_ci    }
114885b47fbSopenharmony_ci    void SetTestKeyPressEvent(int32_t testKeyPressEvent)
115885b47fbSopenharmony_ci    {
116885b47fbSopenharmony_ci        testKeyPressEvent_ = testKeyPressEvent;
117885b47fbSopenharmony_ci    }
118885b47fbSopenharmony_ci    int32_t GetTestDisplayId() const
119885b47fbSopenharmony_ci    {
120885b47fbSopenharmony_ci        return testDisplayId_;
121885b47fbSopenharmony_ci    }
122885b47fbSopenharmony_ci    void SetTestDisplayId(int32_t testDisplayId)
123885b47fbSopenharmony_ci    {
124885b47fbSopenharmony_ci        testDisplayId_ = testDisplayId;
125885b47fbSopenharmony_ci    }
126885b47fbSopenharmony_ci    int32_t GetTestGesture() const
127885b47fbSopenharmony_ci    {
128885b47fbSopenharmony_ci        return testGesture_;
129885b47fbSopenharmony_ci    }
130885b47fbSopenharmony_ci    void SetTestGesture(int32_t testGesture)
131885b47fbSopenharmony_ci    {
132885b47fbSopenharmony_ci        testGesture_ = testGesture;
133885b47fbSopenharmony_ci    }
134885b47fbSopenharmony_ci    int32_t GetTestGestureSimulateResult() const
135885b47fbSopenharmony_ci    {
136885b47fbSopenharmony_ci        return testGestureSimulateResult_;
137885b47fbSopenharmony_ci    }
138885b47fbSopenharmony_ci    void SetTestGestureSimulateResult(int32_t testGestureSimulateResult)
139885b47fbSopenharmony_ci    {
140885b47fbSopenharmony_ci        testGestureSimulateResult_ = testGestureSimulateResult;
141885b47fbSopenharmony_ci    }
142885b47fbSopenharmony_cipublic:
143885b47fbSopenharmony_ci    static const int32_t accountId_ = 100;
144885b47fbSopenharmony_ci
145885b47fbSopenharmony_ciprivate:
146885b47fbSopenharmony_ci    OHOS::sptr<OHOS::Accessibility::IAccessibleAbilityChannel> testStub_ = nullptr;
147885b47fbSopenharmony_ci    std::vector<EventType> mTeventType_ = {};
148885b47fbSopenharmony_ci    int32_t mTgestureId_ = 0;
149885b47fbSopenharmony_ci    uint32_t testStateType_ = 0;
150885b47fbSopenharmony_ci    int32_t testEventType_ = 0;
151885b47fbSopenharmony_ci    int32_t testWindowChangeTypes_ = 0;
152885b47fbSopenharmony_ci    int32_t testWindowId_ = 0;
153885b47fbSopenharmony_ci    int32_t testChannalId_ = -1;
154885b47fbSopenharmony_ci    int32_t testGesture_ = -1;
155885b47fbSopenharmony_ci    int32_t testKeyPressEvent_ = -1;
156885b47fbSopenharmony_ci    int32_t testDisplayId_ = -1;
157885b47fbSopenharmony_ci    int32_t testGestureSimulateResult_ = -1;
158885b47fbSopenharmony_ci    ffrt::mutex mtx_;
159885b47fbSopenharmony_ci};
160885b47fbSopenharmony_ci} // namespace Accessibility
161885b47fbSopenharmony_ci} // namespace OHOS
162885b47fbSopenharmony_ci#endif // ACCESSIBILITY_MT_HELPER_H