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 */ 15import inputMethodEngine from '@ohos.inputMethodEngine'; 16import display from '@ohos.display'; 17import windowManager from '@ohos.window'; 18import promptAction from '@ohos.promptAction'; 19import commoneventmanager from '@ohos.commonEventManager'; 20import Want from '@ohos.app.ability.Want'; 21 22let inputMethodAbility = inputMethodEngine.getInputMethodAbility(); 23let inputKeyboardDelegate = inputMethodEngine.getKeyboardDelegate(); 24 25const TAG = 'KeyboardDelegate'; 26 27export class KeyboardDelegate { 28 mContext; 29 WINDOW_TYPE_INPUT_METHOD_FLOAT = 2105; 30 windowName = 'inputApp'; 31 private windowHeight: number = 0; 32 private windowWidth: number = 0; 33 private nonBarPosition: number = 0; 34 private keyboardController: inputMethodEngine.KeyboardController; 35 private InputClient: inputMethodEngine.InputClient; 36 37 constructor(context) { 38 this.mContext = context; 39 } 40 41 private onInputStop() { 42 try { 43 this.mContext.destroy((err) => { 44 console.info(TAG + '====>inputMethodEngine destroy err:' + JSON.stringify(err)); 45 }) 46 } catch (err) { 47 console.info(TAG + '====>inputMethodEngine destroy catch err:' + JSON.stringify(err)); 48 } 49 } 50 51 public onCreate(): void { 52 this.initWindow(); 53 let that = this; 54 this.onInputStop = this.onInputStop.bind(this) 55 inputMethodAbility.on('inputStop', this.onInputStop) 56 inputMethodAbility.on('inputStart', async (keyboardController, InputClient) => { 57 this.keyboardController = keyboardController; 58 this.InputClient = InputClient 59 console.info(TAG + '====>inputMethodAbility inputStart into'); 60 }) 61 62 function subscriberCallback(err, data) { 63 console.info(TAG + '====>receive event err:' + JSON.stringify(err)); 64 console.info(TAG + '====>receive event data:' + JSON.stringify(data)); 65 switch (data.code) { 66 case 1: 67 console.info(TAG + '====>inputMethodAbility_test_getInputMethodAbility_001 event:' + data.event); 68 that.inputMethodAbility_test_getInputMethodAbility_001(); 69 break; 70 case 2: 71 console.info(TAG + '====>inputMethodAbility_test_getInputMethodDelegate_001 event:' + data.event); 72 that.inputMethodAbility_test_getKeyboardDelegate_001(); 73 break; 74 case 28: 75 console.info(TAG + '====>inputMethodAbility_test_028 event:' + data.event); 76 that.inputMethodAbility_test_028(); 77 break; 78 case 29: 79 console.info(TAG + '====>inputMethodAbility_test_029 event:' + data.event); 80 that.inputMethodAbility_test_029(); 81 break; 82 case 30: 83 console.info(TAG + '====>inputMethodAbility_test_030 event:' + data.event); 84 that.inputMethodAbility_test_030(); 85 break; 86 case 31: 87 console.info(TAG + '====>inputMethodAbility_test_031 event:' + data.event); 88 that.inputMethodAbility_test_031(); 89 break; 90 case 32: 91 console.info(TAG + '====>inputMethodAbility_test_032 event:' + data.event); 92 that.inputMethodAbility_test_032(); 93 break; 94 case 33: 95 console.info(TAG + '====>inputMethodAbility_test_033 event:' + data.event); 96 that.inputMethodAbility_test_033(); 97 break; 98 case 34: 99 console.info(TAG + '====>inputMethodAbility_test_034 event:' + data.event); 100 that.inputMethodAbility_test_034(); 101 break; 102 case 35: 103 console.info(TAG + '====>inputMethodAbility_test_035 event:' + data.event); 104 that.inputMethodAbility_test_035(); 105 break; 106 case 36: 107 console.info(TAG + '====>inputMethodAbility_test_036 event:' + data.event); 108 that.inputMethodAbility_test_036(); 109 break; 110 case 37: 111 console.info(TAG + '====>inputMethodAbility_test_037 event:' + data.event); 112 that.inputMethodAbility_test_037(); 113 break; 114 case 38: 115 console.info(TAG + '====>inputMethodAbility_test_038 event:' + data.event); 116 that.inputMethodAbility_test_038(); 117 break; 118 case 39: 119 console.info(TAG + '====>inputMethodAbility_test_039 event:' + data.event); 120 that.inputMethodAbility_test_039(); 121 break; 122 case 40: 123 console.info(TAG + '====>inputMethodAbility_test_040 event:' + data.event); 124 that.inputMethodAbility_test_040(); 125 break; 126 case 41: 127 console.info(TAG + '====>inputMethodAbility_test_041 event:' + data.event); 128 that.inputMethodAbility_test_041(); 129 break; 130 case 42: 131 console.info(TAG + '====>inputMethodAbility_test_042 event:' + data.event); 132 that.inputMethodAbility_test_042(); 133 break; 134 case 43: 135 console.info(TAG + '====>inputMethodAbility_test_043 event:' + data.event); 136 that.inputMethodAbility_test_043(); 137 break; 138 case 45: 139 console.info(TAG + '====>inputMethodAbility_test_045 event:' + data.event); 140 that.inputMethodAbility_test_045(); 141 break; 142 case 46: 143 console.info(TAG + '====>inputMethodAbility_test_046 event:' + data.event); 144 that.inputMethodAbility_test_046(); 145 break; 146 case 47: 147 console.info(TAG + '====>inputMethodAbility_test_047 event:' + data.event); 148 that.inputMethodAbility_test_047(); 149 break; 150 case 48: 151 console.info(TAG + '====>inputMethodAbility_test_048 event:' + data.event); 152 that.inputMethodAbility_test_048(); 153 break; 154 case 49: 155 console.info(TAG + '====>inputMethodAbility_test_049 event:' + data.event); 156 that.inputMethodAbility_test_049(); 157 break; 158 case 50: 159 console.info(TAG + '====>inputMethodAbility_test_050 event:' + data.event); 160 that.inputMethodAbility_test_050(); 161 break; 162 case 70: 163 console.info(TAG + '====>inputMethodAbility_test_070 event:' + data.event); 164 that.inputMethodAbility_test_070(); 165 break; 166 case 71: 167 console.info(TAG + '====>inputMethodAbility_test_071 event:' + data.event); 168 that.inputMethodAbility_test_071(); 169 break; 170 case 72: 171 console.info(TAG + '====>inputMethodAbility_test_072 event:' + data.event); 172 that.inputMethodAbility_test_072(); 173 break; 174 case 73: 175 console.info(TAG + '====>inputMethodAbility_test_073 event:' + data.event); 176 that.inputMethodAbility_test_073(); 177 break; 178 case 74: 179 console.info(TAG + '====>inputMethodAbility_test_074 event:' + data.event); 180 that.inputMethodAbility_test_074(); 181 break; 182 case 91: 183 console.info(TAG + '====>inputMethodAbility_test_091 event:' + data.event); 184 that.inputMethodAbility_test_091(); 185 break; 186 case 101: 187 console.info(TAG + '====>inputMethodAbility_test_0101 event:' + data.event); 188 that.inputMethodAbility_test_101(); 189 break; 190 case 102: 191 console.info(TAG + '====>inputMethodAbility_test_0102 event:' + data.event); 192 that.inputMethodAbility_test_102(); 193 break; 194 case 103: 195 console.info(TAG + '====>inputMethodAbility_test_0103 event:' + data.event); 196 that.inputMethodAbility_test_103(); 197 break; 198 case 104: 199 console.info(TAG + '====>inputMethodAbility_test_0104 event:' + data.event); 200 that.inputMethodAbility_test_104(); 201 break; 202 case 105: 203 console.info(TAG + '====>inputMethodAbility_test_0105 event:' + data.event); 204 that.inputMethodAbility_test_105(); 205 break; 206 case 106: 207 console.info(TAG + '====>inputMethodAbility_test_0106 event:' + data.event); 208 that.inputMethodAbility_test_106(); 209 break; 210 case 110: 211 console.info(TAG + '====>Sub_Misc_inputMethod_onSelectByRange_0110 event:' + data.event); 212 that.Sub_Misc_inputMethod_onSelectByRange_0110(); 213 break; 214 case 120: 215 console.info(TAG + '====>Sub_Misc_inputMethod_onSelectByMovement_0120 event:' + data.event); 216 that.Sub_Misc_inputMethod_onSelectByMovement_0120(); 217 break; 218 case 130: 219 console.info(TAG + '====>Sub_Misc_inputMethod_offSelectByRange_0130 event:' + data.event); 220 that.Sub_Misc_inputMethod_offSelectByRange_0130(); 221 break; 222 case 140: 223 console.info(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 event:' + data.event); 224 that.Sub_Misc_inputMethod_offSelectByMovement_0140(); 225 break; 226 case 170: 227 console.info(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 event:' + data.event); 228 that.Sub_Misc_inputMethod_sendExtendAction_0170(); 229 break; 230 case 180: 231 console.info(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0180 event:' + data.event); 232 that.Sub_Misc_inputMethod_sendExtendAction_0180(); 233 break; 234 case 200: 235 console.info(TAG + '====>Sub_Misc_inputMethod_getForward_sync_0200 event:' + data.event); 236 that.Sub_Misc_inputMethod_getForward_sync_0200(); 237 break; 238 case 201: 239 console.info(TAG + '====>Sub_Misc_inputMethod_getForward_sync_0201 event:' + data.event); 240 that.Sub_Misc_inputMethod_getForward_sync_0201(); 241 break; 242 case 210: 243 console.info(TAG + '====>Sub_Misc_inputMethod_getBackward_sync_0210 event:' + data.event); 244 that.Sub_Misc_inputMethod_getBackward_sync_0210(); 245 break; 246 case 211: 247 console.info(TAG + '====>Sub_Misc_inputMethod_getBackward_sync_0211 event:' + data.event); 248 that.Sub_Misc_inputMethod_getBackward_sync_0211(); 249 break; 250 case 220: 251 console.info(TAG + '====>Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220 event:' + data.event); 252 that.Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220(); 253 break; 254 case 221: 255 console.info(TAG + '====>Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221 event:' + data.event); 256 that.Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221(); 257 break; 258 case 230: 259 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0230 event:' + data.event); 260 that.Sub_Misc_inputMethod_getEditorAttribute_sync_0230(); 261 break; 262 case 231: 263 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0231 event:' + data.event); 264 that.Sub_Misc_inputMethod_getEditorAttribute_sync_0231(); 265 break; 266 case 233: 267 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0233 event:' + data.event); 268 that.Sub_Misc_inputMethod_getEditorAttribute_sync_0233(); 269 break; 270 case 240: 271 console.info(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0240 event:' + data.event); 272 that.Sub_Misc_inputMethod_moveCursor_sync_0240(); 273 break; 274 case 241: 275 console.info(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0241 event:' + data.event); 276 that.Sub_Misc_inputMethod_moveCursor_sync_0241(); 277 break; 278 case 250: 279 console.info(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0250 event:' + data.event); 280 that.Sub_Misc_inputMethod_deleteForward_sync_0250(); 281 break; 282 case 251: 283 console.info(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0251 event:' + data.event); 284 that.Sub_Misc_inputMethod_deleteForward_sync_0251(); 285 break; 286 case 260: 287 console.info(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0260 event:' + data.event); 288 that.Sub_Misc_inputMethod_deleteBackward_sync_0260(); 289 break; 290 case 261: 291 console.info(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0261 event:' + data.event); 292 that.Sub_Misc_inputMethod_deleteBackward_sync_0261(); 293 break; 294 case 270: 295 console.info(TAG + '====>Sub_Misc_inputMethod_insertText_sync_0270 event:' + data.event); 296 that.Sub_Misc_inputMethod_insertText_sync_0270(); 297 break; 298 case 271: 299 console.info(TAG + '====>Sub_Misc_inputMethod_insertText_sync_0271 event:' + data.event); 300 that.Sub_Misc_inputMethod_insertText_sync_0271(); 301 break; 302 case 280: 303 console.info(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0280 event:' + data.event); 304 that.Sub_Misc_inputMethod_selectByRange_sync_0280(); 305 break; 306 case 281: 307 console.info(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0281 event:' + data.event); 308 that.Sub_Misc_inputMethod_selectByRange_sync_0281(); 309 break; 310 case 290: 311 console.info(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0290 event:' + data.event); 312 that.Sub_Misc_inputMethod_selectByMovement_sync_0290(); 313 break; 314 case 291: 315 console.info(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0291 event:' + data.event); 316 that.Sub_Misc_inputMethod_selectByMovement_sync_0291(); 317 break; 318 case 300: 319 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0400 event:' + data.event); 320 that.Sub_Misc_Request_InputMethod_selectContext_0400(); 321 break; 322 case 310: 323 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0500 event:' + data.event); 324 that.Sub_Misc_Request_InputMethod_selectContext_0500(); 325 break; 326 case 320: 327 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0600 event:' + data.event); 328 that.Sub_Misc_Request_InputMethod_selectContext_0600(); 329 break; 330 331 case 340: 332 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0100 event:' + data.event); 333 that.SUB_InputMethod_IsTextPreviewSupport_0100(); 334 break; 335 case 350: 336 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0200 event:' + data.event); 337 that.SUB_InputMethod_IsTextPreviewSupport_0200(); 338 break; 339 case 360: 340 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0300 event:' + data.event); 341 that.SUB_InputMethod_IsTextPreviewSupport_0300(); 342 break; 343 case 370: 344 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0400 event:' + data.event); 345 that.SUB_InputMethod_IsTextPreviewSupport_0400(); 346 break; 347 case 380: 348 console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_0500 event:' + data.event); 349 that.SUB_InputMethod_IME_PrivateDateTransferred_0500(); 350 break; 351 case 390: 352 console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_0600 event:' + data.event); 353 that.SUB_InputMethod_IME_PrivateDateTransferred_0600(); 354 break; 355 case 400: 356 console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_1100 event:' + data.event); 357 that.SUB_InputMethod_IME_PrivateDateTransferred_1100(); 358 break; 359 } 360 } 361 362 var commonEventSubscribeInfo = { 363 events: ["inputMethodAbilityTest"] 364 }; 365 366 var subscriber; 367 commoneventmanager.createSubscriber(commonEventSubscribeInfo).then(function (data) { 368 subscriber = data; 369 commoneventmanager.subscribe(subscriber, subscriberCallback); 370 console.info(TAG + '====>scene subscribe finish===='); 371 }); 372 } 373 374 public initWindow(): void { 375 let dis = display.getDefaultDisplaySync(); 376 var dWidth = dis.width; 377 var dHeight = dis.height; 378 var keyHeightRate = 0.47; 379 var keyHeight = dHeight * keyHeightRate; 380 this.windowWidth = dWidth; 381 this.windowHeight = keyHeight; 382 this.nonBarPosition = dHeight - keyHeight; 383 384 var config = { 385 name: this.windowName, 386 windowType: windowManager.WindowType.TYPE_INPUT_METHOD, 387 cts: this.mContext 388 }; 389 390 windowManager.createWindow(config).then((win) => { 391 win.resize(dWidth, keyHeight).then(() => { 392 win.moveWindowTo(0, this.nonBarPosition).then(() => { 393 win.setUIContent('page/service/index').then(() => { 394 }); 395 }); 396 }); 397 }); 398 } 399 400 public onDestroy(): void { 401 console.info(TAG + '====>onDestroy'); 402 inputMethodAbility.off('inputStop', this.onInputStop) 403 404 } 405 406 private publishCallback(err): void { 407 if (err) { 408 console.error(TAG + '====>publish failed:' + JSON.stringify(err)); 409 } else { 410 console.info(TAG + '====>publish'); 411 } 412 } 413 414 public async offInputStop_test() { 415 console.info(TAG + '====>inputMethodAbility_test_091.offInputStop_test callback'); 416 let commonEventPublishData = { 417 data: "FAILED" 418 }; 419 this.mContext.destroy((err) => { 420 console.info(TAG + '====>inputMethodAbility offInputStop_test destroy err: ' + JSON.stringify(err)); 421 commoneventmanager.publish("inputMethodAbility_test_091", commonEventPublishData, () => { 422 }); 423 }) 424 } 425 426 public inputMethodAbility_test_091(): void { 427 console.info(TAG + '====>inputMethodAbility_test_091 start'); 428 this.offInputStop_test = this.offInputStop_test.bind(this); 429 inputMethodAbility.on("inputStop", this.offInputStop_test); 430 inputMethodAbility.off("inputStop", this.offInputStop_test); 431 console.info(TAG + '====>inputMethodAbility_test_091 end'); 432 } 433 434 private inputMethodAbility_test_getInputMethodAbility_001(): void { 435 console.info(TAG + '====>receive inputMethodAbility_test_getInputMethodAbility_001 data'); 436 if (typeof (inputMethodAbility) === 'object') { 437 console.info(TAG + '====>inputMethodAbility_test_getInputMethodAbility_001 success'); 438 var commonEventPublishData = { 439 data: "SUCCESS" 440 }; 441 } else { 442 console.info(TAG + '====>inputMethodAbility_test_getInputMethodAbility_001 failed'); 443 var commonEventPublishData = { 444 data: "FAILED" 445 }; 446 } 447 commoneventmanager.publish("inputMethodAbility_test_getInputMethodAbility_001", commonEventPublishData, 448 this.publishCallback); 449 } 450 451 private inputMethodAbility_test_getKeyboardDelegate_001(): void { 452 console.info(TAG + '====>receive inputMethodAbility_test_getKeyboardDelegate_001 data'); 453 if (typeof (inputKeyboardDelegate) === 'object') { 454 console.info(TAG + '====>inputMethodAbility_test_getKeyboardDelegate_001 success'); 455 var commonEventPublishData = { 456 data: "SUCCESS" 457 }; 458 } else { 459 console.info(TAG + '====>inputMethodAbility_test_getKeyboardDelegate_001 failed'); 460 var commonEventPublishData = { 461 data: "FAILED" 462 }; 463 } 464 commoneventmanager.publish("inputMethodAbility_test_getKeyboardDelegate_001", commonEventPublishData, 465 this.publishCallback); 466 } 467 468 async inputMethodAbility_test_028() { 469 console.info(TAG + '====>receive inputMethodAbility_test_028 data'); 470 let commonEventPublishData; 471 let editorAttribyte = await this.InputClient.getEditorAttribute(); 472 console.info(TAG + '====>inputMethodAbility_test_028 editorAttribyte:' + JSON.stringify(editorAttribyte)); 473 this.InputClient.sendKeyFunction(editorAttribyte.enterKeyType, (err, value) => { 474 if (err) { 475 console.info(TAG + '====>inputMethodAbility_test_028 sendKeyFunction err:' + JSON.stringify(err)); 476 commonEventPublishData = { 477 data: "FAILED" 478 }; 479 } else { 480 console.info(TAG + '====>inputMethodAbility_test_028 sendKeyFunction value:' + JSON.stringify(value)); 481 if (value) { 482 commonEventPublishData = { 483 data: "SUCCESS" 484 }; 485 } else { 486 commonEventPublishData = { 487 data: "FAILED" 488 }; 489 } 490 } 491 commoneventmanager.publish("inputMethodAbility_test_028", commonEventPublishData, this.publishCallback); 492 }); 493 } 494 495 async inputMethodAbility_test_029() { 496 console.info(TAG + '====>receive inputMethodAbility_test_029 data'); 497 let commonEventPublishData; 498 let editorAttribyte = await this.InputClient.getEditorAttribute(); 499 console.info(TAG + '====>inputMethodAbility_test_029 editorAttribyte:' + JSON.stringify(editorAttribyte)); 500 let value = this.InputClient.sendKeyFunction(editorAttribyte.enterKeyType); 501 console.info(TAG + '====>inputMethodAbility_test_029 sendKeyFunction value:' + JSON.stringify(value)); 502 if (value) { 503 commonEventPublishData = { 504 data: "SUCCESS" 505 }; 506 } else { 507 commonEventPublishData = { 508 data: "FAILED" 509 }; 510 } 511 commoneventmanager.publish("inputMethodAbility_test_029", commonEventPublishData, this.publishCallback); 512 } 513 514 async inputMethodAbility_test_030() { 515 console.info(TAG + '====>receive inputMethodAbility_test_030 data'); 516 let commonEventPublishData; 517 this.InputClient.deleteForward(1, (err, value) => { 518 if (err) { 519 console.info(TAG + '====>inputMethodAbility_test_030 deleteForward err:' + JSON.stringify(err)); 520 commonEventPublishData = { 521 data: "FAILED" 522 }; 523 } else { 524 console.info(TAG + '====>inputMethodAbility_test_030 deleteForward value:' + JSON.stringify(value)); 525 if (typeof value === 'boolean') { 526 commonEventPublishData = { 527 data: "SUCCESS" 528 }; 529 } else { 530 commonEventPublishData = { 531 data: "FAILED" 532 }; 533 } 534 } 535 commoneventmanager.publish("inputMethodAbility_test_030", commonEventPublishData, this.publishCallback); 536 }); 537 } 538 539 async inputMethodAbility_test_031() { 540 console.info(TAG + '====>receive inputMethodAbility_test_031 data'); 541 let commonEventPublishData; 542 let value = await this.InputClient.deleteForward(1); 543 console.info(TAG + '====>inputMethodAbility_test_031 deleteForward value:' + value); 544 if (typeof value === 'boolean') { 545 commonEventPublishData = { 546 data: "SUCCESS" 547 }; 548 } else { 549 commonEventPublishData = { 550 data: "FAILED" 551 }; 552 } 553 commoneventmanager.publish("inputMethodAbility_test_031", commonEventPublishData, this.publishCallback); 554 } 555 556 async inputMethodAbility_test_032() { 557 console.info(TAG + '====>receive inputMethodAbility_test_032 data'); 558 let commonEventPublishData; 559 this.InputClient.deleteBackward(1, (err, value) => { 560 if (err) { 561 console.info(TAG + '====>inputMethodAbility_test_032 deleteBackward err:' + JSON.stringify(err)); 562 commonEventPublishData = { 563 data: "FAILED" 564 }; 565 } else { 566 console.info(TAG + '====>inputMethodAbility_test_032 deleteBackward value:' + JSON.stringify(value)); 567 if (value) { 568 commonEventPublishData = { 569 data: "SUCCESS" 570 }; 571 } else { 572 commonEventPublishData = { 573 data: "FAILED" 574 }; 575 } 576 } 577 commoneventmanager.publish("inputMethodAbility_test_032", commonEventPublishData, this.publishCallback); 578 }); 579 } 580 581 async inputMethodAbility_test_033() { 582 console.info(TAG + '====>receive inputMethodAbility_test_033 data'); 583 let commonEventPublishData; 584 let value = await this.InputClient.deleteBackward(1); 585 console.info(TAG + '====>inputMethodAbility_test_033 deleteBackward value:' + JSON.stringify(value)); 586 if (value) { 587 commonEventPublishData = { 588 data: "SUCCESS" 589 }; 590 } else { 591 commonEventPublishData = { 592 data: "FAILED" 593 }; 594 } 595 commoneventmanager.publish("inputMethodAbility_test_033", commonEventPublishData, this.publishCallback); 596 } 597 598 async inputMethodAbility_test_034() { 599 console.info(TAG + '====>receive inputMethodAbility_test_034 data'); 600 let commonEventPublishData; 601 this.InputClient.insertText('test', (err, value) => { 602 if (err) { 603 console.info(TAG + '====>inputMethodAbility_test_034 insertText err:' + JSON.stringify(err)); 604 commonEventPublishData = { 605 data: "FAILED" 606 }; 607 } else { 608 console.info(TAG + '====>inputMethodAbility_test_034 insertText value:' + JSON.stringify(value)); 609 if (value) { 610 commonEventPublishData = { 611 data: "SUCCESS" 612 }; 613 } else { 614 commonEventPublishData = { 615 data: "FAILED" 616 }; 617 } 618 } 619 commoneventmanager.publish("inputMethodAbility_test_034", commonEventPublishData, this.publishCallback); 620 }); 621 } 622 623 async inputMethodAbility_test_035() { 624 console.info(TAG + '====>receive inputMethodAbility_test_035 data'); 625 let commonEventPublishData; 626 let value = await this.InputClient.insertText('test'); 627 console.info(TAG + '====>inputMethodAbility_test_035 insertText value:' + JSON.stringify(value)); 628 if (value) { 629 commonEventPublishData = { 630 data: "SUCCESS" 631 }; 632 } else { 633 commonEventPublishData = { 634 data: "FAILED" 635 }; 636 } 637 commoneventmanager.publish("inputMethodAbility_test_035", commonEventPublishData, this.publishCallback); 638 } 639 640 async inputMethodAbility_test_036() { 641 console.info(TAG + '====>receive inputMethodAbility_test_036 data'); 642 let commonEventPublishData; 643 this.InputClient.getForward(1, (err, value) => { 644 if (err) { 645 console.info(TAG + '====>inputMethodAbility_test_036 getForward err:' + JSON.stringify(err)); 646 commonEventPublishData = { 647 data: "FAILED" 648 }; 649 } else { 650 console.info(TAG + '====>inputMethodAbility_test_036 getForward value:' + JSON.stringify(value)); 651 if (typeof (value) !== null) { 652 commonEventPublishData = { 653 data: "SUCCESS" 654 }; 655 } else { 656 commonEventPublishData = { 657 data: "FAILED" 658 }; 659 } 660 } 661 commoneventmanager.publish("inputMethodAbility_test_036", commonEventPublishData, this.publishCallback); 662 }); 663 } 664 665 async inputMethodAbility_test_037() { 666 console.info(TAG + '====>receive inputMethodAbility_test_037 data'); 667 let commonEventPublishData; 668 let value = await this.InputClient.getForward(1); 669 console.info(TAG + '====>inputMethodAbility_test_037 getForward value' + JSON.stringify(value)); 670 if (typeof (value) !== null) { 671 commonEventPublishData = { 672 data: "SUCCESS" 673 }; 674 } else { 675 commonEventPublishData = { 676 data: "FAILED" 677 }; 678 } 679 commoneventmanager.publish("inputMethodAbility_test_037", commonEventPublishData, this.publishCallback); 680 } 681 682 async inputMethodAbility_test_038() { 683 console.info(TAG + '====>receive inputMethodAbility_test_038 data'); 684 let commonEventPublishData; 685 this.InputClient.getEditorAttribute((err, value) => { 686 if (err) { 687 console.info(TAG + '====>inputMethodAbility_test_038 getEditorAttribute err:' + JSON.stringify(err)); 688 commonEventPublishData = { 689 data: "FAILED" 690 }; 691 } else { 692 console.info(TAG + '====>inputMethodAbility_test_038 getEditorAttribute value:' + JSON.stringify(value)); 693 if (value) { 694 commonEventPublishData = { 695 data: "SUCCESS" 696 }; 697 } else { 698 commonEventPublishData = { 699 data: "FAILED" 700 }; 701 } 702 } 703 commoneventmanager.publish("inputMethodAbility_test_038", commonEventPublishData, this.publishCallback); 704 }); 705 } 706 707 async inputMethodAbility_test_039() { 708 console.info(TAG + '====>receive inputMethodAbility_test_039 data'); 709 let commonEventPublishData; 710 let value = await this.InputClient.getEditorAttribute(); 711 console.info(TAG + '====>inputMethodAbility_test_039 getEditorAttribute value:' + JSON.stringify(value)); 712 if (value) { 713 commonEventPublishData = { 714 data: "SUCCESS" 715 }; 716 } else { 717 commonEventPublishData = { 718 data: "FAILED" 719 }; 720 } 721 commoneventmanager.publish("inputMethodAbility_test_039", commonEventPublishData, this.publishCallback); 722 } 723 724 async inputMethodAbility_test_040() { 725 console.info(TAG + '====>receive inputMethodAbility_test_040 data'); 726 let commonEventPublishData; 727 try { 728 this.keyboardController.hideKeyboard((err, value) => { 729 if (err) { 730 console.info(TAG + '====>inputMethodAbility_test_040 hideKeyboard err:' + JSON.stringify(err)); 731 commonEventPublishData = { 732 data: "FAILED" 733 }; 734 } else { 735 commonEventPublishData = { 736 data: "SUCCESS" 737 }; 738 } 739 commoneventmanager.publish("inputMethodAbility_test_040", commonEventPublishData, this.publishCallback); 740 }); 741 } catch (err) { 742 commonEventPublishData = { 743 data: "FAILED" 744 }; 745 console.info(TAG + '====>inputMethodAbility_test_040 hideKeyboard throw_err:'); 746 commoneventmanager.publish("inputMethodAbility_test_040", commonEventPublishData, this.publishCallback); 747 } 748 } 749 750 async inputMethodAbility_test_041() { 751 console.info(TAG + '====>receive inputMethodAbility_test_041 data'); 752 let commonEventPublishData; 753 try { 754 await this.keyboardController.hideKeyboard(); 755 console.info(TAG + '====>inputMethodAbility_test_041 hideKeyboard success'); 756 commonEventPublishData = { 757 data: "SUCCESS" 758 }; 759 } catch (err) { 760 commonEventPublishData = { 761 data: "FAILED" 762 }; 763 console.info(TAG + '====>inputMethodAbility_test_041 hideKeyboard catch err:' + JSON.stringify(err)); 764 } 765 commoneventmanager.publish("inputMethodAbility_test_041", commonEventPublishData, this.publishCallback); 766 } 767 768 async inputMethodAbility_test_042() { 769 console.info(TAG + '====>receive inputMethodAbility_test_042 data'); 770 let commonEventPublishData; 771 this.InputClient.getBackward(1, (err, value) => { 772 if (err) { 773 console.info(TAG + '====>inputMethodAbility_test_042 getBackward err:' + JSON.stringify(err)); 774 commonEventPublishData = { 775 data: "FAILED" 776 }; 777 } else { 778 console.info(TAG + '====>inputMethodAbility_test_042 getBackward value:' + JSON.stringify(value)); 779 commonEventPublishData = { 780 data: "SUCCESS" 781 }; 782 } 783 commoneventmanager.publish("inputMethodAbility_test_042", commonEventPublishData, this.publishCallback); 784 }); 785 } 786 787 async inputMethodAbility_test_043() { 788 console.info(TAG + '====>receive inputMethodAbility_test_043 data'); 789 let commonEventPublishData; 790 let value = await this.InputClient.getBackward(1); 791 console.info(TAG + '====>inputMethodAbility_test_043 getBackward value:' + JSON.stringify(value)); 792 commonEventPublishData = { 793 data: "SUCCESS" 794 }; 795 commoneventmanager.publish("inputMethodAbility_test_043", commonEventPublishData, this.publishCallback); 796 } 797 798 async inputMethodAbility_test_045() { 799 console.info(TAG + '====>receive inputMethodAbility_test_045 data'); 800 let t = setTimeout(() => { 801 let commonEventPublishData; 802 this.InputClient.moveCursor(inputMethodEngine.CURSOR_UP, (err, value) => { 803 if (err) { 804 console.info(TAG + '====>inputMethodAbility_test_045 CURSOR_UP err:' + JSON.stringify(err)); 805 commonEventPublishData = { 806 data: "FAILED" 807 }; 808 } else { 809 console.info(TAG + '====>inputMethodAbility_test_045 CURSOR_UP value:' + JSON.stringify(value)); 810 commonEventPublishData = { 811 data: "SUCCESS" 812 }; 813 } 814 commoneventmanager.publish("inputMethodAbility_test_045", commonEventPublishData, this.publishCallback); 815 }); 816 clearTimeout(t); 817 }, 1000); 818 } 819 820 async inputMethodAbility_test_046() { 821 console.info(TAG + '====>receive inputMethodAbility_test_046 data'); 822 let commonEventPublishData; 823 this.InputClient.moveCursor(inputMethodEngine.CURSOR_DOWN, (err, value) => { 824 if (err) { 825 console.info(TAG + '====>inputMethodAbility_test_046 CURSOR_DOWN err:' + JSON.stringify(err)); 826 commonEventPublishData = { 827 data: "FAILED" 828 }; 829 } else { 830 console.info(TAG + '====>inputMethodAbility_test_046 CURSOR_DOWN value:' + JSON.stringify(value)); 831 commonEventPublishData = { 832 data: "SUCCESS" 833 }; 834 } 835 commoneventmanager.publish("inputMethodAbility_test_046", commonEventPublishData, this.publishCallback); 836 }); 837 } 838 839 async inputMethodAbility_test_047() { 840 console.info(TAG + '====>receive inputMethodAbility_test_047 data'); 841 let commonEventPublishData; 842 await this.InputClient.moveCursor(inputMethodEngine.CURSOR_LEFT); 843 console.info(TAG + '====>inputMethodAbility_test_047 CURSOR_LEFT success'); 844 commonEventPublishData = { 845 data: "SUCCESS" 846 }; 847 commoneventmanager.publish("inputMethodAbility_test_047", commonEventPublishData, this.publishCallback); 848 } 849 850 async inputMethodAbility_test_048() { 851 console.info(TAG + '====>receive inputMethodAbility_test_048 data'); 852 let commonEventPublishData; 853 await this.InputClient.moveCursor(inputMethodEngine.CURSOR_RIGHT); 854 console.info(TAG + '====>inputMethodAbility_test_048 CURSOR_RIGHT success'); 855 commonEventPublishData = { 856 data: "SUCCESS" 857 }; 858 commoneventmanager.publish("inputMethodAbility_test_048", commonEventPublishData, this.publishCallback); 859 } 860 861 async inputMethodAbility_test_049() { 862 console.info(TAG + '====>receive inputMethodAbility_test_049 data'); 863 let commonEventPublishData; 864 try { 865 this.keyboardController.hide((err, value) => { 866 if (err) { 867 console.info(TAG + '====>inputMethodAbility_test_049 hide err:' + JSON.stringify(err)); 868 commonEventPublishData = { 869 data: "FAILED" 870 }; 871 } else { 872 commonEventPublishData = { 873 data: "SUCCESS" 874 }; 875 } 876 commoneventmanager.publish("inputMethodAbility_test_049", commonEventPublishData, this.publishCallback); 877 }); 878 } catch (err) { 879 commonEventPublishData = { 880 data: "FAILED" 881 }; 882 console.info(TAG + '====>inputMethodAbility_test_049 hide throw_err:'); 883 commoneventmanager.publish("inputMethodAbility_test_040", commonEventPublishData, this.publishCallback); 884 } 885 } 886 887 async inputMethodAbility_test_050() { 888 console.info(TAG + '====>receive inputMethodAbility_test_050 data'); 889 let commonEventPublishData; 890 try { 891 await this.keyboardController.hide(); 892 console.info(TAG + '====>inputMethodAbility_test_050 hideKeyboard success'); 893 commonEventPublishData = { 894 data: "SUCCESS" 895 }; 896 } catch (err) { 897 commonEventPublishData = { 898 data: "FAILED" 899 }; 900 console.info(TAG + '====>inputMethodAbility_test_050 hideKeyboard catch err:' + JSON.stringify(err)); 901 } 902 commoneventmanager.publish("inputMethodAbility_test_050", commonEventPublishData, this.publishCallback); 903 904 } 905 906 async inputMethodAbility_test_070() { 907 let commonEventPublishData = { 908 data: "FAILED" 909 }; 910 console.info(TAG + '====>receive inputMethodAbility_test_070 success'); 911 let count = 0; 912 await this.keyboardController.hideKeyboard(); 913 inputMethodAbility.on('keyboardShow', () => { 914 inputMethodAbility.off('keyboardShow'); 915 console.info(TAG + '====>inputMethodAbility.on("keyboardShow") count: ' + count); 916 count += 1; 917 }); 918 inputMethodAbility.on('setSubtype', () => { 919 inputMethodAbility.off('setSubtype'); 920 console.info(TAG + '====>inputMethodAbility.on("setSubtype") count: ' + count); 921 count += 1; 922 }); 923 924 let t = setTimeout(() => { 925 if (count === 1) { 926 commonEventPublishData = { 927 data: "SUCCESS" 928 }; 929 } 930 commoneventmanager.publish("inputMethodAbility_test_070", commonEventPublishData, this.publishCallback); 931 clearTimeout(t); 932 }, 2000); 933 } 934 935 async inputMethodAbility_test_071() { 936 let commonEventPublishData = { 937 data: "FAILED" 938 }; 939 console.info(TAG + '====>receive inputMethodAbility_test_071 success'); 940 let count = 0; 941 inputMethodAbility.on('keyboardHide', () => { 942 count += 1; 943 inputMethodAbility.off("keyboardHide"); 944 console.info(TAG + '====>inputMethodAbility.off("keyboardHide") count: ' + count); 945 }); 946 let t = setTimeout(async () => { 947 await this.keyboardController.hideKeyboard(); 948 console.info(TAG + '====>inputMethodAbility_test_071 hideKeyboard success'); 949 }, 500); 950 let t1 = setTimeout(() => { 951 if (count === 1) { 952 commonEventPublishData = { 953 data: "SUCCESS" 954 }; 955 } 956 commoneventmanager.publish("inputMethodAbility_test_071", commonEventPublishData, this.publishCallback); 957 clearTimeout(t1); 958 }, 2000); 959 } 960 961 async inputMethodAbility_test_072() { 962 let commonEventPublishData = { 963 data: "FAILED" 964 }; 965 console.info(TAG + '====>receive inputMethodAbility_test_072 success'); 966 let count = 0; 967 await this.keyboardController.hideKeyboard(); 968 inputMethodAbility.on('keyboardShow', () => { 969 count += 1; 970 inputMethodAbility.off("keyboardShow"); 971 console.info(TAG + '====>inputMethodAbility.off("keyboardShow") count: ' + count); 972 }); 973 let t = setTimeout(() => { 974 if (count === 1) { 975 commonEventPublishData = { 976 data: "SUCCESS" 977 }; 978 } 979 commoneventmanager.publish("inputMethodAbility_test_072", commonEventPublishData, this.publishCallback); 980 clearTimeout(t); 981 }, 2000); 982 } 983 984 async inputMethodAbility_test_073() { 985 let commonEventPublishData = { 986 data: "FAILED" 987 }; 988 console.info(TAG + '====>receive inputMethodAbility_test_073 success'); 989 let count = 0; 990 inputKeyboardDelegate.on('keyDown', (keyEvent) => { 991 inputKeyboardDelegate.off('keyDown'); 992 console.info(TAG + "====>inputKeyboardDelegate.on('keyDown') count: " + count); 993 if (keyEvent.keyCode === 2000) { 994 count += 1; 995 } 996 return true; 997 }); 998 999 inputKeyboardDelegate.on('keyUp', (keyEvent) => { 1000 inputKeyboardDelegate.off('keyUp'); 1001 console.info(TAG + "====>inputKeyboardDelegate.on('keyUp') count: " + count); 1002 if (keyEvent.keyCode === 2000) { 1003 count += 1; 1004 } 1005 console.info(TAG + "====>inputKeyboardDelegate.on('keyUp') count: " + count); 1006 return true; 1007 }); 1008 let t = setTimeout(() => { 1009 if (count === 2) { 1010 commonEventPublishData = { 1011 data: "SUCCESS" 1012 }; 1013 } 1014 commoneventmanager.publish("inputMethodAbility_test_073", commonEventPublishData, this.publishCallback); 1015 clearTimeout(t); 1016 }, 500); 1017 } 1018 1019 async inputMethodAbility_test_074() { 1020 let commonEventPublishData = { 1021 data: "FAILED" 1022 }; 1023 console.info(TAG + '====>receive inputMethodAbility_test_074 success'); 1024 inputMethodAbility.on('setCallingWindow', (wid) => { 1025 console.info(TAG + "====>inputKeyboardDelegate.on('setCallingWindow')" + wid); 1026 inputMethodAbility.off('setCallingWindow', () => { 1027 console.log('inputMethodAbility off setCallingWindow'); 1028 }); 1029 if (typeof (wid) === "number") { 1030 commonEventPublishData = { 1031 data: "SUCCESS" 1032 }; 1033 } 1034 commoneventmanager.publish("inputMethodAbility_test_074", commonEventPublishData, this.publishCallback); 1035 }); 1036 } 1037 1038 async inputMethodAbility_test_101() { 1039 console.info(TAG + '====>receive inputMethodAbility_test_101 data'); 1040 let commonEventPublishData; 1041 let range = { start: 0, end: 1 }; 1042 try { 1043 this.InputClient.selectByRange(range, (err, value) => { 1044 if (err) { 1045 console.info(TAG + '====>inputMethodAbility_test_101 selectByRange err:' + JSON.stringify(err)); 1046 commonEventPublishData = { 1047 data: "FAILED" 1048 }; 1049 } else { 1050 commonEventPublishData = { 1051 data: "SUCCESS" 1052 }; 1053 } 1054 commoneventmanager.publish("inputMethodAbility_test_101", commonEventPublishData, this.publishCallback); 1055 }); 1056 } catch (err) { 1057 commonEventPublishData = { 1058 data: "FAILED" 1059 }; 1060 console.info(TAG + '====>inputMethodAbility_test_101 selectByRange throw_err:'); 1061 commoneventmanager.publish("inputMethodAbility_test_101", commonEventPublishData, this.publishCallback); 1062 } 1063 } 1064 1065 async inputMethodAbility_test_102() { 1066 console.info(TAG + '====>receive inputMethodAbility_test_102 data'); 1067 let commonEventPublishData; 1068 let range = { start: 1, end: 0 }; 1069 try { 1070 await this.InputClient.selectByRange(range); 1071 console.info(TAG + '====>inputMethodAbility_test_102 selectByRange success'); 1072 commonEventPublishData = { 1073 data: "SUCCESS" 1074 }; 1075 } catch (err) { 1076 commonEventPublishData = { 1077 data: "FAILED" 1078 }; 1079 console.info(TAG + '====>inputMethodAbility_test_102 selectByRange catch err:' + JSON.stringify(err)); 1080 } 1081 commoneventmanager.publish("inputMethodAbility_test_102", commonEventPublishData, this.publishCallback); 1082 } 1083 1084 async inputMethodAbility_test_103() { 1085 console.info(TAG + '====>receive inputMethodAbility_test_103 data'); 1086 let commonEventPublishData; 1087 try { 1088 this.InputClient.getTextIndexAtCursor((err, value) => { 1089 if (err) { 1090 console.info(TAG + '====>inputMethodAbility_test_103 getTextIndexAtCursor err:' + JSON.stringify(err)); 1091 commonEventPublishData = { 1092 data: "FAILED" 1093 }; 1094 } else { 1095 console.info(TAG + '====>inputMethodAbility_test_103 getTextIndexAtCursor success' + JSON.stringify(value)); 1096 if (typeof value === 'number') { 1097 commonEventPublishData = { 1098 data: "SUCCESS" 1099 }; 1100 } else { 1101 commonEventPublishData = { 1102 data: "FAILED" 1103 }; 1104 } 1105 } 1106 commoneventmanager.publish("inputMethodAbility_test_103", commonEventPublishData, this.publishCallback); 1107 }); 1108 } catch (err) { 1109 commonEventPublishData = { 1110 data: "FAILED" 1111 }; 1112 console.info(TAG + '====>inputMethodAbility_test_103 getTextIndexAtCursor throw_err:'); 1113 commoneventmanager.publish("inputMethodAbility_test_103", commonEventPublishData, this.publishCallback); 1114 } 1115 } 1116 1117 async inputMethodAbility_test_104() { 1118 console.info(TAG + '====>receive inputMethodAbility_test_104 data'); 1119 let commonEventPublishData; 1120 try { 1121 let value = await this.InputClient.getTextIndexAtCursor(); 1122 console.info(TAG + '====>inputMethodAbility_test_104 getTextIndexAtCursor value:' + JSON.stringify(value)); 1123 if (typeof value === 'number') { 1124 commonEventPublishData = { 1125 data: "SUCCESS" 1126 }; 1127 } else { 1128 commonEventPublishData = { 1129 data: "FAILED" 1130 }; 1131 } 1132 } catch (err) { 1133 commonEventPublishData = { 1134 data: "FAILED" 1135 }; 1136 console.info(TAG + '====>inputMethodAbility_test_104 getTextIndexAtCursor catch err:'); 1137 } 1138 commoneventmanager.publish("inputMethodAbility_test_104", commonEventPublishData, this.publishCallback); 1139 } 1140 1141 async inputMethodAbility_test_105() { 1142 console.info(TAG + '====>receive inputMethodAbility_test_105 data'); 1143 let commonEventPublishData; 1144 let movement = { direction: inputMethodEngine.CURSOR_DOWN }; 1145 try { 1146 this.InputClient.selectByMovement(movement, (err, value) => { 1147 if (err) { 1148 console.info(TAG + '====>inputMethodAbility_test_105 selectByMovement err:' + JSON.stringify(err)); 1149 commonEventPublishData = { 1150 data: "FAILED" 1151 }; 1152 } else { 1153 console.info(TAG + '====>inputMethodAbility_test_105 selectByMovement success'); 1154 commonEventPublishData = { 1155 data: "SUCCESS" 1156 }; 1157 } 1158 commoneventmanager.publish("inputMethodAbility_test_105", commonEventPublishData, this.publishCallback); 1159 }); 1160 } catch (err) { 1161 commonEventPublishData = { 1162 data: "FAILED" 1163 }; 1164 console.info(TAG + '====>inputMethodAbility_test_105 selectByMovement throw_err:'); 1165 commoneventmanager.publish("inputMethodAbility_test_105", commonEventPublishData, this.publishCallback); 1166 } 1167 } 1168 1169 async inputMethodAbility_test_106() { 1170 console.info(TAG + '====>receive inputMethodAbility_test_106 data'); 1171 let commonEventPublishData; 1172 let movement = { direction: inputMethodEngine.CURSOR_RIGHT }; 1173 try { 1174 let value = await this.InputClient.selectByMovement(movement); 1175 console.info(TAG + '====>inputMethodAbility_test_106 selectByMovement success'); 1176 commonEventPublishData = { 1177 data: "SUCCESS" 1178 }; 1179 } catch (err) { 1180 commonEventPublishData = { 1181 data: "FAILED" 1182 }; 1183 console.info(TAG + '====>inputMethodAbility_test_106 getTextIndexAtCursor catch err:'); 1184 } 1185 commoneventmanager.publish("inputMethodAbility_test_106", commonEventPublishData, this.publishCallback); 1186 } 1187 1188 async Sub_Misc_inputMethod_onSelectByRange_0110() { 1189 console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByRange_0110 success'); 1190 let range = { start: 0, end: 10 }; 1191 try { 1192 console.info(TAG + '====>Sub_Misc_inputMethod_onSelectByRange_0110 selectByRange start'); 1193 await this.InputClient.selectByRange(range); 1194 } catch (err) { 1195 console.info(TAG + '====>Sub_Misc_inputMethod_onSelectByRange_0110 selectByRange catch err:' + 1196 JSON.stringify(err)); 1197 } 1198 } 1199 1200 async Sub_Misc_inputMethod_onSelectByMovement_0120() { 1201 console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByMovement_0120 success'); 1202 let movement = { direction: inputMethodEngine.CURSOR_DOWN }; 1203 try { 1204 console.info(TAG + '====>Sub_Misc_inputMethod_onSelectByMovement_0120 onSelectByMovement start'); 1205 await this.InputClient.selectByMovement(movement); 1206 } catch (err) { 1207 console.info(TAG + '====>Sub_Misc_inputMethod_onSelectByMovement_0120 onSelectByMovement catch err:' + 1208 JSON.stringify(err)); 1209 } 1210 } 1211 1212 async Sub_Misc_inputMethod_offSelectByRange_0130() { 1213 console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByRange_0130 success'); 1214 let timeCount = 0; 1215 let range = { start: 0, end: 10 }; 1216 let t = setInterval(async () => { 1217 ; 1218 await this.InputClient.selectByRange(range); 1219 timeCount += 1; 1220 console.info(TAG + 1221 '====>Sub_Misc_inputMethod_offSelectByRange_0130 this.softKeyboardPanel.hide setInterval timeCount: ' + 1222 timeCount); 1223 if (timeCount === 2) { 1224 clearInterval(t); 1225 } 1226 }, 300); 1227 } 1228 1229 async Sub_Misc_inputMethod_offSelectByMovement_0140() { 1230 console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByMovement_0140 success'); 1231 let timeCount = 0; 1232 let movement = { direction: inputMethodEngine.CURSOR_DOWN }; 1233 let t1 = setInterval(async () => { 1234 ; 1235 await this.InputClient.selectByMovement(movement); 1236 timeCount += 1; 1237 console.info(TAG + 1238 '====>Sub_Misc_inputMethod_offSelectByMovement_0140 this.softKeyboardPanel.hide setInterval timeCount: ' + 1239 timeCount); 1240 if (timeCount === 2) { 1241 clearInterval(t1); 1242 } 1243 }, 300); 1244 } 1245 1246 async Sub_Misc_inputMethod_sendExtendAction_0170() { 1247 console.info(TAG + '====>receive Sub_Misc_inputMethod_sendExtendAction_0170 data'); 1248 let commonEventPublishData; 1249 try { 1250 this.InputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY, (err,) => { 1251 if (err) { 1252 console.info(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 sendExtendAction err:' + 1253 JSON.stringify(err)); 1254 commonEventPublishData = { 1255 data: "FAILED" 1256 }; 1257 } else { 1258 console.info(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 sendExtendAction success'); 1259 commonEventPublishData = { 1260 data: "SUCCESS" 1261 }; 1262 } 1263 commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0170", commonEventPublishData, 1264 this.publishCallback); 1265 }); 1266 } catch (err) { 1267 commonEventPublishData = { 1268 data: "FAILED" 1269 }; 1270 console.info(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 getTextIndexAtCursor throw_err:'); 1271 commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0170", commonEventPublishData, 1272 this.publishCallback); 1273 } 1274 } 1275 1276 async Sub_Misc_inputMethod_sendExtendAction_0180() { 1277 console.info(TAG + '====>receive Sub_Misc_inputMethod_sendExtendAction_0180 data'); 1278 let commonEventPublishData; 1279 try { 1280 await this.InputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY); 1281 console.info(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0180 sendExtendAction success:'); 1282 commonEventPublishData = { 1283 data: "SUCCESS" 1284 }; 1285 } catch (err) { 1286 commonEventPublishData = { 1287 data: "FAILED" 1288 }; 1289 console.info(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0180 sendExtendAction catch err:'); 1290 } 1291 commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0180", commonEventPublishData, 1292 this.publishCallback); 1293 } 1294 1295 async Sub_Misc_inputMethod_getForward_sync_0200() { 1296 console.info(TAG + '====>receive Sub_Misc_inputMethod_getForward_sync_0200 data'); 1297 let commonEventPublishData = { 1298 data: "FAILED" 1299 }; 1300 let str = this.InputClient.getForwardSync(1); 1301 console.info(TAG + '====>Sub_Misc_inputMethod_getForward_sync_0200 getForwardSync str: ' + JSON.stringify(str)); 1302 if (typeof (str) === "string") { 1303 commonEventPublishData = { 1304 data: "SUCCESS" 1305 }; 1306 } 1307 commoneventmanager.publish("Sub_Misc_inputMethod_getForward_sync_0200", commonEventPublishData, 1308 this.publishCallback); 1309 } 1310 1311 async Sub_Misc_inputMethod_getForward_sync_0201() { 1312 console.info(TAG + '====>receive Sub_Misc_inputMethod_getForward_sync_0201 data'); 1313 let commonEventPublishData = { 1314 data: "FAILED" 1315 } 1316 try { 1317 // @ts-ignore 1318 this.InputClient.getForwardSync("1"); 1319 console.info(TAG + '====>Sub_Misc_inputMethod_getForward_sync_0201 getForwardSync over'); 1320 } catch (err) { 1321 console.info(TAG + '====>Sub_Misc_inputMethod_getForward_sync_0201 getForwardSync err: ' + JSON.stringify(err)); 1322 if (err.code === 401) { 1323 commonEventPublishData = { 1324 data: "SUCCESS" 1325 }; 1326 } 1327 } 1328 commoneventmanager.publish("Sub_Misc_inputMethod_getForward_sync_0201", commonEventPublishData, 1329 this.publishCallback); 1330 } 1331 1332 async Sub_Misc_inputMethod_getBackward_sync_0210() { 1333 console.info(TAG + '====>receive Sub_Misc_inputMethod_getBackward_sync_0210 data'); 1334 let commonEventPublishData = { 1335 data: "FAILED" 1336 }; 1337 let str = this.InputClient.getBackwardSync(1); 1338 console.info(TAG + '====>Sub_Misc_inputMethod_getBackward_sync_0210 getBackwardSync str: ' + JSON.stringify(str)); 1339 if (typeof (str) === "string") { 1340 commonEventPublishData = { 1341 data: "SUCCESS" 1342 }; 1343 } 1344 commoneventmanager.publish("Sub_Misc_inputMethod_getBackward_sync_0210", commonEventPublishData, 1345 this.publishCallback); 1346 } 1347 1348 async Sub_Misc_inputMethod_getBackward_sync_0211() { 1349 console.info(TAG + '====>receive Sub_Misc_inputMethod_getBackward_sync_0211 data'); 1350 let commonEventPublishData = { 1351 data: "FAILED" 1352 }; 1353 try { 1354 // @ts-ignore 1355 this.InputClient.getBackwardSync("1"); 1356 console.info(TAG + '====>Sub_Misc_inputMethod_getBackward_sync_0211 getBackwardSync over'); 1357 } catch (err) { 1358 console.info(TAG + '====>Sub_Misc_inputMethod_getBackward_sync_0211 getBackwardSync err: ' + JSON.stringify(err)); 1359 if (err.code === 401) { 1360 commonEventPublishData = { 1361 data: "SUCCESS" 1362 }; 1363 } 1364 } 1365 commoneventmanager.publish("Sub_Misc_inputMethod_getBackward_sync_0211", commonEventPublishData, 1366 this.publishCallback); 1367 } 1368 1369 async Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220() { 1370 console.info(TAG + '====>receive Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220 data'); 1371 let commonEventPublishData = { 1372 data: "FAILED" 1373 }; 1374 let num = this.InputClient.getTextIndexAtCursorSync(); 1375 console.info(TAG + '====>Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220 getTextIndexAtCursorSync num: ' + 1376 JSON.stringify(num)); 1377 if (typeof (num) === "number") { 1378 commonEventPublishData = { 1379 data: "SUCCESS" 1380 }; 1381 } 1382 commoneventmanager.publish("Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220", commonEventPublishData, 1383 this.publishCallback); 1384 } 1385 1386 async Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221() { 1387 console.info(TAG + '====>receive Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221 data'); 1388 let commonEventPublishData = { 1389 data: "FAILED" 1390 }; 1391 try { 1392 // @ts-ignore 1393 this.InputClient.getTextIndexAtCursorSync("1"); 1394 console.info(TAG + '====>Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221 getTextIndexAtCursorSync success'); 1395 commonEventPublishData = { 1396 data: "SUCCESS" 1397 }; 1398 } catch (err) { 1399 console.info(TAG + '====>Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221 getTextIndexAtCursorSync err: ' + 1400 JSON.stringify(err)); 1401 } 1402 commoneventmanager.publish("Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221", commonEventPublishData, 1403 this.publishCallback); 1404 } 1405 1406 async Sub_Misc_inputMethod_getEditorAttribute_sync_0230() { 1407 console.info(TAG + '====>receive Sub_Misc_inputMethod_getEditorAttribute_sync_0230 data'); 1408 let commonEventPublishData = { 1409 data: "FAILED" 1410 }; 1411 let obj = this.InputClient.getEditorAttributeSync(); 1412 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0230 getEditorAttributeSync enterKeyType: ' + 1413 JSON.stringify(obj.enterKeyType)); 1414 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0230 getEditorAttributeSync inputPattern: ' + 1415 JSON.stringify(obj.inputPattern)); 1416 console.info(TAG + 1417 '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0230 getEditorAttributeSync isTextPreviewSupported: ' + 1418 JSON.stringify(obj.isTextPreviewSupported)); 1419 if (typeof (obj.enterKeyType) === 'number' && typeof (obj.inputPattern) === 'number' && 1420 typeof (obj.isTextPreviewSupported) === 'boolean') { 1421 commonEventPublishData = { 1422 data: "SUCCESS" 1423 }; 1424 } 1425 commoneventmanager.publish("Sub_Misc_inputMethod_getEditorAttribute_sync_0230", commonEventPublishData, 1426 this.publishCallback); 1427 } 1428 1429 async Sub_Misc_inputMethod_getEditorAttribute_sync_0231() { 1430 console.info(TAG + '====>receive Sub_Misc_inputMethod_getEditorAttribute_sync_0231 data'); 1431 let commonEventPublishData = { 1432 data: "FAILED" 1433 }; 1434 try { 1435 // @ts-ignore 1436 this.InputClient.getEditorAttributeSync(true); 1437 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0231 getEditorAttributeSync success'); 1438 commonEventPublishData = { 1439 data: "SUCCESS" 1440 }; 1441 } catch (err) { 1442 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0231 getEditorAttributeSync err: ' + 1443 JSON.stringify(err)); 1444 } 1445 commoneventmanager.publish("Sub_Misc_inputMethod_getEditorAttribute_sync_0231", commonEventPublishData, 1446 this.publishCallback); 1447 } 1448 1449 async Sub_Misc_inputMethod_getEditorAttribute_sync_0233() { 1450 console.info(TAG + '====>receive Sub_Misc_inputMethod_getEditorAttribute_sync_0233 data'); 1451 let commonEventPublishData = { 1452 data: "FAILED" 1453 }; 1454 let attribute = this.InputClient.getEditorAttributeSync(); 1455 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0233 getEditorAttributeSync: ' + 1456 JSON.stringify(attribute)); 1457 if (attribute.bundleName === 'com.acts.inputmethodengine.test') { 1458 commonEventPublishData = { 1459 data: "SUCCESS" 1460 }; 1461 } 1462 commoneventmanager.publish("Sub_Misc_inputMethod_getEditorAttribute_sync_0233", commonEventPublishData, 1463 this.publishCallback); 1464 } 1465 1466 async Sub_Misc_inputMethod_moveCursor_sync_0240() { 1467 console.info(TAG + '====>receive Sub_Misc_inputMethod_moveCursor_sync_0240 data'); 1468 let commonEventPublishData = { 1469 data: "FAILED" 1470 }; 1471 try { 1472 this.InputClient.moveCursorSync(inputMethodEngine.CURSOR_UP); 1473 console.info(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0240 moveCursorSync success'); 1474 commonEventPublishData = { 1475 data: "SUCCESS" 1476 }; 1477 } catch (err) { 1478 console.info(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0240 moveCursorSync err: ' + JSON.stringify(err)); 1479 } 1480 commoneventmanager.publish("Sub_Misc_inputMethod_moveCursor_sync_0240", commonEventPublishData, 1481 this.publishCallback); 1482 } 1483 1484 async Sub_Misc_inputMethod_moveCursor_sync_0241() { 1485 console.info(TAG + '====>receive Sub_Misc_inputMethod_moveCursor_sync_0241 data'); 1486 let commonEventPublishData = { 1487 data: "FAILED" 1488 }; 1489 try { 1490 // @ts-ignore 1491 this.InputClient.moveCursorSync(true); 1492 console.info(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0241 moveCursorSync over'); 1493 } catch (err) { 1494 console.info(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0241 moveCursorSync err: ' + JSON.stringify(err)); 1495 if (err.code === 401) { 1496 commonEventPublishData = { 1497 data: "SUCCESS" 1498 }; 1499 } 1500 } 1501 commoneventmanager.publish("Sub_Misc_inputMethod_moveCursor_sync_0241", commonEventPublishData, 1502 this.publishCallback); 1503 } 1504 1505 async Sub_Misc_inputMethod_deleteForward_sync_0250() { 1506 console.info(TAG + '====>receive Sub_Misc_inputMethod_deleteForward_sync_0250 data'); 1507 let commonEventPublishData = { 1508 data: "FAILED" 1509 }; 1510 try { 1511 this.InputClient.deleteForwardSync(1); 1512 console.info(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0250 deleteForwardSync success'); 1513 commonEventPublishData = { 1514 data: "SUCCESS" 1515 }; 1516 } catch (err) { 1517 console.info(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0250 deleteForwardSync err: ' + 1518 JSON.stringify(err)); 1519 } 1520 commoneventmanager.publish("Sub_Misc_inputMethod_deleteForward_sync_0250", commonEventPublishData, 1521 this.publishCallback); 1522 } 1523 1524 async Sub_Misc_inputMethod_deleteForward_sync_0251() { 1525 console.info(TAG + '====>receive Sub_Misc_inputMethod_deleteForward_sync_0251 data'); 1526 let commonEventPublishData = { 1527 data: "FAILED" 1528 }; 1529 try { 1530 // @ts-ignore 1531 this.InputClient.deleteForwardSync(false); 1532 console.info(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0251 deleteForwardSync over'); 1533 } catch (err) { 1534 console.info(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0251 deleteForwardSync err: ' + 1535 JSON.stringify(err)); 1536 if (err.code === 401) { 1537 commonEventPublishData = { 1538 data: "SUCCESS" 1539 }; 1540 } 1541 } 1542 commoneventmanager.publish("Sub_Misc_inputMethod_deleteForward_sync_0251", commonEventPublishData, 1543 this.publishCallback); 1544 } 1545 1546 async Sub_Misc_inputMethod_deleteBackward_sync_0260() { 1547 console.info(TAG + '====>receive Sub_Misc_inputMethod_deleteBackward_sync_0260 data'); 1548 let commonEventPublishData = { 1549 data: "FAILED" 1550 }; 1551 try { 1552 this.InputClient.deleteBackwardSync(1); 1553 console.info(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0260 deleteBackwardSync success'); 1554 commonEventPublishData = { 1555 data: "SUCCESS" 1556 }; 1557 } catch (err) { 1558 console.info(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0260 deleteBackwardSync err: ' + 1559 JSON.stringify(err)); 1560 } 1561 commoneventmanager.publish("Sub_Misc_inputMethod_deleteBackward_sync_0260", commonEventPublishData, 1562 this.publishCallback); 1563 } 1564 1565 async Sub_Misc_inputMethod_deleteBackward_sync_0261() { 1566 console.info(TAG + '====>receive Sub_Misc_inputMethod_deleteBackward_sync_0261 data'); 1567 let commonEventPublishData = { 1568 data: "FAILED" 1569 }; 1570 try { 1571 // @ts-ignore 1572 this.InputClient.deleteBackwardSync(false); 1573 console.info(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0261 deleteBackwardSync over'); 1574 } catch (err) { 1575 console.info(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0261 deleteBackwardSync err: ' + 1576 JSON.stringify(err)); 1577 if (err.code === 401) { 1578 commonEventPublishData = { 1579 data: "SUCCESS" 1580 }; 1581 } 1582 } 1583 commoneventmanager.publish("Sub_Misc_inputMethod_deleteBackward_sync_0261", commonEventPublishData, 1584 this.publishCallback); 1585 } 1586 1587 async Sub_Misc_inputMethod_insertText_sync_0270() { 1588 console.info(TAG + '====>receive Sub_Misc_inputMethod_insertText_sync_0270 data'); 1589 let commonEventPublishData = { 1590 data: "FAILED" 1591 }; 1592 this.InputClient.insertTextSync('test'); 1593 console.info(TAG + '====>Sub_Misc_inputMethod_insertText_sync_0270 insertTextSync'); 1594 commonEventPublishData = { 1595 data: "SUCCESS" 1596 }; 1597 commoneventmanager.publish("Sub_Misc_inputMethod_insertText_sync_0270", commonEventPublishData, 1598 this.publishCallback); 1599 } 1600 1601 async Sub_Misc_inputMethod_insertText_sync_0271() { 1602 console.info(TAG + '====>receive Sub_Misc_inputMethod_insertText_sync_0271 data'); 1603 let commonEventPublishData = { 1604 data: "FAILED" 1605 }; 1606 try { 1607 // @ts-ignore 1608 this.InputClient.insertTextSync(123); 1609 console.info(TAG + '====>Sub_Misc_inputMethod_insertText_sync_0271 insertTextSync over'); 1610 } catch (err) { 1611 console.info(TAG + '====>Sub_Misc_inputMethod_insertText_sync_0271 insertTextSync err: ' + JSON.stringify(err)); 1612 if (err.code === 401) { 1613 commonEventPublishData = { 1614 data: "SUCCESS" 1615 }; 1616 } 1617 } 1618 commoneventmanager.publish("Sub_Misc_inputMethod_insertText_sync_0271", commonEventPublishData, 1619 this.publishCallback); 1620 } 1621 1622 async Sub_Misc_inputMethod_selectByRange_sync_0280() { 1623 console.info(TAG + '====>receive Sub_Misc_inputMethod_selectByRange_sync_0280 data'); 1624 let range = { start: 0, end: 1 }; 1625 let commonEventPublishData = { 1626 data: "FAILED" 1627 }; 1628 try { 1629 this.InputClient.selectByRangeSync(range); 1630 console.info(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0280 selectByRangeSync success'); 1631 commonEventPublishData = { 1632 data: "SUCCESS" 1633 }; 1634 } catch (err) { 1635 console.info(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0280 selectByRangeSync err: ' + 1636 JSON.stringify(err)); 1637 } 1638 commoneventmanager.publish("Sub_Misc_inputMethod_selectByRange_sync_0280", commonEventPublishData, 1639 this.publishCallback); 1640 } 1641 1642 async Sub_Misc_inputMethod_selectByRange_sync_0281() { 1643 console.info(TAG + '====>receive Sub_Misc_inputMethod_selectByRange_sync_0281 data'); 1644 let commonEventPublishData = { 1645 data: "FAILED" 1646 }; 1647 try { 1648 // @ts-ignore 1649 this.InputClient.selectByRangeSync(true); 1650 console.info(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0281 selectByRangeSync over'); 1651 } catch (err) { 1652 console.info(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0281 selectByRangeSync err: ' + 1653 JSON.stringify(err)); 1654 if (err.code === 401) { 1655 commonEventPublishData = { 1656 data: "SUCCESS" 1657 }; 1658 } 1659 } 1660 commoneventmanager.publish("Sub_Misc_inputMethod_selectByRange_sync_0281", commonEventPublishData, 1661 this.publishCallback); 1662 } 1663 1664 async Sub_Misc_inputMethod_selectByMovement_sync_0290() { 1665 console.info(TAG + '====>receive Sub_Misc_inputMethod_selectByMovement_sync_0290 data'); 1666 let movement = { direction: inputMethodEngine.CURSOR_DOWN }; 1667 let commonEventPublishData = { 1668 data: "FAILED" 1669 }; 1670 try { 1671 this.InputClient.selectByMovementSync(movement); 1672 console.info(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0290 selectByMovementSync success'); 1673 commonEventPublishData = { 1674 data: "SUCCESS" 1675 }; 1676 } catch (err) { 1677 console.info(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0290 selectByMovementSync err: ' + 1678 JSON.stringify(err)); 1679 } 1680 commoneventmanager.publish("Sub_Misc_inputMethod_selectByMovement_sync_0290", commonEventPublishData, 1681 this.publishCallback); 1682 } 1683 1684 async Sub_Misc_inputMethod_selectByMovement_sync_0291() { 1685 console.info(TAG + '====>receive Sub_Misc_inputMethod_selectByMovement_sync_0291 data'); 1686 let commonEventPublishData = { 1687 data: "FAILED" 1688 }; 1689 try { 1690 // @ts-ignore 1691 this.InputClient.selectByMovementSync(true); 1692 console.info(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0291 selectByMovementSync over'); 1693 } catch (err) { 1694 console.info(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0291 selectByMovementSync err: ' + 1695 JSON.stringify(err)); 1696 if (err.code === 401) { 1697 commonEventPublishData = { 1698 data: "SUCCESS" 1699 }; 1700 } 1701 } 1702 commoneventmanager.publish("Sub_Misc_inputMethod_selectByMovement_sync_0291", commonEventPublishData, 1703 this.publishCallback); 1704 } 1705 1706 async Sub_Misc_Request_InputMethod_selectContext_0400() { 1707 console.info(TAG + '====>receive Sub_Misc_Request_InputMethod_selectContext_0400 data'); 1708 let commonEventPublishData; 1709 let range = { start: 99, end: 88 }; 1710 try { 1711 this.InputClient.selectByRange(range, (err) => { 1712 if (err) { 1713 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0400 selectByRange err:' + 1714 JSON.stringify(err)); 1715 commonEventPublishData = { 1716 data: "FAILED" 1717 }; 1718 } else { 1719 commonEventPublishData = { 1720 data: "SUCCESS" 1721 }; 1722 } 1723 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0400 selectByRange success'); 1724 commoneventmanager.publish('Sub_Misc_Request_InputMethod_selectContext_0400', commonEventPublishData, 1725 this.publishCallback); 1726 }); 1727 } catch (err) { 1728 commonEventPublishData = { 1729 data: "FAILED" 1730 }; 1731 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0400 selectByRange throw_err:'); 1732 commoneventmanager.publish('Sub_Misc_Request_InputMethod_selectContext_0400', commonEventPublishData, 1733 this.publishCallback); 1734 } 1735 } 1736 1737 async Sub_Misc_Request_InputMethod_selectContext_0500() { 1738 console.info(TAG + '====>receive Sub_Misc_Request_InputMethod_selectContext_0500 data'); 1739 let commonEventPublishData; 1740 let range = { start: 168, end: -66 }; 1741 try { 1742 this.InputClient.selectByRange(range, (err) => { 1743 if (err) { 1744 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0500 selectByRange err:' + 1745 JSON.stringify(err)); 1746 commonEventPublishData = { 1747 data: "SUCCESS" 1748 }; 1749 } else { 1750 commonEventPublishData = { 1751 data: "FAILED" 1752 }; 1753 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0500 selectByRange success'); 1754 } 1755 commoneventmanager.publish('Sub_Misc_Request_InputMethod_selectContext_0500', commonEventPublishData, 1756 this.publishCallback); 1757 }); 1758 } catch (err) { 1759 commonEventPublishData = { 1760 data: "FAILED" 1761 }; 1762 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0500 selectByRange throw_err:'); 1763 commoneventmanager.publish('Sub_Misc_Request_InputMethod_selectContext_0500', commonEventPublishData, 1764 this.publishCallback); 1765 } 1766 } 1767 1768 async Sub_Misc_Request_InputMethod_selectContext_0600() { 1769 console.info(TAG + '====>receive Sub_Misc_Request_InputMethod_selectContext_0600 data'); 1770 let commonEventPublishData; 1771 let range = { start: 100, end: 2000 }; 1772 try { 1773 this.InputClient.selectByRange(range, (err) => { 1774 if (err) { 1775 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0600 selectByRange err:' + 1776 JSON.stringify(err)); 1777 commonEventPublishData = { 1778 data: "FAILED" 1779 }; 1780 } else { 1781 commonEventPublishData = { 1782 data: "SUCCESS" 1783 }; 1784 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0600 selectByRange success'); 1785 } 1786 commoneventmanager.publish('Sub_Misc_Request_InputMethod_selectContext_0600', commonEventPublishData, 1787 this.publishCallback); 1788 }); 1789 } catch (err) { 1790 commonEventPublishData = { 1791 data: "FAILED" 1792 }; 1793 console.info(TAG + '====>Sub_Misc_Request_InputMethod_selectContext_0600 selectByRange throw_err:'); 1794 commoneventmanager.publish('Sub_Misc_Request_InputMethod_selectContext_0600', commonEventPublishData, 1795 this.publishCallback); 1796 } 1797 } 1798 1799 async SUB_InputMethod_IsTextPreviewSupport_0100() { 1800 console.info(TAG + '====>receive SUB_InputMethod_IsTextPreviewSupport_0100 data'); 1801 let commonEventPublishData = { 1802 data: "FAILED" 1803 }; 1804 try { 1805 let range: inputMethodEngine.Range = { start: 'bbb', end: 'ccc' } 1806 await this.InputClient.setPreviewText('adc|03', range); 1807 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0100 setPreviewText success:'); 1808 commonEventPublishData = { 1809 data: "FAILED" 1810 1811 }; 1812 } catch (err) { 1813 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0100 setPreviewText catch err: ' + 1814 JSON.stringify(err)); 1815 if (err.code === 401) { 1816 commonEventPublishData = { 1817 data: "SUCCESS" 1818 }; 1819 } 1820 } 1821 commoneventmanager.publish("SUB_InputMethod_IsTextPreviewSupport_0100", commonEventPublishData, 1822 this.publishCallback); 1823 } 1824 1825 async SUB_InputMethod_IsTextPreviewSupport_0200() { 1826 console.info(TAG + '====>receive SUB_InputMethod_IsTextPreviewSupport_0200 data'); 1827 let commonEventPublishData = { 1828 data: "FAILED" 1829 }; 1830 let range: inputMethodEngine.Range = { start: 'aa', end: 'aa' } 1831 try { 1832 this.InputClient.setPreviewTextSync('adc|03', range); 1833 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0100 setPreviewText success:'); 1834 commonEventPublishData = { 1835 data: "FAILED" 1836 1837 }; 1838 } catch (err) { 1839 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0200 setPreviewTextSync catch err:' + 1840 JSON.stringify(err)); 1841 if (err.code === 401) { 1842 commonEventPublishData = { 1843 data: "SUCCESS" 1844 }; 1845 } 1846 commoneventmanager.publish('SUB_InputMethod_IsTextPreviewSupport_0200', commonEventPublishData, 1847 this.publishCallback); 1848 } 1849 } 1850 1851 async SUB_InputMethod_IsTextPreviewSupport_0300() { 1852 console.info(TAG + '====>receive SUB_InputMethod_IsTextPreviewSupport_0300 data'); 1853 let commonEventPublishData = { 1854 data: "FAILED" 1855 }; 1856 try { 1857 await this.InputClient.finishTextPreview(); 1858 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0300 finishTextPreview success'); 1859 commonEventPublishData = { 1860 data: "SUCCESS" 1861 } 1862 } catch (err) { 1863 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0300 finishTextPreview catch err:' + 1864 JSON.stringify(err)); 1865 } 1866 commoneventmanager.publish("SUB_InputMethod_IsTextPreviewSupport_0300", commonEventPublishData, 1867 this.publishCallback); 1868 } 1869 1870 async SUB_InputMethod_IsTextPreviewSupport_0400() { 1871 console.info(TAG + '====>receive SUB_InputMethod_IsTextPreviewSupport_0400 data'); 1872 let commonEventPublishData = { 1873 data: "FAILED" 1874 }; 1875 try { 1876 this.InputClient.finishTextPreviewSync(); 1877 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0400 finishTextPreviewSync success'); 1878 commonEventPublishData = { 1879 data: "SUCCESS" 1880 } 1881 1882 } catch (err) { 1883 console.info(TAG + '====>SUB_InputMethod_IsTextPreviewSupport_0400 finishTextPreviewSync catch err:' + 1884 JSON.stringify(err)); 1885 } 1886 commoneventmanager.publish('SUB_InputMethod_IsTextPreviewSupport_0400', commonEventPublishData, 1887 this.publishCallback); 1888 } 1889 1890 async SUB_InputMethod_IME_PrivateDateTransferred_0500() { 1891 console.info(TAG + '====>receive SUB_InputMethod_IME_PrivateDateTransferred_0500 data'); 1892 let commonEventPublishData = { 1893 data: "FAILED" 1894 }; 1895 let record: Record<string, inputMethodEngine.CommandDataType> = { 1896 "valueString1": "abcdefg", 1897 "valueString2": true, 1898 "valueString3": 500, 1899 "valueString1": "abcdefgg", 1900 "valueString2": true, 1901 } 1902 try { 1903 await this.InputClient.sendPrivateCommand(record); 1904 console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_0500 setPreviewText success:'); 1905 commonEventPublishData = { 1906 data: "FAILED" 1907 1908 }; 1909 } catch (err) { 1910 console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_0500 setPreviewTextSync catch err:' + 1911 JSON.stringify(err)); 1912 if (err.code === 12800010) { 1913 commonEventPublishData = { 1914 data: "SUCCESS" 1915 }; 1916 } 1917 commoneventmanager.publish('SUB_InputMethod_IME_PrivateDateTransferred_0500', commonEventPublishData, 1918 this.publishCallback); 1919 } 1920 } 1921 1922 async SUB_InputMethod_IME_PrivateDateTransferred_0600() { 1923 console.info(TAG + '====>receive SUB_InputMethod_IME_PrivateDateTransferred_0600 data'); 1924 let commonEventPublishData = { 1925 data: "FAILED" 1926 }; 1927 try { 1928 inputMethodAbility.on('privateCommand', async (record: Record<string, inputMethodEngine.CommandDataType>) => { 1929 console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_0600 on privateCommand into'); 1930 inputMethodAbility.off('privateCommand'); 1931 }) 1932 console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_0600 privateCommand on success'); 1933 } catch (err) { 1934 if (err.code === 12800010) { 1935 commonEventPublishData = { 1936 data: "SUCCESS" 1937 }; 1938 } 1939 console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_0600 on(privateCommand) err: ' + 1940 JSON.stringify(err)); 1941 } 1942 commoneventmanager.publish("SUB_InputMethod_IME_PrivateDateTransferred_0600", commonEventPublishData, 1943 this.publishCallback); 1944 } 1945 1946 async SUB_InputMethod_IME_PrivateDateTransferred_1100() { 1947 console.info(TAG + '====>receive SUB_InputMethod_IME_PrivateDateTransferred_1100 data'); 1948 let commonEventPublishData = { 1949 data: "FAILED" 1950 }; 1951 let want: Want = { 1952 bundleName: 'aaa', 1953 abilityName: 'aaa', 1954 } 1955 try { 1956 await this.mContext.startAbility(want); 1957 console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_1100 startAbility success'); 1958 } catch (err) { 1959 console.info(TAG + '====>SUB_InputMethod_IME_PrivateDateTransferred_1100 err: ' + JSON.stringify(err)); 1960 if (err.code === 16000001) { 1961 commonEventPublishData = { 1962 data: "SUCCESS" 1963 }; 1964 } 1965 } 1966 commoneventmanager.publish("SUB_InputMethod_IME_PrivateDateTransferred_1100", commonEventPublishData, 1967 this.publishCallback); 1968 } 1969}