Information reading method, device, apparatus, and storage medium

By utilizing producer and consumer threads in parallel processing within the in-vehicle Android system and generating scan control commands based on changes in file attributes, the problem of low efficiency in full scans when peripherals such as USB flash drives are inserted is solved, achieving more efficient information reading.

CN119440864BActive Publication Date: 2026-05-15CHENGDU CELIS TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHENGDU CELIS TECH CO LTD
Filing Date
2024-10-12
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

In in-vehicle Android systems, a full scan is performed every time a USB flash drive or other peripheral device is plugged in or out, resulting in low efficiency. This full scan is triggered even when files have not been updated, impacting user experience and system performance.

Method used

By listening for peripheral insertion events, reading file attribute information and comparing it with historical attribute information, scanning control instructions are generated. Producer and consumer threads are used for parallel processing, and a full scan is only performed when the file changes; otherwise, scanning is prohibited, thus improving efficiency.

Benefits of technology

It reduces invalid scans, improves information reading efficiency, shortens scanning and parsing time, and enhances user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440864B_ABST
    Figure CN119440864B_ABST
Patent Text Reader

Abstract

The application relates to an information reading method, device, equipment and storage medium. The method comprises the following steps: after listening to an insertion event corresponding to an external device, reading file attribute information corresponding to the external device from the external device and obtaining historical attribute information corresponding to the external device from a local device; generating a scanning control instruction according to the file attribute information and the historical attribute information; when the type of the scanning control instruction is a start scanning type, using a producer thread to scan a file stored in the external device and adding file information corresponding to the file to a producer queue; using a consumer thread to analyze the file information in the producer queue and storing the analyzed file information in a local storage space; the producer thread and the consumer thread work in parallel. The application scans the file stored in the external device only when the type of the scanning control instruction is the start scanning type, thereby avoiding the problem that the information reading efficiency is reduced due to the scanning of the external device in the case that the file stored in the external device has not been changed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of vehicle technology, and in particular to an information reading method, apparatus, device, and storage medium. Background Technology

[0002] As the entertainment functions of smart cars become increasingly sophisticated, users' demand for in-vehicle systems to read files stored on external devices is growing stronger. For example, more and more users store media, pictures, and other files on USB drives, enabling the in-vehicle system to play and browse these files while driving. Currently, most smart car in-vehicle systems use the Android operating system. Reading files stored on external devices involves the following steps: After the Android system detects the USB drive being inserted, the Media Scanner module in the Android system first performs a full scan of all files on the USB drive, storing the file information of each file in a preset queue during the scan. After the full scan is complete, each file in the queue is parsed individually, and the parsed file information is then stored in the in-vehicle system.

[0003] However, in in-vehicle scenarios, users frequently plug and unplug peripherals such as USB drives. Each time a peripheral is plugged in or unplugged, the Android system has to reread the file information stored on the peripheral, resulting in low efficiency when reading such files. Furthermore, even if the files on the peripheral haven't been updated, regardless of whether a full scan has been performed previously, the Android system will still trigger a full scan every time it detects a peripheral being plugged in or unplugged, incurring additional system overhead and impacting information retrieval efficiency. During a full scan, if the peripheral contains a large number of media and image files, the scan time is relatively long, leading to low scanning efficiency and affecting the user experience. In addition, a full scan scans all file types, including those the user doesn't need, further reducing scanning efficiency. Summary of the Invention

[0004] This application provides an information reading method, apparatus, device, and storage medium to solve the problem that the Android system has to reread the file information stored in the peripheral device every time it is plugged in or unplugged, resulting in low efficiency when the Android system reads the file information stored in the peripheral device.

[0005] To address the aforementioned technical problems, the technical solution of this application is provided through the following embodiments:

[0006] This application provides an information reading method, comprising: after listening to an insertion event corresponding to a peripheral device, reading file attribute information corresponding to the peripheral device from the peripheral device and obtaining historical attribute information corresponding to the peripheral device from the local storage; generating a scan control instruction based on the file attribute information and the historical attribute information; when the type of the scan control instruction is a start scan type, using a preset producer thread to scan the files stored in the peripheral device and adding the file information corresponding to the files to a preset producer queue; using a preset consumer thread to parse the file information in the producer queue and storing the parsed file information in a preset local storage space; wherein the producer thread and the consumer thread work in parallel.

[0007] The step of generating a scan control instruction based on the file attribute information and the historical attribute information includes: if the file attribute information and the historical attribute information are different, generating a scan control instruction of type "start scan"; if the file attribute information and the historical attribute information are the same, querying whether file information corresponding to the peripheral exists in the local storage space; if file information corresponding to the peripheral exists in the local storage space, generating a scan control instruction of type "disable scan"; if file information corresponding to the peripheral does not exist in the local storage space, generating a scan control instruction of type "start scan".

[0008] The scan control command of the start scan type includes: target scan control command and full scan control command; the step of using a preset producer thread to scan the files stored in the peripheral device includes: if the scan control command is a target scan control command of the start scan type, then the producer thread is used to scan the files stored in the peripheral device that meet the preset conditions; if the scan control command is a full scan control command of the start scan type, then the producer thread is used to scan all files stored in the peripheral device.

[0009] The consumer threads include a parsing consumer thread and a storage consumer thread. The step of parsing the file information in the producer queue and storing the parsed file information in a preset local storage space using the preset consumer threads includes: using the parsing consumer thread to parse the file information in the producer queue and add the parsed file information to the preset consumer queue; using the storage consumer thread to generate tag values ​​corresponding to the file information in the consumer queue, and storing the file information in the local storage space according to the tag values ​​corresponding to the file information; wherein the parsing consumer thread and the storage consumer thread work in parallel.

[0010] The consumer threads include a parsing consumer thread and a storage consumer thread. The step of parsing file information in the producer queue and storing the parsed file information in a preset local storage space using the preset consumer threads includes: using the parsing consumer thread to parse preset fields of the file information in the producer queue and adding the parsed field information to the preset consumer queue; using the storage consumer thread to generate tag values ​​corresponding to the field information in the consumer queue, and storing the field information in the local storage space according to the tag values ​​corresponding to the field information; wherein the parsing consumer thread and the storage consumer thread work in parallel.

[0011] The step of using a preset consumer thread to parse the file information in the producer queue includes: using the consumer thread to call a preset third-party processing framework; and using the third-party processing framework to parse the file information in the producer queue.

[0012] The method further includes: if the file attribute information and the historical attribute information are different, then updating the historical attribute information according to the file attribute information.

[0013] This application embodiment also provides an information reading device, including: a reading and acquisition module, used to read file attribute information corresponding to the peripheral from the peripheral and acquire historical attribute information corresponding to the peripheral from the local storage after listening to an insertion event corresponding to the peripheral; a generation module, used to generate a scan control command based on the file attribute information and the historical attribute information; a scanning and adding module, used to scan the files stored in the peripheral using a preset producer thread and add the file information corresponding to the files to a preset producer queue when the type of the scan control command is a start scan type; and a parsing and storage module, used to parse the file information in the producer queue using a preset consumer thread and store the parsed file information in a preset local storage space; wherein the producer thread and the consumer thread work in parallel.

[0014] This application embodiment also provides an information reading device, including: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the processor is configured to execute an information reading program stored in the memory to implement the information reading method described above.

[0015] This application also provides a computer-readable storage medium storing computer-executable instructions, which are executed to implement the information reading method described in any of the above claims.

[0016] Compared with the prior art, the technical solution provided in this application has the following advantages: The method provided in this application can, after listening to the insertion event corresponding to the peripheral device, read the file attribute information corresponding to the peripheral device from the peripheral device and obtain the historical attribute information corresponding to the peripheral device from the local storage; generate a scan control instruction based on the file attribute information and the historical attribute information; when the type of the scan control instruction is a start scan type, use a preset producer thread to scan the files stored in the peripheral device and add the file information corresponding to the files to a preset producer queue; use a preset consumer thread to parse the file information in the producer queue and store the parsed file information in a preset local storage space; wherein, the producer thread and the consumer thread work in parallel. In this embodiment, after detecting an insertion event corresponding to a peripheral device, the file stored in the peripheral device is not scanned in all cases. Instead, based on file attribute information and historical attribute information that indicate whether the file stored in the peripheral device has changed, an appropriate type of scan control instruction is generated. The file stored in the peripheral device is only scanned when the type of the scan control instruction is "start scan". This avoids the problem of reducing information reading efficiency by scanning the peripheral device when the file stored in the peripheral device has not changed. Furthermore, this embodiment uses dual threads to scan the file and parse the file information separately, which can further improve information reading efficiency. Attached Figure Description

[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0020] Figure 1This is a flowchart of an information reading method according to an embodiment of this application;

[0021] Figure 2 This is a flowchart illustrating the steps for generating scanning control instructions according to an embodiment of this application;

[0022] Figure 3 This is a schematic diagram illustrating the operation of a thread according to an embodiment of this application;

[0023] Figure 4 This is a structural diagram of an information reading device according to an embodiment of this application;

[0024] Figure 5 This is a structural diagram of an information reading device according to an embodiment of this application. Detailed Implementation

[0025] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0026] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.

[0027] This application provides an information reading method. This application embodiment is executed on the vehicle side. For example... Figure 1 The diagram shown is a flowchart of an information reading method according to an embodiment of this application.

[0028] Step S110: After listening to the insertion event corresponding to the peripheral, read the file attribute information corresponding to the peripheral from the peripheral and obtain the historical attribute information corresponding to the peripheral from the local machine.

[0029] Peripherals refer to external storage devices. Types of peripherals include, but are not limited to, USB flash drives.

[0030] An insertion event is an event triggered when a peripheral device is detected being inserted. For example, when a USB flash drive is inserted into a vehicle's interface, the USB flash drive mounting module detects the insertion and triggers an insertion event.

[0031] File attribute information refers to the attribute information of the file currently stored in the peripheral device. File attribute information includes, but is not limited to: the file name corresponding to the file stored by the peripheral device at the current time and the modification date of the file.

[0032] Historical attribute information refers to the attribute information of files historically stored in peripherals. This information includes, but is not limited to, the filename of a file stored on the peripheral before the current time and the file's modification date. Furthermore, the historical attribute information for a peripheral is stored locally in the vehicle (the vehicle's local storage space). If the historical attribute information for a peripheral is not found, it can be determined that the historical attribute information for that peripheral is null.

[0033] In this embodiment, if a peripheral device unplug event is detected, a peripheral device unplug notification is issued without triggering the execution of the information reading method of this application. If a peripheral device insertion event is detected, it is checked whether a file is stored in the peripheral device; if a file is found to be stored in the peripheral device, file attribute information is read from the peripheral device; if no file is found to be stored in the peripheral device, a notification that no file is stored in the peripheral device is issued.

[0034] Step S120: Generate scan control instructions based on the file attribute information and the historical attribute information.

[0035] Scan control commands are used to instruct whether to start scanning or disable scanning of files stored on peripheral devices. The types of scan control commands include: Start Scan and Disable Scan. Start Scan commands instruct the user to begin scanning files stored on peripheral devices. Disable Scan commands instruct the user to disable scanning of files stored on peripheral devices.

[0036] The specific steps for generating scan control instructions in this embodiment will be described later, and therefore will not be repeated here.

[0037] Step S130: When the scan control command is of type start scan type, a preset producer thread is used to scan the files stored in the peripheral device and add the file information corresponding to the file to a preset producer queue.

[0038] The producer thread is used to scan the files stored in the peripheral device, obtain the file information corresponding to the file, and store the file information corresponding to the file in the producer queue.

[0039] File information refers to the information required to play or view a file.

[0040] The producer queue is used to cache file information corresponding to a file.

[0041] Step S140: Using a preset consumer thread, parse the file information in the producer queue and store the parsed file information in a preset local storage space; wherein, the producer thread and the consumer thread work in parallel.

[0042] The consumer thread is used to sequentially parse each file information in the producer queue and store each parsed file information in the local storage space, thus completing the reading of file information from the peripheral device.

[0043] Parsing refers to recognizing file information and converting it into information that can be recognized by the vehicle.

[0044] The local storage space is used to store the parsed file information corresponding to each file in the peripheral device. Of course, the historical attribute information of the peripheral device can also be stored in this local storage space.

[0045] In this embodiment, the producer thread and consumer thread work in parallel. The producer thread scans files to obtain their corresponding file information, while the consumer thread parses that information. Compared to the existing single-threaded model, where a single thread first scans all files sequentially and then parses each file's information in the queue after all files' information has been added, this embodiment offers shorter scanning and parsing times, resulting in a more efficient information reading process.

[0046] In this embodiment, after detecting an insertion event corresponding to a peripheral device, file attribute information corresponding to the peripheral device is read from the peripheral device and historical attribute information corresponding to the peripheral device is obtained from the local storage. A scan control instruction is generated based on the file attribute information and the historical attribute information. When the scan control instruction is of the "start scan" type, a preset producer thread is used to scan the files stored in the peripheral device and add the file information corresponding to the files to a preset producer queue. A preset consumer thread is used to parse the file information in the producer queue and store the parsed file information in a preset local storage space. The producer thread and the consumer thread work in parallel. In this embodiment, after detecting an insertion event corresponding to a peripheral device, the file stored in the peripheral device is not scanned in all cases. Instead, based on file attribute information and historical attribute information that indicate whether the file stored in the peripheral device has changed, an appropriate type of scan control instruction is generated. The file stored in the peripheral device is only scanned when the type of the scan control instruction is "start scan". This avoids the problem of reducing information reading efficiency by scanning the peripheral device when the file stored in the peripheral device has not changed. Furthermore, this embodiment uses dual threads to scan the file and parse the file information separately, which can further improve information reading efficiency.

[0047] To make the embodiments of this application easier to understand, the process of generating scan control instructions in the embodiments of this application will be further described below.

[0048] In this embodiment, the file attribute information and the historical attribute information can be compared; if the file attribute information and the historical attribute information are different, a scan control instruction of the start scan type is generated; if the file attribute information and the historical attribute information are the same, a scan control instruction of the prohibit scan type is generated.

[0049] In this embodiment, the file attribute information and the historical attribute information can also be compared; if the file attribute information and the historical attribute information are different, a scan control command of the start scan type is generated; if the file attribute information and the historical attribute information are the same, the system queries whether file information corresponding to the peripheral exists in the local storage space; if file information corresponding to the peripheral exists in the local storage space, a scan control command of the prohibit scan type is generated; if file information corresponding to the peripheral does not exist in the local storage space, a scan control command of the start scan type is generated.

[0050] Figure 2 This is a flowchart illustrating the steps for generating scan control instructions according to an embodiment of this application.

[0051] Step S210: Compare the file attribute information with the historical attribute information.

[0052] Step S220: Determine whether the file attribute information and the historical attribute information are the same; if yes, proceed to step S230; if no, proceed to step S260.

[0053] The same file attribute information and historical attribute information means that the file name included in the file attribute information and the file name included in the historical attribute information are the same, and the modification time corresponding to the same file name in the file attribute information and the historical attribute information is the same.

[0054] Furthermore, the file attribute information and historical attribute information include file names that correspond to the file names in the root directory of the peripheral device.

[0055] Step S230: If the file attribute information and the historical attribute information are the same, then query whether the file information corresponding to the peripheral exists in the local storage space; if yes, then proceed to step S240; if no, then proceed to step S250.

[0056] The file information corresponding to peripherals stored in the local storage space refers to the file information corresponding to files stored by the peripherals before the current time. This file information is required for playing or viewing files on the vehicle side.

[0057] Local storage space can be a storage space used only to store file information corresponding to that peripheral, or it can be a storage space used to store file information corresponding to each of all peripherals, or it can be a storage space used to store information of a preset type. For example, local storage space can be the storage space for a corresponding media database, and this storage space is used to store media file information.

[0058] Furthermore, the unique identifier of the peripheral device can be used to query whether the file information corresponding to the peripheral device is stored in the local storage space. For example, the peripheral device's ID can be used to query whether the file information corresponding to that ID is stored in the local storage space.

[0059] Step S240: If file information corresponding to the peripheral device exists in the local storage space, a scan control command of the prohibited scanning type is generated.

[0060] After generating a scan control command for the prohibited scan type, a file scan completion notification is issued based on this command. Upon receiving the file scan completion notification, the application in the vehicle can read the file information corresponding to the peripheral from the local storage space to play or scan the files on the peripheral.

[0061] Step S250: If the file information corresponding to the peripheral does not exist in the local storage space, a scan control command of the start scan type is generated.

[0062] Step S260: If the file attribute information and the historical attribute information are different, a scan control command of the start scan type is generated.

[0063] After generating a scan control instruction of the start scan type, file scanning and storage logic is executed for the peripheral device according to the scan control instruction of the start scan type.

[0064] In this embodiment, if the file attribute information and the historical attribute information are different, it means that the file stored in the peripheral device has changed. At this time, it is necessary to scan the file stored in the peripheral device. Therefore, a scan control command of the start scan type is generated.

[0065] In this embodiment, if the file attribute information and historical attribute information are the same, it indicates that the file stored in the peripheral has not changed. In this case, to rule out the possibility that the file information corresponding to the peripheral has been deleted from the vehicle's local storage space, it is necessary to query whether the file information corresponding to the peripheral exists in the local storage space. If the file information corresponding to the peripheral exists in the local storage space, it indicates that the file information corresponding to the peripheral has not been deleted from the vehicle's local storage space, and there is no need to scan the file stored in the peripheral again. The file information already stored in the local storage space can be used directly, and a scan control command of the prohibit scan type is generated. If the file information corresponding to the peripheral does not exist in the local storage space, it indicates that the file information corresponding to the peripheral has been deleted from the vehicle's local storage space, and it is necessary to scan the file stored in the peripheral again, and a scan control command of the start scan type is generated.

[0066] In this embodiment, if the file attribute information and the historical attribute information are different, the historical attribute information is updated according to the file attribute information. That is, in the local storage space, the historical attribute information corresponding to the peripheral is replaced with the file attribute information corresponding to the peripheral. Further, by comparing the file attribute information and the historical attribute information corresponding to the peripheral, it can be identified whether the file stored in the peripheral has changed; if the file attribute information and the historical attribute information are the same, it means that the file stored in the peripheral has not changed; if the file attribute information and the historical attribute information are different, it means that the file stored in the peripheral has changed. In this case, the historical attribute information corresponding to the peripheral needs to be updated for the next identification of whether the file stored in the peripheral has changed.

[0067] In this embodiment, since the peripheral device is used to store all files stored by the user, but not all types of files are available for the user to play or view in the vehicle, multiple scanning strategies can be set in this embodiment to adopt different scanning strategies for different scenarios.

[0068] Specifically, there can be one producer thread. This producer thread scans the files stored in the peripherals under the instruction of a start-scan type scan control command. The types of start-scan type scan control commands include, but are not limited to, target scan control commands and full scan control commands. The scan range of the target scan control command differs from that of the full scan control command.

[0069] The target scan control instruction is used to instruct the producer thread to scan files stored in the peripheral device that meet preset conditions. These preset conditions include, but are not limited to: the file extensions and directories to be scanned, and file extensions and directories other than those to be ignored. In other words, only the specified file extensions and directories are scanned, as well as file extensions and directories that do not need to be ignored.

[0070] The full scan control command is used to instruct the producer thread to scan all files stored in the peripheral device.

[0071] Furthermore, based on the scanning range corresponding to different scenarios, the scan control command for starting a scan type corresponding to different scenarios can be set as a target scan control command or a full scan control command. For example: if the file attribute information and the historical attribute information are different, a target scan control command of the start scan type is generated; if the file attribute information and the historical attribute information are the same, but the file information corresponding to the peripheral does not exist in the local storage space, a full scan control command of the start scan type is generated.

[0072] In this embodiment, when scanning files, a producer thread is used to scan the files stored in the peripheral device. If the scan control instruction is a target-type scan control instruction of the start scan type, the producer thread is used to scan the files stored in the peripheral device that meet preset conditions and add the file information corresponding to each file to a preset producer queue; if the scan control instruction is a full-scale scan control instruction of the start scan type, the producer thread is used to sequentially scan all files stored in the peripheral device and add the file information corresponding to each file to the preset producer queue.

[0073] In this embodiment, when scanning files, the producer thread can use the `walkFileTree` method of the `Files` utility class to traverse the files stored in the peripheral device. This `walkFileTree` method can handle the logic before, during, and after directory or file traversal. Based on current in-vehicle requirements, it can customize file extensions and directories to be ignored. Thus, during file traversal, the `walkFileTree` method can traverse files that meet preset conditions, filtering out other files and improving file scanning efficiency. Furthermore, during file traversal using the `walkFileTree` method, if access to a file fails, access to that file can be abandoned.

[0074] In this embodiment, while the producer thread scans the files stored in the peripheral device, the consumer thread parses the file information in the producer queue and stores the parsed file information in a preset local storage space. For example: Figure 3 The diagram illustrates the operation of a thread according to an embodiment of this application. A producer thread corresponds to a producer queue, a consumer thread corresponds to a consumer queue, and the consumer queue corresponds to local storage space. The producer thread sequentially scans the file information stored in the peripheral device and stores the scanned file information in the producer queue. The consumer thread sequentially parses the file information in the producer queue, stores the parsed file information in the consumer queue, and inserts the file information in the consumer queue into the file information corresponding to the peripheral device already stored in the local storage space.

[0075] Furthermore, by utilizing the consumer thread, the file information in the producer queue is parsed, including: the consumer thread can parse the entire content of the file information and store the parsed entire content of the file information in the local storage space, or, parse the preset fields (partial content) of the file information and store the parsed preset fields of the file information in the local storage space.

[0076] There can be multiple consumer threads. Furthermore, the types of consumer threads include, but are not limited to, parsing consumer threads and storage consumer threads. Parsing consumer threads and storage consumer threads perform different tasks.

[0077] The parsing consumer thread is used to perform parsing tasks.

[0078] Storage-class consumer threads are used to execute storage tasks.

[0079] In one approach, the parsing consumer thread is used to parse the file information (i.e., the entire content of the file information) in the producer queue and add the parsed file information to a preset consumer queue; the storage consumer thread is used to generate tag values ​​corresponding to the file information in the consumer queue, and the file information is stored in the local storage space according to the tag values ​​corresponding to the file information; wherein, the parsing consumer thread and the storage consumer thread work in parallel.

[0080] In another approach, the parsing consumer thread parses preset fields (i.e., partial content of the file information) in the producer queue and adds the parsed fields to a preset consumer queue. The storage consumer thread generates tag values ​​corresponding to the fields in the consumer queue and stores the field information in the local storage space according to the tag values. The parsing consumer thread and the storage consumer thread work in parallel. By having the parsing consumer thread parse the file information while the storage consumer thread stores the parsed file information, information reading efficiency can be further improved.

[0081] Furthermore, the consumer queue is used to store the parsed file information (all or part of the content).

[0082] Furthermore, preset fields can be information required for playing or viewing files. Preset fields can be customized according to needs. For example, preset fields include, but are not limited to: file name, cover art information, video resolution, bitrate, video encoding format, duration, audio encoding format, and audio sampling rate.

[0083] Furthermore, the tag values ​​are unique. The tag value can be a hash value of the file information, such as an MD5 value. When storing file information (all or part of the content) in the local storage space, the file information can be inserted into the local storage space according to the size of its corresponding tag value, thus sorting the file information stored in the local storage space according to the size of the tag value. A binary search algorithm can be used to compare the tag value corresponding to the file information with the tag values ​​corresponding to each file information already stored in the local storage space. If the tag value already exists, it means the target file information is an existing file information in the local storage space and does not need to be inserted; otherwise, it means the target file information is new and needs to be inserted into the appropriate position in the local storage space, ensuring that the tag value corresponding to the target file information and the tag values ​​corresponding to the files before and after the target file information are ordered. In this embodiment, it is not limited whether the order of the tag values ​​of the various file information in the local storage space is ascending or descending. For example, if the target file information corresponds to a tag value of 005, and file information with tags 004, 006, and 009 is already stored in the local storage space, then the target file information with tag value 005 can be inserted between the file information with tags 004 and 006, so that 004, 005, and 006 are in ascending order, instead of being inserted between the file information with tags 006 and 009.

[0084] Furthermore, the number of storage-type consumer threads can be one or more. Multiple storage-type consumer threads can execute storage tasks in parallel.

[0085] Furthermore, during the process of storing file information to local storage, if useless file information exists in the local storage space, it is deleted. Useless file information refers to file information that is not included in the parsed file information. After deleting all useless file information, the file information in the local storage space is consistent with the file information corresponding to the files stored in the peripheral device. For example, if the local storage space includes file information corresponding to song A, but song A has been deleted from the peripheral device after it was inserted, then after parsing the file information in the peripheral device, the file information corresponding to song A will definitely not exist. In this case, the file information corresponding to song A can be deleted from the local storage space.

[0086] In this embodiment, based on a producer-consumer model, two queues are created: a producer queue for storing scanned file information and a consumer queue for storing parsed file information. A thread pool is also created, comprising producer threads and consumer threads. These threads (parsing consumer threads and storage consumer threads) process simultaneously, improving file scanning, parsing, and storage efficiency. During the file information parsing phase, based on the current in-vehicle application environment and business characteristics, it can be configured to scan only files from peripherals that meet preset conditions, such as only audio / video files and image files. Other files are not scanned, thus automatically ignoring other files during scanning, such as non-audio / video files and non-image files, thereby improving scanning, parsing, and storage efficiency.

[0087] In this embodiment, since the source and format of the files stored in the peripheral device are unknown, and the compatibility of the native system (the vehicle's current operating system) is poor, the file information may not be parsed correctly. Therefore, this embodiment utilizes the consumer thread (e.g., a parsing consumer thread) to call a preset third-party processing framework; the third-party processing framework then parses the file information in the producer queue.

[0088] A third-party processing framework is used to parse file information. For example, when the Android system processes multimedia files such as audio and video files, the parsing process is time-consuming because the audio and video file information is compressed. Moreover, due to Android system compatibility issues, the audio and video file information may not be parsed correctly, thus affecting the reading efficiency of audio and video files. To address this problem, this application embodiment calls a third-party processing framework to parse the file information.

[0089] Furthermore, before invoking the third-party processing framework, the source code corresponding to the third-party processing framework is downloaded. Using a pre-defined compilation tool, a dynamic library usable by the current operating system is compiled from this source code and integrated into the current operating system. Thus, when file information needs to be parsed, the consumer thread can call the dynamic library corresponding to the third-party processing framework. This dynamic library identifies the file type corresponding to the file information in the producer queue, finds the corresponding decoder for that file type, and uses the parser to parse the file information. Specifically, fields to be parsed can be pre-defined (i.e., preset fields). The decoder parses the corresponding fields of the file information according to these preset fields. If the file information format is not recognizable by the current operating system, the parser or a preset function of the dynamic library can convert the file information into a format recognizable by the current operating system.

[0090] Furthermore, the types of third-party processing frameworks include, but are not limited to, ffmpeg.

[0091] This application embodiment performs a precondition judgment for peripheral file scanning. File scanning is only performed when the file attribute information differs from historical attribute information, or when the file attribute information is the same as historical attributes but the corresponding file information for the peripheral does not exist in the local storage space. This avoids the step of scanning files every time a peripheral is inserted, thus reducing excessive resource consumption caused by each peripheral insertion. This application embodiment can effectively improve the efficiency and parsing effect of peripheral file scanning, shorten the file scanning time and parsing time, and thus improve information reading efficiency. For example, the time to scan and parse 1000 files on a USB flash drive can be reduced from tens of seconds to about 6 seconds.

[0092] This application also provides an information reading device. For example... Figure 4 The diagram shown is a structural diagram of an information reading device according to an embodiment of this application.

[0093] The information reading device includes:

[0094] The reading and acquiring module 410 is used to read the file attribute information corresponding to the peripheral from the peripheral and obtain the historical attribute information corresponding to the peripheral from the local machine after listening to the insertion event corresponding to the peripheral.

[0095] The generation module 420 is used to generate scan control instructions based on the file attribute information and the historical attribute information.

[0096] The scanning and adding module 430 is used to scan the files stored in the peripheral device and add the file information corresponding to the files to a preset producer queue when the type of the scanning control instruction is the start scanning type.

[0097] The parsing and storage module 440 is used to parse the file information in the producer queue using a preset consumer thread and store the parsed file information in a preset local storage space; wherein the producer thread and the consumer thread work in parallel.

[0098] The functions of the apparatus described in this application embodiment have been described in the above method embodiments. Therefore, for any parts not detailed in the description of this embodiment, please refer to the relevant descriptions in the foregoing embodiments, which will not be repeated here.

[0099] This application also provides an information reading device, such as... Figure 5 The diagram shown is a structural diagram of an information reading device according to an embodiment of this application.

[0100] The information reading device includes a processor 510, a communication interface 520, a memory 530, and a communication bus 540. The processor 510, communication interface 520, and memory 530 communicate with each other via the communication bus 540.

[0101] Memory 530 is used to store computer programs.

[0102] In one embodiment of this application, when the processor 510 executes a program stored in the memory 530, it implements the information reading method provided in any of the foregoing method embodiments, including: after listening to an insertion event corresponding to a peripheral device, reading file attribute information corresponding to the peripheral device from the peripheral device and obtaining historical attribute information corresponding to the peripheral device from the local storage; generating a scan control instruction based on the file attribute information and the historical attribute information; when the type of the scan control instruction is a start scan type, using a preset producer thread, scanning the files stored in the peripheral device and adding the file information corresponding to the files to a preset producer queue; using a preset consumer thread, parsing the file information in the producer queue and storing the parsed file information in a preset local storage space; wherein the producer thread and the consumer thread work in parallel.

[0103] The step of generating a scan control instruction based on the file attribute information and the historical attribute information includes: if the file attribute information and the historical attribute information are different, generating a scan control instruction of type "start scan"; if the file attribute information and the historical attribute information are the same, querying whether file information corresponding to the peripheral exists in the local storage space; if file information corresponding to the peripheral exists in the local storage space, generating a scan control instruction of type "disable scan"; if file information corresponding to the peripheral does not exist in the local storage space, generating a scan control instruction of type "start scan".

[0104] The scan control command of the start scan type includes: target scan control command and full scan control command; the step of using a preset producer thread to scan the files stored in the peripheral device includes: if the scan control command is a target scan control command of the start scan type, then the producer thread is used to scan the files stored in the peripheral device that meet the preset conditions; if the scan control command is a full scan control command of the start scan type, then the producer thread is used to scan all files stored in the peripheral device.

[0105] The consumer threads include a parsing consumer thread and a storage consumer thread. The step of parsing the file information in the producer queue and storing the parsed file information in a preset local storage space using the preset consumer threads includes: using the parsing consumer thread to parse the file information in the producer queue and add the parsed file information to the preset consumer queue; using the storage consumer thread to generate tag values ​​corresponding to the file information in the consumer queue, and storing the file information in the local storage space according to the tag values ​​corresponding to the file information; wherein the parsing consumer thread and the storage consumer thread work in parallel.

[0106] The consumer threads include a parsing consumer thread and a storage consumer thread. The step of parsing file information in the producer queue and storing the parsed file information in a preset local storage space using the preset consumer threads includes: using the parsing consumer thread to parse preset fields of the file information in the producer queue and adding the parsed field information to the preset consumer queue; using the storage consumer thread to generate tag values ​​corresponding to the field information in the consumer queue, and storing the field information in the local storage space according to the tag values ​​corresponding to the field information; wherein the parsing consumer thread and the storage consumer thread work in parallel.

[0107] The step of using a preset consumer thread to parse the file information in the producer queue includes: using the consumer thread to call a preset third-party processing framework; and using the third-party processing framework to parse the file information in the producer queue.

[0108] The method further includes: if the file attribute information and the historical attribute information are different, then updating the historical attribute information according to the file attribute information.

[0109] This application also provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the steps of the information reading method provided in any of the foregoing method embodiments. Since the information reading method has already been described in detail above, any omissions in the description of this embodiment can be found in the relevant descriptions in the foregoing embodiments, and will not be repeated here.

[0110] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0111] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0112] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also include the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.

[0113] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. An information reading method, characterized in that, include: After detecting the insertion event corresponding to the peripheral, the file attribute information corresponding to the peripheral is read from the peripheral and the historical attribute information corresponding to the peripheral is obtained from the local machine; wherein, the file attribute information is the attribute information of the file currently stored in the peripheral; the historical attribute information is the attribute information of the file previously stored in the peripheral; the file names included in the file attribute information and the historical attribute information are the file names corresponding to the files in the root directory of the peripheral. Based on the file attribute information and the historical attribute information, a scan control instruction is generated, including: if the file attribute information and the historical attribute information are different, a scan control instruction of type "start scan" is generated; if the file attribute information and the historical attribute information are the same, a query is performed to see if file information corresponding to the peripheral exists in the local storage space; if file information corresponding to the peripheral exists in the local storage space, a scan control instruction of type "disable scan" is generated using the file information already stored in the local storage space; if file information corresponding to the peripheral does not exist in the local storage space, a scan control instruction of type "start scan" is generated. When the scan control command is of type "start scan", a preset producer thread is used to scan the files stored in the peripheral device and add the file information corresponding to the file to a preset producer queue. Using a pre-defined consumer thread, the file information in the producer queue is parsed and the parsed file information is stored in a pre-defined local storage space; wherein, the producer thread and the consumer thread work in parallel; The consumer threads include: parsing consumer threads and storage consumer threads; The step of using a preset consumer thread to parse the file information in the producer queue and storing the parsed file information in a preset local storage space includes: Using the parsing consumer thread, preset fields of file information in the producer queue are parsed and the parsed field information is added to the preset consumer queue; The storage-type consumer thread generates tag values ​​corresponding to the field information in the consumer queue, and stores the field information in the local storage space according to the size of the tag values, so that the file information stored in the local storage space is sorted according to the size of the tag values; wherein, the parsing-type consumer thread and the storage-type consumer thread work in parallel. The step of storing the field information in the local storage space according to the size of the tag value corresponding to the field information includes: using a binary search algorithm to compare the tag value corresponding to the file information to be stored with the tag values ​​corresponding to each file information already stored by the peripheral in the local storage space; if no match is found, insert the file information corresponding to the tag value that cannot be matched into the appropriate position in the local storage space.

2. The method according to claim 1, characterized in that, The scan control commands for the start scan type include: target scan control commands and full scan control commands; The step of using a preset producer thread to scan the files stored in the peripheral device includes: If the scan control instruction is a target class scan control instruction of the start scan type, then the producer thread is used to scan the files stored in the peripheral that meet the preset conditions. If the scan control instruction is a full scan control instruction of the start scan type, then the producer thread is used to scan all files stored in the peripheral device.

3. The method according to claim 1, characterized in that, The step of using a preset consumer thread to parse the file information in the producer queue includes: The consumer thread invokes a preset third-party processing framework; The file information in the producer queue is parsed using the third-party processing framework.

4. The method according to claim 1, characterized in that, The method further includes: If the file attribute information and the historical attribute information are different, then the historical attribute information is updated according to the file attribute information.

5. An information reading device, characterized in that, include: The reading and acquiring module is used to read the file attribute information corresponding to the peripheral from the peripheral and acquire the historical attribute information corresponding to the peripheral from the local machine after listening to the insertion event corresponding to the peripheral; wherein, the file attribute information is the attribute information of the file currently stored in the peripheral; the historical attribute information is the attribute information of the file previously stored in the peripheral; the file names included in the file attribute information and the historical attribute information are the file names corresponding to the files in the root directory of the peripheral; The generation module is used to generate scan control instructions based on the file attribute information and the historical attribute information, including: if the file attribute information and the historical attribute information are different, generating a scan control instruction of type "start scan"; if the file attribute information and the historical attribute information are the same, querying the local storage space to see if there is file information corresponding to the peripheral device; if there is file information corresponding to the peripheral device in the local storage space, using the file information already stored in the local storage space to generate a scan control instruction of type "disable scan"; if there is no file information corresponding to the peripheral device in the local storage space, generating a scan control instruction of type "start scan". The scanning and adding module is used to scan the files stored in the peripheral device and add the file information corresponding to the files to a preset producer queue when the type of the scanning control instruction is the start scanning type. A parsing and storage module is used to parse file information in the producer queue using a preset consumer thread and store the parsed file information in a preset local storage space; wherein the producer thread and the consumer thread work in parallel. The consumer threads include: parsing consumer threads and storage consumer threads; The parsing and storage module is used to parse preset fields of file information in the producer queue using the parsing consumer thread and add the parsed field information to a preset consumer queue; to generate tag values ​​corresponding to the field information in the consumer queue using the storage consumer thread, and to store the field information in the local storage space according to the size of the tag values, so that the file information stored in the local storage space is sorted according to the size of the tag values; wherein, the parsing consumer thread and the storage consumer thread work in parallel; the step of storing the field information in the local storage space according to the size of the tag values ​​includes: using a binary search algorithm to compare the tag value corresponding to the file information to be stored with the tag values ​​corresponding to each file information already stored by the peripheral device in the local storage space; if no match is found, the file information corresponding to the tag value that cannot be compared is inserted into the appropriate position in the local storage space.

6. An information reading device, characterized in that, include: At least one communication interface; At least one bus connected to the at least one communication interface; At least one processor connected to the at least one bus; At least one memory connected to the at least one bus, wherein the processor is configured to execute an information reading program stored in the memory to implement the information reading method according to any one of claims 1-4.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which are executed to implement the information reading method according to any one of claims 1-4.