1e41f4b71Sopenharmony_ci# Input Method Framework ChangeLog 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## cl.inputmethod_frameworks.1 API Error Information Return Method Change 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ciThe internal APIs of the following modules used service logic return values to indicate error information, which did not comply with the error code specifications of OpenHarmony. Therefore, they are modified in API version 9 and later. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci - Input method framework module: system API, @ohos.inputmethod.d.ts 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci - Input method service module: system API, @ohos.inputmethodengine.d.ts 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci - Input method ExtentionAbility module: system API, @ohos.inputmethodextensionability.d.ts 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci - Input method ExtentionContext module: system API, @ohos.inputmethodextensioncontext.d.ts 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci - Input method subtype module: system API, @ohos.inputMethodSubtype.d.ts 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ciAsynchronous API: An error message is returned via **AsyncCallback** or the **error** object of **Promise**. 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciSynchronous API: An error message is returned via an exception. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**Change Impacts** 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciThe application developed based on earlier versions needs to adapt the method for returning API error information. Otherwise, the original service logic will be affected. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**Key API/Component Changes** 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ciError code processing is added for the following APIs: 28e41f4b71Sopenharmony_ci - getSetting(): InputMethodSetting; 29e41f4b71Sopenharmony_ci - getController(): InputMethodController; 30e41f4b71Sopenharmony_ci - switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolean>): void; 31e41f4b71Sopenharmony_ci - switchInputMethod(target: InputMethodProperty): Promise<boolean>; 32e41f4b71Sopenharmony_ci - switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback<boolean>): void; 33e41f4b71Sopenharmony_ci - switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean>; 34e41f4b71Sopenharmony_ci - switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype, callback: AsyncCallback<boolean>): void; 35e41f4b71Sopenharmony_ci - switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype): Promise<boolean>; 36e41f4b71Sopenharmony_ci - listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback<Array<InputMethodSubtype>>): void; 37e41f4b71Sopenharmony_ci - listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Array<InputMethodSubtype>>; 38e41f4b71Sopenharmony_ci - listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSubtype>>): void; 39e41f4b71Sopenharmony_ci - listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>>; 40e41f4b71Sopenharmony_ci - getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethodProperty>>): void; 41e41f4b71Sopenharmony_ci - getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>; 42e41f4b71Sopenharmony_ci - showOptionalInputMethods(callback: AsyncCallback<boolean>): void; 43e41f4b71Sopenharmony_ci - showOptionalInputMethods(): Promise<boolean>; 44e41f4b71Sopenharmony_ci - stopInputSession(callback: AsyncCallback<boolean>): void; 45e41f4b71Sopenharmony_ci - stopInputSession(): Promise<boolean>; 46e41f4b71Sopenharmony_ci - showSoftKeyboard(callback: AsyncCallback<void>): void; 47e41f4b71Sopenharmony_ci - showSoftKeyboard():Promise<void>; 48e41f4b71Sopenharmony_ci - hideSoftKeyboard(callback: AsyncCallback<void>): void; 49e41f4b71Sopenharmony_ci - hideSoftKeyboard():Promise<void>; 50e41f4b71Sopenharmony_ci - hide(callback: AsyncCallback<void>): void; 51e41f4b71Sopenharmony_ci - hide(): Promise<void>; 52e41f4b71Sopenharmony_ci - onCreate(want: Want): void; 53e41f4b71Sopenharmony_ci - onDestroy(): void; 54e41f4b71Sopenharmony_ci In **InputClient**: 55e41f4b71Sopenharmony_ci - sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void; 56e41f4b71Sopenharmony_ci - sendKeyFunction(action: number): Promise<boolean>; 57e41f4b71Sopenharmony_ci - deleteForward(length: number, callback: AsyncCallback<boolean>): void; 58e41f4b71Sopenharmony_ci - deleteForward(length: number): Promise<boolean>; 59e41f4b71Sopenharmony_ci - deleteBackward(length: number, callback: AsyncCallback<boolean>): void; 60e41f4b71Sopenharmony_ci - deleteBackward(length: number): Promise<boolean>; 61e41f4b71Sopenharmony_ci - insertText(text: string, callback: AsyncCallback<boolean>): void; 62e41f4b71Sopenharmony_ci - insertText(text: string): Promise<boolean>; 63e41f4b71Sopenharmony_ci - getForward(length: number, callback: AsyncCallback<string>): void; 64e41f4b71Sopenharmony_ci - getForward(length: number): Promise<string>; 65e41f4b71Sopenharmony_ci - getBackward(length: number, callback: AsyncCallback<string>): void; 66e41f4b71Sopenharmony_ci - getBackward(length: number): Promise<string>; 67e41f4b71Sopenharmony_ci - getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void; 68e41f4b71Sopenharmony_ci - getEditorAttribute(): Promise<EditorAttribute>; 69e41f4b71Sopenharmony_ci - moveCursor(direction: number, callback: AsyncCallback<void>): void; 70e41f4b71Sopenharmony_ci - moveCursor(direction: number): Promise<void>; 71e41f4b71Sopenharmony_ci In **InputMethodExtensionAbility**: 72e41f4b71Sopenharmony_ci - onCreate(want: Want): void; 73e41f4b71Sopenharmony_ci - onDestroy(): void; 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci**Adaptation Guide** 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ciThe following uses **showOptionalInputMethods** as an example for asynchronous APIs: 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ciCallback mode: 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci```js 82e41f4b71Sopenharmony_ciimport inputMethod from '@ohos.inputmethod'; 83e41f4b71Sopenharmony_cilet inputMethodSetting = inputMethod.getSetting(); 84e41f4b71Sopenharmony_citry { 85e41f4b71Sopenharmony_ci inputMethodSetting.showOptionalInputMethods((err, data) => { 86e41f4b71Sopenharmony_ci if (err !== undefined) { 87e41f4b71Sopenharmony_ci console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err)); 88e41f4b71Sopenharmony_ci return; 89e41f4b71Sopenharmony_ci } 90e41f4b71Sopenharmony_ci console.info('Succeeded in showing optionalInputMethods.'); 91e41f4b71Sopenharmony_ci }); 92e41f4b71Sopenharmony_ci} catch (err) { 93e41f4b71Sopenharmony_ci console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err)); 94e41f4b71Sopenharmony_ci} 95e41f4b71Sopenharmony_ci``` 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ciPromise mode: 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci```js 100e41f4b71Sopenharmony_ciimport inputMethod from '@ohos.inputmethod'; 101e41f4b71Sopenharmony_cilet inputMethodSetting = inputMethod.getSetting(); 102e41f4b71Sopenharmony_ciinputMethodSetting.showOptionalInputMethods().then((data) => { 103e41f4b71Sopenharmony_ci console.info('Succeeded in showing optionalInputMethods.'); 104e41f4b71Sopenharmony_ci}).catch((err) => { 105e41f4b71Sopenharmony_ci console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err)); 106e41f4b71Sopenharmony_ci}) 107e41f4b71Sopenharmony_ci``` 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci## cl.inputmethod_frameworks.2 Deprecation of Some APIs 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ciDeprecated APIs: 112e41f4b71Sopenharmony_ci - getInputMethodSetting(): InputMethodSetting; 113e41f4b71Sopenharmony_ci - getInputMethodController(): InputMethodController; 114e41f4b71Sopenharmony_ci - listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>): void; 115e41f4b71Sopenharmony_ci - listInputMethod(): Promise<Array<InputMethodProperty>>; 116e41f4b71Sopenharmony_ci - displayOptionalInputMethod(callback: AsyncCallback<void>): void; 117e41f4b71Sopenharmony_ci - displayOptionalInputMethod(): Promise<void>; 118e41f4b71Sopenharmony_ci - stopInput(callback: AsyncCallback<boolean>): void; 119e41f4b71Sopenharmony_ci - stopInput(): Promise<boolean>; 120e41f4b71Sopenharmony_ci interface InputMethodProperty: 121e41f4b71Sopenharmony_ci - readonly packageName: string; 122e41f4b71Sopenharmony_ci - readonly methodId: string; 123e41f4b71Sopenharmony_ci - getInputMethodEngine(): InputMethodEngine; 124e41f4b71Sopenharmony_ci - createKeyboardDelegate(): KeyboardDelegate; 125e41f4b71Sopenharmony_ci - hideKeyboard(callback: AsyncCallback<void>): void; 126e41f4b71Sopenharmony_ci - hideKeyboard(): Promise<void>; 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ciSubstitute APIs: 129e41f4b71Sopenharmony_ci - getSetting(): InputMethodSetting; 130e41f4b71Sopenharmony_ci - getController(): InputMethodController; 131e41f4b71Sopenharmony_ci - getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethodProperty>>): void; 132e41f4b71Sopenharmony_ci - getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>; 133e41f4b71Sopenharmony_ci - showOptionalInputMethods(callback: AsyncCallback<boolean>): void; 134e41f4b71Sopenharmony_ci - showOptionalInputMethods(): Promise<boolean>; 135e41f4b71Sopenharmony_ci - stopInputSession(callback: AsyncCallback<boolean>): void; 136e41f4b71Sopenharmony_ci - stopInputSession(): Promise<boolean>; 137e41f4b71Sopenharmony_ci interface InputMethodProperty: 138e41f4b71Sopenharmony_ci - readonly name: string; 139e41f4b71Sopenharmony_ci - readonly id: string; 140e41f4b71Sopenharmony_ci - getInputMethodAbility(): InputMethodAbility; 141e41f4b71Sopenharmony_ci - getKeyboardDelegate(): KeyboardDelegate; 142e41f4b71Sopenharmony_ci - hide(callback: AsyncCallback<void>): void; 143e41f4b71Sopenharmony_ci - hide(): Promise<void>; 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci**NOTE** 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci- Use the **getInputMethodAbility()** API to obtain an **InputMethodAbility** object, and do not use **getInputMethodEngine()** to obtain an **InputMethodEngine** object. 148e41f4b71Sopenharmony_ci- Use methods in **InputMethodAbility**, and do not use methods in **InputMethodEngine**. 149e41f4b71Sopenharmony_ci- Use the **on('inputStart')** method in **InputMethodAbility** to obtain a **KeyboardController** instance and an **InputClient** instance, and do not use the **on('inputStart')** method in **InputMethodEngine** to obtain a **TextInputClient** instance. 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ciBefore: 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ci```js 154e41f4b71Sopenharmony_ciinputMethodEngine.getInputMethodEngine().on('inputStart', (kbController, textClient) => { 155e41f4b71Sopenharmony_ci let keyboardController = kbController; 156e41f4b71Sopenharmony_ci let textInputClient = textClient; // Obtain a TextInputClient instance. 157e41f4b71Sopenharmony_ci}); 158e41f4b71Sopenharmony_ci``` 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ciAfter: 161e41f4b71Sopenharmony_ci```js 162e41f4b71Sopenharmony_ciinputMethodEngine.getInputMethodAbility().on('inputStart', (kbController, client) => { 163e41f4b71Sopenharmony_ci let keyboardController = kbController; 164e41f4b71Sopenharmony_ci let inputClient = client; // // Obtain an InputClient instance. 165e41f4b71Sopenharmony_ci}); 166e41f4b71Sopenharmony_ci``` 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci## cl.inputmethod_frameworks.3 Change of Some APIs 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ciBefore change: 171e41f4b71Sopenharmony_ci - listInputMethod(enable: boolean, callback: AsyncCallback<Array<InputMethodProperty>>): void; 172e41f4b71Sopenharmony_ci - listInputMethod(enable: boolean): Promise<Array<InputMethodProperty>>; 173e41f4b71Sopenharmony_ci - terminateSelf(callback: AsyncCallback<void>): void; 174e41f4b71Sopenharmony_ci - terminateSelf(): Promise<void>; 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_ciAfter change: 177e41f4b71Sopenharmony_ci - getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethodProperty>>): void; 178e41f4b71Sopenharmony_ci - getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>; 179e41f4b71Sopenharmony_ci - destroy(callback: AsyncCallback<void>): void; 180e41f4b71Sopenharmony_ci - destroy(): Promise<void>; 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ciDeleted APIs in API version 9: 183e41f4b71Sopenharmony_ci - startAbility(want: Want, callback: AsyncCallback<void>): void; 184e41f4b71Sopenharmony_ci - startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void; 185e41f4b71Sopenharmony_ci - startAbility(want: Want, options?: StartOptions): Promise<void>; 186e41f4b71Sopenharmony_ci 187e41f4b71Sopenharmony_ciAdded APIs: 188e41f4b71Sopenharmony_ci - on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void; 189e41f4b71Sopenharmony_ci - off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void; 190e41f4b71Sopenharmony_ci - interface InputMethodProperty: 191e41f4b71Sopenharmony_ci - readonly label?: string; 192e41f4b71Sopenharmony_ci - readonly icon?: string; 193e41f4b71Sopenharmony_ci - readonly iconId?: number; 194e41f4b71Sopenharmony_ci - extra: object; 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci - interface InputMethodAbility: 197e41f4b71Sopenharmony_ci - on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => void): void; 198e41f4b71Sopenharmony_ci - off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => void): void; 199