WO2025232012A1 - Method for sharing input content among multiple systems, mobile terminal and storage medium - Google Patents
Method for sharing input content among multiple systems, mobile terminal and storage mediumInfo
- Publication number
- WO2025232012A1 WO2025232012A1 PCT/CN2024/110107 CN2024110107W WO2025232012A1 WO 2025232012 A1 WO2025232012 A1 WO 2025232012A1 CN 2024110107 W CN2024110107 W CN 2024110107W WO 2025232012 A1 WO2025232012 A1 WO 2025232012A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- input
- file
- external system
- content
- input method
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/62—Protecting access to data via a platform, e.g. using keys or access control rules
- G06F21/6218—Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
- G06F21/6245—Protecting personal data, e.g. for financial or medical purposes
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/01—Input arrangements or combined input and output arrangements for interaction between user and computer
- G06F3/02—Input arrangements using manually operated switches, e.g. using keyboards or dials
- G06F3/023—Arrangements for converting discrete items of information into a coded form, e.g. arrangements for interpreting keyboard generated codes as alphanumeric codes, operand codes or instruction codes
- G06F3/0233—Character input methods
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/449—Object-oriented method invocation or resolution
Definitions
- This invention relates to Android virtual system technology, and more particularly to a method, mobile terminal, and storage medium for sharing the same input method input content between multiple systems inside and outside Android.
- this privacy information may actually lead to a connection between the external and internal systems, potentially exposing the actual users of the virtual system and rendering the privacy of the Android virtual system meaningless.
- the main objective of this invention is to provide a method, mobile terminal, and storage medium for sharing input content among multiple systems, so that the Android virtual system can share the input method of an external system to input content, thereby avoiding the establishment of privacy information associations between different systems due to input methods.
- a method for sharing input content among multiple systems comprising the steps of:
- An empty shell input method is pre-installed in the internal system.
- An Epoll instance is created in the external system to listen for and modify the empty shell input method's initiation event, so as to call the external system API to launch the external system input method.
- An input file is created on an external system to store the content entered by the external system's input method.
- the input file is then mapped to shared memory using the mmap method.
- the internal system reads the input file in shared memory, obtains the input content, and passes it to the empty shell input method; the empty shell input method calls the internal system's input method framework to interact with the input content.
- an Epoll instance is created on an external system to listen for and modify the empty shell input method to initiate.
- the steps involved in triggering an external system input method by calling an external system API include:
- Files can be created and manipulated using Java's File class, and the file descriptor of the empty shell input method's initiation event can be obtained through either the FileInputStream or FileOutputStream class.
- the system listens for changes to the input method via an internal system broadcast receiver.
- the input method package name obtained from the broadcast is determined to be an empty shell input method, and the current broadcast contains an input method initiation event, the current file descriptor is modified accordingly.
- the Epoll_wait function When the Epoll_wait function detects that the file descriptor of the empty input method that was previously registered with Epoll has undergone a signature modification, it calls the external system API to launch the external system input method.
- the steps of creating an input file on an external system to store the content input by the external system's input method, and mapping the input file to shared memory using the mmap method include:
- the input file is mapped into shared memory using the MappedByteBuffer method
- the step of the internal system reading the input file in shared memory to obtain the input content includes:
- a method for sharing input content among multiple systems comprising the steps of:
- An empty shell input method is pre-installed in the internal system.
- An Epoll instance is created in the external system to listen for and modify the empty shell input method's initiation event, so as to call the external system API to launch the external system input method.
- An input file is created on an external system to store the content input by the external system's input method after dictionary encoding.
- the input file is then mapped to shared memory using the mmap method.
- the internal system reads the input file from shared memory, decodes the input content, and passes it to the empty shell input method; the empty shell input method calls the internal system's input method framework to interact with the input content.
- an input file is created on an external system and stored according to dictionary encoding.
- the steps for mapping the input file from the system's input method to shared memory using the mmap method include:
- the input file is mapped into shared memory using the MappedByteBuffer method
- the input content in its input box is encoded according to a dictionary and then directly written to the input file in shared memory using the put() method of MappedByteBuffer.
- the steps of the internal system reading the input file from shared memory and decoding the input content further include:
- MappedByteBuffer Use the MappedByteBuffer method to read the encoded input content and decode it using a dictionary to restore the original text input content.
- the steps of creating an Epoll instance in the external system to listen for and modify the empty shell input method initiation event, in order to call the external system API to launch the external system input method include:
- Files can be created and manipulated using Java's File class, and the file descriptor of the empty shell input method's initiation event can be obtained through either the FileInputStream or FileOutputStream class.
- the system listens for changes to the input method via an internal system broadcast receiver.
- the input method package name obtained from the broadcast is determined to be an empty shell input method, and the current broadcast contains an input method initiation event, the current file descriptor is modified accordingly.
- the Epoll_wait function When the Epoll_wait function detects that the file descriptor of the empty input method that was previously registered with Epoll has undergone a signature modification, it calls the external system API to launch the external system input method.
- a mobile terminal comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the system implements the steps of the method for sharing input content among multiple systems as described above.
- a computer-readable storage medium is also provided, the computer-readable storage medium storing a computer program, wherein when the computer program is executed, it implements the steps of the method for sharing input content between multiple systems as described above.
- the method, mobile terminal, and storage medium for sharing input content between multiple systems solve the problem of transmission
- the Android platform addresses the issue of internal systems not being able to share input methods with external systems, thus preventing the establishment of privacy information associations between systems based on input methods and providing better privacy protection for internal systems. Furthermore, since internal systems will no longer need to install input methods independently, the possibility of loading malicious functions or monitoring user behavior through input methods is curbed, further enhancing the security of the Android virtual system.
- Figure 1 is a schematic diagram of the steps of the method for sharing input content among multiple systems according to the present invention
- Figure 2 is a schematic diagram illustrating the concept of the method for sharing input content among multiple systems according to the present invention
- Figure 3 is a schematic diagram of the Epoll concept of the method for sharing input content among multiple systems according to the present invention
- Figure 4 is a schematic diagram of the implementation framework of the method for sharing input content among multiple systems according to the present invention.
- this invention attempts to listen for input method initiation events in the internal system (virtual system) by creating an Epoll instance on the external Android system.
- the internal system application wants to retrieve the input method for input, it invokes the empty shell input method installed on the internal system. Simultaneously, when the empty shell input method is invoked, it modifies the file containing the internal input method initiation event.
- the Epoll function is triggered to handle the input method initiation event.
- the system API is used to invoke its own input method. After input is completed, the input content is mapped to a specific address space of the process via mmap, achieving content sharing so that the internal system can also access the input content, thus completing the input method input loop.
- the present invention provides a method for sharing input content among multiple systems, the example steps of which include:
- Step S100 A shell input method is pre-configured in the internal system.
- An Epoll instance is created in the external system to listen for and modify the shell input method's initiation event, so as to call the external system API to launch the external system input method.
- the internal system's empty shell input method is an input method that does not have a specific input function. It only exists as an input method service within the system. For example, an input method can only bring up the input method interface.
- the example steps include:
- Step S110 creates an Epoll instance on the external system and creates an Epoll handle using the Epoll_create function.
- Epoll is an improved version of poll in the Linux kernel for handling large numbers of file descriptors. It is an enhanced version of the select/poll multiplexed I/O interface in Linux, which can significantly improve the system CPU utilization when only a small number of connections are active amidst a large number of concurrent connections. Furthermore, when acquiring events, it does not need to traverse the entire set of monitored descriptors; it only needs to traverse the set of descriptors that have been asynchronously awakened by kernel I/O events and added to the Ready queue.
- Epoll has two operating modes: LT (level triggered) and ET (edge-triggered).
- LT is the default mode and supports both blocking and non-blocking sockets.
- the kernel notifies a file descriptor whether it is ready, and then I/O operations can be performed on that ready file descriptor. If no operation is performed, the kernel will continue to notify.
- ET edge-triggered is a high-speed mode that only supports non-blocking sockets.
- the kernel notifies it via Epoll and will not send any more ready notifications for that file descriptor until some operation causes it to no longer be ready (e.g., during transmission, reception, or).
- An EWOULDBLOCK error occurs when the receiver fails to receive a request or when the amount of data sent and received is less than a certain amount. This can be simply understood as LT being level-triggered and ET being edge-triggered.
- Step S120 uses Java's File class to create and manipulate files, and obtains the file descriptor of the empty input method's initiation event using either the FileInputStream or FileOutputStream class.
- Example code logic is as follows:
- FileInputStreaminputStream new FileInputStream(customFile);
- Step S130 registers the file descriptor for the empty shell input method's initiation event with Epoll to listen for the event.
- Example code logic is as follows:
- EpollEvent event new EpollEvent()
- Step S140 listens for the ACTION_INPUT_METHOD_CHANGED (input method has been changed) broadcast through the internal system broadcast receiver.
- the input method package name obtained from the broadcast is determined to be an empty shell input method, and the input method initiation event is heard in the current broadcast, the current file descriptor is modified for identification.
- the internal system's input method cannot perform input functionality, after the internal system detects that the user wants to activate the input method, it modifies the file set in step S120. For example, it modifies the content class to change the input method mode, writing "inputmethodMode:open" into it. In fact, only this modification is needed.
- This created file is essentially just a record of an identifier and does not record the actual input content.
- this example uses the method described above to allow external systems to monitor the state of this file. This is equivalent to determining the state of the internal system's input method through modifications to the file, thus serving as a means of transmission of the monitoring information.
- the example code logic is as follows:
- Step S150 When the Epoll_wait function detects that the file descriptor of the empty shell input method launch event that was previously registered in Epoll has undergone a distinctive modification, it calls the external system API to launch the external system input method.
- the ⁇ Epoll_wait ⁇ function listens for a file. Internally, the system broadcasts a message indicating that the user's input method is modifying the file specified in step S120. Externally, the ⁇ Epoll ⁇ function registers the file descriptor for this file in step S130. Therefore, after step 140, when the specified file is changed, the external ⁇ Epoll_wait ⁇ function can detect the change and send a feedback.
- Example code logic is as follows:
- the Epoll_wait listener function detects that the system has modified the file for the input method invocation event, the Epoll handler function will be triggered, and the input method will be launched in the handler function.
- InputMethodManager imm (InputMethodManager)
- Step S200 creates an input file on the external system to store the content input by the external system's input method, and maps the input file to shared memory using the mmap method.
- mmap is a memory-mapped file method that maps a file or other object into the process's address space, establishing a one-to-one mapping between the file's disk address and a segment of virtual addresses in the process's virtual address space. After establishing this mapping, the process can read and write to this memory segment using pointers, and the system automatically writes dirty pages back to the corresponding file on disk, thus completing file operations without needing to call system calls like read and write. Conversely, modifications to this region in kernel space are directly reflected in user space, enabling file sharing between different processes.
- this example includes the following steps:
- Step S210 uses the FileOutputStream method to create an input file on an external system. This input file is used to store the specific input content of the input method.
- Example code logic is as follows:
- FileOutputStream fileOutputStream new FileOutputStream(FILE_PATH,true).
- Step S220 maps the input file to shared memory using the MappedByteBuffer method to enable read and write operations in memory.
- MapMode is set to READ_WRITE.
- Example code logic is as follows:
- FileChannel channel fileOutputStream.getChannel()
- MappedByteBuffer buffer channel.map(FileChannel.MapMode.READ_WRITE,0,FILE_SIZE).
- the input box that actually displays the content is in the internal Android system, after the input method is invoked in the external system, an input box needs to exist in the external system to receive the input content, and then the content is stored in the created input file.
- Step S230 When the external system input method is invoked, the input content in its input box is directly written to the input file in shared memory through the put() method of MappedByteBuffer.
- Chinese characters are a complex character set, and machines cannot directly recognize them because they can only recognize binary data, which can easily lead to garbled characters.
- Chinese characters typically require more memory space to store because they occupy twice as many bytes as a single character. Writing large amounts of Chinese character data into memory can lead to excessive memory usage, thereby affecting system performance and stability.
- Processing Chinese characters is generally more complex than processing English letters because Chinese characters may contain complex structures, polyphonic characters, and other characteristics. Therefore, when processing Chinese characters, more linguistic and cultural features need to be considered to ensure the correct processing and display of Chinese character data.
- the input content can be encoded and stored. That is, when an external system input method is invoked, the input content in its input box is encoded according to a dictionary, and then directly written to the input file in shared memory using the ⁇ put() ⁇ method of ⁇ MappedByteBuffer ⁇ .
- text data is generally stored and transmitted in digital form.
- Character encoding maps Chinese characters and letters to numbers, making it easy to store text in computer memory for transmission.
- Transmitting text and numbers directly within the system can lead to garbled characters or incorrect parsing.
- Directly transmitting large amounts of text data can consume significant system resources and network bandwidth, impacting system performance and response speed. This is especially true in the context of frequent reading and writing as an input method in this invention, where it is crucial to ensure that text data is accurately represented, processed, and transmitted within the computer system.
- Unicode is first used to represent Chinese characters using numerical encoding.
- Unicode is a character encoding used on computers that assigns a unique binary code to each character in every language to meet the requirements of cross-language and cross-platform text conversion and processing.
- Unicode uses the numbers 0-0x10FFFF to map these characters, and can hold a maximum of 1,114,112 characters, or 1,114,112 code points.
- a code point is a number that can be assigned to a character.
- the Unicode codes for " ⁇ " are 20320 and 22909. After obtaining the Unicode numbers for the text, the numbers are converted by the program using the following conversion method:
- step S300 the internal system reads the input file in the shared memory, obtains the input content, and passes it to the empty shell input method; the empty shell input method calls the internal system input method framework to interact with the input content.
- the internal Android system's steps for obtaining input content include:
- Step S310 uses the FileOutputStream method to open the input file in shared memory.
- Example code logic is as follows:
- FileOutputStream fileOutputStream new FileOutputStream(FILE_PATH,true).
- Step S320 uses the get() method of MappedByteBuffer to obtain the input content.
- Chinese character decoding can be performed after reading the input content.
- the encoded byte sequence is converted to binary form.
- the first byte is read, and the binary sequence is parsed according to the encoding rules. Specifically, the number of bytes for the character is determined by the leading bit of the first byte. Then, based on the leading bit of the first byte, subsequent bytes are read sequentially. Each byte is assembled into the corresponding binary encoding value for the character. Finally, the corresponding Chinese character is found by referring to the Unicode dictionary table based on the encoding value, thus restoring the original input text content.
- the present invention also provides a mobile terminal, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the system implements the steps of the method for sharing input content between multiple systems as described above.
- the present invention also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed, it implements the steps of the method for sharing input content between multiple systems as described above.
- the method, mobile terminal, and storage medium for sharing input content between multiple systems solve the problem that internal systems on the traditional Android platform cannot share input methods from external systems. This avoids establishing privacy information associations between systems based on input methods, thereby providing better privacy protection for internal systems. Furthermore, since internal systems no longer need to install input methods independently, the possibility of loading malicious functions and monitoring user behavior through input methods is curbed, further enhancing the security of the Android virtual system.
- system, apparatus, unit, and its modules provided by this invention can be considered a hardware component, and the modules included therein for implementing various programs can also be considered structures within the hardware component; alternatively, modules for implementing various functions can be considered both software programs implementing the method and structures within the hardware component.
- All or part of the steps in the methods described in the above embodiments can be implemented by a program instructing related hardware.
- This program is stored in a storage medium and includes several instructions to cause a microcontroller, chip, or processor to...
- the processor executes all or part of the steps of the methods described in the various embodiments of this application.
- the aforementioned storage media include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- General Health & Medical Sciences (AREA)
- Health & Medical Sciences (AREA)
- Bioethics (AREA)
- Computer Security & Cryptography (AREA)
- Computer Hardware Design (AREA)
- Databases & Information Systems (AREA)
- Medical Informatics (AREA)
- Human Computer Interaction (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
本发明涉及安卓虚拟系统技术,尤其涉及一种基于Android内外多系统之间共享同一输入法输入内容的方法、移动终端、存储介质。This invention relates to Android virtual system technology, and more particularly to a method, mobile terminal, and storage medium for sharing the same input method input content between multiple systems inside and outside Android.
随着智能终端的普及,终端自带的操作系统,例如Android系统已经无法满足用户日益复杂的隐私保护需求,为此现有技术曾提出了虚拟Android系统的技术,以在一部智能终端中设置多套操作系统,以分别应对用户在不同使用场景下的隐私保护需求。With the widespread adoption of smart terminals, the built-in operating systems, such as Android, can no longer meet users' increasingly complex privacy protection needs. To address this, existing technologies have proposed virtual Android systems to set up multiple operating systems within a single smart terminal, thereby catering to users' privacy protection needs in different usage scenarios.
然而,现有的Android多系统方案在运行时,无论是在外部系统(主系统)还是内部系统(虚拟系统)中,通常都需要分别安装输入法,以实现输入功能,但现有部分输入法程序因为各种原因,通常会存在一些搜集用户隐私信息的行为,例如:收集用户的输入内容,键盘敲击使用习惯,获取敏感信息如密码、银行卡等涉及支付交易安全的信息,监控用户的输入行为,记录用户输入的文字内容、搜索记录行为等。However, existing Android multi-system solutions typically require separate installation of input methods in both the external system (main system) and the internal system (virtual system) to enable input functionality. However, some existing input method programs, for various reasons, often engage in behaviors that collect user privacy information, such as: collecting user input content, keyboard typing habits, obtaining sensitive information such as passwords, bank card information, and other information related to payment transaction security, monitoring user input behavior, and recording user input text content and search history.
如此一来,实际上通过这些隐私信息,可能会使得外部系统与内部系统存在隐私信息关联,进而可能暴露出虚拟系统的实际用户,从而使得Android虚拟系统的私密性形同虚设。In this way, this privacy information may actually lead to a connection between the external and internal systems, potentially exposing the actual users of the virtual system and rendering the privacy of the Android virtual system meaningless.
发明内容Summary of the Invention
为此本发明的主要目的在于提供一种多系统间共享输入内容的方法、移动终端、存储介质,以使安卓虚拟系统能够共用外部系统的输入法来输入内容,以避免各系统之间因输入法建立隐私信息关联。Therefore, the main objective of this invention is to provide a method, mobile terminal, and storage medium for sharing input content among multiple systems, so that the Android virtual system can share the input method of an external system to input content, thereby avoiding the establishment of privacy information associations between different systems due to input methods.
为了实现上述目的,根据本发明的一个方面,提供了一种多系统间共享输入内容的方法,步骤包括:To achieve the above objectives, according to one aspect of the present invention, a method for sharing input content among multiple systems is provided, comprising the steps of:
在内部系统预置空壳输入法,在外部系统创建Epoll实例监听及修改空壳输入法调起事件,以调用外部系统API拉起外部系统输入法;An empty shell input method is pre-installed in the internal system. An Epoll instance is created in the external system to listen for and modify the empty shell input method's initiation event, so as to call the external system API to launch the external system input method.
在外部系统创建输入文件,存储外部系统输入法输入的内容,通过mmap方法将输入文件映射到共享内存中;An input file is created on an external system to store the content entered by the external system's input method. The input file is then mapped to shared memory using the mmap method.
内部系统读取共享内存中的输入文件,获取输入内容后传递给空壳输入法;空壳输入法调用内部系统输入法框架交互输入内容。The internal system reads the input file in shared memory, obtains the input content, and passes it to the empty shell input method; the empty shell input method calls the internal system's input method framework to interact with the input content.
在可能的优选实施方式中,其中在外部系统创建Epoll实例监听及修改空壳输入法调起 事件,以调用外部系统API拉起外部系统输入法的步骤包括:In a possible preferred implementation, an Epoll instance is created on an external system to listen for and modify the empty shell input method to initiate. The steps involved in triggering an external system input method by calling an external system API include:
在外部系统创建Epoll实例,并通过Epoll_create函数创建Epoll句柄;Create an Epoll instance on an external system and create an Epoll handle using the Epoll_create function;
通过Java的File类来创建和操作文件,并通过FileInputStream或FileOutputStream类任一方式,获取空壳输入法调起事件的文件描述符;Files can be created and manipulated using Java's File class, and the file descriptor of the empty shell input method's initiation event can be obtained through either the FileInputStream or FileOutputStream class.
将空壳输入法调起事件的文件描述符注册到Epoll中;Register the file descriptor for the empty input method initiation event to Epoll;
通过内部系统广播接收器监听操作输入法已更改广播,当从广播中获取的输入法包名,判断为空壳输入法,且在当前广播中监听到的是输入法调起事件时,对当前文件描述符进行标识性修改;The system listens for changes to the input method via an internal system broadcast receiver. When the input method package name obtained from the broadcast is determined to be an empty shell input method, and the current broadcast contains an input method initiation event, the current file descriptor is modified accordingly.
当Epoll_wait函数监听到,曾注册到Epoll中的空壳输入法调起事件的文件描述符,进行了标识性修改时,调用外部系统API拉起外部系统输入法。When the Epoll_wait function detects that the file descriptor of the empty input method that was previously registered with Epoll has undergone a signature modification, it calls the external system API to launch the external system input method.
在可能的优选实施方式中,其中在外部系统创建输入文件,存储外部系统输入法输入的内容,通过mmap方法将输入文件映射到共享内存中的步骤包括:In a possible preferred embodiment, the steps of creating an input file on an external system to store the content input by the external system's input method, and mapping the input file to shared memory using the mmap method include:
使用FileOutputStream方法在外部系统创建输入文件;Use the FileOutputStream method to create an input file on an external system;
通过MappedByteBuffer方法将输入文件映射到共享内存中;The input file is mapped into shared memory using the MappedByteBuffer method;
在外部系统输入法调起时,将其输入框中的输入内容通过MappedByteBuffer的put()方法直接写入共享内存中的输入文件。When an external system input method is invoked, the input content in its input box is directly written to the input file in shared memory using the put() method of MappedByteBuffer.
在可能的优选实施方式中,其中内部系统读取共享内存中的输入文件,获取输入内容的步骤包括:In a possible preferred embodiment, the step of the internal system reading the input file in shared memory to obtain the input content includes:
使用FileOutputStream方法打开共享内存中的输入文件;Use the FileOutputStream method to open the input file in shared memory;
使用MappedByteBuffer的get()方法获取输入内容。Use the get() method of MappedByteBuffer to get the input content.
为了实现上述目的,根据本发明的另一方面,还提供了一种多系统间共享输入内容的方法,步骤包括:To achieve the above objectives, according to another aspect of the present invention, a method for sharing input content among multiple systems is also provided, comprising the steps of:
在内部系统预置空壳输入法,在外部系统创建Epoll实例监听及修改空壳输入法调起事件,以调用外部系统API拉起外部系统输入法;An empty shell input method is pre-installed in the internal system. An Epoll instance is created in the external system to listen for and modify the empty shell input method's initiation event, so as to call the external system API to launch the external system input method.
在外部系统创建输入文件,存储根据字典编码后的外部系统输入法输入的内容,通过mmap方法将输入文件映射到共享内存中;An input file is created on an external system to store the content input by the external system's input method after dictionary encoding. The input file is then mapped to shared memory using the mmap method.
内部系统读取共享内存中的输入文件,解码输入内容后传递给空壳输入法;空壳输入法调用内部系统输入法框架交互输入内容。The internal system reads the input file from shared memory, decodes the input content, and passes it to the empty shell input method; the empty shell input method calls the internal system's input method framework to interact with the input content.
在可能的优选实施方式中,其中在外部系统创建输入文件,存储根据字典编码后的外 部系统输入法输入的内容,通过mmap方法将输入文件映射到共享内存中的步骤包括:In a possible preferred embodiment, an input file is created on an external system and stored according to dictionary encoding. The steps for mapping the input file from the system's input method to shared memory using the mmap method include:
使用FileOutputStream方法在外部系统创建输入文件;Use the FileOutputStream method to create an input file on an external system;
通过MappedByteBuffer方法将输入文件映射到共享内存中;The input file is mapped into shared memory using the MappedByteBuffer method;
在外部系统输入法调起时,将其输入框中的输入内容根据字典编码后,通过MappedByteBuffer的put()方法直接写入共享内存中的输入文件。When the input method of an external system is invoked, the input content in its input box is encoded according to a dictionary and then directly written to the input file in shared memory using the put() method of MappedByteBuffer.
在可能的优选实施方式中,其中内部系统读取共享内存中的输入文件,解码输入内容的步骤还包括:In a possible preferred embodiment, the steps of the internal system reading the input file from shared memory and decoding the input content further include:
使用FileOutputStream方法打开共享内存中的输入文件;Use the FileOutputStream method to open the input file in shared memory;
使用MappedByteBuffer方法读取编码的输入内容,并对照字典解码还原原始文本输入内容。Use the MappedByteBuffer method to read the encoded input content and decode it using a dictionary to restore the original text input content.
在可能的优选实施方式中,其中在外部系统创建Epoll实例监听及修改空壳输入法调起事件,以调用外部系统API拉起外部系统输入法的步骤包括:In a possible preferred implementation, the steps of creating an Epoll instance in the external system to listen for and modify the empty shell input method initiation event, in order to call the external system API to launch the external system input method, include:
在外部系统创建Epoll实例,并通过Epoll_create函数创建Epoll句柄;Create an Epoll instance on an external system and create an Epoll handle using the Epoll_create function;
通过Java的File类来创建和操作文件,并通过FileInputStream或FileOutputStream类任一方式,获取空壳输入法调起事件的文件描述符;Files can be created and manipulated using Java's File class, and the file descriptor of the empty shell input method's initiation event can be obtained through either the FileInputStream or FileOutputStream class.
将空壳输入法调起事件的文件描述符注册到Epoll中;Register the file descriptor for the empty input method initiation event to Epoll;
通过内部系统广播接收器监听操作输入法已更改广播,当从广播中获取的输入法包名,判断为空壳输入法,且在当前广播中监听到的是输入法调起事件时,对当前文件描述符进行标识性修改;The system listens for changes to the input method via an internal system broadcast receiver. When the input method package name obtained from the broadcast is determined to be an empty shell input method, and the current broadcast contains an input method initiation event, the current file descriptor is modified accordingly.
当Epoll_wait函数监听到,曾注册到Epoll中的空壳输入法调起事件的文件描述符,进行了标识性修改时,调用外部系统API拉起外部系统输入法。When the Epoll_wait function detects that the file descriptor of the empty input method that was previously registered with Epoll has undergone a signature modification, it calls the external system API to launch the external system input method.
为了实现上述目的,对应上述方法示例,根据本发明的另一方面,还提供了一种移动终端,其包括:包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其中所述处理器执行所述计算机程序时,所述系统实现如上任一所述多系统间共享输入内容的方法的步骤。To achieve the above objectives, corresponding to the above method examples, according to another aspect of the present invention, a mobile terminal is also provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the system implements the steps of the method for sharing input content among multiple systems as described above.
为了实现上述目的,对应上述方法示例,根据本发明的另一方面,还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其中所述计算机程序被执行时,实现如上任一所述多系统间共享输入内容的方法的步骤。To achieve the above objectives, corresponding to the above method examples, according to another aspect of the present invention, a computer-readable storage medium is also provided, the computer-readable storage medium storing a computer program, wherein when the computer program is executed, it implements the steps of the method for sharing input content between multiple systems as described above.
通过本发明提供的该多系统间共享输入内容的方法、移动终端、存储介质,解决了传 统Android平台的内部系统无法共享外部系统输入法的问题,从而避免各系统之间因输入法建立隐私信息关联,籍此为内部系统提供更好的隐私保护。此外鉴于内部系统将无需再独立安装输入法,使得通过输入法加载恶意功能、监控用户行为的情况得以遏制,从而进一步提升了Android虚拟系统的安全性。The method, mobile terminal, and storage medium for sharing input content between multiple systems provided by this invention solve the problem of transmission The Android platform addresses the issue of internal systems not being able to share input methods with external systems, thus preventing the establishment of privacy information associations between systems based on input methods and providing better privacy protection for internal systems. Furthermore, since internal systems will no longer need to install input methods independently, the possibility of loading malicious functions or monitoring user behavior through input methods is curbed, further enhancing the security of the Android virtual system.
构成本申请的一部分的附图用来提供对本发明的进一步理解,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The accompanying drawings, which form part of this application, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings:
图1为本发明的多系统间共享输入内容的方法的步骤示意图;Figure 1 is a schematic diagram of the steps of the method for sharing input content among multiple systems according to the present invention;
图2为本发明的多系统间共享输入内容的方法的构思示意图;Figure 2 is a schematic diagram illustrating the concept of the method for sharing input content among multiple systems according to the present invention;
图3为本发明的多系统间共享输入内容的方法的Epoll概念示意图;Figure 3 is a schematic diagram of the Epoll concept of the method for sharing input content among multiple systems according to the present invention;
图4为本发明的多系统间共享输入内容的方法的实施构架示意图。Figure 4 is a schematic diagram of the implementation framework of the method for sharing input content among multiple systems according to the present invention.
为了使本领域的技术人员能够更好的理解本发明的技术方案,下面将结合实施例来对本发明的具体技术方案进行清楚、完整地描述,以助于本领域的技术人员进一步理解本发明。显然,本案所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。应当指出的是,对本领域的普通技术人员来说,在不脱离本发明构思及相互不冲突的前提下,本申请中的实施例及实施例中的特征可以相互组合。基于本发明中的实施例,在本领域普通技术人员没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明的揭露及保护范围。To enable those skilled in the art to better understand the technical solutions of the present invention, the specific technical solutions of the present invention will be clearly and completely described below in conjunction with embodiments, so as to help those skilled in the art further understand the present invention. Obviously, the embodiments described in this application are merely some embodiments of the present invention, and not all embodiments. It should be noted that, for those skilled in the art, the embodiments and features in the embodiments of this application can be combined with each other without departing from the concept of the present invention and without conflict. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the disclosure and protection scope of the present invention.
此外本发明的说明书和权利要求书及附图中的术语“第一”、“第二”、“S100”、“S200”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的特征在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里描述的那些以外的顺序实施。同时各个步骤记载的阶段并非强制在同一步骤中实施,应当理解每个步骤阶段中的内容在不违反发明构思的前提下其实施顺序可以调整及互换,以便这里描述的本发明的步骤实施例能够以除了在这里描述的那些以外的顺序实施。另外本发明中的术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含。除非另有明确的规定和限定,术语“设置”、“布设”、“安装”、“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通。对于本领域 的普通技术人员而言,可以根据具体情况,结合现有技术来理解上述术语在本案中的具体含义。Furthermore, the terms "first,""second,""S100,""S200," etc., used in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such features can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those described herein. At the same time, the stages described in each step are not necessarily to be implemented in the same step; it should be understood that the implementation order of the contents of each step stage can be adjusted and interchanged without violating the inventive concept, so that embodiments of the invention described herein can be implemented in orders other than those described herein. Additionally, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. Unless otherwise expressly specified and limited, the terms "set,""arrange,""install,""connect," and "link" should be interpreted broadly, for example, referring to a fixed connection, a detachable connection, or an integral connection; a mechanical connection or an electrical connection; a direct connection or an indirect connection through an intermediate medium; or a connection within two elements. For those in the art... For a person skilled in the art, the specific meaning of the above terms in this case can be understood based on the specific circumstances and in conjunction with existing technology.
为了使安卓虚拟系统能够共用外部系统的输入法来输入内容,以避免各系统之间因输入法建立隐私信息关联,本发明构思上如图2所示,试图通过对外部Android系统创建Epoll实例来监听内部系统(虚拟系统)输入法调起事件,当内部系统应用程序想要拉取输入法实现输入时,会调起内部系统所安装的空壳输入法,同时内部空壳输入法调起时,会去修改内部调起输入法事件的文件,当监听到内部调起输入法事件的文件描述符改变后,会触发Epoll的函数来处理输入法调起事件,此时通过系统API拉起自身输入法,完成输入后,将输入内容通过mmap映射到进程的某个地址空间,实现内容共享,以使内部系统也能访问到该输入内容,完成使用输入法输入闭环To enable Android virtual systems to share input methods from external systems and avoid establishing privacy information associations between systems based on input methods, as shown in Figure 2, this invention attempts to listen for input method initiation events in the internal system (virtual system) by creating an Epoll instance on the external Android system. When the internal system application wants to retrieve the input method for input, it invokes the empty shell input method installed on the internal system. Simultaneously, when the empty shell input method is invoked, it modifies the file containing the internal input method initiation event. Upon detecting a change in the file descriptor of the internal input method initiation event, the Epoll function is triggered to handle the input method initiation event. At this point, the system API is used to invoke its own input method. After input is completed, the input content is mapped to a specific address space of the process via mmap, achieving content sharing so that the internal system can also access the input content, thus completing the input method input loop.
据此如图1至图4所示,本发明提供了一种多系统间共享输入内容的方法,其示例步骤包括:As shown in Figures 1 to 4, the present invention provides a method for sharing input content among multiple systems, the example steps of which include:
步骤S100在内部系统预置空壳输入法,在外部系统创建Epoll实例监听及修改空壳输入法调起事件,以调用外部系统API拉起外部系统输入法。Step S100: A shell input method is pre-configured in the internal system. An Epoll instance is created in the external system to listen for and modify the shell input method's initiation event, so as to call the external system API to launch the external system input method.
具体来说,该内部系统的空壳输入法,不具备具体实现输入功能的输入法,只是在系统内被作为输入法服务的存在,例如实现一个输入法只可以调起输入法界面。Specifically, the internal system's empty shell input method is an input method that does not have a specific input function. It only exists as an input method service within the system. For example, an input method can only bring up the input method interface.
其中,为了在外部Android系统中,实现对内部空壳输入法调起事件的监听,并实现对应调用外部系统API拉起外部系统输入法,示例步骤包括:In order to listen for the initiation event of the internal shell input method in the external Android system and call the corresponding external system API to launch the external system input method, the example steps include:
步骤S110在外部系统创建Epoll实例,并通过Epoll_create函数创建Epoll句柄。Step S110 creates an Epoll instance on the external system and creates an Epoll handle using the Epoll_create function.
如图3所示Epoll是Linux内核为处理大批量文件描述符而作了改进的poll,是Linux下多路复用IO接口select/poll的增强版本,它能显著提高程序在大量并发连接中只有少量活跃的情况下的系统CPU利用率。并且在获取事件的时候,它无须遍历整个被侦听的描述符集,只要遍历那些被内核IO事件异步唤醒而加入Ready队列的描述符集合就可以实现。As shown in Figure 3, Epoll is an improved version of poll in the Linux kernel for handling large numbers of file descriptors. It is an enhanced version of the select/poll multiplexed I/O interface in Linux, which can significantly improve the system CPU utilization when only a small number of connections are active amidst a large number of concurrent connections. Furthermore, when acquiring events, it does not need to traverse the entire set of monitored descriptors; it only needs to traverse the set of descriptors that have been asynchronously awakened by kernel I/O events and added to the Ready queue.
Epoll有两种工作方式:LT和ET。LT(level triggered)是缺省的工作方式,并且同时支持block和no-block socket,在这种工作方式中,内核告知一个文件描述符是否就绪了,然后就可以对这个就绪的fd进行IO操作。如果不作任何操作,内核还是会继续通知。另外ET(edge-triggered)是高速工作方式,只支持non-block socket,在这种模式下,当描述符从未就绪变为就绪时,内核通过Epoll进行告知,并且不会再为那个文件描述符发送更多的就绪通知,直到做了某些操作导致那个文件描述符不再为就绪状态了(比如,在发送,接收或 者接收请求,或者发送接收的数据少于一定量时导致了一个EWOULDBLOCK错误)。可以简单的理解为LT为水平触发,ET为边缘触发。Epoll has two operating modes: LT (level triggered) and ET (edge-triggered). LT is the default mode and supports both blocking and non-blocking sockets. In this mode, the kernel notifies a file descriptor whether it is ready, and then I/O operations can be performed on that ready file descriptor. If no operation is performed, the kernel will continue to notify. ET (edge-triggered) is a high-speed mode that only supports non-blocking sockets. In this mode, when a file descriptor changes from not ready to ready, the kernel notifies it via Epoll and will not send any more ready notifications for that file descriptor until some operation causes it to no longer be ready (e.g., during transmission, reception, or...). An EWOULDBLOCK error occurs when the receiver fails to receive a request or when the amount of data sent and received is less than a certain amount. This can be simply understood as LT being level-triggered and ET being edge-triggered.
步骤S120通过Java的File类来创建和操作文件,并通过FileInputStream或FileOutputStream类任一方式,获取空壳输入法调起事件的文件描述符。示例代码逻辑如:Step S120 uses Java's File class to create and manipulate files, and obtains the file descriptor of the empty input method's initiation event using either the FileInputStream or FileOutputStream class. Example code logic is as follows:
File inputMethodFile=new File("InputMethod_file.txt");File inputMethodFile=new File("InputMethod_file.txt");
if(!customFile.exists()){customFile.createNewFile();}if(!customFile.exists()){customFile.createNewFile();}
//获取文件输入流并获取文件描述符//Get the file input stream and get the file descriptor
FileInputStreaminputStream=new FileInputStream(customFile);FileInputStreaminputStream=new FileInputStream(customFile);
int fileDescriptor=inputStream.getFD().getInt$()。int fileDescriptor=inputStream.getFD().getInt$().
步骤S130将空壳输入法调起事件的文件描述符注册到Epoll中,以便监听事件。示例代码逻辑如:Step S130 registers the file descriptor for the empty shell input method's initiation event with Epoll to listen for the event. Example code logic is as follows:
int inputMethodFd=...;//输入法的文件描述符int inputMethodFd = ...; // File descriptor for the input method
EpollEvent event=new EpollEvent();EpollEvent event=new EpollEvent();
event.events=EPOLLIN;event.events = EPOLLIN;
event.data.fd=inputMethodFd;event.data.fd=inputMethodFd;
Epoll_ctl(EpollFd,EPOLL_CTL_ADD,inputMethodFd,&event)。Epoll_ctl(EpollFd,EPOLL_CTL_ADD,inputMethodFd,&event).
步骤S140通过内部系统广播接收器监听ACTION_INPUT_METHOD_CHANGED(操作输入法已更改)广播,当从广播中获取的输入法包名,判断为空壳输入法,且在当前广播中监听到的是输入法调起事件时,对当前文件描述符进行标识性修改。Step S140 listens for the ACTION_INPUT_METHOD_CHANGED (input method has been changed) broadcast through the internal system broadcast receiver. When the input method package name obtained from the broadcast is determined to be an empty shell input method, and the input method initiation event is heard in the current broadcast, the current file descriptor is modified for identification.
具体的,由于内部系统输入法不可以实现输入功能,所以内部系统监听到用户想要调起输入法事件后,便会去修改在步骤S120设定的文件,例如修改内容类为改变输入法模式,便写进入“inputmethodMode:open”,其实只要修改了即可。创建的这个文件类似于只是一个标识符的记录,不记录具体输入法输入的内容。Specifically, since the internal system's input method cannot perform input functionality, after the internal system detects that the user wants to activate the input method, it modifies the file set in step S120. For example, it modifies the content class to change the input method mode, writing "inputmethodMode:open" into it. In fact, only this modification is needed. This created file is essentially just a record of an identifier and does not record the actual input content.
因为外部系统无法监听到内部系统调起输入法事件,所以本示例中通过上述方式,使得外部系统通过监听这个文件的状态,就可相当于通过这个文件的修改,来判断出内部系统输入法的状态,从而作为一个监听的传递。示例代码逻辑如:
Because external systems cannot listen to the input method activation event of the internal system, this example uses the method described above to allow external systems to monitor the state of this file. This is equivalent to determining the state of the internal system's input method through modifications to the file, thus serving as a means of transmission of the monitoring information. The example code logic is as follows:
步骤S150当Epoll_wait函数监听到,曾注册到Epoll中的空壳输入法调起事件的文件描述符,进行了标识性修改时,调用外部系统API拉起外部系统输入法。Step S150: When the Epoll_wait function detects that the file descriptor of the empty shell input method launch event that was previously registered in Epoll has undergone a distinctive modification, it calls the external system API to launch the external system input method.
其中该Epoll_wait函数监听的是文件,即内部系统广播监听到用户输入法调起去修改步骤S120设定的文件,而外部系统的Epoll函数在步骤S130注册了这个文件的文件描述符,此时经过步骤140当该设定文件改变后,外部系统的Epoll_wait函数就能够监听到反馈回来。示例代码逻辑如:
The `Epoll_wait` function listens for a file. Internally, the system broadcasts a message indicating that the user's input method is modifying the file specified in step S120. Externally, the `Epoll` function registers the file descriptor for this file in step S130. Therefore, after step 140, when the specified file is changed, the external `Epoll_wait` function can detect the change and send a feedback. Example code logic is as follows:
由于外部系统的输入法只能由外部系统调起,当在外部的Epoll_wait监听函数里,监听到系统对输入法调起事件的文件进行修改时,便会触发Epoll的处理函数,在处理函数里实现输入法的拉起。Since the input method of an external system can only be invoked by the external system, when the Epoll_wait listener function detects that the system has modified the file for the input method invocation event, the Epoll handler function will be triggered, and the input method will be launched in the handler function.
例如:在外部系统创建一个InputMethodManager对象,用于管理输入法。For example, create an InputMethodManager object in an external system to manage input methods.
InputMethodManager imm=(InputMethodManager)InputMethodManager imm=(InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE) getSystemService(Context.INPUT_METHOD_SERVICE)
然后使用showSoftInput方法弹出输入法。传入一个View对象作为参数,用于指定接收输入的视图“imm.showSoftInput(view,0)”。Then use the showSoftInput method to bring up the input method. Pass a View object as a parameter to specify the view that receives input: "imm.showSoftInput(view,0)".
步骤S200在外部系统创建输入文件,存储外部系统输入法输入的内容,通过mmap方法将输入文件映射到共享内存中。Step S200 creates an input file on the external system to store the content input by the external system's input method, and maps the input file to shared memory using the mmap method.
具体来说,为了实现内部/外部系统间的输入内容传输,本示例考虑以共享内存的方式来解决,例如采用mmap方案,mmap是一种内存映射文件的方法,即将一个文件或者其它对象映射到进程的地址空间,实现文件磁盘地址和进程虚拟地址空间中一段虚拟地址的一一对映关系。实现这样的映射关系后,进程就可以采用指针的方式读写操作这一段内存,而系统会自动回写脏页面到对应的文件磁盘上,即完成了对文件的操作而不必再调用read,write等系统调用函数。相反,内核空间对这段区域的修改也直接反映用户空间,从而可以实现不同进程间的文件共享。Specifically, to achieve input transfer between internal and external systems, this example considers using shared memory, such as the mmap approach. mmap is a memory-mapped file method that maps a file or other object into the process's address space, establishing a one-to-one mapping between the file's disk address and a segment of virtual addresses in the process's virtual address space. After establishing this mapping, the process can read and write to this memory segment using pointers, and the system automatically writes dirty pages back to the corresponding file on disk, thus completing file operations without needing to call system calls like read and write. Conversely, modifications to this region in kernel space are directly reflected in user space, enabling file sharing between different processes.
其中,为了存储外部系统的输入内容,并共享到内存中,本示例步骤包括:In order to store the input content of the external system and share it in memory, this example includes the following steps:
步骤S210使用FileOutputStream方法在外部系统创建输入文件。该输入文件用于存储输入法具体的输入内容,示例代码逻辑如:Step S210 uses the FileOutputStream method to create an input file on an external system. This input file is used to store the specific input content of the input method. Example code logic is as follows:
String FILE_PATH="/data/com.example.xxx/input.txt";String FILE_PATH="/data/com.example.xxx/input.txt";
FileOutputStream fileOutputStream=new FileOutputStream(FILE_PATH,true)。FileOutputStream fileOutputStream=new FileOutputStream(FILE_PATH,true).
步骤S220通过MappedByteBuffer方法将输入文件映射到共享内存中,以便在内存中进行读写操作,将MapMode设置为READ_WRITE,示例代码逻辑如:Step S220 maps the input file to shared memory using the MappedByteBuffer method to enable read and write operations in memory. MapMode is set to READ_WRITE. Example code logic is as follows:
int FILE_SIZE=1024*1024;//文件大小int FILE_SIZE = 1024 * 1024; //File size
FileChannel channel=fileOutputStream.getChannel();FileChannel channel=fileOutputStream.getChannel();
MappedByteBuffer buffer=channel.map(FileChannel.MapMode.READ_WRITE,0,FILE_SIZE)。MappedByteBuffer buffer=channel.map(FileChannel.MapMode.READ_WRITE,0,FILE_SIZE).
因为具体实现内容显示的输入框是在内部Android系统,在外部系统输入法调起后,需要外部系统存在一个输入框来承接输入的内容,之后再将内容存储到创建的输入文件。Because the input box that actually displays the content is in the internal Android system, after the input method is invoked in the external system, an input box needs to exist in the external system to receive the input content, and then the content is stored in the created input file.
步骤S230在外部系统输入法调起时,将其输入框中的输入内容通过MappedByteBuffer的put()方法直接写入共享内存中的输入文件。Step S230: When the external system input method is invoked, the input content in its input box is directly written to the input file in shared memory through the put() method of MappedByteBuffer.
此时,由于已经将文件映射到内存中,之后外部系统输入法的输入框获取到的内容,就可以直接在内存中写入,通过使用MappedByteBuffer的put()方法来实现这一步骤。At this point, since the file has already been mapped into memory, the content obtained by the input box of the external system input method can be directly written into memory. This step is achieved by using the put() method of MappedByteBuffer.
此外,鉴于汉字相比英文字母存在一些特殊性,例如: Furthermore, given that Chinese characters have some unique characteristics compared to the English alphabet, for example:
汉字是复杂的字符集,并且机器无法直接识别,因为机器只能识别二进制数据,容易出现乱码现象。Chinese characters are a complex character set, and machines cannot directly recognize them because they can only recognize binary data, which can easily lead to garbled characters.
汉字通常需要更多的内存空间来存储,因为它们比单个字符占用多一倍的字节,在内存中写入大量的汉字数据可能会导致内存占用过高,从而影响系统的性能和稳定性。Chinese characters typically require more memory space to store because they occupy twice as many bytes as a single character. Writing large amounts of Chinese character data into memory can lead to excessive memory usage, thereby affecting system performance and stability.
汉字的处理通常比英文字母更加复杂,因为汉字可能包含复合结构、多音字等特性。因此,在处理汉字时需要考虑更多的语言和文化特性,以确保正确处理和显示汉字数据。Processing Chinese characters is generally more complex than processing English letters because Chinese characters may contain complex structures, polyphonic characters, and other characteristics. Therefore, when processing Chinese characters, more linguistic and cultural features need to be considered to ensure the correct processing and display of Chinese character data.
因此,为了保证传输的高效性,同时保证内容的安全性,在可选示例中,在面对汉字输入内容时,可对输入的内容进行编码存储。即在外部系统输入法调起时,将其输入框中的输入内容根据字典编码后,再通过MappedByteBuffer的put()方法直接写入共享内存中的输入文件。Therefore, to ensure both efficient transmission and content security, in the optional example, when dealing with Chinese character input, the input content can be encoded and stored. That is, when an external system input method is invoked, the input content in its input box is encoded according to a dictionary, and then directly written to the input file in shared memory using the `put()` method of `MappedByteBuffer`.
具体的,在计算机系统中,文本数据一般都以数字形式存储和传输。文字编码将汉字和字母映射到数字,使得文本可以方便地存储在计算机内存中进行传输。Specifically, in computer systems, text data is generally stored and transmitted in digital form. Character encoding maps Chinese characters and letters to numbers, making it easy to store text in computer memory for transmission.
由于文本数字直接在系统里传递,会造成乱码或者错误的解析。直接传递大量的文本数据可能会占用大量的系统资源和网络带宽,影响系统的性能和响应速度。特别是本发明中作为输入法频繁读写的情况下,为了保证文本数据能够在计算机系统中被准确地表示、处理和传输。Transmitting text and numbers directly within the system can lead to garbled characters or incorrect parsing. Directly transmitting large amounts of text data can consume significant system resources and network bandwidth, impacting system performance and response speed. This is especially true in the context of frequent reading and writing as an input method in this invention, where it is crucial to ensure that text data is accurately represented, processed, and transmitted within the computer system.
本示例中,首先采用统一码对汉字进行数字编码表示。其中统一码是一种在计算机上使用的字符编码,它为每种语言中的每个字符设定了统一并且唯一的二进制编码,以满足跨语言、跨平台进行文本转换、处理的要求。In this example, Unicode is first used to represent Chinese characters using numerical encoding. Unicode is a character encoding used on computers that assigns a unique binary code to each character in every language to meet the requirements of cross-language and cross-platform text conversion and processing.
统一码用数字0-0x10FFFF来映射这些字符,最多可以容纳1114112个字符,或者说有1114112个码位。码位就是可以分配给字符的数字。Unicode uses the numbers 0-0x10FFFF to map these characters, and can hold a maximum of 1,114,112 characters, or 1,114,112 code points. A code point is a number that can be assigned to a character.
具体实现方式例如:“你好”对应的统一码分别为:20320和22909。获取到文字的统一码数字之后对数字进行程序数据转换,采用如下对照方式:
For example, the Unicode codes for "你好" are 20320 and 22909. After obtaining the Unicode numbers for the text, the numbers are converted by the program using the following conversion method:
对于不同范围的字符使用不同长度的编码,针对“你好”获取到的码点范围确定两个汉字都是3字节的,将“你”字的码位20320换算成十六进制数为4F60,将4个数分别单独拆为二进制数为:0100 1111 0110 0000,将得到十六个数字放进3字节对应的格式中,代替模版中的x,就会得到三个十六位的数字:11100100 10111101 10100000,再转化为十六进制即为E4 BD A0。Different length encodings are used for characters with different ranges. For the code point range obtained for "你好", both Chinese characters are determined to be 3 bytes. The code point of the character "你" (20320) is converted into the hexadecimal number 4F60. The four numbers are then separately decomposed into binary numbers: 0100 1111 0110 0000. The resulting sixteen numbers are placed into the format corresponding to the 3 bytes, replacing the x in the template, which will give three sixteen-bit numbers: 11100100 10111101 10100000. Converting these to hexadecimal gives E4 BD A0.
这样根据统一码在进行编码后的汉字都会变成不同长度是十六进制数来表示,将该数字存储到内存文件中。存储代码实现如:buffer.put(input)。In this way, Chinese characters encoded according to Unicode will be represented as hexadecimal numbers of different lengths, and these numbers will be stored in a memory file. The storage code implementation is as follows: `buffer.put(input)`.
在写入内容后,可手动刷新内存映射,以确保数据被及时写入文件中,通过使用MappedByteBuffer的force()方法来实现这一步骤:buffer.force(),最后需要关闭内存映射和文件,释放资源channel.close()。After writing content, you can manually refresh the memory mapping to ensure that the data is written to the file in a timely manner. This step can be achieved by using the `force()` method of `MappedByteBuffer`: `buffer.force()`. Finally, you need to close the memory mapping and the file, and release the resources using `channel.close()`.
步骤S300内部系统读取共享内存中的输入文件,获取输入内容后传递给空壳输入法;空壳输入法调用内部系统输入法框架交互输入内容。In step S300, the internal system reads the input file in the shared memory, obtains the input content, and passes it to the empty shell input method; the empty shell input method calls the internal system input method framework to interact with the input content.
具体的,内部Android系统获取输入内容的示例步骤包括:Specifically, the internal Android system's steps for obtaining input content include:
步骤S310使用FileOutputStream方法打开共享内存中的输入文件。示例代码逻辑如:Step S310 uses the FileOutputStream method to open the input file in shared memory. Example code logic is as follows:
String FILE_PATH="/data/com.droi.xxx/input.txt";String FILE_PATH="/data/com.droi.xxx/input.txt";
FileOutputStream fileOutputStream=new FileOutputStream(FILE_PATH,true)。FileOutputStream fileOutputStream=new FileOutputStream(FILE_PATH,true).
步骤S320使用MappedByteBuffer的get()方法获取输入内容。Step S320 uses the get() method of MappedByteBuffer to obtain the input content.
此时,若输入内容曾通过上述示例进行了编码,则此时可在读取输入内容后,进行汉字解码。将编码的字节序列转化为二进制形式,读取第一个字节,根据编码规则解析二进制序列,即根据首字节的前导位来确定该字符的字节数,然后根据首字节的前导位数,依次读取后续的字节,将每一个字节组装成对应字符的二进制编码值,最后根据编码值对照统一码字典表找到对应真实汉字,还原原始的输入文本内容。If the input content was previously encoded using the example above, then Chinese character decoding can be performed after reading the input content. The encoded byte sequence is converted to binary form. The first byte is read, and the binary sequence is parsed according to the encoding rules. Specifically, the number of bytes for the character is determined by the leading bit of the first byte. Then, based on the leading bit of the first byte, subsequent bytes are read sequentially. Each byte is assembled into the corresponding binary encoding value for the character. Finally, the corresponding Chinese character is found by referring to the Unicode dictionary table based on the encoding value, thus restoring the original input text content.
之后关闭内存映射和文件,释放资源,将解码后的文字传递给空壳输入法,内部系统 的空壳输入法,调用的内部系统输入法框架在提供的用户界面,显示输入状态和输入的内容等信息,并与用户进行交互。籍此实现安卓虚拟系统,能够共用外部系统的输入法来输入内容,以避免各系统之间因输入法建立隐私信息关联。Afterwards, memory mapping and files are closed, resources are released, and the decoded text is passed to the empty input method and internal system. This is a shell-like input method that calls upon the internal system input method framework to display information such as input status and input content in the provided user interface, and interacts with the user. This enables an Android virtual system that can share input methods from external systems, thus avoiding the establishment of privacy information associations between different systems due to input methods.
另一方面,对应上述方法示例,本发明还提供了一种移动终端,其包括:包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其中所述处理器执行所述计算机程序时,所述系统实现如上任一所述多系统间共享输入内容的方法的步骤。On the other hand, corresponding to the above method examples, the present invention also provides a mobile terminal, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the system implements the steps of the method for sharing input content between multiple systems as described above.
另一方面,对应上述方法示例,本发明还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其中所述计算机程序被执行时,实现如上任一所述多系统间共享输入内容的方法的步骤。On the other hand, corresponding to the above method examples, the present invention also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed, it implements the steps of the method for sharing input content between multiple systems as described above.
综上所述,通过本发明提供的该多系统间共享输入内容的方法、移动终端、存储介质,解决了传统Android平台的内部系统无法共享外部系统输入法的问题,从而避免各系统之间因输入法建立隐私信息关联,籍此为内部系统提供更好的隐私保护。此外鉴于内部系统将无需再独立安装输入法,使得通过输入法加载恶意功能、监控用户行为的情况得以遏制,从而进一步提升了Android虚拟系统的安全性。In summary, the method, mobile terminal, and storage medium for sharing input content between multiple systems provided by this invention solve the problem that internal systems on the traditional Android platform cannot share input methods from external systems. This avoids establishing privacy information associations between systems based on input methods, thereby providing better privacy protection for internal systems. Furthermore, since internal systems no longer need to install input methods independently, the possibility of loading malicious functions and monitoring user behavior through input methods is curbed, further enhancing the security of the Android virtual system.
以上公开的本发明优选实施例只是用于帮助阐述本发明。优选实施例并没有详尽叙述所有的细节,也不限制该发明仅为所述的具体实施方式。显然,根据本说明书的内容,可作很多的修改和变化。本说明书选取并具体描述这些实施例,是为了更好地解释本发明的原理和实际应用,从而使所属技术领域技术人员能很好地理解和利用本发明。本发明仅受权利要求书及其全部范围和等效物的限制,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The preferred embodiments of the present invention disclosed above are merely illustrative of the invention. These preferred embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the invention, thereby enabling those skilled in the art to better understand and utilize the invention. The present invention is limited only by the claims and their full scope and equivalents. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the protection scope of the invention.
本领域技术人员可以理解,除了以纯计算机可读程序代码方式实现本发明提供的系统、装置、单元及其各个模块以外,完全可以通过将方法步骤进行逻辑编程来使得本发明提供的系统、装置、单元及其各个模块以逻辑门、开关、专用集成电路、可编程逻辑控制器以及嵌入式微控制器等的形式来实现相同程序。所以,本发明提供的系统、装置及其各个模块可以被认为是一种硬件部件,而对其内包括的用于实现各种程序的模块也可以视为硬件部件内的结构;也可以将用于实现各种功能的模块视为既可以是实现方法的软件程序又可以是硬件部件内的结构。Those skilled in the art will understand that, besides implementing the system, apparatus, unit, and its modules provided by this invention in purely computer-readable program code, the same program can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system, apparatus, and its modules provided by this invention can be considered a hardware component, and the modules included therein for implementing various programs can also be considered structures within the hardware component; alternatively, modules for implementing various functions can be considered both software programs implementing the method and structures within the hardware component.
此外实现上述实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序存储在一个存储介质中,包括若干指令用以使得单片机、芯片或处理器 (processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。Furthermore, all or part of the steps in the methods described in the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a microcontroller, chip, or processor to... The processor executes all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage media include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
此外,本发明实施例的各种不同的实施方式之间也可以进行任意组合,只要其不违背本发明实施例的思想,其同样应当视为本发明实施例所公开的内容。 Furthermore, various different implementations of the present invention can be combined arbitrarily, as long as they do not violate the spirit of the present invention, they should also be regarded as the content disclosed in the present invention.
Claims (10)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410556806.2 | 2024-05-07 | ||
| CN202410556806.2A CN118349377A (en) | 2024-05-07 | 2024-05-07 | Method, mobile terminal, and storage medium for sharing input content among multiple systems |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2025232012A1 true WO2025232012A1 (en) | 2025-11-13 |
Family
ID=91815711
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2024/110107 Pending WO2025232012A1 (en) | 2024-05-07 | 2024-08-06 | Method for sharing input content among multiple systems, mobile terminal and storage medium |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN118349377A (en) |
| WO (1) | WO2025232012A1 (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118349377A (en) * | 2024-05-07 | 2024-07-16 | 上海卓易科技股份有限公司 | Method, mobile terminal, and storage medium for sharing input content among multiple systems |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105653353A (en) * | 2015-12-31 | 2016-06-08 | 北京元心科技有限公司 | Multi-system interactive communication method and device based on container |
| CN106874751A (en) * | 2017-01-13 | 2017-06-20 | 北京奇虎科技有限公司 | Input method, device and mobile terminal under system protection pattern |
| CN108959918A (en) * | 2017-05-18 | 2018-12-07 | 北京搜狗科技发展有限公司 | A kind of guard method, device and the electronic equipment of input method file |
| US20190073316A1 (en) * | 2017-09-05 | 2019-03-07 | NGINX, Inc. | Using Shared Memory To Transport Data Between Server Processes |
| CN113157464A (en) * | 2021-04-27 | 2021-07-23 | 麒麟软件有限公司 | Method for sharing Linux end input event to Android |
| CN118349377A (en) * | 2024-05-07 | 2024-07-16 | 上海卓易科技股份有限公司 | Method, mobile terminal, and storage medium for sharing input content among multiple systems |
-
2024
- 2024-05-07 CN CN202410556806.2A patent/CN118349377A/en active Pending
- 2024-08-06 WO PCT/CN2024/110107 patent/WO2025232012A1/en active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105653353A (en) * | 2015-12-31 | 2016-06-08 | 北京元心科技有限公司 | Multi-system interactive communication method and device based on container |
| CN106874751A (en) * | 2017-01-13 | 2017-06-20 | 北京奇虎科技有限公司 | Input method, device and mobile terminal under system protection pattern |
| CN108959918A (en) * | 2017-05-18 | 2018-12-07 | 北京搜狗科技发展有限公司 | A kind of guard method, device and the electronic equipment of input method file |
| US20190073316A1 (en) * | 2017-09-05 | 2019-03-07 | NGINX, Inc. | Using Shared Memory To Transport Data Between Server Processes |
| CN113157464A (en) * | 2021-04-27 | 2021-07-23 | 麒麟软件有限公司 | Method for sharing Linux end input event to Android |
| CN118349377A (en) * | 2024-05-07 | 2024-07-16 | 上海卓易科技股份有限公司 | Method, mobile terminal, and storage medium for sharing input content among multiple systems |
Also Published As
| Publication number | Publication date |
|---|---|
| CN118349377A (en) | 2024-07-16 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN108170503B (en) | Method, terminal and storage medium for cross-system android application running | |
| US10862982B2 (en) | Cloud-scale heterogeneous datacenter management infrastructure | |
| US9451026B2 (en) | Electronic devices | |
| US11860796B2 (en) | Execution space agnostic device drivers | |
| US7539854B2 (en) | System and method to seamlessly enable enhanced management and scripting of a computer system and its add-in devices | |
| CN111930676A (en) | Method, device, system and storage medium for communication among multiple processors | |
| EA006814B1 (en) | System and method for use of multiple applications | |
| WO2021013243A1 (en) | Method for starting mini program, device, and computer storage medium | |
| CN113067849B (en) | Network communication optimization method and device based on Glusterfs | |
| CN117692416B (en) | Network message processing method, device, computer equipment and storage medium | |
| WO2025232012A1 (en) | Method for sharing input content among multiple systems, mobile terminal and storage medium | |
| US9760380B2 (en) | Using grammar to serialize and de-serialize objects | |
| EP4052141B1 (en) | System and method for constructing filter graph-based media processing pipelines in a browser | |
| US10642667B1 (en) | Apparatus, system, and method for efficiently sharing data between processes | |
| CN113646744B (en) | Widen memory accesses to aligned addresses for unaligned memory operations | |
| EP3797356B1 (en) | Code base sharing between standalone and web-based versions of an application due to the implementing of an emulated network communication channel | |
| US7434223B2 (en) | System and method for allowing a current context to change an event sensitivity of a future context | |
| CN116107774A (en) | IO request processing method and device, electronic equipment and storage medium | |
| CN118055084A (en) | Network packet receiving method, device, electronic device, storage medium and program | |
| JP4318456B2 (en) | Method and apparatus for enabling cross-platform configuration | |
| CN115878282A (en) | Cross-platform interaction method, device and equipment | |
| CN109032724A (en) | A kind of processing method, device, terminal and the storage medium of customized barrage message |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 24940365 Country of ref document: EP Kind code of ref document: A1 |