Key mapping method based on android system mobile terminal

By designing multi-function physical entity keys on Android system mobile terminal devices and mapping them into virtual keys, using Android Framework to intercept and broadcast key events, the problem of traditional devices lacking flexible one-click triggering function is solved, and more efficient and reliable key event recognition and processing is achieved.

CN119988048APending Publication Date: 2025-05-13SHANDONG SENTER ELECTRONICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311494608.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-10
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

Traditional Android system mobile terminal devices lack flexible one-click triggering function. The existing technology is difficult to obtain physical key events, and file mapping methods lead to waste of resources and low key sensitivity.

Method used

By designing multi-function physical entity keys, mapping them into virtual keys, and intercepting key events in the Android Framework, publishing events through orderly broadcasts, application layer services register and listen and identify key events, triggering corresponding business functions.

Benefits of technology

It improves the accuracy and robustness of key recognition, simplifies key event recognition logic, avoids resource waste, and enhances the operability and interactivity of user equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119988048A_ABST
    Figure CN119988048A_ABST
Patent Text Reader

Abstract

The invention discloses a key mapping method based on an android system mobile terminal, and belongs to the field of communication. According to the method, the existing virtual key processing logic of the Android system is utilized, the physical key is monitored through virtual-real mapping, and the design concept of the Android system is better met. The key event is received in a broadcast mode, the logic of key event identification is simplified, and the precision is improved. Through orderly broadcasting, the transmission of the key event can be effectively controlled. The key event processing mode of the system is flexibly expanded, and the customizability and interactivity of the system are improved. Single-click, double-click and long-press events are recognized through an algorithm, tedious gesture recognition is avoided, and key event recognition is simpler and more reliable. By binding the predefined shortcut function with the physical key event, the user can quickly access the application function by triggering the physical key, so that the use experience of the user equipment is optimized, and the operability of the user on the equipment is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communications, and in particular to a key mapping method based on an Android system mobile terminal. Background Art

[0002] Traditional Android mobile devices do not have any physical buttons other than power and volume, and most operations on the device are triggered by the launcher touching the screen. This method lacks the flexibility of one-touch triggering.

[0003] In some implementations, physical key events are captured and logic is processed in the kernel key driver. This method is inflexible and difficult to obtain APIs that implement related business logic.

[0004] In other implementations, the physical key events are captured in the kernel layer key driver, and the key events are mapped to a sys file node. The Android application layer starts a service to poll and read the file node to obtain the key events. This method of using file mapping and starting service polling to obtain key events requires the service to run for a long time and conduct real-time polling detection, and the sensitivity of the key is affected by the inspection time granularity, which wastes resources. Summary of the invention

[0005] The present invention provides a key mapping method based on an Android system mobile terminal, which improves recognition accuracy and robustness.

[0006] The present invention provides the following technical solutions:

[0007] A key mapping method based on an Android system mobile terminal, comprising:

[0008] S1: Design a multifunctional physical entity key, and map the multifunctional physical entity key to a virtual key on an Android device;

[0009] S2: When the multifunctional physical entity key is triggered, the key event is intercepted in the Android Framework and the key event is published through orderly broadcasting;

[0010] S3: the application layer service registers and listens to the ordered broadcast, recognizes the key event after receiving the ordered broadcast, and publishes the recognized key message;

[0011] S4: receiving a key message, and triggering the business function corresponding to the key event of the key message according to the predefined binding relationship between the key event and the business function.

[0012] Further, the S1 includes:

[0013] S11: Design a multifunctional physical button, accurately define each physical pin and related information of the multifunctional physical button, and add a corresponding node for each multifunctional physical button;

[0014] S12: Mapping the pins of the multi-function physical key to corresponding key values ​​by modifying the configuration of the specific input subsystem, and ensuring that the selected key value matches the virtual key to be simulated;

[0015] S13: Capture physical key events in the key driver, and use key mapping to trigger the Android system to perceive virtual key events.

[0016] Further, the S2 includes:

[0017] S21: Modify the interceptKeyBeforeDispatching method in the PhoneWindowManager class and add monitoring for the corresponding virtual keys;

[0018] S22: Add an ordered broadcast to transmit the intercepted virtual key events to the external system.

[0019] Further, the S3 includes:

[0020] S31: The application layer starts the service, registers to listen to the ordered broadcast, sets the broadcast reception priority to 1000, and stops the transmission operation after receiving the ordered broadcast;

[0021] S32: Use algorithms to recognize single-click, double-click, and long-press events, and publish recognized key messages.

[0022] Further, the S32 includes:

[0023] Determine whether it is the first press. If so, record the current time, reset the relevant status, and record the time of the first press;

[0024] If it is determined that it is not the first press, the long press event judgment logic is entered, and the long press event judgment logic includes: judging whether a long press occurs according to a set long press time threshold, and if it occurs, triggering a key message corresponding to the long press event;

[0025] Record the current press and pop-up time, and compare the difference between the last pop-up time and the current press time with the set time difference to determine whether it is a double-click event. If it is a double-click event, trigger the key message corresponding to the double-click event and reset the single-click event timer T; if it is not a double-click event and no second press is detected within the time threshold set by the single-click event timer T, it is judged as a single-click event, trigger the key message corresponding to the single-click event, and reset the single-click detection timer T.

[0026] Further, the S4 includes:

[0027] S41: defining a list of pre-implemented quick trigger service functions, and implementing respective activation or action triggering methods for the functions in the function list;

[0028] S42: Use a mapping table to record the binding relationship between the key events and the business functions;

[0029] S43: receiving a key message, and triggering a business function corresponding to the key event of the key message according to a predefined binding relationship between the key event and the business function.

[0030] The present invention has the following beneficial effects:

[0031] The present invention utilizes the existing processing logic of virtual keys in the Android system, and realizes the monitoring of physical keys through virtual-real mapping, which is more in line with the design concept of the Android system. The key events are received by broadcasting, which simplifies the logic of key event recognition and improves the accuracy. Through orderly broadcasting, the transmission of key events can be effectively controlled. The system's processing method for key events is flexibly expanded to improve the customizability and interactivity of the system. By identifying single-click, double-click and long-press events through algorithms, cumbersome gesture recognition is avoided, and key event recognition is simpler and more reliable. By binding predefined shortcut functions with physical key events, users can quickly access application functions by triggering physical keys, thereby optimizing the user experience of the user's device and enhancing the user's operability of the device.

[0032] The present invention is more in line with the design concept of the Android system, solves the difficulty of directly obtaining the service API from the kernel layer, and simplifies the complex logic and low precision of key event recognition of polling file nodes, making key event recognition simpler and more reliable. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 The present invention is a flowchart of a key mapping method based on an Android system mobile terminal. DETAILED DESCRIPTION

[0034] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.

[0035] The embodiment of the present invention provides a key mapping method based on an Android system mobile terminal, such as Figure 1 As shown, the method includes:

[0036] S1: Design multi-function physical buttons and map them to virtual buttons on Android devices.

[0037] In an example, the specific implementation of this step includes:

[0038] S11: This step is used for device tree configuration, including: designing a multi-function physical entity button, accurately defining each physical pin and related information of each multi-function physical entity button in the device, and adding a corresponding node for each multi-function physical entity button.

[0039] S12: This step is used for key value mapping, including: mapping the pins of the multi-function physical entity keys to corresponding key values ​​by modifying the configuration of the specific input subsystem, and ensuring that the selected key value matches the virtual key to be simulated.

[0040] Taking the virtual key F12 as an example, the physical key is mapped to the key code KEYCODE_F12 predefined by the Android system through the configuration file.

[0041] S13: Capture physical key events in the key driver, and use key mapping to trigger the Android system to perceive virtual key events.

[0042] Through the above steps, the mapping between physical keys and virtual keys can be achieved, so that the user can trigger the corresponding virtual key event through the physical key.

[0043] S2: When the multi-function physical entity button is triggered, the button event is intercepted in the Android Framework and published through orderly broadcasting.

[0044] Taking the virtual key F12 as an example, S2 includes:

[0045] S21: Modify the interceptKeyBeforeDispatching method in the PhoneWindowManager class and add a listener for the corresponding virtual key F12 code creation.

[0046] S22: Add a customized ordered broadcast to transmit the intercepted key event of the virtual key F12 to an external system. In this embodiment, the ordered broadcast is referred to as B1.

[0047] Through the above steps, the system can monitor the virtual key F12 and pass the event to other components or modules for further processing through orderly broadcast. This can flexibly expand the system's processing method for key events and improve the system's customizability and interactivity.

[0048] S3: The application layer service registers to listen to the ordered broadcast. After receiving the ordered broadcast, it recognizes the key events and publishes the recognized key messages.

[0049] As an example, the specific implementation of this step includes:

[0050] S31: The application layer starts service S1, registers to listen to the ordered broadcast B1, sets the broadcast reception priority to 1000, and stops the transmission operation after receiving the ordered broadcast B1, thus realizing the absolute priority control of the broadcast B1.

[0051] S32: Use algorithms to recognize single-click, double-click, and long-press events, and publish recognized key messages.

[0052] In this embodiment, the calculation and recognition of key events uses three parameters: key repetition count, key code, and action type event. Specifically, they include:

[0053] 1. Determine whether it is the first press (repeatCount==0&&event==0). If so, record the current time, reset the relevant status, and record the time of the first press tClickNowDown.

[0054] 2. If it is determined that it is not the first press, enter the long press event judgment logic (repeatCount!=0). The long press event judgment logic includes: judging whether a long press occurs according to the set long press time threshold (PRESS_LONG_TIME) (when the duration is greater than the threshold and the press flag is false, it is judged that a long press event occurs). If it occurs, the key message B2_Long corresponding to the long press event is triggered; if the condition is not met, it is silent.

[0055] 3. Record the bounce-up (up) time tUpLastTime of the last key press, the current up time tClickNowUp, the current key press (Down) time tClickNowDown, and the current key press timing tdownSum for use in double-click event determination. Determine whether it is a double-click event based on the set time difference (tClickNowDown - tUpLastTime < DOUBLE_CLICK_TIME_DELTA && tdownSum == 0 && tClickNowUp - tClickNowDown < PRESS_LONG_TIME). If it is a double-click event, trigger the key message B2_Double corresponding to the double-click event and reset the single-click event timer T. If it is not a double-click event and no second press is detected within the time threshold DOUBLE_CLICK_TIMEOUT of the single-click event timer T, it is determined as a single-click event, trigger the key message B2_Single corresponding to the single-click event, and reset the single-click timer T at the same time.

[0056] S4: Receive the key message and trigger the service function corresponding to the key event of the key message according to the predefined binding relationship between the key event and the service function.

[0057] Specifically, S4 includes:

[0058] S41: Define a list of service functions for pre-implemented quick triggers and implement their respective opening or action trigger methods for the functions in the function list.

[0059] The function list in this embodiment includes functions that are commonly used by users and are expected to be quickly opened, and these functions register to listen for wake-up messages in advance. Specifically, it includes: turning on Ethernet card 1, turning on Ethernet card 2, turning on wifi, turning on gps, turning on the flashlight, turning on the QR code scanner, turning on a certain preset application, turning on the quick border bar, etc. This is not limited to this, and the function list can be customized according to user needs.

[0060] S42: Use the mapping table map to record the binding relationship between the key event and the service function.

[0061] S43: Receive the key message B2 and trigger the service function corresponding to the key event of the key message according to the predefined binding relationship between the key event and the service function, to implement the physical key to quickly trigger the service logic function.

[0062] The present invention utilizes the existing processing logic of virtual keys in the Android system, and realizes the monitoring of physical keys through virtual-real mapping, which is more in line with the design concept of the Android system. The key events are received by broadcasting, which simplifies the logic of key event recognition and improves the accuracy. Through orderly broadcasting, the transmission of key events can be effectively controlled. The system's processing method for key events is flexibly expanded to improve the customizability and interactivity of the system. By identifying single-click, double-click and long-press events through algorithms, cumbersome gesture recognition is avoided, and key event recognition is simpler and more reliable. By binding predefined shortcut functions with physical key events, users can quickly access application functions by triggering physical keys, thereby optimizing the user experience of the user's device and enhancing the user's operability of the device.

[0063] The present invention is more in line with the design concept of the Android system, solves the difficulty of directly obtaining the service API from the kernel layer, and simplifies the complex logic and low precision of key event recognition of polling file nodes, making key event recognition simpler and more reliable.

[0064] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A key mapping method based on an Android system mobile terminal, characterized in that: include: S1: Design a multifunctional physical entity key, and map the multifunctional physical entity key to a virtual key on an Android device; S2: When the multifunctional physical entity key is triggered, the key event is intercepted in the Android Framework and the key event is published through orderly broadcasting; S3: the application layer service registers and listens to the ordered broadcast, recognizes the key event after receiving the ordered broadcast, and publishes the recognized key message; S4: receiving a key message, and triggering the business function corresponding to the key event of the key message according to the predefined binding relationship between the key event and the business function.

2. The key mapping method based on the Android system mobile terminal according to claim 1 is characterized in that: The S1 includes: S11: Design a multifunctional physical button, accurately define each physical pin and related information of the multifunctional physical button, and add a corresponding node for each multifunctional physical button; S12: Mapping the pins of the multi-function physical key to corresponding key values ​​by modifying the configuration of the specific input subsystem, and ensuring that the selected key value matches the virtual key to be simulated; S13: Capture physical key events in the key driver, and use key mapping to trigger the Android system to perceive virtual key events.

3. The key mapping method based on the Android system mobile terminal according to claim 2 is characterized in that: The S2 includes: S21: Modify the interceptKeyBeforeDispatching method in the PhoneWindowManager class and add monitoring for the corresponding virtual keys; S22: Add an ordered broadcast to transmit the intercepted virtual key events to the external system.

4. The key mapping method based on the Android system mobile terminal according to claim 3 is characterized in that: The S3 includes: S31: The application layer starts the service, registers to listen to the ordered broadcast, sets the broadcast reception priority to 1000, and stops the transmission operation after receiving the ordered broadcast; S32: Use algorithms to recognize single-click, double-click, and long-press events, and publish recognized key messages.

5. The key mapping method based on the Android system mobile terminal according to claim 4 is characterized in that: The S32 includes: Determine whether it is the first press. If so, record the current time, reset the relevant status, and record the time of the first press; If it is determined that it is not the first press, the long press event judgment logic is entered, and the long press event judgment logic includes: judging whether a long press occurs according to a set long press time threshold, and if it occurs, triggering a key message corresponding to the long press event; Record the current press and pop-up time, and compare the difference between the last pop-up time and the current press time with the set time difference to determine whether it is a double-click event. If it is a double-click event, trigger the key message corresponding to the double-click event and reset the single-click event timer T; if it is not a double-click event and no second press is detected within the time threshold set by the single-click event timer T, it is judged as a single-click event, trigger the key message corresponding to the single-click event, and reset the single-click detection timer T.

6. The key mapping method based on the Android system mobile terminal according to claim 4 or 5, characterized in that: The S4 includes: S41: defining a list of pre-implemented quick trigger service functions, and implementing respective activation or action triggering methods for the functions in the function list; S42: Use a mapping table to record the binding relationship between the key events and the business functions; S43: receiving a key message, and triggering a business function corresponding to the key event of the key message according to a predefined binding relationship between the key event and the business function.