• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_CONTROLLER_H
17 #define FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_CONTROLLER_H
18 
19 #include <atomic>
20 #include <condition_variable>
21 #include <mutex>
22 #include <thread>
23 
24 #include "block_queue.h"
25 #include "controller_listener.h"
26 #include "element_name.h"
27 #include "event_handler.h"
28 #include "event_status_manager.h"
29 #include "global.h"
30 #include "i_input_method_agent.h"
31 #include "i_input_method_system_ability.h"
32 #include "input_client_info.h"
33 #include "input_method_property.h"
34 #include "input_method_setting_listener.h"
35 #include "input_method_status.h"
36 #include "input_method_utils.h"
37 #include "ipc_skeleton.h"
38 #include "iremote_object.h"
39 #include "key_event.h"
40 #include "message_handler.h"
41 #include "panel_info.h"
42 #include "visibility.h"
43 
44 namespace OHOS {
45 namespace MiscServices {
46 class OnTextChangedListener : public virtual RefBase {
47 public:
48     virtual void InsertText(const std::u16string &text) = 0;
49     virtual void DeleteForward(int32_t length) = 0;
50     virtual void DeleteBackward(int32_t length) = 0;
51     virtual void SendKeyEventFromInputMethod(const KeyEvent &event) = 0;
52     virtual void SendKeyboardStatus(const KeyboardStatus &keyboardStatus) = 0;
NotifyPanelStatusInfo(const PanelStatusInfo & info)53     virtual void NotifyPanelStatusInfo(const PanelStatusInfo &info)
54     {
55     }
NotifyKeyboardHeight(uint32_t height)56     virtual void NotifyKeyboardHeight(uint32_t height)
57     {
58     }
59     virtual void SendFunctionKey(const FunctionKey &functionKey) = 0;
60     virtual void SetKeyboardStatus(bool status) = 0;
61     virtual void MoveCursor(const Direction direction) = 0;
62     virtual void HandleSetSelection(int32_t start, int32_t end) = 0;
63     virtual void HandleExtendAction(int32_t action) = 0;
64     virtual void HandleSelect(int32_t keyCode, int32_t cursorMoveSkip) = 0;
65     virtual std::u16string GetLeftTextOfCursor(int32_t number) = 0;
66     virtual std::u16string GetRightTextOfCursor(int32_t number) = 0;
67     virtual int32_t GetTextIndexAtCursor() = 0;
68 };
69 
70 using KeyEventCallback = std::function<void(std::shared_ptr<MMI::KeyEvent> &keyEvent, bool isConsumed)>;
71 class InputMethodController : public RefBase {
72 public:
73     /**
74      * @brief Get the instance of InputMethodController.
75      *
76      * This function is used to get the instance of InputMethodController.
77      *
78      * @return The instance of InputMethodController.
79      * @since 6
80      */
81     IMF_API static sptr<InputMethodController> GetInstance();
82 
83     /**
84      * @brief Show soft keyboard, set listener and bind IMSA with default states and attribute.
85      *
86      * This function is used to show soft keyboard,  set listener and bind IMSA,
87      * default state is 'true', default attribute is 'InputAttribute::PATTERN_TEXT'.
88      *
89      * @param listener Indicates the listener in order to manipulate text.
90      * @return Returns 0 for success, others for failure.
91      * @since 6
92      */
93     IMF_API int32_t Attach(sptr<OnTextChangedListener> &listener);
94 
95     /**
96      * @brief Set listener and bind IMSA with given states and default attribute.
97      *
98      * This function is used to set listener and bind IMSA,
99      * default attribute is 'InputAttribute::PATTERN_TEXT'. Show soft keyboard when state is true.
100      *
101      * @param listener          Indicates the listener in order to manipulate text.
102      * @param isShowKeyboard    Indicates the state, if you want to show soft keyboard, please pass in true.
103      * @return Returns 0 for success, others for failure.
104      * @since 8
105      */
106     IMF_API int32_t Attach(sptr<OnTextChangedListener> &listener, bool isShowKeyboard);
107 
108     /**
109      * @brief Set listener and bind IMSA with given states and attribute.
110      *
111      * This function is used to set listener and bind IMSA.
112      * Show soft keyboard when state is true, and customized attribute.
113      *
114      * @param listener          Indicates the listener in order to manipulate text.
115      * @param isShowKeyboard    Indicates the state, if you want to show soft keyboard, please pass in true.
116      * @param attribute         Indicates the attribute, such as input pattern, enter eyType, input option.
117      * @return Returns 0 for success, others for failure.
118      * @since 8
119      */
120     IMF_API int32_t Attach(sptr<OnTextChangedListener> &listener, bool isShowKeyboard, const InputAttribute &attribute);
121 
122     /**
123      * @brief Set listener and bind IMSA with given states and textConfig.
124      *
125      * This function is used to set listener and bind IMSA.
126      * Show soft keyboard when state is true, and customized attribute.
127      *
128      * @param listener          Indicates the listener in order to manipulate text.
129      * @param isShowKeyboard    Indicates the state, if you want to show soft keyboard, please pass in true.
130      * @param textConfig        Indicates the textConfig, such as input attribute, cursorInfo, range of text selection,
131      *                          windowId.
132      * @return Returns 0 for success, others for failure.
133      * @since 10
134      */
135     IMF_API int32_t Attach(sptr<OnTextChangedListener> &listener, bool isShowKeyboard, const TextConfig &textConfig);
136 
137     /**
138      * @brief Show soft keyboard.
139      *
140      * This function is used to show soft keyboard of current client.
141      *
142      * @return Returns 0 for success, others for failure.
143      * @since 6
144      */
145     IMF_API int32_t ShowTextInput();
146 
147     /**
148      * @brief Hide soft keyboard.
149      *
150      * This function is used to hide soft keyboard of current client, and keep binding.
151      *
152      * @return Returns 0 for success, others for failure.
153      * @since 6
154      */
155     IMF_API int32_t HideTextInput();
156 
157     /**
158      * @brief Hide current input method, clear text listener and unbind IMSA.
159      *
160      * This function is used to stop input, whick will set listener to nullptr,
161      * hide current soft keyboard and unbind IMSA.
162      *
163      * @return Returns 0 for success, others for failure.
164      * @since 6
165      */
166     IMF_API int32_t Close();
167 
168     /**
169      * @brief A callback function when the cursor changes.
170      *
171      * This function is the callback when the cursor changes.
172      *
173      * @param cursorInfo Indicates the information of current cursor changes.
174      * @return Returns 0 for success, others for failure.
175      * @since 6
176      */
177     IMF_API int32_t OnCursorUpdate(CursorInfo cursorInfo);
178 
179     /**
180      * @brief A callback function when the cursor changes.
181      *
182      * This function is the callback when the cursor changes.
183      *
184      * @param text  Indicates the currently selected text.
185      * @param start Indicates the coordinates of the current start.
186      * @param end   Indicates the coordinates of the current end.
187      * @return Returns 0 for success, others for failure.
188      * @since 6
189      */
190     IMF_API int32_t OnSelectionChange(std::u16string text, int start, int end);
191 
192     /**
193      * @brief Changing the configuration of soft keyboard.
194      *
195      * This function is used to change the configuration of soft keyboard.
196      *
197      * @param info Indicates the current configuration.
198      * @return Returns 0 for success, others for failure.
199      * @since 6
200      */
201     IMF_API int32_t OnConfigurationChange(Configuration info);
202 
203     /**
204      * @brief Set InputMethodSettingListener listener.
205      *
206      * This function is used to set InputMethodSettingListener  listener to facilitate listening input method changes.
207      *
208      * @param listener Indicates the listener to be set.
209      * @since 6
210      */
211     IMF_API void SetSettingListener(std::shared_ptr<InputMethodSettingListener> listener);
212     IMF_API int32_t UpdateListenEventFlag(const std::string &type, bool isOn);
213     IMF_API void SetControllerListener(std::shared_ptr<ControllerListener> controllerListener);
214 
215     /**
216      * @brief Dispatch keyboard event.
217      *
218      * This function is used to Dispatch events of keyboard.
219      *
220      * @param keyEvent Indicates the events keyboard.
221      * @return Returns true for success otherwise for failure.
222      * @since 6
223      */
224     /**
225      * @brief Dispatch keyboard event.
226      *
227      * This function is used to Dispatch events of keyboard.
228      *
229      * @param keyEvent Indicates the events keyboard.
230      * @param callback Indicates the consumption result of key event.
231      * @return Returns 0 for success, others for failure.
232      * @since 11
233      */
234     IMF_API int32_t DispatchKeyEvent(std::shared_ptr<MMI::KeyEvent> keyEvent, KeyEventCallback callback);
235 
236     /**
237      * @brief List input methods.
238      *
239      * This function is used to list all of input methods.
240      *
241      * @param props Indicates the input methods that will be listed.
242      * @return Returns 0 for success, others for failure.
243      * @since 6
244      */
245     IMF_API int32_t ListInputMethod(std::vector<Property> &props);
246 
247     /**
248      * @brief List input methods.
249      *
250      * This function is used to list enabled or disabled input methods.
251      *
252      * @param props     Indicates the input methods that will be listed.
253      * @param enable    Indicates the state of input method.
254      * @return Returns 0 for success, others for failure.
255      * @since 6
256      */
257     IMF_API int32_t ListInputMethod(bool enable, std::vector<Property> &props);
258 
259     /**
260      * @brief List input method subtypes.
261      *
262      * This function is used to list specified input method subtypes.
263      *
264      * @param property      Indicates the specified input method property.
265      * @param subProperties Indicates the subtypes of specified input method that will be listed.
266      * @return Returns 0 for success, others for failure.
267      * @since 6
268      */
269     IMF_API int32_t ListInputMethodSubtype(const Property &property, std::vector<SubProperty> &subProperties);
270 
271     /**
272      * @brief List current input method subtypes.
273      *
274      * This function is used to list current input method subtypes.
275      *
276      * @param subProperties Indicates the subtypes of current input method that will be listed.
277      * @return Returns 0 for success, others for failure.
278      * @since 6
279      */
280     IMF_API int32_t ListCurrentInputMethodSubtype(std::vector<SubProperty> &subProperties);
281 
282     /**
283      * @brief Get enter key type.
284      *
285      * This function is used to get enter key type of current client.
286      *
287      * @param keyType Indicates the enter key type of current client that will be obtained, such as SEND, SEARCH...
288      * @return Returns 0 for success, others for failure.
289      * @since 6
290      */
291     IMF_API int32_t GetEnterKeyType(int32_t &keyType);
292 
293     /**
294      * @brief Get input pattern.
295      *
296      * This function is used to get text input type of current client.
297      *
298      * @param inputPattern Indicates the text input type of current client that will be obtained, such as TEXT, URL...
299      * @return Returns 0 for success, others for failure.
300      * @since 6
301      */
302     IMF_API int32_t GetInputPattern(int32_t &inputPattern);
303 
304     /**
305      * @brief Get text config.
306      *
307      * This function is used to get text config of current client.
308      *
309      * @param textConfig Indicates the text config of current client that will be obtained.
310      * @return Returns 0 for success, others for failure.
311      * @since 10
312      */
313     IMF_API int32_t GetTextConfig(TextTotalConfig &config);
314 
315     /**
316      * @brief Get current input method property.
317      *
318      * This function is used to get current input method property.
319      *
320      * @return The property of current input method.
321      * @since 6
322      */
323     IMF_API std::shared_ptr<Property> GetCurrentInputMethod();
324 
325     /**
326      * @brief Get current input method subtypes.
327      *
328      * This function is used to get current input method's current subtype.
329      *
330      * @return The subtypes of current input method.
331      * @since 6
332      */
333     IMF_API std::shared_ptr<SubProperty> GetCurrentInputMethodSubtype();
334 
335     /**
336      * @brief Get default input method property.
337      *
338      * This function is used to get default input method property.
339      *
340      * @return The property of default input method.
341      * @since 10
342      */
343     IMF_API int32_t GetDefaultInputMethod(std::shared_ptr<Property> &prop);
344 
345     /**
346      * @brief get input method config ability.
347      *
348      * This function is used to get input method config ability.
349      *
350      * @return The info of input settings.
351      * @since 10
352      */
353     IMF_API int32_t GetInputMethodConfig(AppExecFwk::ElementName &inputMethodConfig);
354 
355     /**
356      * @brief Set calling window id.
357      *
358      * This function is used to set calling window id to input method.
359      *
360      * @param windowId Indicates the window id.
361      * @return Returns 0 for success, others for failure.
362      * @since 6
363      */
364     IMF_API int32_t SetCallingWindow(uint32_t windowId);
365 
366     /**
367      * @brief Switch input method or subtype.
368      *
369      * This function is used to switch input method or subtype.
370      *
371      * @param name      Indicates the id of target input method.
372      * @param subName   Optional parameter. Indicates the subtype of target input method.
373      * @return Returns 0 for success, others for failure.
374      * @since 11
375      */
376     IMF_API int32_t SwitchInputMethod(SwitchTrigger trigger, const std::string &name, const std::string &subName = "");
377 
378     /**
379      * @brief Show soft keyboard.
380      *
381      * This function is used to show soft keyboard of current client.
382      *
383      * @return Returns 0 for success, others for failure.
384      * @since 6
385      */
386     IMF_API int32_t ShowSoftKeyboard();
387 
388     /**
389      * @brief Hide soft keyboard.
390      *
391      * This function is used to hide soft keyboard of current client, and keep binding.
392      *
393      * @return Returns 0 for success, others for failure.
394      * @since 6
395      */
396     IMF_API int32_t HideSoftKeyboard();
397 
398     /**
399      * @brief Stop current input session.
400      *
401      * This function is used to stop current input session.
402      *
403      * @return Returns 0 for success, others for failure.
404      * @since 6
405      */
406     IMF_API int32_t StopInputSession();
407 
408     /**
409      * @brief Show input method setting extension dialog.
410      *
411      * This function is used to show input method setting extension dialog.
412      *
413      * @return Returns 0 for success, others for failure.
414      * @since 8
415      */
416     IMF_API int32_t ShowOptionalInputMethod();
417 
418     // Deprecated innerkits with no permission check, kept for compatibility
419 
420     /**
421      * @brief Show soft keyboard.
422      *
423      * This function is used to show soft keyboard of current client.
424      *
425      * @return Returns 0 for success, others for failure.
426      * @deprecated since 9
427      * @since 6
428      */
429     IMF_API int32_t ShowCurrentInput();
430 
431     /**
432      * @brief Hide soft keyboard.
433      *
434      * This function is used to hide soft keyboard of current client, and keep binding.
435      *
436      * @return Returns 0 for success, others for failure.
437      * @deprecated since 9
438      * @since 6
439      */
440     IMF_API int32_t HideCurrentInput();
441 
442     /**
443      * @brief Request to show input method.
444      *
445      * This function is used to request to show input method.
446      *
447      * @return Returns 0 for success, others for failure.
448      * @since 11
449      */
450     IMF_API int32_t RequestShowInput();
451 
452     /**
453      * @brief Request to hide input method.
454      *
455      * This function is used to request to hide input method.
456      *
457      * @return Returns 0 for success, others for failure.
458      * @since 11
459      */
460     IMF_API int32_t RequestHideInput();
461 
462     /**
463      * @brief Show input method setting extension dialog.
464      *
465      * This function is used to show input method setting extension dialog.
466      *
467      * @return Returns 0 for success, others for failure.
468      * @deprecated since 9
469      * @since 6
470      */
471     IMF_API int32_t DisplayOptionalInputMethod();
472 
473     /**
474      * @brief Get attach status.
475      *
476      * This function is used to get status of attach.
477      *
478      * @return Returns true for attached otherwise for detached.
479      * @since 10
480      */
481     IMF_API bool WasAttached();
482 
483     /**
484      * @brief Set agent which will be used to communicate with IMA.
485      *
486      * This function is used to Set agent.
487      *
488      * @since 10
489      */
490     IMF_API void OnInputReady(sptr<IRemoteObject> agentObject);
491 
492     /**
493      * @brief Unbind IMC with Service.
494      *
495      * This function is unbind imc with service.
496      *
497      * @since 10
498      */
499     IMF_API void OnInputStop();
500 
501     /**
502      * @brief Insert text.
503      *
504      * This function is used to insert text into editor.
505      *
506      * @param text Indicates the text which will be inserted.
507      * @return Returns 0 for success, others for failure.
508      * @since 10
509      */
510     IMF_API int32_t InsertText(const std::u16string &text);
511 
512     /**
513      * @brief Move cursor.
514      *
515      * This function is used to move cursor according to the direction.
516      *
517      * @param direction Indicates the direction according to which the cursor will be moved.
518      * @return Returns 0 for success, others for failure.
519      * @since 10
520      */
521     IMF_API int32_t MoveCursor(Direction direction);
522 
523     /**
524      * @brief Delete forward.
525      *
526      * This function is used to delete text at the left of cursor.
527      *
528      * @param length Indicates the length of deleted text.
529      * @return Returns 0 for success, others for failure.
530      * @since 10
531      */
532     IMF_API int32_t DeleteForward(int32_t length);
533 
534     /**
535      * @brief Delete backward.
536      *
537      * This function is used to delete text at the right of cursor.
538      *
539      * @param length Indicates the length of deleted text.
540      * @return Returns 0 for success, others for failure.
541      * @since 10
542      */
543     IMF_API int32_t DeleteBackward(int32_t length);
544 
545     /**
546      * @brief Get text at the left of cursor.
547      *
548      * This function is used to get text at the left of cursor.
549      *
550      * @param length Indicates the length of text.
551      * @param text Indicates the text which will be get.
552      * @return Returns 0 for success, others for failure.
553      * @since 10
554      */
555     IMF_API int32_t GetLeft(int32_t length, std::u16string &text);
556 
557     /**
558      * @brief Get text at the right of cursor.
559      *
560      * This function is used to get text at the right of cursor.
561      *
562      * @param length Indicates the length of text.
563      * @param text Indicates the text which will be get.
564      * @return Returns 0 for success, others for failure.
565      * @since 10
566      */
567     IMF_API int32_t GetRight(int32_t length, std::u16string &text);
568 
569     /**
570      * @brief Select text in editor by range.
571      *
572      * This function is used to select text in editor by range.
573      *
574      * @param start Indicates the beginning of the range.
575      * @param start Indicates the end of the range.
576      * @return Returns 0 for success, others for failure.
577      * @since 10
578      */
579     IMF_API void SelectByRange(int32_t start, int32_t end);
580 
581     /**
582      * @brief Select text in editor by cursor movement.
583      *
584      * This function is used to select text in editor by cursor movement.
585      *
586      * @param direction Indicates the direction of cursor movement.
587      * @param cursorMoveSkip Indicates the skip of cursor movement.
588      * @return Returns 0 for success, others for failure.
589      * @since 10
590      */
591     IMF_API void SelectByMovement(int32_t direction, int32_t cursorMoveSkip);
592 
593     /**
594      * @brief Handle extend action code.
595      *
596      * This function is used to handle extend action code.
597      *
598      * @param action Indicates the action code which will be handled.
599      * @return Returns 0 for success, others for failure.
600      * @since 10
601      */
602     IMF_API int32_t HandleExtendAction(int32_t action);
603 
604     /**
605      * @brief Get the index number of text at cursor.
606      *
607      * This function is used to get the index number of text at cursor.
608      *
609      * @param index Indicates the index number of text at cursor.
610      * @return Returns 0 for success, others for failure.
611      * @since 10
612      */
613     IMF_API int32_t GetTextIndexAtCursor(int32_t &index);
614 
615     /**
616      * @brief Send keyboard status.
617      *
618      * This function is used to send keyboard status to editor.
619      *
620      * @param status Indicates the status of keyboard.
621      * @since 10
622      */
623     IMF_API void SendKeyboardStatus(KeyboardStatus status);
624 
625     /**
626      * @brief Send panel status info.
627      *
628      * This function is used to send panel status info to editor.
629      * Only notify the status info of soft keyboard(not contain candidate column) at present
630      *
631      * @param info Indicates the status info of panel.
632      * @since 11
633      */
634     IMF_API void NotifyPanelStatusInfo(const PanelStatusInfo &info);
635 
636     /**
637      * @brief Send panel height.
638      *
639      * This function is used to send panel height to editor.
640      *
641      * @param info Indicates the panel height.
642      * @since 11
643      */
644     IMF_API void NotifyKeyboardHeight(uint32_t height);
645 
646     /**
647      * @brief Send function key.
648      *
649      * This function is used to send function key to editor.
650      *
651      * @param functionKey Indicates the function key.
652      * @return Returns 0 for success, others for failure.
653      * @since 10
654      */
655     IMF_API int32_t SendFunctionKey(int32_t functionKey);
656 
657     /**
658      * @brief Inform the change of ime to client.
659      *
660      * This function is used to inform the change of ime to client.
661      *
662      * @param property Indicates the property of ime.
663      * @param subProperty Indicates the sub property of ime.
664      * @return Returns 0 for success, others for failure.
665      * @since 10
666      */
667     IMF_API int32_t OnSwitchInput(const Property &property, const SubProperty &subProperty);
668 
669     /**
670      * @brief Inform the change panel status.
671      *
672      * This function is used to inform the change panel status.
673      *
674      * @param status Indicates the status of panel.
675      * @param windowInfo Indicates the detailed info of window.
676      * @return Returns 0 for success, others for failure.
677      * @since 10
678      */
679     IMF_API int32_t OnPanelStatusChange(
680         const InputWindowStatus &status, const std::vector<InputWindowInfo> &windowInfo);
681 
682     /**
683      * @brief Deactivate the input client.
684      *
685      * This function is used to deactivate the input client.
686      *
687      * @since 11
688      */
689     IMF_API void DeactivateClient();
690 
691     /**
692      * @brief Query whether an input type is supported.
693      *
694      * This function is used to query whether an input type is supported.
695      *
696      * @param type Indicates the input type being queried.
697      * @return Returns true for supported, false for not supported.
698      * @since 11
699      */
700     IMF_API bool IsInputTypeSupported(InputType type);
701 
702     /**
703      * @brief Start the input method which provides the specific input type.
704      *
705      * This function is used to start the input method which provides the specific input type.
706      *
707      * @param type Indicates the input type being specified.
708      * @return Returns 0 for success, others for failure.
709      * @since 11
710      */
711     IMF_API int32_t StartInputType(InputType type);
712 
713     /**
714      * @brief Query whether the specific type panel is shown.
715      *
716      * This function is used to query whether the specific type panel is shown.
717      *
718      * @param panelInfo Indicates the info of the panel.
719      * @param isShown Indicates the state of the specific panel.
720      * @return Returns 0 for success, others for failure.
721      * @since 11
722      */
723     IMF_API int32_t IsPanelShown(const PanelInfo &panelInfo, bool &isShown);
724 
725 private:
726     InputMethodController();
727     ~InputMethodController();
728 
729     int32_t Initialize();
730     sptr<IInputMethodSystemAbility> GetSystemAbilityProxy();
731     int32_t StartInput(InputClientInfo &inputClientInfo, sptr<IRemoteObject> &agent);
732     int32_t ShowInput(sptr<IInputClient> &client);
733     int32_t HideInput(sptr<IInputClient> &client);
734     int32_t ReleaseInput(sptr<IInputClient> &client);
735     int32_t ListInputMethodCommon(InputMethodStatus status, std::vector<Property> &props);
736     void ClearEditorCache();
737     void OnRemoteSaDied(const wptr<IRemoteObject> &object);
738     void RestoreListenInfoInSaDied();
739     void RestoreAttachInfoInSaDied();
740     int32_t RestoreListenEventFlag();
741     void UpdateNativeEventFlag(EventType eventType, bool isOn);
742     void SaveTextConfig(const TextConfig &textConfig);
743     sptr<OnTextChangedListener> GetTextListener();
744     void SetTextListener(sptr<OnTextChangedListener> listener);
745     bool IsEditable();
746     bool IsBound();
747     void SetAgent(sptr<IRemoteObject> &agentObject);
748     std::shared_ptr<IInputMethodAgent> GetAgent();
749     int32_t DispatchKeyEventInner(std::shared_ptr<MMI::KeyEvent> &keyEvent, KeyEventCallback &callback);
750     void PrintLogIfAceTimeout(int64_t start);
751 
752     std::shared_ptr<InputMethodSettingListener> settingListener_;
753     std::shared_ptr<ControllerListener> controllerListener_;
754     std::mutex abilityLock_;
755     sptr<IInputMethodSystemAbility> abilityManager_ = nullptr;
756     sptr<InputDeathRecipient> deathRecipient_;
757     std::mutex agentLock_;
758     sptr<IRemoteObject> agentObject_ = nullptr;
759     std::shared_ptr<IInputMethodAgent> agent_ = nullptr;
760     std::mutex textListenerLock_;
761     sptr<OnTextChangedListener> textListener_ = nullptr;
762     std::atomic_bool isDiedAttached_{ false };
763 
764     std::mutex cursorInfoMutex_;
765     CursorInfo cursorInfo_;
766 
767     std::mutex editorContentLock_;
768     std::u16string textString_;
769     int selectOldBegin_ = 0;
770     int selectOldEnd_ = 0;
771     int selectNewBegin_ = 0;
772     int selectNewEnd_ = 0;
773 
774     static std::mutex instanceLock_;
775     static sptr<InputMethodController> instance_;
776     static std::shared_ptr<AppExecFwk::EventHandler> handler_;
777 
778     std::atomic_bool isEditable_{ false };
779     std::atomic_bool isBound_{ false };
780 
781     std::recursive_mutex clientInfoLock_;
782     InputClientInfo clientInfo_;
783 
784     static constexpr int CURSOR_DIRECTION_BASE_VALUE = 2011;
785     std::atomic_bool isDiedRestoreListen_{ false };
786 
787     std::mutex textConfigLock_;
788     TextConfig textConfig_;
789 
790     struct KeyEventInfo {
791         std::chrono::system_clock::time_point timestamp{};
792         std::shared_ptr<MMI::KeyEvent> keyEvent;
793         bool operator==(const KeyEventInfo &info) const
794         {
795             return (timestamp == info.timestamp && keyEvent == info.keyEvent);
796         }
797     };
798     static constexpr int32_t MAX_WAIT_TIME = 5000;
799     BlockQueue<KeyEventInfo> keyEventQueue_{ MAX_WAIT_TIME };
800 };
801 } // namespace MiscServices
802 } // namespace OHOS
803 #endif // FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_CONTROLLER_H
804