Search

CN-121996442-A - Method for remotely operating Android terminal hardware function keys based on virtual keyboard equipment

CN121996442ACN 121996442 ACN121996442 ACN 121996442ACN-121996442-A

Abstract

The invention discloses a method for remotely operating Android terminal hardware function keys based on virtual keyboard equipment, which belongs to the field of automatic testing, and comprises the steps of presetting custom function keys for equipment terminal A, writing corresponding mapping files, loading a virtual equipment management module to create a virtual keyboard, loading an HTTP server module, sending a network request event B to the HTTP server module by a user, finding out a key name and a scanning code corresponding to the event B, packaging the scanning code as a key event C, writing the key event C into the virtual keyboard, finally loading a key event processing module, reading the key event C written into the virtual keyboard and an event D written by driving the hardware key keyboard corresponding to the virtual keyboard, broadcasting to related application software, and triggering corresponding functions according to the key type after the application software receives broadcasting. The invention realizes automatic testing of the terminal.

Inventors

  • LIU JIANBING
  • FENG BO
  • YIN LI
  • SHANG YINZHONG
  • GAO FENG
  • ZHU HAIBO
  • JIANG RUI
  • SONG JUPO
  • LIU YONGHUI

Assignees

  • 北京方位智联科技有限公司

Dates

Publication Date
20260508
Application Date
20260123

Claims (5)

  1. 1. The method for remotely operating the Android terminal hardware function keys based on the virtual keyboard equipment is characterized by comprising the following steps: Firstly, aiming at an Android device terminal A, presetting a user-defined function key by a manufacturer, and writing a corresponding mapping file; mapping file, which is a text file containing key keywords, scan codes corresponding to hardware keys and key names, wherein each row corresponds to one hardware key; loading a virtual equipment management module on the terminal A, and creating a virtual keyboard through the virtual equipment management module; The specific process is as follows: step 201, calling open statement to create file descriptor fd of virtual keyboard, the statement is as follows: open("/dev/uinput", O_WRONLY | O_NONBLOCK) Step 202, constructing an ioctl sentence to set a key event type and a synchronous event supported by a virtual keyboard, and transmitting the key event type and the synchronous event to a file descriptor fd; ioctl(fd, UI_SET_EVBIT, EV_KEY) ioctl(fd, UI_SET_EVBIT, EV_SYN) Step 203, each custom function key invokes statement ioctl respectively, sets a key code corresponding to the custom function key on the virtual keyboard, and transmits the key code to the file descriptor fd; the statement called is ioctl ((fd, ui_set_key_speed); key_SPEAKER is a custom KEY code constant; Step 204, creating uinput _setup type structure variables usetup, and sequentially writing in the attributes of the virtual keyboard; step 205, call statement ioctl (fd, ui_dev_setup, & usetup) passes the structure variables usetup to the file descriptor fd; step 206, calling statement ioctl (fd, ui_dev_create) to CREATE a virtual keyboard; loading an HTTP server module on the terminal A, and sending a network request event B to the HTTP server module by a user; The network request event B comprises a URL of a user-defined function key name, wherein the URL comprises an IP address of the terminal A and the name of the user-defined key; Step four, the HTTP server module finds out the key name and the scanning code corresponding to the event B according to the mapping file, packages the scanning code into a key event C and writes the key event C into the virtual keyboard; the HTTP server module monitors the port of the equipment terminal A, analyzes the URL in the request event B, and obtains the custom key name contained in the URL; then, the mapping file is read row by row, the corresponding key name is found, the character string is used as the key of the key value pair, and the scanning code behind the key name is used as the value of the key value pair; Finally, creating a key event C, taking the type of the key event in the virtual keyboard as the type of the key event C, and writing the type of the key event C into a key value stored in a hash table; Loading a key event processing module on the terminal A, reading a key event C written in the virtual keyboard and an event D written in a hardware key keyboard drive corresponding to the virtual keyboard; And step six, the key event processing module transmits the event C or D to related application software in an Android broadcast mode, and the application software triggers corresponding functions according to the key types after receiving the broadcast.
  2. 2. The method of claim 1, wherein in the first step, the custom function key is a hardware key included in a non-standard keyboard, including an mute key, a handsfree key, or a redial key.
  3. 3. The method of claim 1, wherein the attributes in step 204 include a bus type of the virtual keyboard, a manufacturer ID of the virtual keyboard, a custom virtual keyboard ID, and a virtual keyboard name.
  4. 4. The method of claim 1, wherein in the step six, the key EVENT processing module receives the key EVENT C or D, encapsulates the scan code, the key press state and the key long press state into a newly created Android broadcast message E, carries a com.fv.aex.device.action.key_event broadcast action, and distributes the message E to application software monitoring the action in a form of Android broadcast.
  5. 5. The method of claim 4, wherein the application software is software that registers com.fv.aex.device.action.key_event action listeners with an Android system; After receiving the message E containing the above actions, the Android system calls onReceive (Context: context? Intent? triggering a hardware key or a key corresponding to the virtual keyboard according to the key event type, thereby triggering a corresponding function; keyCode is the value of the scan code.

Description

Method for remotely operating Android terminal hardware function keys based on virtual keyboard equipment Technical Field The invention belongs to the field of automatic testing, and particularly relates to a method for remotely operating Android terminal hardware function keys based on virtual keyboard equipment. Background With the continuous progress of network terminal technology, the functions of the network terminal are becoming diversified. In order to simplify the user operation in case of complicated product functions, manufacturers often add hardware keys for quick triggering functions on the network terminal device. The traditional terminal test flow is usually highly dependent on manual operation, so that a large amount of time and manpower resources are consumed, the terminal test flow is easily influenced by personal differences of operators, fatigue and other human factors, and the accuracy and reliability of test results are difficult to fully guarantee. Therefore, in order to effectively reduce the uncertainty introduced by manual key operation and remarkably improve the overall test efficiency, a set of method capable of automatically simulating the hardware key action is urgently required to be introduced so as to realize the automation and standardization of the test flow. The hardware keys of the terminal are generally mapped into one or several device nodes in the Android system. Therefore, a virtual keyboard device similar to the hardware keys is created in the system, and a custom key mapping table file is compiled, so that hardware function keys beyond the conventional keyboard can be flexibly simulated. Furthermore, HTTP service is introduced, so that a network request event initiated by a manager or a tester drives a virtual keyboard to send a key event, namely, a method for remotely operating hardware keys on network terminal equipment is realized, software function test and hardware key test can be separated, and accurate positioning of related developers is facilitated. In addition, it is convenient for the tester to operate a plurality of tested devices in parallel, and the workload of the tester is effectively reduced. Disclosure of Invention Aiming at the problems existing in the prior art, the invention provides a method for remotely operating Android terminal hardware function keys based on virtual keyboard equipment. The functions of custom keys and remote trigger keys are realized by converting the HTTP request into hardware key operation logic. The user not only avoids the trouble of searching hardware keys on the terminal, but also provides convenience for the subsequent parallel operation of a large number of terminals and the realization of automatic test of the terminals. The method for remotely operating the Android terminal hardware function keys based on the virtual keyboard equipment comprises the following specific steps: Firstly, aiming at an Android device terminal A, presetting a user-defined function key by a manufacturer, and writing a corresponding mapping file; The custom function key is a hardware key contained in a non-standard keyboard and comprises an mute key, a hands-free key or a redial key. Mapping file, which is a text file containing key keywords, scan codes corresponding to hardware keys and key names, wherein each row corresponds to one hardware key. Loading a virtual equipment management module on the terminal A, and creating a virtual keyboard through the virtual equipment management module; The specific process is as follows: step 201, calling open statement to create file descriptor fd of virtual keyboard, the statement is as follows: open("/dev/uinput", O_WRONLY | O_NONBLOCK) Step 202, constructing an ioctl sentence to set a key event type and a synchronous event supported by a virtual keyboard, and transmitting the key event type and the synchronous event to a file descriptor fd; ioctl(fd, UI_SET_EVBIT, EV_KEY) ioctl(fd, UI_SET_EVBIT, EV_SYN) Step 203, each custom function key invokes statement ioctl respectively, sets a key code corresponding to the custom function key on the virtual keyboard, and transmits the key code to the file descriptor fd; the statement called is ioctl ((fd, ui_set_key_speed); The key_SPEAKER is a custom constant and comprises a KEY code corresponding to a hands-free KEY or a KEY code corresponding to an mute KEY; Step 204, creating uinput _setup type structure variables usetup, and sequentially writing in the attributes of the virtual keyboard; The attributes include the bus type of the virtual keyboard, the manufacturer ID of the virtual keyboard, the custom virtual keyboard ID, and the virtual keyboard name. Step 205, call statement ioctl (fd, ui_dev_setup, & usetup) passes the structure variables usetup to the file descriptor fd; step 206, call statement ioctl (fd, ui_dev_create) CREATEs a virtual keyboard. Loading an HTTP server module on the terminal A, and sending a network request event B to the HTTP ser