diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts index 9d029f26f0ba0a3c2583de24a910ef0fb79819bb..14d4f356d55496bd8f08af3046b32f2bd63fd14f 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/InputStageService.ts @@ -25,6 +25,5 @@ export default class InputDemoService extends InputMethodExtensionAbility { onDestroy() { console.log("onDestroy inputStageService**"); - this.context.destroy(); } } \ No newline at end of file diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts index ea466e4be5e42c48d3ea7bdf91dbbd19357ac6d8..1a421a95cd149350206800d8bb4a07215d1f74d8 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodAbility/KeyboardDelegate.ts @@ -38,6 +38,16 @@ export class KeyboardDelegate { public onCreate(): void { this.initWindow(); let that = this; + inputMethodAbility.on("inputStop", () => { + try{ + that.mContext.destroy((err) => { + console.info(TAG + '====>inputMethodAbility destroy err:' + JSON.stringify(err)); + }) + }catch(err){ + console.info(TAG + '====>inputMethodAbility destroy catch err:' + JSON.stringify(err)); + console.info(TAG + '====>inputMethodAbility destroy catch err:' + err); + } + }) function subscriberCallback(err, data) { console.debug(TAG + '====>receive event err:' + JSON.stringify(err)); diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/InputDemoService.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/InputDemoService.ts index b309c8521245d41d0fcaf0e03429b3c7b8cab436..c88bfb09d56038f578380fd65ba79d9385676d08 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/InputDemoService.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/InputDemoService.ts @@ -25,6 +25,5 @@ export default class InputDemoService extends InputMethodExtensionAbility { onDestroy() { console.log("onDestroy inputMethodEngine**"); - this.context.destroy(); } } \ No newline at end of file diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts index 2529cf2ca4adc950abc6d8f52e023060097371a4..ee3b5fe1077719ba0232a8b56bea4d511ebb1a26 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/InputMethodEngine/KeyboardController.ts @@ -21,6 +21,7 @@ import commoneventmanager from '@ohos.commonEventManager'; let inputMethodEngine = inputmethodengine.getInputMethodEngine(); let inputKeyboardDelegate = inputmethodengine.createKeyboardDelegate(); +let inputMethodAbility = inputmethodengine.getInputMethodAbility(); const TAG = "keyboardController"; export class KeyboardController { @@ -38,6 +39,15 @@ export class KeyboardController { public onCreate(): void { this.initWindow(); let that = this; + inputMethodAbility.on("inputStop", () => { + try{ + that.mContext.destroy((err) => { + console.info(TAG + '====>inputMethodEngine destroy err:' + JSON.stringify(err)); + }) + }catch(err){ + console.info(TAG + '====>inputMethodEngine destroy catch err:' + JSON.stringify(err)); + } + }) function subscriberCallback(err, data) { console.debug(TAG + '====>receive event err: ' + JSON.stringify(err)); diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/test/List.test.ets b/inputmethod/InputMethodEngine/entry/src/main/ets/test/List.test.ets index 3b1e0268fd24288686623f99503832c8721b2e5a..974ce5b62dd6de453ce0c29ea22ca24d32e99947 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/test/List.test.ets +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/test/List.test.ets @@ -17,5 +17,5 @@ import inputMethodAbility from './inputMethodAbility.test' export default function testsuite() { inputMethodEngine(); - inputMethodAbility() + inputMethodAbility(); } \ No newline at end of file diff --git a/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets b/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets index 9215ff7ade570dc7b5289ad2b9ea70e6c814c410..74a427771b2f03b03a9f842e426f5ea9786d72f9 100644 --- a/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets +++ b/inputmethod/InputMethodEngine/entry/src/main/ets/test/inputMethodAbility.test.ets @@ -69,6 +69,19 @@ export default function inputMethodAbility() { } }) + afterAll(async (done) => { + try { + await inputMethod.switchInputMethod(inputServer); + console.info("====>afterAll: inputMethodStageJSUnit switchInputMethod success" + JSON.stringify(inputServer)); + setTimeout(() => { + console.info("====>afterAll: inputMethodStageJSUnit switchInputMethod success"); + done(); + }, 2000) + } catch (err) { + console.info("====>afterAll: inputMethodStageJSUnit fail" + JSON.stringify(err)); + } + }) + it('inputMethodEngine_test_001', 0, async function (done) { let keyType = inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED; console.info("====>inputMethodEngine_test_001 result:" + keyType);