1 /*
2 * Copyright (c) 2025 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 "component/XComponent.h"
17
18 namespace ArkUICapiTest {
19
20 static int32_t g_testFunctionIndex = 0;
21 static int32_t g_result = -1;
22 static OH_NativeXComponent_KeyEvent* g_keyEvent = nullptr;
23 static OH_NativeXComponent_KeyAction g_action = OH_NATIVEXCOMPONENT_KEY_ACTION_UNKNOWN;
24 static OH_NativeXComponent_EventSourceType g_eventSourceType = OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN;
25 static int64_t g_deviceId = PARAM_NEGATIVE_2;
26 static int64_t g_timestamp = PARAM_NEGATIVE_2;
27 static uint64_t g_targetTimestamp = 0;
28 static uint64_t g_keys = PARAM_NEGATIVE_2;
29 static bool g_isNumLockOn = NULL;
30 static bool g_isCapsLockOn = NULL;
31 static bool g_isScrollLockOn = NULL;
32 static XComponent g_xComponent = XComponent(ARKUI_NODE_COLUMN);
33 static XComponent* g_childXComponent = new XComponent(ARKUI_NODE_XCOMPONENT);
34 static OHNativeWindow* g_nativeWindow = nullptr;
35 static OH_NativeXComponent_TouchEvent g_touchEvent;
36 static int g_touchIndex = 0;
37 static int32_t g_point = 0;
38 static int32_t g_action_result = 0;
39 static void (*const TEST_FUNCTIONS[19])() = {
40 XComponent::GetKeyEventAction001,
41 XComponent::GetKeyEventAction002,
42 XComponent::GetKeyEventSourceType001,
43 XComponent::GetKeyEventSourceType002,
44 XComponent::GetKeyEventDeviceId001,
45 XComponent::GetKeyEventDeviceId002,
46 XComponent::GetKeyEventTimestamp001,
47 XComponent::GetKeyEventTimestamp002,
48 XComponent::GetKeyEventModifierKeyStates001,
49 XComponent::GetKeyEventModifierKeyStates002,
50 XComponent::GetKeyEventNumLockState001,
51 XComponent::GetKeyEventNumLockState002,
52 XComponent::GetKeyEventCapsLockState001,
53 XComponent::GetKeyEventCapsLockState002,
54 XComponent::GetKeyEventScrollLockState001,
55 XComponent::GetKeyEventScrollLockState002,
56 XComponent::GetKeyEventActionEnum001,
57 XComponent::GetKeyEventActionEnum002,
58 XComponent::GetKeyEventActionEnum003
59 };
60
ChooseTestFunction(napi_env env,napi_callback_info info)61 napi_value ChooseTestFunction(napi_env env, napi_callback_info info)
62 {
63 if ((env == nullptr) || (info == nullptr)) {
64 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "CreateNativeNode env or info is null");
65 return nullptr;
66 }
67 size_t argCnt = 1;
68 napi_value args[1] = { nullptr };
69 if (napi_get_cb_info(env, info, &argCnt, args, nullptr, nullptr) != napi_ok) {
70 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "CreateNativeNode napi_get_cb_info failed");
71 }
72 if (argCnt != PARAM_1) {
73 napi_throw_type_error(env, NULL, "Wrong number of arguments");
74 return nullptr;
75 }
76 napi_get_value_int32(env, args[PARAM_0], &g_testFunctionIndex);
77 return nullptr;
78 }
79
GetKeyEventAction(napi_env env,napi_callback_info info)80 napi_value GetKeyEventAction(napi_env env, napi_callback_info info)
81 {
82 napi_value retValue = 0;
83 int32_t result = PARAM_NEGATIVE_2;
84 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
85 "KeyEventXComponent", "Choose Function GetKeyEventAction");
86 if (g_action == OH_NATIVEXCOMPONENT_KEY_ACTION_UNKNOWN) {
87 result = -1;
88 } else if (g_action == OH_NATIVEXCOMPONENT_KEY_ACTION_DOWN) {
89 result = 0;
90 } else if (g_action == OH_NATIVEXCOMPONENT_KEY_ACTION_UP) {
91 result = 1;
92 }
93 g_action = OH_NATIVEXCOMPONENT_KEY_ACTION_UNKNOWN;
94 napi_create_int32(env, result, &retValue);
95 return retValue;
96 }
97
GetKeyEventActionEnum(napi_env env,napi_callback_info info)98 napi_value GetKeyEventActionEnum(napi_env env, napi_callback_info info)
99 {
100 napi_value retValue = 0;
101 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
102 "KeyEventXComponent", "Choose Function GetKeyEventAction");
103 napi_create_int32(env, g_action_result, &retValue);
104 g_action_result = 0;
105 return retValue;
106 }
107
GetKeyEventSourceType(napi_env env,napi_callback_info info)108 napi_value GetKeyEventSourceType(napi_env env, napi_callback_info info)
109 {
110 napi_value retValue = 0;
111 int32_t result = PARAM_NEGATIVE_2;
112 if (g_eventSourceType == OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN) {
113 result = OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN;
114 } else if (g_eventSourceType == OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE) {
115 result = OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE;
116 } else if (g_eventSourceType == OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN) {
117 result = OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN;
118 } else if (g_eventSourceType == OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD) {
119 result = OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD;
120 } else if (g_eventSourceType == OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK) {
121 result = OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK;
122 } else if (g_eventSourceType == OH_NATIVEXCOMPONENT_SOURCE_TYPE_KEYBOARD) {
123 result = OH_NATIVEXCOMPONENT_SOURCE_TYPE_KEYBOARD;
124 }
125 g_eventSourceType = OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN;
126 napi_create_int32(env, result, &retValue);
127 return retValue;
128 }
129
GetKeyEventDeviceId(napi_env env,napi_callback_info info)130 napi_value GetKeyEventDeviceId(napi_env env, napi_callback_info info)
131 {
132 napi_value retValue = 0;
133 int64_t result = PARAM_NEGATIVE_2;
134 if (g_deviceId == PARAM_NEGATIVE_2) {
135 result = 0;
136 } else {
137 result = 1;
138 }
139 g_deviceId = PARAM_NEGATIVE_2;
140 napi_create_int64(env, result, &retValue);
141 return retValue;
142 }
143
GetKeyEventTimestamp(napi_env env,napi_callback_info info)144 napi_value GetKeyEventTimestamp(napi_env env, napi_callback_info info)
145 {
146 napi_value retValue = 0;
147 int64_t result = PARAM_NEGATIVE_2;
148 if (g_timestamp == PARAM_NEGATIVE_2) {
149 result = 0;
150 } else {
151 result = 1;
152 }
153 g_timestamp = PARAM_NEGATIVE_2;
154 napi_create_int64(env, result, &retValue);
155 return retValue;
156 }
157
GetKeyEventModifierKeyStates(napi_env env,napi_callback_info info)158 napi_value GetKeyEventModifierKeyStates(napi_env env, napi_callback_info info)
159 {
160 napi_value retValue = 0;
161 napi_create_int32(env, g_result, &retValue);
162 return retValue;
163 }
164
GetKeyEventNumLockState(napi_env env,napi_callback_info info)165 napi_value GetKeyEventNumLockState(napi_env env, napi_callback_info info)
166 {
167 napi_value retValue = 0;
168 napi_create_int32(env, g_result, &retValue);
169 return retValue;
170 }
GetKeyEventCapsLockState(napi_env env,napi_callback_info info)171 napi_value GetKeyEventCapsLockState(napi_env env, napi_callback_info info)
172 {
173 napi_value retValue = 0;
174 napi_create_int32(env, g_result, &retValue);
175 return retValue;
176 }
GetKeyEventScrollLockState(napi_env env,napi_callback_info info)177 napi_value GetKeyEventScrollLockState(napi_env env, napi_callback_info info)
178 {
179 napi_value retValue = 0;
180 napi_create_int32(env, g_result, &retValue);
181 return retValue;
182 }
183
AttachNativeRootNode001(napi_env env,napi_callback_info info)184 napi_value AttachNativeRootNode001(napi_env env, napi_callback_info info)
185 {
186 XComponent Column = XComponent(ARKUI_NODE_COLUMN);
187 Column.SetBackgroundColor(0xffff0000);
188 Column.SetWidth(COLUMN_WIDTH_AND_HEIGHT);
189 Column.SetHeight(COLUMN_WIDTH_AND_HEIGHT);
190 ArkUI_NativeNodeAPI_1* _nodeAPI;
191 OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, _nodeAPI);
192 _nodeAPI->addChild(g_childXComponent->GetComponent(), Column.GetComponent());
193 napi_value retValue = 0;
194 int32_t result = ARKUI_ERROR_CODE_PARAM_INVALID;
195 result = OH_NativeXComponent_AttachNativeRootNode(g_childXComponent->GetXComponent(), Column.GetComponent());
196 OH_NativeXComponent_DetachNativeRootNode(g_childXComponent->GetXComponent(), Column.GetComponent());
197 napi_create_int32(env, result, &retValue);
198 return retValue;
199 }
200
AttachNativeRootNode002(napi_env env,napi_callback_info info)201 napi_value AttachNativeRootNode002(napi_env env, napi_callback_info info)
202 {
203 napi_value retValue = 0;
204 int32_t result = 0;
205 if (OH_NativeXComponent_AttachNativeRootNode(g_xComponent.GetXComponent(), nullptr) ==
206 OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER) {
207 result = ARKUI_ERROR_CODE_PARAM_INVALID;
208 }
209 napi_create_int32(env, result, &retValue);
210 return retValue;
211 }
212
DetachNativeRootNode001(napi_env env,napi_callback_info info)213 napi_value DetachNativeRootNode001(napi_env env, napi_callback_info info)
214 {
215 XComponent Column = XComponent(ARKUI_NODE_COLUMN);
216 Column.SetBackgroundColor(0xffff0000);
217 Column.SetWidth(COLUMN_WIDTH_AND_HEIGHT);
218 Column.SetHeight(COLUMN_WIDTH_AND_HEIGHT);
219 ArkUI_NativeNodeAPI_1* _nodeAPI;
220 OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, _nodeAPI);
221 _nodeAPI->addChild(g_childXComponent->GetComponent(), Column.GetComponent());
222 napi_value retValue = 0;
223 int32_t result = ARKUI_ERROR_CODE_PARAM_INVALID;
224 OH_NativeXComponent_AttachNativeRootNode(g_childXComponent->GetXComponent(), Column.GetComponent());
225 result = OH_NativeXComponent_DetachNativeRootNode(g_childXComponent->GetXComponent(), Column.GetComponent());
226 napi_create_int32(env, result, &retValue);
227 return retValue;
228 }
229
DetachNativeRootNode002(napi_env env,napi_callback_info info)230 napi_value DetachNativeRootNode002(napi_env env, napi_callback_info info)
231 {
232 napi_value retValue = 0;
233 int32_t result = 0;
234 if (OH_NativeXComponent_DetachNativeRootNode(g_xComponent.GetXComponent(), nullptr) ==
235 OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER) {
236 result = ARKUI_ERROR_CODE_PARAM_INVALID;
237 }
238 napi_create_int32(env, result, &retValue);
239 return retValue;
240 }
241
SetExpectedFrameRateRange001(napi_env env,napi_callback_info info)242 napi_value SetExpectedFrameRateRange001(napi_env env, napi_callback_info info)
243 {
244 napi_value retValue = 0;
245 OH_NativeXComponent_ExpectedRateRange ExpectedRateRange = { .min = 30, .max = 60, .expected = 45 };
246 int32_t result = 0;
247 result = OH_NativeXComponent_SetExpectedFrameRateRange(g_childXComponent->GetXComponent(), &ExpectedRateRange);
248 napi_create_int32(env, result, &retValue);
249 return retValue;
250 }
251
SetExpectedFrameRateRange002(napi_env env,napi_callback_info info)252 napi_value SetExpectedFrameRateRange002(napi_env env, napi_callback_info info)
253 {
254 napi_value retValue = 0;
255 OH_NativeXComponent_ExpectedRateRange ExpectedRateRange = { .min = 30, .max = 60, .expected = 45 };
256 if (OH_NativeXComponent_SetExpectedFrameRateRange(nullptr, &ExpectedRateRange) == 0) {
257 napi_create_int32(env, 0, &retValue);
258 return retValue;
259 }
260 if (OH_NativeXComponent_SetExpectedFrameRateRange(g_childXComponent->GetXComponent(), nullptr) == 0) {
261 napi_create_int32(env, 0, &retValue);
262 return retValue;
263 }
264 napi_create_int32(env, ARKUI_ERROR_CODE_PARAM_INVALID, &retValue);
265 return retValue;
266 }
267
SetArkUIExpectedFrameRateRange001(napi_env env,napi_callback_info info)268 napi_value SetArkUIExpectedFrameRateRange001(napi_env env, napi_callback_info info)
269 {
270 napi_value retValue = 0;
271 OH_NativeXComponent_ExpectedRateRange ExpectedRateRange = { .min = 30, .max = 60, .expected = 45 };
272 int32_t result = 0;
273 OH_ArkUI_XComponent_Initialize(g_childXComponent->GetComponent());
274 result = OH_ArkUI_XComponent_SetExpectedFrameRateRange(g_childXComponent->GetComponent(), ExpectedRateRange);
275 napi_create_int32(env, result, &retValue);
276 return retValue;
277 }
278
SetArkUIExpectedFrameRateRange002(napi_env env,napi_callback_info info)279 napi_value SetArkUIExpectedFrameRateRange002(napi_env env, napi_callback_info info)
280 {
281 napi_value retValue = 0;
282 OH_NativeXComponent_ExpectedRateRange ExpectedRateRange = { .min = 30, .max = 60, .expected = 45 };
283 if (OH_ArkUI_XComponent_SetExpectedFrameRateRange(nullptr, ExpectedRateRange) == 0) {
284 napi_create_int32(env, 0, &retValue);
285 return retValue;
286 }
287 napi_create_int32(env, ARKUI_ERROR_CODE_PARAM_INVALID, &retValue);
288 return retValue;
289 }
290
RegisterOnFrameCallback001(napi_env env,napi_callback_info info)291 napi_value RegisterOnFrameCallback001(napi_env env, napi_callback_info info)
292 {
293 napi_value retValue = 0;
294 int32_t result = ARKUI_ERROR_CODE_PARAM_INVALID;
295 result = OH_NativeXComponent_RegisterOnFrameCallback(g_childXComponent->GetXComponent(), OnFrameCallback);
296 napi_create_int32(env, result, &retValue);
297 return retValue;
298 }
299
RegisterOnFrameCallback002(napi_env env,napi_callback_info info)300 napi_value RegisterOnFrameCallback002(napi_env env, napi_callback_info info)
301 {
302 napi_value retValue = 0;
303 int32_t result = 0;
304 result = OH_NativeXComponent_RegisterOnFrameCallback(nullptr, OnFrameCallback) == PARAM_NEGATIVE_2 ?
305 ARKUI_ERROR_CODE_PARAM_INVALID : 0;
306 napi_create_int32(env, result, &retValue);
307 return retValue;
308 }
309
ArkUIRegisterOnFrameCallback001(napi_env env,napi_callback_info info)310 napi_value ArkUIRegisterOnFrameCallback001(napi_env env, napi_callback_info info)
311 {
312 napi_value retValue = 0;
313 int32_t result = ARKUI_ERROR_CODE_PARAM_INVALID;
314 result = OH_ArkUI_XComponent_RegisterOnFrameCallback(g_childXComponent->GetComponent(), OnArkUIFrameCallback);
315 napi_create_int32(env, result, &retValue);
316 return retValue;
317 }
318
ArkUIRegisterOnFrameCallback002(napi_env env,napi_callback_info info)319 napi_value ArkUIRegisterOnFrameCallback002(napi_env env, napi_callback_info info)
320 {
321 napi_value retValue = 0;
322 int32_t result = 0;
323 result = OH_ArkUI_XComponent_RegisterOnFrameCallback(nullptr, OnArkUIFrameCallback);
324 napi_create_int32(env, result, &retValue);
325 return retValue;
326 }
327
OnFrameCallback(OH_NativeXComponent * component,uint64_t timestamp,uint64_t targetTimestamp)328 void OnFrameCallback(OH_NativeXComponent* component, uint64_t timestamp, uint64_t targetTimestamp)
329 {
330 return;
331 }
332
OnArkUIFrameCallback(ArkUI_NodeHandle node,uint64_t timestamp,uint64_t targetTimestamp)333 void OnArkUIFrameCallback(ArkUI_NodeHandle node, uint64_t timestamp, uint64_t targetTimestamp)
334 {
335 return;
336 }
337
UnregisterOnFrameCallback001(napi_env env,napi_callback_info info)338 napi_value UnregisterOnFrameCallback001(napi_env env, napi_callback_info info)
339 {
340 napi_value retValue = 0;
341 int32_t result = ARKUI_ERROR_CODE_PARAM_INVALID;
342 result = OH_NativeXComponent_UnregisterOnFrameCallback(g_childXComponent->GetXComponent());
343 napi_create_int32(env, result, &retValue);
344 return retValue;
345 }
346
UnregisterOnFrameCallback002(napi_env env,napi_callback_info info)347 napi_value UnregisterOnFrameCallback002(napi_env env, napi_callback_info info)
348 {
349 napi_value retValue = 0;
350 int32_t result = 0;
351 result = OH_NativeXComponent_UnregisterOnFrameCallback(nullptr) == PARAM_NEGATIVE_2 ?
352 ARKUI_ERROR_CODE_PARAM_INVALID : 0;
353 napi_create_int32(env, result, &retValue);
354 return retValue;
355 }
356
ArkUIUnregisterOnFrameCallback001(napi_env env,napi_callback_info info)357 napi_value ArkUIUnregisterOnFrameCallback001(napi_env env, napi_callback_info info)
358 {
359 napi_value retValue = 0;
360 int32_t result = ARKUI_ERROR_CODE_PARAM_INVALID;
361 result = OH_ArkUI_XComponent_UnregisterOnFrameCallback(g_childXComponent->GetComponent());
362 napi_create_int32(env, result, &retValue);
363 return retValue;
364 }
365
ArkUIUnregisterOnFrameCallback002(napi_env env,napi_callback_info info)366 napi_value ArkUIUnregisterOnFrameCallback002(napi_env env, napi_callback_info info)
367 {
368 napi_value retValue = 0;
369 int32_t result = 0;
370 result = OH_ArkUI_XComponent_UnregisterOnFrameCallback(nullptr);
371 napi_create_int32(env, result, &retValue);
372 return retValue;
373 }
374
RegisterUIInputEventCallback001(napi_env env,napi_callback_info info)375 napi_value RegisterUIInputEventCallback001(napi_env env, napi_callback_info info)
376 {
377 napi_value retValue = 0;
378 int32_t result = ARKUI_ERROR_CODE_PARAM_INVALID;
379 result = OH_NativeXComponent_RegisterUIInputEventCallback(g_childXComponent->GetXComponent(),
380 UIInputEventCallback, ARKUI_UIINPUTEVENT_TYPE_AXIS);
381 napi_create_int32(env, result, &retValue);
382 return retValue;
383 }
384
RegisterUIInputEventCallback002(napi_env env,napi_callback_info info)385 napi_value RegisterUIInputEventCallback002(napi_env env, napi_callback_info info)
386 {
387 napi_value retValue = 0;
388 if (OH_NativeXComponent_RegisterUIInputEventCallback(g_childXComponent->GetXComponent(),
389 UIInputEventCallback, ARKUI_UIINPUTEVENT_TYPE_KEY) == 0) {
390 napi_create_int32(env, 0, &retValue);
391 return retValue;
392 }
393 if (OH_NativeXComponent_RegisterUIInputEventCallback(g_childXComponent->GetXComponent(),
394 UIInputEventCallback, ARKUI_UIINPUTEVENT_TYPE_MOUSE) == 0) {
395 napi_create_int32(env, 0, &retValue);
396 return retValue;
397 }
398 if (OH_NativeXComponent_RegisterUIInputEventCallback(g_childXComponent->GetXComponent(),
399 UIInputEventCallback, ARKUI_UIINPUTEVENT_TYPE_TOUCH) == 0) {
400 napi_create_int32(env, 0, &retValue);
401 return retValue;
402 }
403 if (OH_NativeXComponent_RegisterUIInputEventCallback(g_childXComponent->GetXComponent(),
404 UIInputEventCallback, ARKUI_UIINPUTEVENT_TYPE_UNKNOWN) == 0) {
405 napi_create_int32(env, 0, &retValue);
406 return retValue;
407 }
408 napi_create_int32(env, ARKUI_ERROR_CODE_PARAM_INVALID, &retValue);
409 return retValue;
410 }
411
UIInputEventCallback(OH_NativeXComponent * component,ArkUI_UIInputEvent * event,ArkUI_UIInputEvent_Type type)412 void UIInputEventCallback(OH_NativeXComponent* component, ArkUI_UIInputEvent* event, ArkUI_UIInputEvent_Type type)
413 {
414 return;
415 }
416
RegisterOnTouchInterceptCallback001(napi_env env,napi_callback_info info)417 napi_value RegisterOnTouchInterceptCallback001(napi_env env, napi_callback_info info)
418 {
419 napi_value retValue = 0;
420 int32_t result = 0;
421 result = OH_NativeXComponent_RegisterOnTouchInterceptCallback(g_childXComponent->GetXComponent(),
422 OnTouchInterceptCallback);
423 napi_create_int32(env, result, &retValue);
424 return retValue;
425 }
426
RegisterOnTouchInterceptCallback002(napi_env env,napi_callback_info info)427 napi_value RegisterOnTouchInterceptCallback002(napi_env env, napi_callback_info info)
428 {
429 napi_value retValue = 0;
430 if (OH_NativeXComponent_RegisterOnTouchInterceptCallback(nullptr, OnTouchInterceptCallback) == 0) {
431 napi_create_int32(env, 0, &retValue);
432 return retValue;
433 }
434 if (OH_NativeXComponent_RegisterOnTouchInterceptCallback(g_childXComponent->GetXComponent(), nullptr) == 0) {
435 napi_create_int32(env, 0, &retValue);
436 return retValue;
437 }
438 napi_create_int32(env, ARKUI_ERROR_CODE_PARAM_INVALID, &retValue);
439 return retValue;
440 }
441
OnTouchInterceptCallback(OH_NativeXComponent * component,ArkUI_UIInputEvent * event)442 HitTestMode OnTouchInterceptCallback(OH_NativeXComponent* component, ArkUI_UIInputEvent* event)
443 {
444 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TouchPoint", "OnTouchInterceptCallback");
445 return HTM_BLOCK;
446 }
447
GetNativeAccessibilityProvider001(napi_env env,napi_callback_info info)448 napi_value GetNativeAccessibilityProvider001(napi_env env, napi_callback_info info)
449 {
450 napi_value retValue = 0;
451 int32_t result = 0;
452 ArkUI_AccessibilityProvider* handle;
453 result = OH_NativeXComponent_GetNativeAccessibilityProvider(g_childXComponent->GetXComponent(), &handle);
454 napi_create_int32(env, result, &retValue);
455 return retValue;
456 }
457
GetNativeAccessibilityProvider002(napi_env env,napi_callback_info info)458 napi_value GetNativeAccessibilityProvider002(napi_env env, napi_callback_info info)
459 {
460 napi_value retValue = 0;
461 ArkUI_AccessibilityProvider* handle;
462 if (OH_NativeXComponent_GetNativeAccessibilityProvider(nullptr, &handle) == 0) {
463 napi_create_int32(env, 0, &retValue);
464 return retValue;
465 }
466 if (OH_NativeXComponent_GetNativeAccessibilityProvider(g_childXComponent->GetXComponent(), nullptr) == 0) {
467 napi_create_int32(env, 0, &retValue);
468 return retValue;
469 }
470 napi_create_int32(env, ARKUI_ERROR_CODE_PARAM_INVALID, &retValue);
471 return retValue;
472 }
473
RegisterKeyEventCallbackWithResult001(napi_env env,napi_callback_info info)474 napi_value RegisterKeyEventCallbackWithResult001(napi_env env, napi_callback_info info)
475 {
476 napi_value retValue = 0;
477 int32_t result = 0;
478 ArkUI_AccessibilityProvider* handle;
479 result = OH_NativeXComponent_RegisterKeyEventCallbackWithResult(g_childXComponent->GetXComponent(),
480 OnKeyEventCallbackWithResult);
481 napi_create_int32(env, result, &retValue);
482 return retValue;
483 }
484
RegisterKeyEventCallbackWithResult002(napi_env env,napi_callback_info info)485 napi_value RegisterKeyEventCallbackWithResult002(napi_env env, napi_callback_info info)
486 {
487 napi_value retValue = 0;
488 ArkUI_AccessibilityProvider* handle;
489 if (OH_NativeXComponent_RegisterKeyEventCallbackWithResult(nullptr, OnKeyEventCallbackWithResult) == 0) {
490 napi_create_int32(env, 0, &retValue);
491 return retValue;
492 }
493 if (OH_NativeXComponent_RegisterKeyEventCallbackWithResult(g_childXComponent->GetXComponent(), nullptr) == 0) {
494 napi_create_int32(env, 0, &retValue);
495 return retValue;
496 }
497 napi_create_int32(env, ARKUI_ERROR_CODE_PARAM_INVALID, &retValue);
498 return retValue;
499 }
500
OnKeyEventCallbackWithResult(OH_NativeXComponent * component,void * window)501 bool OnKeyEventCallbackWithResult(OH_NativeXComponent* component, void* window)
502 {
503 return false;
504 }
505
XComponentInitialize001(napi_env env,napi_callback_info info)506 napi_value XComponentInitialize001(napi_env env, napi_callback_info info)
507 {
508 napi_value retValue = 0;
509 Component temp = Component(ARKUI_NODE_XCOMPONENT);
510 int32_t result = 0;
511 result = OH_ArkUI_XComponent_Initialize(temp.GetComponent());
512 result = OH_ArkUI_XComponent_Initialize(temp.GetComponent());
513 napi_create_int32(env, result, &retValue);
514 return retValue;
515 }
516
XComponentFinalize001(napi_env env,napi_callback_info info)517 napi_value XComponentFinalize001(napi_env env, napi_callback_info info)
518 {
519 napi_value retValue = 0;
520 Component temp = Component(ARKUI_NODE_XCOMPONENT);
521 if (OH_ArkUI_XComponent_Finalize(temp.GetComponent()) == ARKUI_ERROR_CODE_XCOMPONENT_STATE_INVALID) {
522 napi_create_int32(env, ARKUI_ERROR_CODE_XCOMPONENT_STATE_INVALID, &retValue);
523 return retValue;
524 }
525 if (OH_ArkUI_XComponent_Finalize(temp.GetComponent()) == ARKUI_ERROR_CODE_XCOMPONENT_STATE_INVALID) {
526 napi_create_int32(env, ARKUI_ERROR_CODE_XCOMPONENT_STATE_INVALID, &retValue);
527 return retValue;
528 }
529 napi_create_int32(env, 0, &retValue);
530 return retValue;
531 }
532
XComponentSetNeedSoftKeyboard001(napi_env env,napi_callback_info info)533 napi_value XComponentSetNeedSoftKeyboard001(napi_env env, napi_callback_info info)
534 {
535 napi_value retValue = 0;
536 int32_t result = 0;
537 result = OH_ArkUI_XComponent_SetNeedSoftKeyboard(g_childXComponent->GetComponent(), false);
538 napi_create_int32(env, result, &retValue);
539 return retValue;
540 }
541
XComponentSetNeedSoftKeyboard002(napi_env env,napi_callback_info info)542 napi_value XComponentSetNeedSoftKeyboard002(napi_env env, napi_callback_info info)
543 {
544 napi_value retValue = 0;
545 if (OH_ArkUI_XComponent_SetNeedSoftKeyboard(nullptr, true) == 0) {
546 napi_create_int32(env, 0, &retValue);
547 return retValue;
548 }
549 if (OH_ArkUI_XComponent_SetNeedSoftKeyboard(nullptr, false) == 0) {
550 napi_create_int32(env, 0, &retValue);
551 return retValue;
552 }
553 napi_create_int32(env, ARKUI_ERROR_CODE_PARAM_INVALID, &retValue);
554 return retValue;
555 }
556
GetExtraMouseEventInfo001(napi_env env,napi_callback_info info)557 napi_value GetExtraMouseEventInfo001(napi_env env, napi_callback_info info)
558 {
559 napi_value retValue = 0;
560 int32_t result = ARKUI_ERROR_CODE_PARAM_INVALID;
561 OH_NativeXComponent_ExtraMouseEventInfo* ExtraMouseEventInfo;
562 result = OH_NativeXComponent_GetExtraMouseEventInfo(g_childXComponent->GetXComponent(), &ExtraMouseEventInfo);
563 napi_create_int32(env, result, &retValue);
564 return retValue;
565 }
566
GetExtraMouseEventInfo002(napi_env env,napi_callback_info info)567 napi_value GetExtraMouseEventInfo002(napi_env env, napi_callback_info info)
568 {
569 napi_value retValue = 0;
570 int32_t result = 0;
571 OH_NativeXComponent_ExtraMouseEventInfo* ExtraMouseEventInfo;
572 result = OH_NativeXComponent_GetExtraMouseEventInfo(nullptr, &ExtraMouseEventInfo);
573 result = OH_NativeXComponent_GetExtraMouseEventInfo(g_childXComponent->GetXComponent(),
574 nullptr) == ARKUI_ERROR_CODE_PARAM_INVALID && result ==
575 ARKUI_ERROR_CODE_PARAM_INVALID ?
576 ARKUI_ERROR_CODE_PARAM_INVALID : 0;
577 napi_create_int32(env, result, &retValue);
578 return retValue;
579 }
580
GetMouseEventModifierKeyStates001(napi_env env,napi_callback_info info)581 napi_value GetMouseEventModifierKeyStates001(napi_env env, napi_callback_info info)
582 {
583 napi_value retValue = 0;
584 int32_t result = ARKUI_ERROR_CODE_PARAM_INVALID;
585 OH_NativeXComponent_ExtraMouseEventInfo* ExtraMouseEventInfo;
586 OH_NativeXComponent_GetExtraMouseEventInfo(g_childXComponent->GetXComponent(), &ExtraMouseEventInfo);
587 result = OH_NativeXComponent_GetMouseEventModifierKeyStates(ExtraMouseEventInfo, &g_keys);
588 napi_create_int32(env, g_result, &retValue);
589 return retValue;
590 }
591
GetMouseEventModifierKeyStates002(napi_env env,napi_callback_info info)592 napi_value GetMouseEventModifierKeyStates002(napi_env env, napi_callback_info info)
593 {
594 napi_value retValue = 0;
595 int32_t result = 0;
596 OH_NativeXComponent_ExtraMouseEventInfo* ExtraMouseEventInfo;
597 OH_NativeXComponent_GetExtraMouseEventInfo(g_childXComponent->GetXComponent(), &ExtraMouseEventInfo);
598 result = OH_NativeXComponent_GetMouseEventModifierKeyStates(nullptr, &g_keys);
599 result = OH_NativeXComponent_GetMouseEventModifierKeyStates(ExtraMouseEventInfo, nullptr) ==
600 ARKUI_ERROR_CODE_PARAM_INVALID && result == ARKUI_ERROR_CODE_PARAM_INVALID ?
601 ARKUI_ERROR_CODE_PARAM_INVALID : 0;
602 napi_create_int32(env, result, &retValue);
603 return retValue;
604 }
605
RegisterFocusEventCallback001(napi_env env,napi_callback_info info)606 napi_value RegisterFocusEventCallback001(napi_env env, napi_callback_info info)
607 {
608 napi_value retValue = 0;
609 int32_t result = ARKUI_ERROR_CODE_PARAM_INVALID;
610 result = OH_NativeXComponent_RegisterFocusEventCallback(g_childXComponent->GetXComponent(), OnFocusEvent);
611 napi_create_int32(env, result, &retValue);
612 return retValue;
613 }
614
RegisterFocusEventCallback002(napi_env env,napi_callback_info info)615 napi_value RegisterFocusEventCallback002(napi_env env, napi_callback_info info)
616 {
617 napi_value retValue = 0;
618 int32_t result = 0;
619 result = OH_NativeXComponent_RegisterFocusEventCallback(nullptr, OnFocusEvent);
620 result = OH_NativeXComponent_RegisterFocusEventCallback(g_childXComponent->GetXComponent(),
621 nullptr) == PARAM_NEGATIVE_2 && result == PARAM_NEGATIVE_2 ?
622 ARKUI_ERROR_CODE_PARAM_INVALID : 0;
623 napi_create_int32(env, result, &retValue);
624 return retValue;
625 }
626
RegisterBlurEventCallback001(napi_env env,napi_callback_info info)627 napi_value RegisterBlurEventCallback001(napi_env env, napi_callback_info info)
628 {
629 napi_value retValue = 0;
630 int32_t result = ARKUI_ERROR_CODE_PARAM_INVALID;
631 result = OH_NativeXComponent_RegisterBlurEventCallback(g_childXComponent->GetXComponent(), OnBlurEvent);
632 napi_create_int32(env, result, &retValue);
633 return retValue;
634 }
635
RegisterBlurEventCallback002(napi_env env,napi_callback_info info)636 napi_value RegisterBlurEventCallback002(napi_env env, napi_callback_info info)
637 {
638 napi_value retValue = 0;
639 int32_t result = 0;
640 result = OH_NativeXComponent_RegisterBlurEventCallback(nullptr, OnBlurEvent);
641 result = OH_NativeXComponent_RegisterBlurEventCallback(g_childXComponent->GetXComponent(),
642 nullptr) == PARAM_NEGATIVE_2 && result == PARAM_NEGATIVE_2 ?
643 ARKUI_ERROR_CODE_PARAM_INVALID : 0;
644 napi_create_int32(env, result, &retValue);
645 return retValue;
646 }
647
CreateNativeNode(napi_env env,napi_callback_info info)648 napi_value CreateNativeNode(napi_env env, napi_callback_info info)
649 {
650 if ((env == nullptr) || (info == nullptr)) {
651 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "CreateNativeNode env or info is null");
652 return nullptr;
653 }
654 size_t argCnt = 1;
655 napi_value args[1] = { nullptr };
656 if (napi_get_cb_info(env, info, &argCnt, args, nullptr, nullptr) != napi_ok) {
657 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "CreateNativeNode napi_get_cb_info failed");
658 }
659 if (argCnt != PARAM_1) {
660 napi_throw_type_error(env, NULL, "Wrong number of arguments");
661 return nullptr;
662 }
663 ArkUI_NodeContentHandle nodeContentHandle_ = nullptr;
664 OH_ArkUI_GetNodeContentFromNapiValue(env, args[0], &nodeContentHandle_);
665 g_xComponent.SetPercentWidth(PARAM_80);
666 g_xComponent.SetPercentHeight(PARAM_80);
667 g_xComponent.SetBackgroundColor(0xffff0000);
668 g_childXComponent->SetXComponentType(ARKUI_XCOMPONENT_TYPE_SURFACE);
669 g_childXComponent->SetXComponentId("TestXComponent");
670 g_childXComponent->SetPercentWidth(PARAM_1);
671 g_childXComponent->SetPercentHeight(PARAM_1);
672 g_childXComponent->SetId("NativeXComponentTest");
673 g_childXComponent->SetFocusable(true);
674 g_childXComponent->SetFocusDefault(true);
675 g_childXComponent->PrintXComponentInfo();
676 std::shared_ptr<Component> ptr = std::make_shared<XComponent>(*g_childXComponent);
677 g_xComponent.AddChild(ptr);
678 int32_t ret = OH_ArkUI_NodeContent_SetUserData(nodeContentHandle_, &g_childXComponent);
679 OH_NativeXComponent_RegisterKeyEventCallback(g_childXComponent->GetXComponent(), OnKeyEvent);
680 if (ret != ARKUI_ERROR_CODE_NO_ERROR) {
681 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "setUserData failed error=%{public}d", ret);
682 }
683 ret = OH_ArkUI_NodeContent_AddNode(nodeContentHandle_, g_xComponent.GetComponent());
684 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "NodeAttach", "setUserData failed error=%{public}d", ret);
685 return nullptr;
686 }
687
SetXComponentType(ArkUI_XComponentType type)688 void XComponent::SetXComponentType(ArkUI_XComponentType type)
689 {
690 ArkUI_NumberValue value[] = {0};
691 value[0].i32 = type;
692 ArkUI_AttributeItem item = {value, 1};
693 _nodeAPI->setAttribute(_component, NODE_XCOMPONENT_TYPE, &item);
694 }
695
SetXComponentId(char * id)696 void XComponent::SetXComponentId(char* id)
697 {
698 ArkUI_NumberValue value[] = {0};
699 ArkUI_AttributeItem item = {value, 1, id};
700 _nodeAPI->setAttribute(_component, NODE_XCOMPONENT_ID, &item);
701 }
702
SetXComponentSurfaceSize(uint32_t width,uint32_t height)703 void XComponent::SetXComponentSurfaceSize(uint32_t width, uint32_t height)
704 {
705 ArkUI_NumberValue value[] = {{.u32 = width}, {.u32 = height}};
706 ArkUI_AttributeItem item = {value, 2};
707 _nodeAPI->setAttribute(_component, NODE_XCOMPONENT_SURFACE_SIZE, &item);
708 }
709
SetFocusable(bool flag)710 void XComponent::SetFocusable(bool flag)
711 {
712 ArkUI_NumberValue FocusValue[] = {{.i32 = flag?1:0}};
713 ArkUI_AttributeItem FocusItem = {FocusValue, 1};
714 _nodeAPI->setAttribute(_component, NODE_FOCUSABLE, &FocusItem);
715 }
716
SetFocusDefault(bool flag)717 void XComponent::SetFocusDefault(bool flag)
718 {
719 ArkUI_NumberValue FocusValue[] = {{.i32 = flag?1:0}};
720 ArkUI_AttributeItem FocusItem = {FocusValue, 1};
721 _nodeAPI->setAttribute(_component, NODE_DEFAULT_FOCUS, &FocusItem);
722 }
723
PrintXComponentInfo()724 void XComponent::PrintXComponentInfo()
725 {
726 auto *nativeXComponent = OH_NativeXComponent_GetNativeXComponent(_component);
727 if (!nativeXComponent) {
728 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "PluginManager", "GetNativeXComponent error");
729 }
730 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "PluginManager", "GetNativeXComponent success");
731 auto typeRet = _nodeAPI->getAttribute(_component, NODE_XCOMPONENT_TYPE);
732 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "PluginManager", "xcomponent type: %{public}d",
733 typeRet->value[0].i32);
734 auto idRet = _nodeAPI->getAttribute(_component, NODE_XCOMPONENT_ID);
735 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "PluginManager", "xcomponent id: %{public}s",
736 idRet->string);
737 }
738
OnFocusEvent(OH_NativeXComponent * component,void * window)739 void OnFocusEvent(OH_NativeXComponent* component, void* window)
740 {
741 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TouchPoint", "OnFocusEvent");
742 return;
743 }
744
OnBlurEvent(OH_NativeXComponent * component,void * window)745 void OnBlurEvent(OH_NativeXComponent* component, void* window)
746 {
747 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "TouchPoint", "OnTouchInterceptCallback");
748 return;
749 }
750
OnKeyEvent(OH_NativeXComponent * component,void * window)751 void OnKeyEvent(OH_NativeXComponent* component, void* window)
752 {
753 // 2. 获取键盘事件数据
754 int32_t ret = OH_NativeXComponent_GetKeyEvent(component, &g_keyEvent);
755 if (ret != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) {
756 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "XComponent", "GetKeyEventError");
757 return;
758 }
759 // 3. 处理按键事件
760 if (g_testFunctionIndex >= PARAM_0 && g_testFunctionIndex <= PARAM_18) {
761 TEST_FUNCTIONS[g_testFunctionIndex]();
762 }
763 }
764
GetKeyEventAction001()765 void XComponent::GetKeyEventAction001()
766 {
767 OH_NativeXComponent_GetKeyEventAction(g_keyEvent, &g_action);
768 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
769 "KeyEventXComponent", "Choose Function GetKeyEventAction001");
770 }
771
GetKeyEventAction002()772 void XComponent::GetKeyEventAction002()
773 {
774 OH_NativeXComponent_GetKeyEventAction(nullptr, &g_action);
775 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN,
776 "KeyEventXComponent", "Choose Function GetKeyEventAction001");
777 }
778
GetKeyEventActionEnum001()779 void XComponent::GetKeyEventActionEnum001()
780 {
781 OH_NativeXComponent_GetKeyEventAction(g_keyEvent, &g_action);
782 if (g_action == OH_NATIVEXCOMPONENT_KEY_ACTION_DOWN) {
783 g_action_result = 1;
784 }
785 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
786 "KeyEventXComponent", "Choose Function GetKeyEventAction001");
787 }
788
GetKeyEventActionEnum002()789 void XComponent::GetKeyEventActionEnum002()
790 {
791 OH_NativeXComponent_GetKeyEventAction(g_keyEvent, &g_action);
792 if (g_action == OH_NATIVEXCOMPONENT_KEY_ACTION_UP) {
793 g_action_result = 1;
794 }
795 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
796 "KeyEventXComponent", "Choose Function GetKeyEventAction001");
797 }
798
GetKeyEventActionEnum003()799 void XComponent::GetKeyEventActionEnum003()
800 {
801 OH_NativeXComponent_GetKeyEventAction(g_keyEvent, &g_action);
802 if (g_action == OH_NATIVEXCOMPONENT_KEY_ACTION_UNKNOWN) {
803 g_action_result = 1;
804 }
805 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
806 "KeyEventXComponent", "Choose Function GetKeyEventActionEnum003${public}%d", g_action);
807 }
808
GetKeyEventSourceType001()809 void XComponent::GetKeyEventSourceType001()
810 {
811 OH_NativeXComponent_GetKeyEventSourceType(g_keyEvent, &g_eventSourceType);
812 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
813 "KeyEventXComponent", "Choose Function GetKeyEventSourceType001");
814 }
815
GetKeyEventSourceType002()816 void XComponent::GetKeyEventSourceType002()
817 {
818 OH_NativeXComponent_GetKeyEventSourceType(nullptr, &g_eventSourceType);
819 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN,
820 "KeyEventXComponent", "Choose Function GetKeyEventSourceType001");
821 }
822
GetKeyEventDeviceId001()823 void XComponent::GetKeyEventDeviceId001()
824 {
825 OH_NativeXComponent_GetKeyEventDeviceId(g_keyEvent, &g_deviceId);
826 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
827 "KeyEventXComponent", "Choose Function GetKeyEventSourceType001");
828 }
829
GetKeyEventDeviceId002()830 void XComponent::GetKeyEventDeviceId002()
831 {
832 OH_NativeXComponent_GetKeyEventDeviceId(nullptr, &g_deviceId);
833 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN,
834 "KeyEventXComponent", "Choose Function GetKeyEventSourceType001");
835 }
836
GetKeyEventTimestamp001()837 void XComponent::GetKeyEventTimestamp001()
838 {
839 OH_NativeXComponent_GetKeyEventTimestamp(g_keyEvent, &g_timestamp);
840 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
841 "KeyEventXComponent", "Choose Function GetKeyEventSourceType001");
842 }
843
GetKeyEventTimestamp002()844 void XComponent::GetKeyEventTimestamp002()
845 {
846 OH_NativeXComponent_GetKeyEventTimestamp(nullptr, &g_deviceId);
847 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN,
848 "KeyEventXComponent", "Choose Function GetKeyEventSourceType001");
849 }
850
GetKeyEventModifierKeyStates001()851 void XComponent::GetKeyEventModifierKeyStates001()
852 {
853 g_result = OH_NativeXComponent_GetKeyEventModifierKeyStates(g_keyEvent, &g_keys);
854 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
855 "KeyEventXComponent", "Choose Function GetKeyEventSourceType001");
856 }
857
GetKeyEventModifierKeyStates002()858 void XComponent::GetKeyEventModifierKeyStates002()
859 {
860 g_result = OH_NativeXComponent_GetKeyEventModifierKeyStates(nullptr, &g_keys);
861 OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN,
862 "KeyEventXComponent", "Choose Function GetKeyEventSourceType001");
863 }
864
GetKeyEventNumLockState001()865 void XComponent::GetKeyEventNumLockState001()
866 {
867 g_result = OH_NativeXComponent_GetKeyEventNumLockState(g_keyEvent, &g_isNumLockOn);
868 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
869 "KeyEventXComponent", "Choose Function GetKeyEventNumLockState001");
870 }
871
GetKeyEventNumLockState002()872 void XComponent::GetKeyEventNumLockState002()
873 {
874 g_result = OH_NativeXComponent_GetKeyEventNumLockState(nullptr, &g_isNumLockOn);
875 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
876 "KeyEventXComponent", "Choose Function GetKeyEventNumLockState002");
877 }
878
GetKeyEventCapsLockState001()879 void XComponent::GetKeyEventCapsLockState001()
880 {
881 g_result = OH_NativeXComponent_GetKeyEventCapsLockState(g_keyEvent, &g_isCapsLockOn);
882 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
883 "KeyEventXComponent", "Choose Function GetKeyEventCapsLockState001");
884 }
885
GetKeyEventCapsLockState002()886 void XComponent::GetKeyEventCapsLockState002()
887 {
888 g_result = OH_NativeXComponent_GetKeyEventCapsLockState(nullptr, &g_isCapsLockOn);
889 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
890 "KeyEventXComponent", "Choose Function GetKeyEventCapsLockState002");
891 }
892
GetKeyEventScrollLockState001()893 void XComponent::GetKeyEventScrollLockState001()
894 {
895 g_result = OH_NativeXComponent_GetKeyEventScrollLockState(g_keyEvent, &g_isScrollLockOn);
896 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
897 "KeyEventXComponent", "Choose Function GetKeyEventScrollLockState001");
898 }
899
GetKeyEventScrollLockState002()900 void XComponent::GetKeyEventScrollLockState002()
901 {
902 g_result = OH_NativeXComponent_GetKeyEventScrollLockState(nullptr, &g_isScrollLockOn);
903 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN,
904 "KeyEventXComponent", "Choose Function GetKeyEventScrollLockState002");
905 }
906
907 }
908