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 #include "accessibility_element_operator_proxy.h"
17 #include "accessibility_ut_helper.h"
18 #include "hilog_wrapper.h"
19 
20 namespace OHOS {
21 namespace Accessibility {
AccessibilityElementOperatorProxy(const sptr<IRemoteObject> & impl)22 AccessibilityElementOperatorProxy::AccessibilityElementOperatorProxy(
23     const sptr<IRemoteObject> &impl) : IRemoteProxy<IAccessibilityElementOperator>(impl)
24 {}
25 
WriteInterfaceToken(MessageParcel & data)26 bool AccessibilityElementOperatorProxy::WriteInterfaceToken(MessageParcel &data)
27 {
28     (void)data;
29     return true;
30 }
31 
SendTransactCmd(AccessibilityInterfaceCode code,MessageParcel & data,MessageParcel & reply,MessageOption & option)32 bool AccessibilityElementOperatorProxy::SendTransactCmd(AccessibilityInterfaceCode code,
33     MessageParcel &data, MessageParcel &reply,  MessageOption &option)
34 {
35     (void)code;
36     (void)data;
37     (void)reply;
38     (void)option;
39     return true;
40 }
41 
SearchElementInfoByAccessibilityId(const int64_t elementId,const int32_t requestId,const sptr<IAccessibilityElementOperatorCallback> & callback,const int32_t mode,bool isFilter)42 void AccessibilityElementOperatorProxy::SearchElementInfoByAccessibilityId(const int64_t elementId,
43     const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback, const int32_t mode,
44     bool isFilter)
45 {
46     AccessibilityAbilityHelper::GetInstance().SetTestChannelElementId(elementId);
47     (void)requestId;
48     (void)callback;
49     (void)mode;
50     (void)isFilter;
51 }
52 
SearchElementInfosByText(const int64_t elementId,const std::string & text,const int32_t requestId,const sptr<IAccessibilityElementOperatorCallback> & callback)53 void AccessibilityElementOperatorProxy::SearchElementInfosByText(const int64_t elementId,
54     const std::string &text,
55     const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
56 {
57     AccessibilityAbilityHelper::GetInstance().SetTestChannelElementId(elementId);
58     (void)text;
59     (void)requestId;
60     (void)callback;
61 }
62 
FindFocusedElementInfo(const int64_t elementId,const int32_t focusType,const int32_t requestId,const sptr<IAccessibilityElementOperatorCallback> & callback)63 void AccessibilityElementOperatorProxy::FindFocusedElementInfo(const int64_t elementId,
64     const int32_t focusType, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
65 {
66     (void)focusType;
67     AccessibilityAbilityHelper::GetInstance().SetTestChannelElementId(elementId);
68     if (callback) {
69         AccessibilityElementInfo info;
70         callback->SetFindFocusedElementInfoResult(info, requestId);
71     }
72 }
73 
FocusMoveSearch(const int64_t elementId,const int32_t direction,const int32_t requestId,const sptr<IAccessibilityElementOperatorCallback> & callback)74 void AccessibilityElementOperatorProxy::FocusMoveSearch(const int64_t elementId,
75     const int32_t direction, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback)
76 {
77     AccessibilityAbilityHelper::GetInstance().SetTestChannelElementId(elementId);
78     (void)direction;
79     (void)requestId;
80     (void)callback;
81 }
82 
ExecuteAction(const int64_t elementId,const int32_t action,const std::map<std::string,std::string> & arguments,const int32_t requestId,const sptr<IAccessibilityElementOperatorCallback> & callback)83 void AccessibilityElementOperatorProxy::ExecuteAction(const int64_t elementId, const int32_t action,
84     const std::map<std::string, std::string> &arguments, const int32_t requestId,
85     const sptr<IAccessibilityElementOperatorCallback> &callback)
86 {
87     (void)arguments;
88     AccessibilityAbilityHelper::GetInstance().SetExecuteAction(action);
89     AccessibilityAbilityHelper::GetInstance().SetTestChannelElementId(elementId);
90     if (callback) {
91         callback->SetExecuteActionResult(true, requestId);
92     }
93 }
94 
GetCursorPosition(const int64_t elementId,const int32_t requestId,const sptr<IAccessibilityElementOperatorCallback> & callback)95 void AccessibilityElementOperatorProxy::GetCursorPosition(const int64_t elementId, const int32_t requestId,
96     const sptr<IAccessibilityElementOperatorCallback> &callback)
97 {
98     AccessibilityAbilityHelper::GetInstance().SetTestChannelElementId(elementId);
99     if (callback) {
100         callback->SetCursorPositionResult(1, requestId);
101     }
102 }
103 
ClearFocus()104 void AccessibilityElementOperatorProxy::ClearFocus()
105 {
106 }
107 
OutsideTouch()108 void AccessibilityElementOperatorProxy::OutsideTouch()
109 {
110 }
111 
SetChildTreeIdAndWinId(const int64_t elementId,const int32_t treeId,const int32_t childWindowId)112 void AccessibilityElementOperatorProxy::SetChildTreeIdAndWinId(const int64_t elementId, const int32_t treeId,
113     const int32_t childWindowId)
114 {
115     (void)elementId;
116     (void)treeId;
117     (void)childWindowId;
118 }
119 
SetBelongTreeId(const int32_t treeId)120 void AccessibilityElementOperatorProxy::SetBelongTreeId(const int32_t treeId)
121 {
122     (void)treeId;
123 }
124 
SetParentWindowId(const int32_t parentWindowId)125 void AccessibilityElementOperatorProxy::SetParentWindowId(const int32_t parentWindowId)
126 {
127     (void)parentWindowId;
128 }
129 } // namespace Accessibility
130 } // namespace OHOS