An Android-based character input cache control method and electronic device
Patent Information
- Application Number
- CN202410024305.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-08
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2044-01-08
AI Technical Summary
[0005]综上所述,现有技术已经不能满足人们的需求,亟需得到改进
[0026] This invention provides a superior caching solution for continuous deletion operations in input methods. By analyzing usage scenarios and implementing data caching and asynchronous preloading, it reduces the sensitivity of the compilation process to calling translation processing functions while ensuring a user experience that synchronizes deletion and candidate word list updates. This alleviates unreasonable demands on computing resources, resulting in lower performance resource consumption and better performance when the in-vehicle system lags.
Smart Images

Figure CN117950507B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a caching control method and an electronic device, and more particularly to an Android-based text input caching control method and electronic device. Background Technology
[0002] In the era of smart cars, in-vehicle infotainment systems often experience high CPU usage and lag during driving. This phenomenon is often caused by the infotainment system simultaneously handling a large amount of vehicle information, such as navigation, music playback, and dashcam recordings, as well as other environmental factors.
[0003] When using an input method, assuming we press the "b" and "j" keys in sequence, the top of the input method will display the character to be confirmed as "bj" and a list of corresponding candidate words such as "Beijing," "mark," "layout," and "edit." When lag occurs, the retrieval and display of suggested words after inputting or deleting words will result in a very poor user experience.
[0004] Currently, some caching methods use LruCache's caching approach, which dynamically adjusts the data being operated on to the last position during data storage and retrieval. However, in caching use cases, the last cached data will always be used first, so there's no need for LruCache to automatically adjust the order of cached data. Furthermore, the LruCache utility class does not include preloading functionality.
[0005] In conclusion, existing technologies can no longer meet people's needs and urgently need to be improved. Summary of the Invention
[0006] The purpose of this invention is to provide a text input caching control method and electronic device based on Android, thereby overcoming the shortcomings of existing technologies.
[0007] This invention provides the following solution:
[0008] An Android-based text input caching control method includes:
[0009] Check if a deletion operation exists. If a deletion operation exists, further check if there is any available historical cache data in the historical cache area.
[0010] If available historical cached data exists, load the corresponding cached data; otherwise, if no corresponding cached data exists, check the preloaded data area.
[0011] If the corresponding cached data exists in the preloaded data area, then the corresponding cached data is loaded from the preloaded data area.
[0012] Furthermore, during the text input process, the text input content and the candidate word list are mapped into the historical cache pool, and the storage data of the current historical cache pool is detected in real time to see if it exceeds its upper limit.
[0013] The system detects whether candidate word operations exist during the text input process. If such candidate word operations exist, caching is no longer performed.
[0014] Furthermore, it checks whether the capacity of the preloaded data area has reached its limit. If the capacity of the preloaded data area has reached its limit, the earliest data added to the preloaded data area is deleted.
[0015] Furthermore, if the corresponding cached data is not found in the preloaded data area, the required cached data is loaded asynchronously.
[0016] Furthermore, the historical cache area and the preloaded data area are cached and stored using a LinkedHashMap that combines a doubly linked list structure with a HashMap.
[0017] Furthermore, it also includes locking the historical cache area and the preloaded data area to ensure that when multiple threads operate on the cache area, only one thread accesses the cache area at any given time.
[0018] An Android-based text input caching control system includes:
[0019] The deletion operation detection and cache area detection module detects whether a deletion operation exists. If a deletion operation exists, it further detects whether there is any available historical cache data in the historical cache area.
[0020] The historical cache area data detection and loading module loads the corresponding cache data if available historical cache data exists, or if no corresponding cache data exists, it detects the preloaded data area.
[0021] The preloaded data area detection and loading module loads the corresponding cached data if the preloaded data area contains corresponding cached data.
[0022] A vehicle infotainment system, wherein the vehicle infotainment system is equipped with the aforementioned Android-based text input cache control system, and executes the aforementioned Android-based text input cache control method.
[0023] An electronic device includes: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus; the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the method.
[0024] A computer-readable storage medium storing a computer program executable by an electronic device, which, when run on the electronic device, causes the electronic device to perform the steps of the method.
[0025] Compared with the prior art, the present invention has the following advantages:
[0026] This invention provides a superior caching solution for continuous deletion operations in input methods. By analyzing usage scenarios and implementing data caching and asynchronous preloading, it reduces the sensitivity of the compilation process to calling translation processing functions while ensuring a user experience that synchronizes deletion and candidate word list updates. This alleviates unreasonable demands on computing resources, resulting in lower performance resource consumption and better performance when the in-vehicle system lags. Attached Figure Description
[0027] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0028] Figure 1 This is a flowchart of a text input caching control method based on Android.
[0029] Figure 2 This is an architecture diagram of a text input caching control system based on Android.
[0030] Figure 3 This is a flowchart of the caching module's workflow.
[0031] Figure 4 This is a schematic diagram of the cache module architecture.
[0032] Figure 5 This is a physical diagram of the input method's input prompt interface.
[0033] Figure 6 This is a flowchart of the caching scheme according to an embodiment of the present invention.
[0034] Figure 7 This is a schematic diagram of the electronic device. Detailed Implementation
[0035] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0036] like Figure 1 The Android-based text input caching control method shown includes:
[0037] Step S1: Detect whether a deletion operation exists. If a deletion operation exists, further detect whether there is available historical cache data in the historical cache area.
[0038] Step S2: If available historical cached data exists, load the corresponding cached data; or if no corresponding cached data exists, detect the preloaded data area.
[0039] Specifically, during the text input process, the text input content and the candidate word list are mapped into the historical cache pool, and the storage data of the current historical cache pool is detected in real time to see if it exceeds its upper limit.
[0040] The system detects whether candidate word operations exist during the text input process. If such candidate word operations exist, caching is no longer performed.
[0041] Specifically, it checks whether the capacity of the preloaded data area has reached its limit. If the capacity of the preloaded data area has reached its limit, it deletes the earliest data added to the preloaded data area.
[0042] Specifically, if the corresponding cached data is not found in the preloaded data area, the required cached data is loaded asynchronously.
[0043] For example, the historical cache area and the preloaded data area are cached and stored using a LinkedHashMap that combines a doubly linked list structure with a HashMap.
[0044] Step S3: If the preloaded data area contains corresponding cached data, then load the corresponding cached data from the preloaded data area.
[0045] Specifically, this also includes locking the historical cache area and the preloaded data area to ensure that when multiple threads operate on the cache area, only one thread accesses the cache area at any given time.
[0046] For the purpose of simplicity, the method steps disclosed in the above embodiments are described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0047] like Figure 2 The Android-based text input caching control system shown includes:
[0048] The deletion operation detection and cache area detection module detects whether a deletion operation exists. If a deletion operation exists, it further detects whether there is any available historical cache data in the historical cache area.
[0049] The historical cache area data detection and loading module loads the corresponding cache data if available historical cache data exists, or if no corresponding cache data exists, it detects the preloaded data area.
[0050] The preloaded data area detection and loading module loads the corresponding cached data if the preloaded data area contains corresponding cached data.
[0051] The implementation methods of the system described above are merely illustrative. For example, the various functional modules, units, or subsystems within the system may or may not be physically separate, or they may or may not be physical units; that is, they may be located in the same place or distributed across multiple different systems and their subsystems or modules. Those skilled in the art can select some or all of the functional modules, units, or subsystems to achieve the objectives of the embodiments of the present invention according to actual needs. Those skilled in the art can understand and implement the above-described situations without any creative effort.
[0052] like Figure 3As shown, according to statistics on user usage habits, in the process of using an input method, the scenario where a user inputs a whole sentence by means of continuous input and segmented confirmation is a very common user usage scenario. For example, if a user wants to directly input "The Palace Museum in Beijing", this location includes three parts: "Beijing", "Palace Museum" and "Museum of Chinese History". Due to the particularity of this example, it can be directly obtained from the city location association lexicon of a general input method for confirmation and submission. Assuming that there is no support from the city location association lexicon, the user first needs to select "Beijing" from (Beijing, background, times mirror...), at this time the characters to be submitted become "Beijing gugongbowuyuan", then it is necessary to select "Palace Museum" from the candidate list (Palace Museum, construction supervisor, employee...), and finally select "Museum of Chinese History" from the candidate list when the characters to be submitted are "Beijing Palace Museum bowuyuan", and submit all of them to the input box.
[0053] In the above process, if a delete key operation is performed when the characters to be submitted are "Beijing Palace Museum bowuyuan", since the two candidates "Beijing" and "Palace Museum" have been partially confirmed at this time, the most recent candidate confirmation will be restored first, that is, the characters to be submitted will become "Beijing gugongbowuyuan" again, and executing the delete key logic again will completely restore to the pinyin letters:
[0054] "beijinggugongbowuyuan", after that, the delete key logic starts to delete the pinyin letters one by one.
[0055] During the operation, the candidate list will be refreshed in real time with each letter input or deleted by the user or the confirmation of part of the candidates. However, the usage scenario of dense clicks on the delete key within a period of time is far more frequent than the usage scenario of quickly clicking the keyboard to input letters. During vehicle driving, when the vehicle infotainment system is under high load, the user will obviously perceive stuttering during continuous deletion, and the time for requesting and refreshing the candidate list after deleting one letter will be four to six times that when the performance of the vehicle infotainment system is normal.
[0056] This embodiment takes into account that memory occupation support limits the capacity of the cache pool, and also takes into account that preloading of the candidate list is supported when there is no available cache data, which ensures that the display of the preferred candidate list can be updated while the delete key is clicked and executed, without occupying excessive performance resources, and can ensure efficiency and user experience when the performance occupation of the vehicle infotainment system is high.
[0057] The cache mechanism is internally divided into two levels of caches: a history cache and a preloading cache. For example, when a user intends to perform predictive input by entering the initial pinyin letters "bjggbwy" corresponding to "The Palace Museum in Beijing", the candidate word list obtained when initially entering "b" is (ba, bu, bei...). When the candidate word list is acquired, "b" and the list (ba, bu, bei...) should be stored in the cache mechanism in the form of a key-value pair. Only after successful storage can the candidate word list cache data be directly obtained from the cache without making a new request when the input is truncated back to "b" after entering other characters. In this way, each time a letter is entered and a new candidate word list is requested and obtained, the requested pinyin letter and the acquired candidate word list are stored in the history cache in a corresponding relationship, with each corresponding set of data serving as one data entry. When the stored data exceeds the capacity limit of the history cache, the earliest stored data is moved to the preloading cache. If the preloading cache reaches its upper limit, the earliest data added to the preloading cache is cleared. During fast deletion, it is checked whether the cache data required for the next two deletion operations exists. If the data does not exist, an asynchronous request for candidate words is made in an asynchronous thread, and the obtained data is stored in the cache mechanism.
[0058] During rapid consecutive deletion operations, the pinyin letters for which candidate words currently need to be requested can be directly retrieved from the cache mechanism for display in the input order, which improves efficiency. The workflow of the delete key logic of the cache module is shown in the following figure:
[0059] As Figure 4 shown, the architecture of the cache module can be simply summarized as a cache capacity control module, a history cache pool, a preloading cache pool, and a preloading function module. The history cache pool is dedicated to storing cache data generated during the input process; the preloading cache pool is dedicated to storing cache data that may be used in the future. The capacity limits of both cache pools are handled by the cache capacity control module. When the history cache pool reaches its storage upper limit, the earliest added data is imported into the preloading cache pool through this functional module; when the preloading cache pool reaches its capacity upper limit, this module directly deletes the earliest added data. The preloading function module is mainly responsible for, upon successful retrieval of cache data, estimating whether the data required for the next two deletion operations can be obtained from the two cache pools. If the data cannot be obtained, an asynchronous request operation is performed, and the requested cache data is stored in the preloading cache pool.
[0060] The internal details of this embodiment are divided into the following 6 parts:
[0061] 1. Considering that the cache model contains asynchronous pre-cache requests, the cache model is encapsulated using a singleton pattern, and a thread pool is maintained internally to process asynchronous candidate word request tasks for candidate words. The cache model internally adopts a two-level cache mode of historical data cache and preloaded data cache. The first-level cache is a historical cache for storing cache data generated during the input process; the second-level cache is a preloaded cache for storing data exceeding the upper capacity limit of the historical cache and preloaded data after an asynchronous candidate word list request is made when no available cache data is available.
[0062] 2. The capacity of each level of cache can be configured during initialization. For example: the historical data cache is the main cache area, and its capacity is set to 40; the preloaded data cache is the secondary cache, and its capacity is set to 10. In order to ensure that the to-be-confirmed characters and the requested candidate word list data are stored as cache data in a corresponding form, a HashMap storage structure is adopted. At the same time, to ensure that the order of the stored cache data can be retained, LinkedHashMap combining a doubly linked list structure and HashMap is finally used for storage.
[0063] 3. Query the candidate word list data from the cache mechanism according to the input pinyin characters. In addition, the cache mechanism needs to retain the sequence in which the cache data is stored, and clear the earliest stored data when the data exceeds the limit.
[0064] 4. In order to solve its thread-unsafe feature, locking processing is performed on the two cache pools, ensuring that when multiple threads operate on the cache pools, only one thread performs access and storage operations on them at the same time.
[0065] 5. When the delete key is clicked continuously, the corresponding cache to be fetched can be predicted. When there is no available cache data in the content to be processed, a data request will be made in an asynchronous thread, and the data will be stored in the preloaded cache.
[0066] 6. When the delete key is clicked, the cache data will be deleted after the result is found in the cache mechanism.
[0067] As Figure 5 shown, the deletion logic is to preferentially determine whether there are confirmed partial candidate words in the characters to be confirmed and submitted. As shown in the figure below: "Beijing" and "Forbidden City" are the partial candidate words we confirmed during continuous input, and "bowuy" is what we will confirm in the candidate word list next. After all the input pinyin is confirmed, it will be completely submitted to the input box. At this time, clicking delete will first restore the last selected "Forbidden City" to pinyin, the to-be-confirmed string becomes "beijinggugongbowuy", then sequentially expand until all are restored to full pinyin - "beijinggugongbowuy", and then delete the pinyin one by one.
[0068] In the caching scheme of this embodiment, each time a letter is input, the character from the candidate word list and its corresponding name in the requested candidate word list are stored. However, if some candidate words are selected during the input, the requested confirmation string will change; for example, in the above figure, it has been changed to "bowuy" for the candidate word request. Inputting characters when some candidate words have already been selected will no longer be cached, because the deletion logic will prioritize restoring previously confirmed candidate words, rendering cached data useless. When there is no corresponding cache during continuous deletion, we need to preload data for caching.
[0069] like Figure 6 As shown, each state is saved during the input process, so during continuous deletion, we can predict the key that needs to be retrieved from the cache for the next operation. During the prediction process, if there is no available cached data at the end of the most recently stored table in the historical data cache, and there is also no usable cache in the preloaded cache, it means that the cached data needs to be asynchronously preloaded. This ensures that when deleting to a specified position, the preloaded candidate word list data can be retrieved. This not only achieves synchronous refreshing of the candidate word list during character deletion but also minimizes performance consumption, requiring minimal performance even when the vehicle's system is under heavy load.
[0070] like Figure 7 As shown, this invention, based on the disclosed Android-based text input caching control method and system, also provides corresponding in-vehicle systems, electronic devices, and storage media:
[0071] A vehicle infotainment system, wherein the vehicle infotainment system is equipped with the aforementioned Android-based text input cache control system, and executes the aforementioned Android-based text input cache control method.
[0072] An electronic device includes: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the Android-based text input cache control method.
[0073] A computer-readable storage medium storing a computer program executable by an electronic device, which, when run on the electronic device, causes the electronic device to perform the steps of an Android-based text input cache control method.
[0074] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0075] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0076] The electronic device comprises a hardware layer, an operating system layer running on top of the hardware layer, and an application layer running on the operating system. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and memory. The operating system can be any one or more computer operating systems that control the electronic device through processes, such as Linux, Unix, Android, iOS, or Windows. Furthermore, in this embodiment of the invention, the electronic device can be a smartphone, tablet computer, or other handheld device, or a desktop computer, portable computer, or other electronic device; there is no particular limitation in this embodiment.
[0077] In this embodiment of the invention, the executing entity for electronic device control can be an electronic device itself, or a functional module within an electronic device capable of calling and executing a program. The electronic device can obtain the firmware corresponding to the storage medium. This firmware is provided by the supplier, and different storage media may have the same or different firmware; no limitation is made here. After obtaining the firmware corresponding to the storage medium, the electronic device can write this firmware into the storage medium; specifically, it burns the firmware corresponding to the storage medium into the storage medium. The process of burning the firmware into the storage medium can be implemented using existing technology, and will not be elaborated upon in this embodiment of the invention.
[0078] Electronic devices can also obtain reset commands corresponding to the storage media. The reset commands corresponding to the storage media are provided by the supplier. The reset commands corresponding to different storage media can be the same or different, and no restrictions are imposed here.
[0079] At this time, the storage medium of the electronic device is a storage medium on which the corresponding firmware has been written. The electronic device can respond to the reset command corresponding to the storage medium on which the corresponding firmware has been written, thereby resetting the storage medium on which the corresponding firmware has been written according to the reset command. The process of resetting the storage medium according to the reset command can be implemented by existing technology and will not be described in detail in this embodiment of the invention.
[0080] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0081] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features but not others included in other embodiments, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, any of the embodiments claimed in the claims can be used in any combination of embodiments of the invention.
[0082] In the description of this specification, references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0083] Furthermore, the technical solutions of the various embodiments of the present invention can be combined with each other, but only if they are feasible for those skilled in the art. If the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such combination of technical solutions does not exist and is not within the scope of protection claimed by the present invention.
[0084] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A text input caching control method based on Android, characterized in that, include: During text input, the text input content and the candidate word list are mapped into the historical cache pool, and the storage data of the current historical cache pool is detected in real time to see if it exceeds its upper limit. The system detects whether candidate word operations exist during the text input process. If such candidate word operations exist, caching is no longer performed. Check if a deletion operation exists. If a deletion operation exists, further check if there is any available historical cache data in the historical cache area. If available historical cached data exists, load the corresponding cached data; otherwise, if no corresponding cached data exists, check the preloaded data area. If the corresponding cached data exists in the preloaded data area, then the corresponding cached data is loaded from the preloaded data area; If the corresponding cached data is not found in the preloaded data area, the required cached data is loaded asynchronously. When the storage capacity of the historical cache is exceeded, the earliest stored data will be moved to the preload cache. Check if the capacity of the preloaded data area has reached its limit. If the capacity of the preloaded data area has reached its limit, delete the earliest data added to the preloaded data area.
2. The Android-based text input caching control method according to claim 1, characterized in that, The historical cache area and the preloaded data area are cached and stored using a LinkedHashMap that combines a doubly linked list structure with a HashMap.
3. The Android-based text input caching control method according to claim 1, characterized in that, It also includes locking the historical cache area and the preloaded data area to ensure that when multiple threads operate on the cache area, only one thread accesses the cache area at any given time.
4. An Android-based text input caching control system, used to execute the method according to any one of claims 1 to 3, characterized in that, include: The deletion operation detection and cache area detection module detects whether a deletion operation exists. If a deletion operation exists, it further detects whether there is any available historical cache data in the historical cache area. The historical cache area data detection and loading module loads the corresponding cache data if available historical cache data exists, or if no corresponding cache data exists, it detects the preloaded data area. The preloaded data area detection and loading module loads the corresponding cached data if the preloaded data area contains corresponding cached data.
5. A vehicle infotainment system, characterized in that, The vehicle infotainment system is equipped with the Android-based text input cache control system as described in claim 4, and executes the Android-based text input cache control method as described in any one of claims 1 to 3.
6. An electronic device, characterized in that, include: The system includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus; the memory stores a computer program, which, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1 to 3.
7. A computer-readable storage medium, characterized in that, It stores a computer program executable by an electronic device, which, when run on the electronic device, causes the electronic device to perform the steps of the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Information display method and device and electronic equipment
CN113589953A
Input method intelligent font library calling method aiming at user behavior habits
CN115563157A