File preloading method and device, electronic equipment and computer readable storage medium
By preloading the files needed during application execution into memory when the application starts, the problem of decreased application smoothness is solved, and more efficient file access and system performance are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
- Filing Date
- 2018-08-15
- Publication Date
- 2026-05-19
AI Technical Summary
When an application runs, it needs to load data files or configuration files from external storage into system memory, which leads to a decrease in the smoothness of operation.
When an application launch command is detected, the corresponding file is located and loaded into memory based on the pre-stored correspondence between files and applications. The application then reads the file in memory directly during its operation.
It improves the smoothness of application operation, avoids delays caused by frequent loading of files from external storage during application operation, and improves system performance.
Smart Images

Figure CN109284142B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to file preloading methods, apparatus, electronic devices, and computer-readable storage media. Background Technology
[0002] With the widespread use of mobile phones, tablets, and other devices, the types of apps (APPs) on these devices are also increasing. When an application runs, it needs to load a certain amount of data files or configuration files from external storage into the system memory, and then read the loaded files from memory to run them. Summary of the Invention
[0003] The purpose of this application is to provide a file preloading method, apparatus, electronic device, and computer-readable storage medium that can improve the smoothness of application operation.
[0004] The embodiments of this application provide a file preloading method, comprising: when an application start command is detected, searching for a file corresponding to the application according to a pre-stored correspondence between files and applications; wherein the file is a file used during the operation of the application; loading the searched corresponding file into memory, and directly reading the file loaded in memory during the operation of the application.
[0005] An embodiment of this application also provides a file preloading device, comprising: a search module, configured to, upon detecting an application launch command, search for a file corresponding to the application based on a pre-stored correspondence between files and applications; wherein the file is a file used during the operation of the application; a preloading module, configured to load the corresponding file found by the search module into memory; and a running module, configured to directly read the file loaded in memory during the operation of the application.
[0006] Embodiments of this application also provide an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the above-described file preloading method.
[0007] Embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described file preloading method.
[0008] This application's implementation improves application smoothness by detecting when an application is opened, using a pre-stored file-application mapping to locate the file corresponding to the opened application, and loading the located file into memory. In other words, when an application starts, the files needed for its operation are loaded into memory, and the loaded files are directly read during the application's execution, thus improving application performance. Attached Figure Description
[0009] One or more embodiments are illustrated by way of example with reference to the accompanying drawings, and these illustrations are not intended to limit the embodiments.
[0010] Figure 1 This is a flowchart of the file preloading method in the first embodiment of this application;
[0011] Figure 2 This is a diagram of the Android system architecture in the first embodiment of this application;
[0012] Figure 3 This is a flowchart of the file preloading method in the second embodiment of this application;
[0013] Figure 4 This is a diagram of the Android system architecture, memory, and external storage structure in the second embodiment of this application;
[0014] Figure 5 This is a flowchart of the file preloading method in the third embodiment of this application;
[0015] Figure 6 This is a structural block diagram of the file preloading device in the fourth embodiment of this application;
[0016] Figure 7 This is a structural block diagram of the file preloading device in the fifth embodiment of this application;
[0017] Figure 8 This is a structural block diagram of the file preloading device in the sixth embodiment of this application;
[0018] Figure 9 This is a schematic diagram of the structure of the electronic device provided in the seventh embodiment of this application. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the various embodiments of this application will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details have been presented in the various embodiments of this application to facilitate a better understanding of the application. However, the technical solutions claimed in this application can be implemented even without these technical details and with various variations and modifications based on the following embodiments.
[0020] The first embodiment of this application relates to a file preloading method. This embodiment can be implemented using, but is not limited to, an electronic device, such as a mobile phone, computer, tablet computer, or smart TV. When an application runs, it needs to read data files and / or configuration files. The files in this embodiment include data files and / or configuration files. The data files may include, but are not limited to, application data.
[0021] The following is a detailed description of the implementation details of the file preloading method in this embodiment. The following content is only for the convenience of understanding and is not limited to the implementation of this solution.
[0022] like Figure 1 As shown, file preloading methods include:
[0023] Step 101: Pre-store the mapping between files and applications in the database. The files corresponding to the applications are those used during the application's operation. For example, an application might use data files or configuration files during operation. Data files can be various types of files such as images, text, audio, and video; configuration files can be various types of files such as program items, screen colors, network connections, printer connections, mouse settings, and window size and position. The terminal device can obtain the file-application mapping from the network-side server and store it in the local database. Furthermore, in practical applications, synchronization with the network-side server can be performed to update the saved file-application mapping.
[0024] In this embodiment, the mapping between file indication information and application package names can be stored in a database, serving as a way to store the correspondence between files and applications. The file indication information can include the file path and file name. Since the information in the database can be stored on external storage, it will not be lost due to power outages or restarts of the terminal, ensuring that the file-application mapping is stably preserved within the terminal.
[0025] It should be noted that this embodiment does not limit how the "correspondence between file instruction information and application package name is stored in the database". In this embodiment, the correspondence between file instruction information and application package name can be stored in the database in a tabular manner.
[0026] It's important to note that each application may use multiple files during runtime. That is, one application can correspond to multiple files. Furthermore, different applications may use the same file; that is, one file can correspond to multiple different applications.
[0027] In some implementations, the database can store the correspondence between multiple applications and the files used by those applications during runtime. As shown in Table 1, an application with package name A corresponds to the filename "File1," and its file path is "Path1." The application with package name A also corresponds to the filename "File2," and its file path is "Path2," and so on. Table 1 is merely an example and does not limit the types or number of applications stored in the database, nor does it limit the number of files corresponding to each application during runtime. Furthermore, as shown in Table 1, different applications in this implementation may use the same file during runtime; that is, the same file may correspond to multiple different applications.
[0028] Table 1
[0029]
[0030]
[0031] The database in this embodiment is not limited to storing the correspondence between file instruction information and application package name in a tabular storage manner. It can also store the correspondence between file instruction information and application package name in other ways according to the actual design requirements. This embodiment does not impose any restrictions on this.
[0032] Step 102: Determine if an application launch command has been detected. If yes, proceed to step 103; otherwise, return to step 102.
[0033] like Figure 2 As shown, the Android system is used as an example for explanation. The Android system includes: application layer 21, framework layer 22, system library layer 23 (libc layer), and system kernel layer 24 (linuxkernel layer).
[0034] Applications layer 21 includes applications running on the Android virtual machine, such as browsers, contacts, calendars, and other applications. Users can interact with the applications in application layer 21.
[0035] Framework layer 22 refers to the core of Android application development, providing various basic API frameworks necessary for development. For example, framework layer 22 includes various service functions such as package name recording, application management, and background management.
[0036] The system library layer 23 (libraries layer) supports upper-layer applications. The Android system uses C / C++ libraries in this layer to support the various modules and components we use. System library layer 23 includes function libraries and the Android execution environment. Function libraries include web, open, sql, and other functions, while the Android execution environment includes the DV virtual machine, Java function libraries, and other environments.
[0037] System kernel layer 24 (Linux kernel layer) primarily implements functions such as file system, memory management, process scheduling, inter-process communication, power management, and drivers. It also implements other functions such as display drivers, camera drivers, and WiFi drivers. System kernel layer 24 communicates with hardware outside the Android architecture.
[0038] When a user needs to open an application in application layer 21, the user will perform a specific operation to open the application. Taking a click operation as an example, when frame layer 22 detects that the user clicks on the icon of an application on the desktop, it is considered that the opening command of the application has been detected, thereby triggering the opening of the application and proceeding to step 103.
[0039] Step 103: Based on the correspondence between the application opened by the opening instruction and the database, find the file corresponding to the application and load the found file into memory.
[0040] In this embodiment, when an application is opened and displayed on the terminal interface (i.e., an application is launched), the application management service function of the framework layer 22 can record which application was opened, and can send information such as the application's package name to the service unit with background management services in the same layer through the local daemon process of this layer. Furthermore, the package name of the application can be recorded through the package name recording function. In other words, when an application is opened and displayed on the terminal interface, the package name of the application can be recorded in the framework layer 22 of the Android system.
[0041] Since the database pre-stores the correspondence between file indication information and application package names, it can retrieve the file indication information corresponding to the application from the database based on the application's package name, and then retrieve the file from the external storage where the file is stored based on the retrieved file indication information, and load the retrieved file into memory.
[0042] The file indication information includes the file name and file path. That is, based on the found file name and file path, the system retrieves files that the application might use during runtime and loads these files into memory.
[0043] Step 104: During the operation of the opened application, files loaded into memory are read directly. Since files that may be used during application startup are loaded into memory, if a file is needed during application operation, it can be read directly from memory, improving the smoothness of application operation. Furthermore, even in special cases where the required file cannot be read from memory during application operation (such as when the application is upgraded but the terminal device still saves the old application-file mapping), the required file can be retrieved from external storage and loaded into memory to ensure smooth application operation. Moreover, in the event of such a special case, the file's information can be added to the saved file-application mapping, thereby achieving automatic updates to the file-application mapping.
[0044] In practical applications, files loaded into memory can be released when the application is closed; or, files loaded into memory can be deleted when the application is uninstalled or deleted. For example, when an application is uninstalled or deleted, the name of the file corresponding to the application can be retrieved from the database based on the application's package name, and the file loaded into memory can be deleted based on the file name. Furthermore, after the uninstallation or deletion of the application is complete, the mapping between the uninstalled application and its file can be removed from the saved mapping, ensuring that the applications in the saved mapping are all applications that the terminal device might open.
[0045] In this implementation, files needed by the application during its operation are loaded into memory when the application starts, instead of retrieving and loading files only when needed during application runtime. Compared to the approach of retrieving and loading files from external storage only when needed during application runtime, the ability to directly read required files from memory during runtime improves application smoothness and better meets user needs.
[0046] Furthermore, the application loading-as-you-go approach results in the scattered distribution of related files required by the application on external storage, further slowing down file loading and making the application run less smoothly. Therefore, this implementation can also avoid the scattered distribution of related files required by the application on external storage, thereby helping to further improve the smoothness of application operation.
[0047] Although the terminal device locally stores the correspondence between files and applications in this embodiment, in practical applications, it can also obtain or directly query the correspondence between files and applications from the server that stores the correspondence between files and applications in real time when an application opening command is detected. That is, the correspondence between files and applications is pre-stored on the network side, and the file corresponding to the opened application is found according to the correspondence stored on the network side and pre-loaded. This will not be elaborated further here.
[0048] The second embodiment of this application relates to a file preloading method. In this second embodiment, by recording the application package name and the indication information of the files called by the application as a correspondence between the application and the files during the first runtime of the application, and storing this information in a database, an effective and feasible implementation method for writing the correspondence between file indication information and package names into a database is provided. This provides an effective and feasible solution for loading relevant file indication information when the application runs subsequently.
[0049] like Figure 3 As shown, the file preloading method of this embodiment includes:
[0050] Step 301: Determine if an application's first launch command has been detected. If yes, proceed to step 302; otherwise, return to step 301. Since the framework layer 22 triggers the launch of an application when it detects that the user has performed a specific action (such as a click) on an application icon on the desktop to open that application, in this step, if the user's first action to open an application icon on the desktop is detected, it is determined that an application's first launch command has been detected. The application is then opened and displayed on the terminal interface, proceeding to step 302.
[0051] Step 302: Record the application's package name in the buffer. Specifically, this can be achieved using the package name recording function module added to framework layer 22 (such as...). Figure 2As shown), the package name recording module of the framework layer 22 records the package name of the foreground application in the buffer when an application is first opened and displayed on the terminal interface (i.e., when the application is first launched). The foreground application package name recording module records the application package name in the buffer through the I / O interface of the system kernel layer 24, such as... Figure 4 As shown. The buffer (the area marked 251 in the diagram) is an address space allocated in memory 25. In other words, a buffer is a storage space of a specified size reserved in memory to be used as a temporary storage area for data. Using a buffer has two advantages: 1. It reduces the number of actual physical read and write operations; 2. The location of the buffer is allocated when it is created, and this memory area is always reused, which can reduce the number of times storage space is dynamically allocated and reclaimed.
[0052] Step 303: When a file opening operation is detected, obtain the package name of the application in the buffer.
[0053] The framework layer 22 can reserve a function interface to communicate with the `open` function in the system library layer 23, used to call the `open` function to run data. The `open` function is generally used to open or create a file, and various parameters such as file attributes and user permissions can be customized according to the parameters. The first parameter in the `open` function is the pathname or filename of the file to be opened. In this embodiment, by overriding the `open` function, the name and path of the opened file can be obtained from the execution data of the `open` function. Furthermore, in this embodiment, the system library layer 23 is relative to the application layer 21; in fact, this system library layer 23 refers to the libraries within the Android framework. `libc` is a function library within the library, and the `open` function is located within the `libc` function library, which is usually stored in external memory. The framework layer 22 obtains the application's package name from the buffer through the I / O interface in the system kernel layer 24.
[0054] Step 304: Record the indication information of the file to be opened by the process, and write it into the database as the indication information of the file corresponding to the package name of the application in the buffer, so as to store the correspondence between the application package name and the file indication information in the database.
[0055] Specifically, the recording process in framework layer 22 writes the opened file indication information and the mapping relationship of the acquired package names to the database through the I / O interface in system kernel layer 24. Writing the opened file indication information and the mapping relationship to the database through the recording process is convenient. Furthermore, the recording is performed by a recording thread within the recording process. Since the recording thread consumes fewer system resources, the writing of the mapping relationship can be achieved with fewer system resources.
[0056] The file indication information includes at least the file path and file name. The database (as shown by label 261 in the figure) is a region established in external storage 26 for storing the correspondence between file indication information and package names. By writing the correspondence between file indication information and package names into the database in the above manner, an effective and feasible implementation method for writing this correspondence into the database is provided, offering an effective and feasible solution for loading relevant file indication information during subsequent application runtime.
[0057] This implementation may, but is not limited to, storing the correspondence between file indication information and application package names in a table format in the database. It may also store the correspondence between file indication information and application package names in other ways according to the actual design requirements. During the operation of each application, it may use one file or multiple files.
[0058] Step 305: Determine whether the currently opened application is a preset target optimization program. If yes, proceed to step 306; otherwise, return to step 305.
[0059] In this embodiment, when an application is opened, the package name of the opened application is obtained, and it is determined whether the currently opened application is a preset target optimized program based on the obtained package name. Specifically, the detection process in this step is as follows: the framework layer 22 communicates with the buffer through the I / O interface in the system kernel layer 24 to obtain the package name of the application in the buffer, and determines whether the currently opened application is a preset target optimized program based on the obtained package name. It should be noted that in actual design, the determination of whether the currently opened application is a target optimized program is not limited to the above method; this embodiment does not impose such limitations, and the above is merely an example.
[0060] The target optimizer can be a single application or multiple applications. The target optimizer can be configured by the user or by the terminal's system default settings. For example, a whitelist can be set within the terminal, and all applications on the whitelist will be targeted optimizers. Alternatively, the target optimizer can be set by defining an application category; for instance, if the category is set to "games," then any application in the "games" category will be a target optimizer.
[0061] Furthermore, it's worth mentioning that in practical applications, all applications in the stored mapping can be the target optimization program. That is, before step 304, a judgment step can be added to determine whether the package name of the application in the buffer is the package name of the target optimization program. If it is, then step 304 is executed, recording the indication information of the file to be opened by the process as the indication information of the file corresponding to the package name of the application in the buffer, and writing it to the database. If the package name of the application in the buffer is not the package name of the target optimization program, no recording is performed. This design allows users or the system to define the target optimization program to be optimized, preloading only the files of the target optimization program. It also reduces the space required to store the file-application mapping in the database and further improves the efficiency of finding the corresponding file for the optimized application.
[0062] Step 306: Based on the correspondence between the opened application and the database, find the file corresponding to the opened application and load the found file into memory.
[0063] Specifically, based on the application's package name, the database is used to find the file name and path of the file that the application might use during runtime from the "file indication information and package name correspondence". The file is then retrieved based on the file name and path and loaded into memory. Specifically, the file can be loaded into the area indicated by label 252 in the figure.
[0064] In practical applications, file priorities can be pre-defined. Specifically, file priorities can be pre-set based on the number of times a file is used, its size, or its frequency of use. When loading these files into memory, files with higher priority are loaded first, based on memory usage, file size, and file priority. Specifically, when loading the found files into memory, the memory usage and the size of each file are checked first. If the memory usage is high (limited available memory space), higher priority files can be selected to be loaded into memory. Alternatively, if the memory space required by the found files exceeds the available memory space (i.e., the available memory space is insufficient to store all the found files), higher priority files can be loaded first.
[0065] For example, the following is merely an example and does not further limit this implementation. The files identified based on the searched file indication information are P, L, M, and N, and the sum of their sizes is W1, while the available memory space is W2. If W1 is greater than W2, then the available memory space is insufficient to store all the searched files. In this case, the higher-priority files (such as files P, L, and M) need to be loaded into memory first. Alternatively, a memory occupancy threshold can be preset; if the current memory occupancy exceeds the set threshold, then the higher-priority files are selected and loaded into memory.
[0066] For example, using the QQ application as an example, we will explain in detail how to set file priority, but this is not intended to further limit the method of setting file priority; it is merely an example for illustration.
[0067] For example, during the first run of QQ, files F1, F2, F3, F4, and F5 are used; during the second run, they are used; and during the third run, they are used; with a preset count of 3. Since files F1, F2, and F3 are used a maximum of 3 times, they can be considered frequently used files during application runtime and are therefore classified as high-priority files. Conversely, since files F4, F5, F6, F7, F8, and F9 are used less than 3 times, they are not frequently used files during application runtime and are therefore classified as low-priority files. If the available memory is insufficient to load all the files required for QQ to run, or if the current memory usage exceeds the set memory usage threshold, you can choose to load only F1, F2, and F3.
[0068] Step 307: During the execution of the opened application, the file loaded in memory is read directly. Specifically, the application can directly read the file loaded in memory through the I / O interface in system kernel layer 24 to begin execution.
[0069] In this embodiment, when the application starts, it can directly retrieve the corresponding file indication information from the database. Based on this information, it loads the files required for application runtime into memory and reads these files directly during the application's operation, rather than loading a file into memory only when needed. Compared to loading files into memory as the application runs, this approach is faster, improves application smoothness, and better meets user needs. Furthermore, loading files into memory as the application runs results in a scattered distribution of required files on external storage, further slowing down file loading and making the application run less smooth. This approach, however, loads the necessary files into memory at application startup, allowing the application to read the required files directly from memory during runtime, avoiding the scattered distribution of files on external storage and further improving application smoothness.
[0070] The third embodiment of this application relates to a file preloading method. The third embodiment improves upon the first embodiment, primarily by determining the current memory usage before searching for the file corresponding to the opened application. If the current memory usage is greater than or equal to a preset threshold, file preloading is not performed. If the current memory usage is less than the preset threshold, the file corresponding to the opened application is then searched for and loaded into memory.
[0071] The specific process is as follows: Figure 5 As shown, in step 501, the correspondence between files and applications is pre-stored in the database. This step is similar to step 101 and will not be described again here.
[0072] In step 502, it is determined whether an application launch command has been detected. If so, proceed to step 503; otherwise, return to step 502. This step is similar to step 102 and will not be described again here.
[0073] In step 503, it is determined whether the current memory usage rate is less than a preset usage rate threshold. This threshold can be set based on experience. If it is determined to be less than the preset threshold, proceed to step 504; if it is determined to be greater than or equal to the preset threshold, proceed to step 506, where, during application execution, the required files are retrieved from external storage and loaded into memory.
[0074] In step 504, based on the correspondence between the application opened by the opening instruction and the database, the file corresponding to the application is located, and the found file is loaded into memory. Then, proceed to step 505, where the file loaded into memory is directly read during the execution of the opened application. Steps 504 and 505 are similar to steps 103 and 104, respectively, and will not be described in detail here.
[0075] Step 506: During the operation of the application, the required files are retrieved from external storage and loaded into memory.
[0076] In this embodiment, the file loading method is differentiated based on the current memory usage rate. If the current memory usage rate has not exceeded a preset threshold, the files required by the application during its operation are loaded into memory when the application starts, and the loaded files are directly read during the application's operation, which improves the smoothness of the application's operation. If the current memory usage rate has exceeded the preset threshold, the method of retrieving the required file from external storage and loading it into memory only when needed during the application's operation can effectively reduce the burden on current memory resources.
[0077] The fourth embodiment of this application relates to a file preloading device. For example... Figure 6 As shown, the file preloading device includes a lookup module 42, used to look up the file corresponding to the application based on a pre-stored file-application mapping when an application launch command is detected. The file is one used during the application's operation. In a specific implementation, the pre-storage of the file-application mapping can be achieved through a preset module 41. The pre-storage of the file-application mapping includes: recording the application package name and the indication information of the files called by the application as the application-file mapping when the application first runs, and storing this mapping in a database; or obtaining the file-application mapping from the network side and storing it in the database.
[0078] The preloading module 43 is used to load the corresponding file found by the search module into memory.
[0079] The execution module 44 is used to directly read files loaded in the memory during the execution of the application.
[0080] In this embodiment, when the application starts, it can directly retrieve the corresponding file indication information from the database. The file indication information includes at least the file path and the file name. Based on the file indication information, the files required for application runtime are loaded into memory, and the loaded files are read directly during the application's operation, rather than loading a file into memory only when needed during application runtime. Compared to the approach of loading files into memory as the application runs, this approach consumes less time, improves application smoothness, and helps meet user needs. Furthermore, the approach of loading files into memory as the application runs results in a scattered distribution of required files on external storage, further slowing down file loading and making application performance less smooth. However, this approach loads the necessary files into memory at application startup, allowing the application to directly read the required files from memory during runtime, avoiding the scattered distribution of required files on external storage and further improving application smoothness.
[0081] The fifth embodiment of the present invention relates to a file preloading device. For example... Figure 7 As shown, the system includes: a lookup module 42, used to find the file corresponding to the application based on a pre-stored file-application mapping when an application launch command is detected. The file is one used during the application's execution. In a specific implementation, the pre-storage of the file-application mapping can be achieved through a preset module 41. A preloading module 43 is used to load the corresponding file found by the lookup module into memory. A running module 44 is used to directly read the file loaded into memory during application execution.
[0082] The preset module 41 includes: a recording submodule 411, used to record the application's package name in a buffer when the application is first launched; an acquisition submodule 412, used to acquire the application's package name in the buffer when a file opening operation is detected; and a writing submodule 413, used to write the indication information of the opened file as the indication information of the file corresponding to the application's package name in the buffer into a database. Specifically, the writing submodule 413 is used to write the indication information of the opened file as the indication information of the file corresponding to the application's package name in the buffer into the database through the recording process.
[0083] In a specific implementation, the applications written into the database by the preset module 41 can all be target optimized programs. Before searching for the file corresponding to the application, the search module 42 can first determine whether the application opened by the currently detected start command is a preset target optimized program. If the application opened by the start command is a target optimized program, then it searches for the file corresponding to the opened application based on the application and the aforementioned correspondence. For example, it can determine whether the application opened by the currently detected start command is a preset target optimized program by obtaining the package name of the application opened by the start command and determining whether the application opened by the start command is a preset target optimized program based on the package name.
[0084] The sixth embodiment of this application relates to a file preloading device. For example... Figure 8 As shown, the system includes: a lookup module 42, used to find the file corresponding to the application based on a pre-stored file-application mapping when an application launch command is detected. The file is one used during the application's execution. In a specific implementation, the pre-storage of the file-application mapping can be achieved through a preset module 41. A preloading module 43 is used to load the corresponding file found by the lookup module into memory. A running module 44 is used to directly read the file loaded into memory during application execution.
[0085] The file preloading device in this embodiment further includes: a judgment module 46, used to judge the current memory usage rate before searching for the file corresponding to the application; and a search module 42, specifically used to search for the file corresponding to the opened application only when the judgment module 46 determines that the current memory usage rate is less than a preset usage rate threshold.
[0086] The seventh embodiment of this application relates to an electronic device. The electronic device includes at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor using a file preloading method according to a first or second embodiment. The memory and processor are connected via a bus, which may include any number of interconnected buses and bridges, connecting various circuits of one or more processors and the memory together. The bus may also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be further described herein.
[0087] The bus interface provides an interface between the bus and the transceiver. The transceiver can be a single component or multiple components, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by the processor is transmitted over the wireless medium via an antenna, which further receives data and transmits it back to the processor. The processor manages the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory can be used to store data used by the processor during operation.
[0088] like Figure 9 As shown, the electronic device may include: a memory 601, a central processing unit (CPU) 602 (processor), and the memory 601 for storing executable program code; the processor 602 reads the executable program code stored in the memory 601 to run a program corresponding to the executable program code for execution.
[0089] When an application launch command is detected, the file corresponding to the application is searched according to the pre-stored correspondence between files and applications; wherein the file is a file used during the operation of the application; the searched corresponding file is loaded into memory, and the file loaded into memory is directly read during the operation of the application.
[0090] The electronic device also includes: a peripheral interface 603, a radio frequency (RF) circuit 605, an audio circuit 606, a speaker 611, a power management chip 608, an input / output (I / O) subsystem 609, a touch screen 612, other input / control devices 610, and an external port 604. These components communicate via one or more communication buses or signal lines 607.
[0091] It should be understood that the illustrated electronic device 600 is merely an example of an electronic device, and the electronic device 600 may have more or fewer components than those shown in the figure, may combine two or more components, or may have different component configurations. The various components shown in the figure can be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application-specific integrated circuits. The electronic device provided in this embodiment, using a mobile phone as an example, will be described in detail below.
[0092] The memory 601 can be accessed by the CPU 602, peripheral interface 603, etc. The memory 601 may include high-speed random access memory (RAM) and non-volatile memory, such as one or more disk storage devices, flash memory devices, or other volatile solid-state storage devices. In this embodiment, the memory 601 includes main memory 6011 and secondary memory 6012. Secondary memory 6012 is used to store files and the correspondence between files and applications (i.e., the database is located in secondary memory 6012). A buffer is allocated in main memory 6011 to record the package names of opened applications. When searching for a file corresponding to an opened application, the file corresponding to the application is retrieved from secondary memory 6012 based on the package name recorded in the buffer and the correspondence stored in the database, and then loaded into main memory 6011.
[0093] Peripheral interface 603 can connect the device's input and output peripherals to CPU 502 and memory 601.
[0094] I / O subsystem 609 connects input / output peripherals on the device, such as touchscreen 612 and other input / control devices 610, to peripheral interface 603. I / O subsystem 609 may include display controller 6091 and one or more input controllers 6092 for controlling other input / control devices 610. The one or more input controllers 6092 receive or send electrical signals to other input / control devices 610, which may include physical buttons (press buttons, rocker buttons, etc.), dial pads, slide switches, joysticks, and click wheels. It is worth noting that input controller 6092 can be connected to any of the following: keyboard, infrared port, USB interface, and pointing device such as a mouse.
[0095] The touch screen 612 is an input and output interface between the user terminal and the user, and displays visual output to the user. The visual output may include graphics, text, icons, videos, etc.
[0096] The display controller 6091 in the I / O subsystem 609 receives or sends electrical signals to the touchscreen 612. The touchscreen 612 detects touches, and the display controller 6091 converts these touches into interactions with user interface objects displayed on the touchscreen 612, thus achieving human-computer interaction. These user interface objects can be icons for running games, connecting to a network, etc. It is worth noting that the device may also include an optical mouse, which is a touch-sensitive surface that does not display visual output, or an extension of the touch-sensitive surface formed by the touchscreen.
[0097] RF circuit 605 is primarily used to establish communication between the mobile phone and the wireless network (i.e., the network side), enabling data reception and transmission between the mobile phone and the wireless network. Examples include sending and receiving SMS messages and emails. Specifically, RF circuit 605 receives and transmits RF signals, also known as electromagnetic signals. RF circuit 605 converts electrical signals into electromagnetic signals or vice versa, and uses these electromagnetic signals to communicate with the communication network and other devices. RF circuit 605 may include known circuits for performing these functions, including but not limited to antenna systems, RF transceivers, one or more amplifiers, tuners, one or more oscillators, digital signal processors, CODEC (Coder-Coder) chipsets, Subscriber Identity Modules (SIMs), etc.
[0098] The audio circuit 606 is mainly used to receive audio data from the peripheral interface 603, convert the audio data into an electrical signal, and send the electrical signal to the speaker 611.
[0099] Speaker 611 is used to convert the voice signal received by the mobile phone from the wireless network via RF circuit 605 back into sound and play the sound to the user.
[0100] The power management chip 608 is used to provide power and manage the power supply for the CPU 602, the I / O subsystem, and the hardware connected to the peripheral interface 603.
[0101] This embodiment is a device embodiment corresponding to the first or second embodiment, and therefore can be implemented in conjunction with the first or second embodiment. The relevant technical details mentioned in the first or second embodiment remain valid in this embodiment, and the technical effects achievable in the first or second embodiment can also be achieved in this embodiment. To reduce repetition, they will not be repeated here. Correspondingly, the relevant technical details mentioned in this embodiment can also be applied to the first or second embodiment.
[0102] In this embodiment, when the application starts, it can directly retrieve the corresponding file indication information from the database. Based on this information, it loads the files required for application runtime into memory and reads these files directly during the application's operation, rather than loading a file into memory only when needed. Compared to loading files into memory as the application runs, this approach is faster, improves application smoothness, and better meets user needs. Furthermore, loading files into memory as the application runs results in a scattered distribution of required files on external storage, further slowing down file loading and making the application run less smooth. This approach, however, loads the necessary files into memory at application startup, allowing the application to read the required files directly from memory during runtime, avoiding the scattered distribution of files on external storage and further improving application smoothness.
[0103] The eighth embodiment of this application relates to a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the file preloading method of the first, second, or third embodiment.
[0104] That is, those skilled in the art will understand that all or part of the steps in the methods described above can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0105] Those skilled in the art will understand that the above embodiments are specific implementations of this application, and in practical applications, various changes can be made in form and detail without departing from the spirit and scope of this application.
Claims
1. A file preloading method, characterized in that, include: When an application launch command is detected, the system searches for the file corresponding to the application based on a pre-stored file-application mapping. The file is one used during the application's execution. The pre-stored file-application mapping is achieved by: recording the application's package name in a buffer via the system kernel layer upon initial application launch; retrieving the application's package name from the buffer upon detecting a file opening operation; and writing the indication information of the opened file, as the file's indication information corresponding to the application's package name in the buffer, into a database via a process recording mechanism. This indication information includes the file's name and path. All the corresponding files found are loaded into memory, and the files loaded into memory are read directly during the operation of the application. If the required file cannot be read from the memory during the operation of the application, the required file is retrieved from the external storage and loaded into the memory. The indication information of the required file is added to the correspondence to update the pre-stored correspondence between the file and the application. When the application is closed, the file loaded into memory is released.
2. The file preloading method according to claim 1, characterized in that, The instruction information of the file includes at least the path of the file and the name of the file.
3. The file preloading method according to claim 1, characterized in that, The applications in the mapping relationship are all target optimization programs; before searching for the file corresponding to the application based on the application and the mapping relationship, the file preloading method further includes: Determine whether the application launched by the currently detected launch command is a preset target optimization program; When the application opened by the opening command is the target optimized program, the file corresponding to the opened application is searched according to the application and the correspondence.
4. The file preloading method according to claim 3, characterized in that, The step of determining whether the application launched by the currently detected launch command is a preset target optimization program includes: Get the package name of the application currently opened by the detected opening command; Based on the obtained package name, determine whether the application opened by the opening command is a preset target optimization program.
5. The file preloading method according to claim 1, characterized in that, Also includes: Before searching for the file corresponding to the application, determine the current memory usage. If the current memory usage is less than a preset usage threshold, then the process of finding the file corresponding to the application will be executed again.
6. A file preloading device, characterized in that, include: The search module is used to search for the file corresponding to the application based on a pre-stored correspondence between files and applications when an application launch command is detected; wherein the file is a file used by the application during its operation. Specifically, a preset module is used to pre-store the correspondence between files and applications; the preset module is used to record the package name of the application in a buffer when the application runs for the first time; the package name of the application and the indication information of the files called by the application are recorded as the correspondence between the application and the file and stored in the database; The preset module includes: a recording submodule, used to record the application's package name into a buffer through the system kernel layer when the application is first launched; an acquisition submodule, used to acquire the application's package name in the buffer when a file opening operation is detected; and a writing submodule, used to write the indication information of the opened file as the indication information of the file corresponding to the application's package name in the buffer into the database through the recording process; the indication information includes the file name and the file path. A preloading module is used to load all the corresponding files found by the search module into memory; The running module is configured to, if the required file cannot be read from the memory during the operation of the application, retrieve the required file from external storage and load it into the memory, supplement the correspondence with the indication information of the required file, so as to update the correspondence between the pre-stored file and the application; the running module is also configured to directly read the file loaded in the memory during the operation of the application; and release the file loaded in the memory when the application is closed.
7. An electronic device, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the file preloading method as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the file preloading method according to any one of claims 1 to 5.