Input event processing method, device, storage medium and product

CN121187709BActive Publication Date: 2026-08-07HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-06-14
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

然而,不同的输入法应用程序处理逻辑也各不相同,有些输入法应用程序会基于自身的处理逻辑将按下键盘按键“Ctrl”+“C”的事件传递给Linux应用程序,但是会对抬起键盘按键“Ctrl”+“C”的事件进行拦截,这就导致了最终传递到Linux应用程序的输入事件中缺少键盘按键“Ctrl”+“C”的抬起动作,从而使Linux应用程序中会出现持续输入字母“C”的情况,导致用户无法正常使用Linux应用程序,用户体验较差

Benefits of technology

[0035]在本申请实施例提供的方案中,通过调用输入法前处理阶段中进行输入事件处理的接口,获取用户触发的输入事件,实现了在输入法应用处理阶段之前对输入事件的拦截。在将该输入事件拦截后,若识别出输入事件是快捷按键输入事件,则说明该输入事件容易被输入法应用程序误处理,在此情况下,直接将快捷按键输入事件发送至第二应用程序进行处理,确保了在遇到“快捷按键输入事件”的情况下第二应用程序依然可以正常使用,提高了用户体验。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121187709B_ABST
    Figure CN121187709B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide an input event processing method and device, a storage medium and a product, and relate to the technical field of computers. The method is applied to a first application program included in a target application program of a mobile terminal. The method comprises: obtaining an input event triggered by a user by calling an interface for processing the input event in a pre-input method processing stage, wherein an input method framework sends the input event to the first application program after sequentially processing the input event in multiple processing stages, and the multiple processing stages comprise a pre-input method processing stage and an input method application processing stage which are sequentially performed; and if the input event is identified as a shortcut key input event, the shortcut key input event is sent to a second application program for processing. The present application can avoid the input event being misprocessed by the input method application program, ensure that the second application program can still be normally used in the case of the "shortcut key input event", and improve the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to an input event processing method, device, storage medium and product. Background Technology

[0002] With the development of technology, users' demand for working on large-screen Android devices (Android devices are terminal devices running the Android system) such as tablets and smart TVs is becoming increasingly strong. However, applications designed for Android devices such as tablets and smart TVs often lack the professionalism of desktop and laptop applications (also known as PC applications). Porting PC applications to Android devices can solve this problem. Specifically, since the Android system is based on the Linux kernel, Linux PC-level applications (hereinafter referred to as Linux applications) can be run on Android devices to meet users' professional-level office needs.

[0003] In practical applications, when an Android device receives an input event triggered by the user (i.e., an action related to devices such as a keyboard or mouse, such as pressing or releasing a key on a keyboard), it sends the input event to a Linux application to enable the application of PC-level applications on the Android device.

[0004] The following example, using the input event of a user pressing and releasing the keyboard keys "Ctrl" + "C", illustrates the relevant technology: In this technology, when an Android device receives an input event and sends it to a Linux application, the input event of the user pressing and releasing the keyboard keys "Ctrl" + "C" needs to be processed by the input method application before being sent to the Linux application. However, different input method applications have different processing logics. Some applications, based on their own logic, will pass the "Ctrl" + "C" press event to the Linux application, but will intercept the "Ctrl" + "C" release event. This results in the input event ultimately delivered to the Linux application lacking the "Ctrl" + "C" release action, leading to continuous input of the letter "C" in the Linux application. This prevents the user from using the Linux application properly, resulting in a poor user experience. Summary of the Invention

[0005] This application provides an input event processing method, device, storage medium, and product to prevent input events from being mishandled by input method applications and improve user experience.

[0006] In a first aspect, embodiments of this application provide an input event processing method, the method being applied to a first application contained in a target application in a mobile terminal, the target application comprising the first application located outside a Linux container and a second application located within a Linux container, including:

[0007] By calling the interface for input event processing in the input method preprocessing stage, the input event triggered by the user is obtained. After obtaining the input event, the input method framework processes the input event in multiple processing stages in sequence and then sends it to the first application. The multiple processing stages include the input method preprocessing stage and the input method application processing stage performed in sequence.

[0008] If the input event is identified as a shortcut key input event, the shortcut key input event is sent to the second application for processing.

[0009] In one possible implementation, the step of sending the shortcut key input event to the second application for processing if the input event is identified as a shortcut key input event includes:

[0010] If the input event is identified as a shortcut key input event where a target key with a shortcut state is pressed, the shortcut key input event is sent to the second application for processing, and the encoding identifier of the target key is stored in the setting storage file.

[0011] In one possible implementation, the step of sending the shortcut key input event to the second application for processing if the input event is identified as a shortcut key input event includes:

[0012] If the input event is identified as a shortcut key input event where a target key associated with a shortcut state is released, the shortcut key input event is sent to the second application for processing, and the encoding identifier of the target key is deleted from the setting storage file, which is used to store the encoding identifier of a pressed key associated with a shortcut state.

[0013] In one possible implementation, sending the shortcut key input event to the second application for processing includes:

[0014] Extract the key information from the shortcut key input events;

[0015] The key information is encapsulated;

[0016] The encapsulated key information is sent to the second application using the configured socket method.

[0017] In one possible implementation, sending the encapsulated key information to the second application includes:

[0018] The encapsulated key information is sent to the virtual screen component in the Linux container, so that the encapsulated key information can be sent to the second application through the virtual screen component.

[0019] In one possible implementation, the method further includes:

[0020] The input event is received by the input method framework after processing the input event through the input method application processing stage;

[0021] If it is determined that the input event has been identified as the shortcut key input event, then the input event received from the input method framework is deleted.

[0022] In one possible implementation, the method further includes:

[0023] If the input event is determined to be a non-shortcut key input event, then the non-shortcut key input event is sent to the second application for processing.

[0024] In one possible implementation, sending the non-shortcut key input event to the second application for processing includes:

[0025] If it is determined that the non-shortcut key input event is an English non-shortcut key input event, then the key information of the non-shortcut key input event is extracted, the key information is encapsulated, and the encapsulated key information is sent to the second application through the set socket method.

[0026] In one possible implementation, sending the non-shortcut key input event to the second application for processing includes:

[0027] If it is determined that the non-shortcut key input event is a Chinese non-shortcut key input event, then the input content corresponding to the non-shortcut key input event is converted into a string;

[0028] The converted string is sent to the Linux input method application in the Linux container via the set socket method, so that the converted string can be sent to the second application through the Linux input method application.

[0029] Secondly, embodiments of this application provide an input event processing apparatus, the apparatus comprising:

[0030] The acquisition module is used to acquire user-triggered input events by calling the interface for input event processing in the input method preprocessing stage. After acquiring the input event, the input method framework processes the input event in a series of processing stages before sending it to the first application. The series of processing stages include the input method preprocessing stage and the input method application processing stage performed in sequence.

[0031] The sending module is used to send the shortcut key input event to the second application for processing if it is identified that the input event is a shortcut key input event.

[0032] Thirdly, embodiments of this application provide a terminal device, the terminal device including a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the terminal device is triggered to execute the method described in the first aspect.

[0033] Fourthly, embodiments of this application provide a computer-readable storage medium including a stored program, wherein the program, when running, controls the device where the computer-readable storage medium is located to execute the method described in the first aspect.

[0034] Fifthly, embodiments of this application provide a computer program product, the computer program product comprising: a computer program, which, when executed by a processor of an electronic device, causes the processor to execute the method described in the first aspect.

[0035] In the solution provided in this application embodiment, the user-triggered input event is obtained by calling the interface for input event processing in the input method preprocessing stage, thus achieving interception of the input event before the input method application processing stage. After intercepting the input event, if it is identified as a shortcut key input event, it indicates that the input event is easily mishandled by the input method application. In this case, the shortcut key input event is directly sent to the second application for processing, ensuring that the second application can still be used normally when encountering a "shortcut key input event," thereby improving the user experience. Attached Figure Description

[0036] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0037] Figure 1 A flowchart illustrating an input event processing method provided in an embodiment of this application;

[0038] Figure 2This application example diagram illustrates an input event processing method provided in an embodiment of this application.

[0039] Figure 3 A flowchart illustrating how a shortcut key input event is sent to a second application for processing, as provided in this embodiment of the application;

[0040] Figure 4 A first schematic diagram of the first application side and the second application side provided in the embodiments of this application;

[0041] Figure 5 A flowchart illustrating yet another input event handling method provided in an embodiment of this application;

[0042] Figure 6 A second schematic diagram of the first application side and the second application side provided in the embodiments of this application;

[0043] Figure 7 This is a schematic diagram of the structure of an input event processing device provided in an embodiment of this application;

[0044] Figure 8 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application;

[0045] Figure 9 This is a software structure block diagram of a terminal device provided in an embodiment of this application. Detailed Implementation

[0046] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0047] With the development of technology, users' demand for working on large-screen Android devices (Android devices are terminal devices running the Android system) such as tablets and smart TVs is becoming increasingly strong. However, applications designed for Android devices such as tablets and smart TVs often lack the professionalism of desktop and laptop applications (also known as PC applications). Porting PC applications to Android devices can solve this problem. Specifically, since the Android system is based on the Linux kernel, Linux PC-level applications (hereinafter referred to as Linux applications) can run on Android devices to meet users' professional-level office needs. In practical applications, when the Android device receives an input event triggered by the user (i.e., an action related to the keyboard, mouse, etc., such as pressing or releasing a key on the keyboard), it sends the input event to the Linux application to enable the application of PC-level applications on the Android device.

[0048] The following example, using the input event of a user pressing and releasing the keyboard keys "Ctrl" + "C", illustrates the relevant technology: In this technology, when an Android device receives an input event and sends it to a Linux application, the input event of the user pressing and releasing the keyboard keys "Ctrl" + "C" needs to be processed by the input method application before being sent to the Linux application. However, different input method applications have different processing logics. Some applications, based on their own logic, will pass the "Ctrl" + "C" press event to the Linux application, but will intercept the "Ctrl" + "C" release event. This results in the final input event passed to the Linux application lacking the "Ctrl" + "C" release action, leading to continuous input of the letter "C" in the Linux application, making it unusable for the user and resulting in a poor user experience.

[0049] To address the aforementioned problems, this application proposes the following approach:

[0050] It should be understood that in practical applications, after acquiring an input event, the input method framework processes the input event through multiple stages before sending it to the Linux application via the first application. These multiple stages include a pre-processing stage and an application processing stage. Based on this, this application intercepts the input event in advance during the pre-processing stage and identifies it. If the input event is identified as a shortcut key input event, it bypasses the application processing stage and sends the shortcut key input event directly to the Linux application. This avoids the input method application mishandling shortcut keys (such as "Ctrl+C", "Ctrl+V", etc.), ensuring that the Linux application can still function normally even when encountering shortcut key input events, thus improving the user experience.

[0051] Figure 1 A flowchart illustrating an input event processing method provided in this application embodiment. This method is applied to a first application contained in a target application within a mobile terminal. The target application includes a first application located outside a Linux container and a second application located inside a Linux container, such as... Figure 1 As shown, the method specifically includes the following steps:

[0052] 101. By calling the interface for input event processing in the input method preprocessing stage, the input event triggered by the user is obtained. After obtaining the input event, the input method framework processes the input event in multiple processing stages in sequence and then sends it to the first application. The multiple processing stages include the input method preprocessing stage and the input method application processing stage performed in sequence.

[0053] 102. If the input event is identified as a shortcut key input event, the shortcut key input event is sent to the second application for processing.

[0054] It should be noted that the mobile terminal can be a smartphone, tablet, laptop, or other similar device, which will not be listed here. The target application on this mobile terminal can be one of many different types of applications, such as office applications or games, and is not limited here.

[0055] In this embodiment, the target application includes a first application located outside the Linux container and a second application located inside the Linux container. Assuming the mobile terminal is running an Android system, the first application is used for interaction between the Android system and the Linux container. Specifically, the first application mainly has two parts: input and output. The input part includes peripheral input such as keyboard, mouse, and touchscreen, as well as Android's input method and clipboard functions. The output part includes image display and audio output functions from the second application. The second application can be understood as a Linux application; for example, it could be an office application such as Office or WPS. The Linux container runs in the target application's runtime path. Specifically, a Linux container is a lightweight virtualization technology that encapsulates the second application and its dependent environment in an independent runtime environment, achieving application isolation and rapid deployment. In this application, the main functions of the Linux container are: running the second application, outputting image data, and receiving and processing input events sent by the first application.

[0056] In practical applications, the first application obtains user-triggered input events by calling the interface for input event processing in the input method preprocessing stage. In other words, the input event is intercepted before it enters the input method application processing stage. For ease of understanding, the various processing stages described above are explained in detail below:

[0057] Stage 1, NativePreImeInputStage; This stage is used to dispatch input events that occur before the InputMethod Editor (IME) to the NativeActivity for processing. It is typically used in scenarios such as game development, but touch events are not supported.

[0058] Phase 2, ViewPreImeInputStage; This phase is used to dispatch input events that occur before the IME to the view frame (also known as the View frame) for processing, allowing messages to be received and processed before the input method application processes them.

[0059] Stage 3, ImeInputStage; This stage is used to dispatch input events to IME processing, typically handling input events related to the input method.

[0060] Stage 4, EarlyPostImeInputStage; This stage is used to process input events after the IME and is related to the touch mode.

[0061] Stage 5, NativePostImeInputStage; This stage handles input events after the IME has finished processing the message. Touch event handling is supported in this stage.

[0062] Stage 6, ViewPostImeInputStage; This stage is used to dispatch input events to the View framework for touch and focus event processing.

[0063] Stage 7, SyntheticInputStage; This stage is used to process unprocessed input events. As the final stage for processing unprocessed events, it ensures that all input events are properly processed.

[0064] Based on the above, in the multiple processing stages, stages 1 and 2 are the input method preprocessing stages, and stages 3-7 are the input method application processing stages. Traditional solutions process input events in stages 3-7, for example, processing the input event of a user pressing and releasing the keyboard keys "Ctrl" + "C". In this case, the input method application in stage 3, based on its own processing logic, might only pass the "Ctrl + "C" press event to the second application, while intercepting the "Ctrl + "C" release event. This results in the input event ultimately passed to the second application lacking the "Ctrl + "C" release action. Therefore, this embodiment intercepts and identifies the input event before stage 3 to determine if it is a shortcut key input event. If the input event is identified as a shortcut key input event, it indicates that continuing to process it in stage 3 risks event interception. In this case, the shortcut key input event is directly sent to the second application for processing. For ease of understanding, this process can be specifically described in [link to documentation]. Figure 2 .

[0065] In practice, if the input event is identified as a shortcut key input event where a target key with a shortcut state is pressed, the shortcut key input event is sent to the second application for processing, and the encoding identifier of the target key is stored in the setting storage file.

[0066] For example, after receiving an input event, the first application can determine whether the input event is a "Ctrl" key press using `KeyEvent$isCtrlPressed`. Here, "KeyEvent" refers to the event generated when a user presses a key on the keyboard, and `isCtrlPressed` is a method or function commonly used to detect whether the user has pressed the Ctrl key. Assuming the input event is that the user pressed the "Ctrl" key or simultaneously pressed "Ctrl+V", as long as it includes the "Ctrl" key, it indicates that the input event is a shortcut key input event associated with a shortcut state. In this case, the input event of the user pressing the "Ctrl" key or simultaneously pressing "Ctrl+V" can be sent to the second application for processing, and the encoding identifier of the target key can be stored in a configuration file. That is, the encoding identifier corresponding to the "Ctrl" key or "Ctrl+V" key can be stored. This encoding identifier can be in the form of a keycode, which refers to the code corresponding to each key on the computer keyboard. By reading the keycode, the computer can be controlled to respond to the user's input information on the keyboard, thereby realizing a specific function. It's important to note that keycode is not ASCII code; it corresponds to the key encoding on the keyboard, with each key having only one code. For example, the letters "A" and "a" have the same keycode because they both correspond to the same key on the keyboard.

[0067] By sending shortcut key input events when a target key with a shortcut status is pressed to a second application for processing, and storing the encoding identifier of the target key in a configuration file, it is possible to ensure that the second application can still be used normally when a "shortcut key input event" occurs. Furthermore, it is easier to find and process subsequent shortcut key input events when a target key with a shortcut status is released, thereby ensuring the integrity of the input events sent to the second application.

[0068] If the input event is identified as a shortcut key input event where the target key associated with a shortcut state is released, the shortcut key input event is sent to the second application for processing, and the encoding identifier of the target key is deleted from the configuration storage file. The configuration storage file is used to store the encoding identifier of the pressed key associated with a shortcut state.

[0069] Continuing the example above, suppose the input event is that the user releases the "Ctrl" key or simultaneously releases the "Ctrl+V" key. As long as the "Ctrl" key is present, it indicates that the input event is a shortcut key input event where the target key associated with the shortcut state is released. In this case, the input event of the user releasing the "Ctrl" key or simultaneously releasing the "Ctrl+V" key can be sent to the second application for processing, and the target key's code identifier can be deleted from the configuration file. It should be understood that if the user has already pressed the "Ctrl" key or simultaneously pressed the "Ctrl+V" key beforehand, then the target key's code identifier has already been saved in the configuration file. Finding the target key's code identifier in the configuration file and deleting it is equivalent to ending the entire "Ctrl" key or "Ctrl+V" key press and release action. This avoids confusion regarding the target key's code identifier during subsequent input event processing, ensuring the integrity of the input event and further guaranteeing the smooth processing of the input event.

[0070] The input event handling method provided in this application intercepts user-triggered input events by calling the interface for input event processing during the input method preprocessing stage, thus achieving interception of input events before the input method application processing stage. After intercepting the input event, if it is identified as a shortcut key input event, it indicates that the input event is easily mishandled by the input method application. In this case, the shortcut key input event is directly sent to a second application for processing, ensuring that the second application can still be used normally even when encountering a "shortcut key input event," thereby improving the user experience.

[0071] Figure 3 A flowchart for sending shortcut key input events to a second application for processing, such as... Figure 3 As shown, the shortcut key input event is sent to a second application for processing, including:

[0072] 301. Extract key information from shortcut key input events.

[0073] 302. Encapsulate key information.

[0074] 303. Send the encapsulated key information to the second application through the set socket method.

[0075] In step 303, the encapsulated key information is sent to the second application, including: sending the encapsulated key information to a virtual screen component in the Linux container, so that the encapsulated key information is sent to the second application through the virtual screen component. The interaction process between the first application and the second application can be found in [reference needed]. Figure 4 .

[0076] In practice, after receiving a shortcut key input event, the first application extracts key information from the event. For example, for a shortcut key input event where the user simultaneously presses "Ctrl+V", the key information of "pressed" and "Ctrl+V" is extracted. This key information is then encapsulated and sent to the second application via a predefined socket method. The first and second applications can communicate using a Socket.

[0077] During the process of sending the encapsulated key information to the second application, the encapsulated key information is first sent to the virtual screen component Xserver in the Linux container. Xserver then injects the encapsulated key information into the corresponding virtual input device (such as a virtual keyboard or virtual mouse), and then sends the encapsulated key information to the second application through the virtual input device.

[0078] By extracting key information from shortcut key input events and encapsulating it, the encapsulated key information is sent to a virtual screen component in a Linux container using a predefined socket method. This virtual screen component then sends the encapsulated key information to a second application, improving the transmission efficiency of shortcut key input events.

[0079] Furthermore, it should be noted that when this application embodiment identifies an input event as a shortcut key input event, it sends the shortcut key input event to the second application for processing. Simultaneously, to ensure that the original key logic of the input method application is not affected, the shortcut key input event is also passed to the input method application processing stage for further processing. For example, in some input method applications, "Ctrl+Shift" is a shortcut key for switching between Chinese and English, and it also includes the "Ctrl" key. If this key is sent directly to the second application, bypassing the input method application processing stage, it will affect the original key logic of the input method application. While this application avoids affecting the original key logic of the input method application in this way, it introduces a new problem: the input event obtained after processing by the input method application processing stage may be the same as the shortcut key input event directly sent to the second application by the input method preprocessing stage. This would cause the second application to receive two identical input events, affecting the normal use of the second application. Therefore, this application embodiment also provides an input event processing method.

[0080] Figure 5 A flowchart of another input event handling method provided in the embodiments of this application is shown below. Figure 5 As shown, the method includes the following steps:

[0081] 501. By calling the interface for input event processing in the input method preprocessing stage, the input event triggered by the user is obtained. After obtaining the input event, the input method framework processes the input event in multiple processing stages in sequence and then sends it to the first application. The multiple processing stages include the input method preprocessing stage and the input method application processing stage performed in sequence.

[0082] 502. If the input event is identified as a shortcut key input event, the shortcut key input event is sent to the second application for processing.

[0083] 503. Input events received by the input method framework after processing the input events in the input method application processing stage.

[0084] 504. If it is determined that the input event has been identified as a shortcut key input event, then delete the input event received from the input method framework.

[0085] The specific implementation methods of steps 501 and 502 can be referred to the above embodiments, and will not be repeated here.

[0086] For steps 503 and 504, since all input events are processed through the input method application processing stage, after receiving the input event sent by the input method framework after processing it through the input method application processing stage, it is necessary to identify the input event. If the input event is identified as a shortcut key input event, it means that the input event has already been sent to the second application in the input method preprocessing stage. In this case, if the shortcut key input event is sent to the second application again, it will cause the second application to receive duplicate input events, such as repeatedly receiving the shortcut key input event of the user pressing "Ctrl+V" simultaneously. Therefore, this application will delete the input event received from the input method framework when it determines that the input event has been identified as a shortcut key input event to ensure the smooth operation of the second application.

[0087] Of course, the input event sent after the input method framework processes the input event during the input method application processing stage may be a shortcut key input event or a non-shortcut key input event. If it is determined that the input event is a non-shortcut key input event, it can be directly sent to the second application for processing. Specifically, it should be understood that if the input event is a non-shortcut key input event, then the input event will not be sent to the second application during the input method preprocessing stage, and there will be no problem of duplicate sending of the input event. In this case, the non-shortcut key input event can be directly sent to the second application for processing.

[0088] As one implementation method, non-shortcut key input events are sent to a second application for processing, including:

[0089] If it is determined that the non-shortcut key input event is an English non-shortcut key input event, then the key information of the non-shortcut key input event is extracted, the key information is encapsulated, and the encapsulated key information is sent to the second application through the set socket method.

[0090] In practical applications, if it is determined that the non-shortcut key input event is an English non-shortcut key input event, it means that this input event is a normal key event (such as the user pressing any of the "A", "B", or "C" keys on the keyboard). This input event does not need to be processed in the input method preprocessing stage, and therefore there is no problem of duplicate input events. In this case, the key information of the non-shortcut key input event can be directly extracted, encapsulated, and sent to the second application through the set socket method.

[0091] As another implementation, non-shortcut key input events are sent to a second application for processing. This includes: if the non-shortcut key input event is determined to be a Chinese non-shortcut key input event, then converting the input content corresponding to the non-shortcut key input event into a string; and sending the converted string to the Linux input method application in the Linux container through a set socket method, so that the data can be successfully transmitted to the Linux container through the Linux input method application. The reason for sending it to the Linux input method application here is to utilize its Chinese input function, which allows the Linux input method application to send the string to the second application.

[0092] For ease of understanding, a specific embodiment is provided below to illustrate the solution of this application:

[0093] like Figure 6 As shown, on the first application side, the first application obtains input events through dispatchKeyEventPreIme, which is called in the processKeyEvent flow within stage 2 of the aforementioned processing stages, specifically in ViewPreImeInputStage. Here, processKeyEvent is used to handle key events (KeyEvent), a basic event in the Android system that represents when a user inputs or presses a key on the keyboard. dispatchKeyEventPreIme is used to dispatch input events before they are processed by the input method application.

[0094] The KeyEvent$isCtrlPressed function identifies whether the input event has a target key "Ctrl" associated with the shortcut key, and whether that "Ctrl" key is pressed.

[0095] For input events where the "Ctrl" key is pressed (including pressing only the "Ctrl" key, as well as pressing "Ctrl+C", "Ctrl+V", and other shortcut key combinations simultaneously), the keycode is saved in the configuration storage file, and the input event is sent directly to the second application.

[0096] For input events where the "Ctrl" key is released (including releasing only the "Ctrl" key, as well as releasing the "Ctrl+C", "Ctrl+V", and other shortcut combinations simultaneously), check if the keycode corresponding to the input event has been saved in the settings storage file. If it has, send the input event to the second application and clear the saved keycode in the settings storage file.

[0097] The input event is sent to the input method application processing stage for further processing.

[0098] The system continuously receives key events (KeyEvents) processed by the input method application. If the received event is a non-shortcut English key input event, it extracts the key information, encapsulates it, and sends the encapsulated key information to the second application via a predefined socket method. If the received event is a non-shortcut Chinese key input event, it performs string conversion on the corresponding input content and sends the converted string to the Linux input method application within the Linux container via a predefined socket method. The Linux input method application then sends the converted string to the second application.

[0099] The system receives input events sent by the input method framework after processing them during the input method application processing phase. If the input event is determined to be a shortcut key input event, the input event received from the input method framework is deleted. If the input event is determined to be a non-shortcut key input event, it is sent normally, that is, the non-shortcut key input event is sent to the second application for processing through the virtual screen component Xserver.

[0100] In some of the processes described in the above embodiments and accompanying drawings, multiple operations are included in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not represent any execution order. Furthermore, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.

[0101] The following describes in detail one or more embodiments of the input event processing apparatus of this application. Those skilled in the art will understand that these apparatuses can all be configured using commercially available hardware components through the steps taught in this solution.

[0102] Figure 7 This is a schematic diagram of the structure of an input event processing device provided in an embodiment of this application, as shown below. Figure 7 As shown, the device is applied to a first application contained in a target application in a mobile terminal. The target application contains the first application located outside a Linux container and a second application located inside a Linux container. The device includes: an acquisition module 11 and a sending module 12.

[0103] The acquisition module 11 is used to acquire user-triggered input events by calling the interface for input event processing in the input method preprocessing stage. After acquiring the input event, the input method framework processes the input event in sequence through multiple processing stages and then sends it to the first application. The multiple processing stages include the input method preprocessing stage and the input method application processing stage performed in sequence.

[0104] The sending module 12 is used to send the shortcut key input event to the second application for processing if it is identified that the input event is a shortcut key input event.

[0105] Optionally, the sending module 12 is specifically configured to: if the input event is identified as a shortcut key input event where a target key associated with a shortcut state is pressed, send the shortcut key input event to the second application for processing and store the encoding identifier of the target key in a setting storage file; and if the input event is identified as a shortcut key input event where a target key associated with a shortcut state is released, send the shortcut key input event to the second application for processing and delete the encoding identifier of the target key in the setting storage file, wherein the setting storage file is used to store the encoding identifier of a pressed key associated with a shortcut state.

[0106] Optionally, the sending module 12 is further configured to: extract key information of the shortcut key input event; encapsulate the key information; and send the encapsulated key information to the second application through a set socket method.

[0107] Optionally, the sending module 12 is further configured to: send the encapsulated key information to the virtual screen component in the Linux container, so as to send the encapsulated key information to the second application through the virtual screen component.

[0108] Optionally, the device further includes a receiving module and a deletion module.

[0109] The receiving module is used to receive the input event sent by the input method framework after processing the input event through the input method application processing stage.

[0110] A deletion module is used to delete the input event received from the input method framework if it is determined that the input event has been identified as the shortcut key input event.

[0111] Optionally, the device further includes a sending processing module, configured to send the non-shortcut key input event to the second application for processing if it is determined that the input event is a non-shortcut key input event.

[0112] Optionally, the sending processing module is specifically used for: if it is determined that the non-shortcut key input event is an English non-shortcut key input event, then extracting the key information of the non-shortcut key input event, encapsulating the key information, and sending the encapsulated key information to the second application through a set socket method; and if it is determined that the non-shortcut key input event is a Chinese non-shortcut key input event, then performing string conversion on the input content corresponding to the non-shortcut key input event; and sending the converted string to the Linux input method application in the Linux container through a set socket method, so that the converted string can be sent to the second application through the Linux input method application.

[0113] Figure 7 The device shown can perform the steps based on the input event processing method in the foregoing embodiments. For detailed execution process and technical effects, please refer to the description in the foregoing embodiments, which will not be repeated here.

[0114] This application also provides a terminal device, including a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the terminal device is triggered to execute the above-described input event processing method.

[0115] The terminal device can be a mobile phone, wearable device, tablet computer, vehicle terminal, etc. The embodiments of this application do not limit the specific technology or device form used in the terminal device.

[0116] To better understand the embodiments of this application, the structure of the terminal device to which the embodiments of this application are applicable will be described below. Figure 8 The diagram shown is a structural schematic of a terminal device provided in an embodiment of this application. Figure 8 The terminal device 10 shown may include a processor 110, a memory 120, a universal serial bus (USB) interface 130, a power supply 140, a communication module 150, and a display screen 160, etc.

[0117] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the terminal device 10. In other embodiments of this application, the terminal device 10 may include more or fewer components than illustrated, or combine some components, or split some components, or arrange different components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware. The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a digital signal processor (DSP, baseband processor), etc. Different processing units may be independent devices or integrated into one or more processors.

[0118] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.

[0119] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0120] Power supply 140 supplies power to terminal device 10.

[0121] The communication module 150 can use any transceiver-like device to provide applications on the terminal device 10, including...

[0122] Wireless Local Area Networks (WLANs) (such as Wireless Fidelity (Wi-Fi) networks), Bluetooth (BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR), and other wireless communication solutions. The communication module 150 can be one or more devices integrating at least one communication processing module. The communication module 150 receives electromagnetic waves via an antenna, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to the processor 110. The communication module 150 can also receive signals to be transmitted from the processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via the antenna.

[0123] In some embodiments, the antenna of the terminal device 10 is coupled to the communication module 150, enabling the terminal device 10 to communicate with networks and other devices via wireless communication technologies. The wireless communication technologies may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies. The GNSS may include Global Positioning System (GPS), Global Navigation Satellite System (GLONASS), BeiDou Navigation Satellite System (BDS), Quasi-Zenith Satellite System (QZSS), and / or Satellite Based Augmentation Systems (SBAS).

[0124] Terminal device 10 implements display functions through a GPU, display screen 160, and application processor. The GPU is a microprocessor for image processing, connected to the display screen 160 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0125] The display screen 160 is used to display images, videos, etc. The display screen 160 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Miniled LED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the terminal device 10 may include one or N display screens 160, where N is a positive integer greater than 1.

[0126] The memory 120 can be used to store one or more computer programs, which include instructions. The processor 110 can execute the instructions stored in the memory 120, thereby enabling the terminal device 10 to perform various functional applications and data processing. The memory 120 may include a program storage area and a data storage area. The program storage area may store the operating system.

[0127] The storage data area can store data created during the use of the terminal device 10. Furthermore, the memory 120 can...

[0128] The device may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. In some embodiments, the processor 110 may cause the terminal device 10 to perform various functional applications and data processing by executing instructions stored in the memory 120 and / or instructions stored in the memory disposed in the processor 110.

[0129] Figure 9 This is a software structure block diagram of a terminal device provided in an embodiment of this application.

[0130] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer (Android Framework), the Android runtime and system libraries, and the kernel layer (Android Kernel).

[0131] The application layer can include a series of application packages.

[0132] Figure 9 As shown, the application layer includes application modules on the first application side and application modules within the Linux container. The first application is used for interaction between the Android system and the Linux container. Specifically, the first application mainly has two parts: input and output. The input part includes peripheral input such as keyboard, mouse, and touchscreen, as well as Android's input method and clipboard functions. The output part includes image display and audio output functions from the second application. The second application can be understood as a Linux application, for example, an office application such as Office or WPS. The Linux container runs in the target application's path. Specifically, the Linux container is a lightweight virtualization technology that encapsulates the second application and its dependent environment in an independent runtime environment, achieving application isolation and rapid deployment. In this application, the main functions of the Linux container are: running the second application, outputting image data, and receiving and processing input events sent by the first application.

[0133] It should be noted that the sandbox path for running Linux containers is implemented through proot, an open-source project that can create a new root file system in any directory and then use that root file system as the runtime environment for Linux applications (i.e., secondary applications).

[0134] Since the Linux container runs within the Android sandbox, the Android program can directly access the files in the container. Therefore, the output image data can be written to a file in the Linux container and then read from the image data file on the Android side. This method can greatly improve the image refresh efficiency.

[0135] For smaller data sets (such as input events, short text segments, and other simple commands), sockets are used for communication. Unlike network sockets, PC application engines use UDS (Unix Domain Sockets), an IPC (Inter-Process Communication) mechanism used on Unix and Unix-like systems. It provides an efficient and reliable way to transfer data and messages between processes on the same host. Unix domain sockets are generally faster and more secure than network sockets because data is transmitted directly within the host machine without being processed by the network protocol stack. Unix domain sockets are widely used in various applications, including web servers, database systems, and message queues.

[0136] The application framework layer provides an Application Programming Interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions.

[0137] Figure 9 As shown, the framework layer can include telephone framework, Bluetooth framework, and audio framework, etc.

[0138] The phone framework is used to manage the phone application. It can obtain the screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0139] The Bluetooth framework is used to provide Bluetooth functionality.

[0140] The audio framework is used to provide audio data.

[0141] The Android runtime consists of core libraries and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system.

[0142] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.

[0143] The application layer and framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0144] The hardware abstraction layer can include multiple functional modules, such as a call manager, Bluetooth manager, and audio manager.

[0145] The call manager is used to manage call functionality.

[0146] The Bluetooth manager is used to manage Bluetooth functionality.

[0147] The audio manager supports playback and recording of various common audio and video formats, as well as still image files. It also supports a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.

[0148] The driver layer is the layer between hardware and software. It includes at least display drivers, Bluetooth drivers, and audio drivers.

[0149] The following example illustrates the workflow of the software and hardware of terminal device 10, using an input event processing scenario as an example.

[0150] After acquiring maintenance information generated by the second communication device when a call abnormality occurs, the processor 110 determines, based on the abnormality cause data, that the abnormality type corresponding to the call abnormality cannot be directly obtained through the maintenance information. Based on the call stage corresponding to the call abnormality, if it is determined that a target call abnormality event corresponding to the call stage has occurred, the processor 110 determines the abnormality type corresponding to the call abnormality based on the target call abnormality event.

[0151] This application also provides a computer-readable storage medium including a stored program, wherein, when the program runs, it controls the device where the computer-readable storage medium is located to execute the above-described input event processing method. Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-readable program code.

[0152] This application also provides a computer program product, which includes a computer program that, when executed by a processor of an electronic device, causes the processor to perform the above-described input event processing method.

[0153] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0154] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0155] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0156] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0157] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0158] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0159] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0160] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. An input event handling method, characterized in that, A first application included in a target application within a mobile terminal, the target application comprising the first application located outside a Linux container and a second application located within a Linux container, including: By calling the interface for input event processing in the input method preprocessing stage, the input event triggered by the user is obtained. After obtaining the input event, the input method framework processes the input event in multiple processing stages in sequence and then sends it to the first application. The multiple processing stages include the input method preprocessing stage and the input method application processing stage performed in sequence. The input method preprocessing stage includes NativePreImeInputStage and ViewPreImeInputStage, and the input method application processing stage includes ImeInputStage, EarlyPostImeInputStage, NativePostImeInputStage, ViewPostImeInputStage, and SyntheticInputStage. If the input event is identified as a shortcut key input event, the shortcut key input event is sent to the second application for processing.

2. The method according to claim 1, characterized in that, If the input event is identified as a shortcut key input event, then the shortcut key input event is sent to the second application for processing, including: If the input event is identified as a shortcut key input event where a target key with a shortcut state is pressed, the shortcut key input event is sent to the second application for processing, and the encoding identifier of the target key is stored in the setting storage file.

3. The method according to claim 1, characterized in that, If the input event is identified as a shortcut key input event, then the shortcut key input event is sent to the second application for processing, including: If the input event is identified as a shortcut key input event where a target key associated with a shortcut state is released, the shortcut key input event is sent to the second application for processing, and the encoding identifier of the target key is deleted from the setting storage file, which is used to store the encoding identifier of a pressed key associated with a shortcut state.

4. The method according to any one of claims 1-3, characterized in that, Sending the shortcut key input event to the second application for processing includes: Extract the key information from the shortcut key input events; The key information is encapsulated; The encapsulated key information is sent to the second application using the configured socket method.

5. The method according to claim 4, characterized in that, Sending the encapsulated key information to the second application includes: The encapsulated key information is sent to the virtual screen component in the Linux container, so that the encapsulated key information can be sent to the second application through the virtual screen component.

6. The method according to claim 1, characterized in that, The method further includes: The input event is received by the input method framework after processing the input event through the input method application processing stage; If it is determined that the input event has been identified as the shortcut key input event, then the input event received from the input method framework is deleted.

7. The method according to claim 6, characterized in that, The method further includes: If the input event is determined to be a non-shortcut key input event, then the non-shortcut key input event is sent to the second application for processing.

8. The method according to claim 7, characterized in that, Sending the non-shortcut key input event to the second application for processing includes: If it is determined that the non-shortcut key input event is an English non-shortcut key input event, then the key information of the non-shortcut key input event is extracted, the key information is encapsulated, and the encapsulated key information is sent to the second application through the set socket method.

9. The method according to claim 7, characterized in that, Sending the non-shortcut key input event to the second application for processing includes: If it is determined that the non-shortcut key input event is a Chinese non-shortcut key input event, then the input content corresponding to the non-shortcut key input event is converted into a string; The converted string is sent to the Linux input method application in the Linux container via the set socket method, so that the converted string can be sent to the second application through the Linux input method application.

10. A terminal device, characterized in that, It includes a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the terminal device is triggered to execute the method of any one of claims 1-9.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method according to any one of claims 1-9.

12. A computer program product, characterized in that, include: A computer program, when executed by a processor of an electronic device, causes the processor to perform the method as described in any one of claims 1-9.

Citation Information

Patent Citations

  • Key processing method, device and apparatus and storage medium

    CN111381686A

  • Key event processing method and device, storage medium and terminal

    CN114489354A