WO2015096541A1 - 一种检索外部sd卡的方法及装置 - Google Patents
一种检索外部sd卡的方法及装置 Download PDFInfo
- Publication number
- WO2015096541A1 WO2015096541A1 PCT/CN2014/088728 CN2014088728W WO2015096541A1 WO 2015096541 A1 WO2015096541 A1 WO 2015096541A1 CN 2014088728 W CN2014088728 W CN 2014088728W WO 2015096541 A1 WO2015096541 A1 WO 2015096541A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- path
- card
- external
- current
- loading
- Prior art date
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/061—Improving I/O performance
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/13—File access structures, e.g. distributed indices
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0604—Improving or facilitating administration, e.g. storage management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0629—Configuration or reconfiguration of storage systems
- G06F3/0632—Configuration or reconfiguration of storage systems by initialisation or re-initialisation of storage systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0629—Configuration or reconfiguration of storage systems
- G06F3/0635—Configuration or reconfiguration of storage systems by changing the path, e.g. traffic rerouting, path reconfiguration
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0673—Single storage device
- G06F3/0679—Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0683—Plurality of storage devices
Definitions
- the invention relates to a method and a device for retrieving an external SD card, belonging to the field of computers.
- the Android platform supports Java and C/C++ languages. It is an operating system based on mobile devices developed and maintained by Google. Due to the limited storage space of mobile devices, the higher the storage space of mobile devices, the higher the cost of hardware components. The input and output of a large amount of application data can only be realized by relying on the SD card. At present, many mobile phone manufacturers integrate the SD card into the mobile phone. Of course, some mobile phones support the pluggable SD card at the same time, and the mobile phone appears for the mobile phone. Built-in SD card and external SD card. When the mobile phone supports both built-in and external SD cards, the Android system API is called to obtain the SD card path as the built-in SD card path. Due to the "fragmentation" of the Android system, many mobile phone manufacturers have different paths for processing SD cards, which increases the difficulty of obtaining their own SD. How to find the external SD card to be operated under the Android platform is a prior art solved problem.
- the object of the present invention is to provide a method and a device for retrieving an external SD card, which can obtain a mounting path of an external SD card on different customized Android platforms of different versions, so as to implement an external SD card under the Android operating system.
- the search can no longer be implemented lazy in the API function, and the compatibility is better.
- a method for retrieving an external SD card comprising:
- Step S1 obtaining a loading path list
- Step S2 Record the first loading path in the loading path list as current information
- Step S3 determining whether the current information record satisfies the filtering condition, if yes, executing step S4, otherwise performing step S9;
- Step S4 split the current information record into multiple paths by using a space, and use the first path as the current path of the current information record;
- Step S5 determining whether the current path contains a preset character string, if yes, proceeding to step S6, otherwise performing step S7;
- Step S6 recording the current path and acting as a suspected external SD card path, performing step S7;
- Step S7 determining whether there is still an unprocessed path in the current information record, if yes, proceeding to step S8, otherwise performing step S9;
- Step S8 the next path is taken as the current path of the current information record, returning to step S5;
- Step S9 determining whether there is an unprocessed loading path in the loading path list, if yes, proceeding to step S10, otherwise performing step S11;
- the step is S10: the next loading path in the loading path list is recorded as current information, and returns to step S3;
- Step S11 determining whether a suspect external SD card path is recorded, if yes, proceeding to step S12; otherwise, the final external SD card is not found;
- Step S12 determining whether there is a final external SD card path in the suspected external SD card path of the record, and then finding the final external SD card, otherwise the final external SD card is not found.
- the step S1 is specifically: obtaining all loading paths from the file system table by using the mount command, obtaining all loading paths in the Linux file system table, and obtaining a loading path list according to all the obtained loading paths.
- the step S3 is specifically: determining whether the first preset character string and the second character string are included in the current information record, and if yes, the filtering condition is met; otherwise, the filtering condition is not satisfied;
- the step S5 is specifically: determining whether the first preset character string is included in the current path, if yes, executing step S6, otherwise performing step S7.
- step S12 is specifically:
- Step S12-1 using the first suspected external SD card path of the record as a current suspected external SD card path;
- Step S12-2 determining whether the current suspected external SD card path is the final external SD card path, and then finding the final external SD card, otherwise performing step S12-3;
- Step S12-3 judging whether all the suspected external SD card paths have been processed, the final external SD card is not found, otherwise the next suspected external SD card path of the record is regarded as the current suspected external SD card path, and the process returns to the step. S12-2.
- the step S1 is specifically: obtaining, by using a mount command, all loading paths from the file system table to obtain a loading path list;
- the method further includes:
- Step S13 Obtain all loading paths in the Linux file system table.
- Step S14 Record the obtained first loading path as current information
- Step S15 determining whether the current information record satisfies the filtering condition, if yes, executing step S16, otherwise performing step S21;
- Step S16 splitting the current information into multiple paths by using a space, and using the first path as the current path of the current information record;
- Step S17 determining whether the preset path is included in the current path, if yes, proceeding to step S18, otherwise performing step S19;
- Step S18 Recording the current path as a suspected external SD card path, step S19 is performed; Step S19: determining whether there is still an unprocessed path in the current information record, if yes, executing step S20, otherwise performing step S21;
- Step S20 the next path is taken as the current path of the current information record, returning to step S17;
- Step S21 determining whether there is still an unprocessed acquired loading path, if yes, proceeding to step S22, otherwise performing step S21;
- Step S22 The acquired next loading path is recorded as current information, and returns to step S15;
- Step S23 determining whether a suspected external SD card path is recorded, if yes, executing step S24; otherwise, not finding the final external SD card;
- Step S24 It is judged whether there is a final external SD card path in the suspected external SD card path of the record, and then the final external SD card is found, otherwise the final external SD card is not found.
- an apparatus for retrieving an external SD card including:
- An obtaining module configured to obtain a loading path list
- a first pointing module configured to record the first loading path in the loading path list as current information, and to record the next loading path in the loading path list as current information;
- the first determining module is configured to determine whether the current information record satisfies the filtering condition, and the splitting module works, otherwise the fourth determining module works;
- the splitting module is configured to split the current information record into multiple paths by using spaces
- a second pointing module configured to use the first path as the current path of the current information record, and also to use the next path as the current path of the current information record;
- the second judging module is configured to determine whether the preset string is included in the current path, and the recording module works, otherwise the third judging module works;
- the recording module is configured to record the current path and act as a suspected external SD card path
- the third determining module is configured to determine whether there is an unprocessed path in the current information record, and the second pointing module works, otherwise the fourth determining module works;
- the fourth determining module is configured to determine whether there is an unprocessed loading path in the loading path list, and the first pointing module works, otherwise the fifth determining module works;
- the fifth determining module is configured to determine whether a suspected external SD card path is recorded, and the sixth determining module works, otherwise the final external SD card is not found;
- the sixth judging module is configured to determine whether there is a final external SD card path in the suspected external SD card path of the record, and then find the final external SD card, otherwise the final external SD card is not found.
- the obtaining module comprises:
- a first acquiring unit configured to acquire all loading paths from the system file by using a mount command
- a second obtaining unit configured to acquire all loading paths in the Linux file system table
- a generating unit configured to obtain a loading path list according to all loading paths acquired by the first acquiring unit and all loading paths acquired by the second acquiring unit.
- the first determining module is specifically configured to determine whether the first preset character string and the second character string are included in the current information record, and the splitting module works, otherwise the fourth determining module works;
- the second determining module is specifically configured to determine whether the first preset character string is included in the current path, and the recording module works, otherwise the third determining module works.
- the sixth determining module comprises:
- a first pointing unit configured to use the first suspected external SD card path of the record as a current suspected external SD card path, and to use the next suspected external SD card path of the record as a current suspected external SD card path ;
- the first determining unit is configured to determine whether the current suspected external SD card path is the final external SD card path, and then find the final external SD card, otherwise the second determining unit works;
- the second determining unit is configured to determine whether all suspected external SD card paths have been processed, and the final external SD card is not found, otherwise the first pointing unit operates.
- the present invention has the following advantages: the technical solution of the present invention is through Linux.
- the mount command obtains all load paths from the file system table (vold.fstab), and then determines whether there are external SD card load paths in the load path, or directly analyzes the Linux file system table to obtain the external SD card load path.
- the mounting path of the external SD card is obtained on different customized Android platforms of different versions, so that The retrieval of the external SD card under the Android operating system can no longer be achieved by lazy API function, and the compatibility is good.
- FIG. 1 is a flowchart of a method for retrieving an external SD card according to Embodiment 1 of the present invention
- FIG. 6 is a block diagram of an apparatus for retrieving an external SD card according to Embodiment 3 of the present invention.
- FIG. 7 is a block diagram showing a specific implementation of a sixth judging module according to Embodiment 3 of the present invention.
- the Android operating system consists of two large blocks.
- the communication between the underlying and the hardware is realized by the Android tailored version of the standard Linux kernel released by the Linux Foundation.
- the Android tailoring version can not only run the dalvik program, so that the dalvik program can pass better.
- the Linux kernel manages the hardware, and it also maps the hardware drivers of third-party vendors that do not have open source code to the Linux kernel for management.
- the interactive functions of the Android operating system and the actual operation of the user are based on the Java language implementation on the dalvik virtual machine and/or assisted by the C/C++ shared library.
- Embodiment 1 of the present invention provides a method for retrieving an external SD card, as shown in FIG. 1 , including:
- Step S1 obtaining a loading path list
- all the loading paths are obtained from the file system table by using the mount command. All loading paths in the Linux file system table, and obtaining a loading path list according to all the loading paths obtained above;
- Step S2 Recording the first loading path in the loading path list as current information
- Step S3 determining whether the current information record satisfies the filtering condition, if yes, executing step S4, otherwise performing step S9;
- the filtering condition in the first embodiment is that the information record includes a first preset character string and a second preset character string.
- the first preset character string is mnt or storage
- the second preset character is String is vfat;
- Step S4 split the current information record into multiple paths by using a space, and use the first path as the current path of the current information record;
- Step S5 determining whether the current path contains a preset character string, if yes, proceeding to step S6, otherwise performing step S7;
- the preset character string in this embodiment is a first preset character string, preferably mnt or storage;
- Step S6 recording the current path and acting as a suspected external SD card path, performing step S7;
- Step S7 determining whether there is still an unprocessed path in the current information record, if yes, proceeding to step S8, otherwise performing step S9;
- Step S8 the next path is taken as the current path of the current information record, returning to step S5;
- Step S9 determining whether there is still an unprocessed loading path in the loading path list, if yes, proceeding to step S10, otherwise performing step S11;
- Step S10 Recording the next loading path in the loading path list as the current information, and returning to step S3;
- Step S11 determining whether a suspect external SD card path is recorded, if yes, proceeding to step S12; otherwise, the final external SD card is not found;
- Step S12 determining whether there is a final external SD card path in the suspected external SD card path of the record, and then finding the final external SD card, otherwise the final external SD card is not found.
- the step S12 includes: using the recorded external SD card path as a parameter, calling an interface function, determining the result returned by the interface function, and finding the final external SD card as the first preset value, Determining the current suspected external SD card path as the final external SD card path, and if the second preset value is not found, the final external SD card is not found;
- the interface function is sequentially called, and one of the suspected external SD card paths is used as a parameter to try the SD corresponding to the suspected external SD card path.
- the card communicates and returns the corresponding result. If the returned result is the first preset value, the communication is successful. If the returned result is the second preset value, the communication is unsuccessful; preferably, the first preset value is True, the first The default value is False; attempt to communicate with the SD card corresponding to the path of the suspected external SD card is specifically: sending an initialization command to the device corresponding to the path suspected of the external SD card, and determining whether the response returned by the device is received, such as receiving The communication is successful, otherwise the communication is unsuccessful;
- step S11 is removed, and after step S6 is executed, step S12 is performed, and step S12 is performed. If not, step S7 is performed, and when the determination of step S9 is NO, the final external SD card path is not found.
- the identifier corresponding to the SD card may be set or the corresponding handle may be saved.
- Embodiment 2 of the present invention provides a method for retrieving an external SD card.
- the mount command is opened by the popen function.
- the popen() function creates a pipeline by calling fork, and executes a shell to run the command to open the application.
- the method in this embodiment includes:
- Step 101 The application starts, and the loading path in the file system table is obtained by calling the mount command.
- the loading path obtained in the second embodiment is as follows:
- Proc on /proc type proc (rw, noexec, nosuid, nodev)
- Step 102 Record the obtained first loading path as current information.
- Step 103 Determine whether the current information record meets the filter condition, if yes, go to step 104, otherwise go to step 109;
- the filtering condition in the second embodiment is that the information record includes a first preset character string and a second preset character string.
- the first preset character string is mnt or storage
- the second preset character is String is vfat;
- Step 104 Split the current information record into multiple paths by using a space, and use the first path as the current path of the current information record;
- Vfat rw, dirsync, nosuid, nodev split into /dev/block/vold/179.9, /storage/sdcard1, vfat Rw, dirsync, nosuid, nodev three paths;
- Step 105 Determine whether the current path contains a preset string, if yes, go to step 106, otherwise go to step 107;
- the preset character string in the second embodiment is a first preset character string, preferably mnt or storage;
- the nodev path does not contain mnt or storage, go to step 107; include storage in /storage/sdcard1 path, go to step 106;
- Step 106 Record the current path and perform the step 107 as a suspected external SD card path; specifically, in the embodiment, use /storage/sdcard1 as the suspected external SD card path;
- Step 107 Determine whether there is still an unprocessed path in the current information record, if yes, go to step 108, otherwise go to step 109;
- Step 108 The next path is taken as the current path of the current information record, and returns to step 105;
- Step 109 Determine whether there is an unprocessed loading path in the load path list, if yes, go to step 110, otherwise go to step 111;
- Step 110 The next loading path is recorded as current information, and returns to step 103;
- Step 111 Determine whether there is a suspected external SD card path, if yes, go to step 112, otherwise the final external SD card is not found, go to step 113;
- Step 112 sequentially record the suspected external SD card path as a parameter, call an interface function, and determine the result returned by the interface function. If the first preset value is found, the final external SD card is found, and the current suspected external is found. The SD card path is determined as the final external SD card path, if the final external SD card is not found for the second preset value, step 113 is performed;
- Step 113 Obtain all loading paths in the Linux file system table.
- Step 114 Record the first loading path as current information
- Step 115 Determine whether the current information record meets the filter condition, if yes, go to step 116, otherwise go to step 121;
- Step 116 Split the current information record into multiple paths by using a space, and use the first path as the current path of the current information record;
- Step 117 Determine whether the current path contains a preset string, if yes, go to step 118, otherwise go to step 119;
- step 105 The filtering conditions in this step in the second embodiment are the same as those in step 105, and are not described herein again.
- Step 118 Record the current path and act as a suspected external SD card path, step 119;
- Step 119 Determine whether there is still an unprocessed path in the current information record, if yes, go to step 120, otherwise go to step 121;
- Step 120 The next path is taken as the current path of the current information record, returning to step 117;
- Step 121 Determine whether there is an unprocessed loading path in the loading path list, if yes, go to step 122, otherwise go to step 123;
- Step 122 The next loading path is recorded as the current information, and returns to step 115;
- Step 123 Determine whether there is a suspect external SD card path, if yes, go to step 124, otherwise the final external SD card is not found;
- Step 124 sequentially record the suspected external SD card path, call the interface function, and determine the result returned by the interface function. If the first preset value is found, the final external SD card is found, and the current suspected external SD card path is determined as the final The external SD card path, if it is the second preset value, the final external SD card is not found;
- the interface function is called with a path in the suspected external SD card path as a parameter, and the attempt is made to correspond to the suspected external SD card path.
- the SD card communicates and returns the corresponding result. If the returned result is the first preset value, the communication is successful, and the current suspected external SD card path is determined as the final external SD card path, if the returned result is the second preset value.
- the communication is unsuccessful; preferably, the first preset value is True, and the second preset value is False.
- each suspected external SD card path is used as a parameter calling interface function to try to communicate with the corresponding device, and the communication succeeds to find the final SD card path;
- it can be used as a parameter call interface function to try to communicate with the corresponding device, that is, step 111 and step 123 are removed, and after step 106 is executed, step 112 is performed, and step 112 is judged as second.
- Step 107 is performed when the preset value is determined, and step 113 is executed when the step 109 is negative.
- Step 124 is performed after the step 118 is executed. When the step 124 is determined to be the second preset value, the step 119 is executed. If the step 121 is negative, the final step is not found.
- the external SD card the specific implementation process is shown in Figure 4 and Figure 5.
- the second embodiment there is no suspected externality in all the loading paths acquired by the mount command.
- SD card path then get all the loading path from the Linux file system table to determine whether there is a suspect external SD card path, such as finding the suspected external
- the SD card path attempts to communicate with the device corresponding to the path. If the communication succeeds, the SD card in the device corresponding to the path is the external SD card to be found.
- the method of the second embodiment is made in Android The retrieval of the external SD card under the operating system is no longer lazy than the API function, and the compatibility is good.
- Embodiment 3 of the present invention provides an apparatus for retrieving an external SD card, as shown in FIG. 6, including:
- the obtaining module 601 is configured to obtain a loading path list.
- the obtaining module 601 in this embodiment includes:
- the first obtaining unit 6011 is configured to obtain all loading paths from the system file by using a mount command.
- the second obtaining unit 6012 is configured to obtain all loading paths in the Linux file system table.
- a generating unit 6013 configured to obtain a loading path list according to all loading paths acquired by the first obtaining unit 6011 and all loading paths acquired by the second acquiring unit 6012;
- the first pointing module 602 is configured to record the first loading path in the loading path list as the current information, and also use the next loading path in the loading path list as the current information record;
- the first determining module 603 is configured to determine whether the current information record satisfies the filtering condition, and the splitting module is 604 works, otherwise the fourth judgment module 609 works;
- the first determining module 603 in this embodiment is specifically configured to determine whether the first preset character string and the second preset character string are included in the current information record, and the splitting module 604 works, otherwise the fourth determining module 609 works; preferably, the first preset string is mnt or storage, and the second preset string is vfat;
- a splitting module 604 configured to split the current information into multiple paths by using a space
- the second pointing module 605 is configured to use the first path as the current path of the current information record, and also to use the next path as the current path of the current information record;
- the second determining module 606 is configured to determine whether the preset path is included in the current path, and the recording module is 607 works, otherwise the third judgment module 608 works;
- the second determining module 606 is specifically configured to determine whether the first preset character string is included in the current path, and the recording module 607 is working, otherwise the third determining module 608 is working;
- a recording module 607 configured to record the current path and act as a suspected external SD card path
- the third determining module 608 is configured to determine whether there is an unprocessed path in the current information record, and the second pointing module 605 works, otherwise the fourth determining module 609 works;
- the fourth determining module 609 is configured to determine whether there is an unprocessed loading path in the loading path list, and the first pointing module 602 works, otherwise the fifth determining module 610 works;
- the fifth judging module 610 is configured to determine whether a suspect external SD card path is recorded, and the sixth judging module 611 works, otherwise the final external SD card is not found;
- the sixth judging module 611 is configured to determine whether there is a final external SD card path in the suspected external SD card path, and then find the final external SD card, otherwise the final external SD card is not found;
- the sixth determining module 611 is specifically configured to use a interface function to determine a result of the interface function, such as a first preset. The value then finds the final external SD card, determining the current suspected external SD card path as the final external SD card path, and if it is the second preset value, the final external SD card is not found.
- the sixth determining module 611 in this embodiment includes:
- the first pointing unit 611-1 is configured to use the first suspected external SD card path as the current suspected external SD card path, and also to record the next suspected external SD card path as the current suspected external SD card path;
- the first determining unit 611-2 is configured to determine whether the current suspected external SD card path is the final external SD card path, and then find the final external SD card, otherwise the second determining unit 611-3 operates;
- the second judging unit 611-3 is configured to judge whether all the suspected external SD card paths have been processed, and the final external SD card is not found, otherwise the first pointing unit 611-1 operates.
- the device may first record all suspected external SD card paths, and then communicate with one of the devices corresponding to the suspected external SD card path, and the communication succeeds to find the final external SD card, such as All devices suspected to be connected to the external SD card path failed to communicate and the final external SD card was not found.
- the specific implementation manner is as follows: the obtaining module 601 first obtains a loading path list, and the first pointing module 602 records the first loading path in the loading path list as current information, and the first determining module 603 determines whether the current information record satisfies the filtering condition.
- the splitting module 604 After the judging module 603 satisfies the condition, the splitting module 604 records the current information as a plurality of paths by using a space, the second pointing module 605 uses the first path as the current path of the current information record, and the second determining module 606 determines the current path.
- the second determining module 606 determines that the current recording path is recorded by the recording module 607 as a suspected external SD card path; and when the second determining module 606 determines No, the third determining module 608 determines whether the current information record is There are also unprocessed paths, the third judgment module 608 determines that there is an unprocessed path, and the second pointing module 605 uses the next path as the current path of the current information record; the third determining module 608: determining that there is no unprocessed path and the first determining module 603 determines that the filtering condition is not satisfied, the fourth determining module 609 determines whether there is an unprocessed loading path, and the fourth determining module 609 determines that there is an unprocessed loading path.
- the pointing module 602 records the next loading path in the loading path list as the current information.
- the fifth determining module 610 is configured to determine whether a suspected external SD card path is recorded.
- the sixth determining module 611 determines whether there is a final external SD card path in the suspected external SD card path, and then finds the final external SD card, the fifth determining module 610 and the sixth determining When the module 611 determines NO, the final external SD card is not found.
- the loading path list may be obtained first by the first obtaining unit 6011 in the obtaining module 601, and then the first pointing module 602 works, when the fifth determining module 610 and the sixth determining module 611 determine that The second acquisition unit 6012 in the acquisition module 601 obtains the load path list, and then the first pointing module 602 works again.
- the device in this embodiment does not suspect the external SD card path in all the loading paths obtained by the mount command, then all the loading paths are obtained from the Linux file system table to determine whether there is a suspect external SD card path, such as finding a suspect external
- the SD card path attempts to communicate with the device corresponding to the path. If the communication succeeds, the SD card in the device corresponding to the path is the external SD card to be found.
- the method of this embodiment made in Android The retrieval of the external SD card under the operating system is no longer lazy than the API function, and the compatibility is good.
- the device retrieves an external SD card and has another implementation manner, that is, if a suspected external SD card path is found, it tries to communicate with its corresponding device. If the communication succeeds, the final external is found. SD card, otherwise find the next suspected external SD card path.
- the specific implementation manner is: after the recording module 607 is working, the sixth determining module 611 determines whether there is a final external SD card path in the suspected external SD card path, and then finds the final external SD card, otherwise the third determining module 608 works. Third judgment module When the determination of 608 is negative, the fourth determination module 609 operates, and the fourth determination module 609 determines that the final external SD card is not found.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Computer Networks & Wireless Communication (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Telephone Function (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
一种检索外部SD卡的方法,该方法包括:获取加载路径列表;判断加载路径列表中的每一条加载路径是否满足过滤条件,如满足条件则以空格拆分当前加载路径为多个路径,判断每一个路径中是否包含预设字符串,是则记录当前路径并作为疑似外部SD卡路径;判断记录的疑似外部SD卡路径中是否有最终的外部SD卡路径,是则找到最终的外部SD卡,否则未找到最终的外部SD卡。本发明通过对文件系统表和mount命令进行分析,实现在不同版本不同定制的Android平台上来获取外部SD卡的挂载路径,使得在Android操作系统下实现对外部SD卡的检索可不再依懒于API函数来实现,兼容性较好。
Description
本发明涉及一种检索外部SD卡的方法及装置,属于计算机领域。
Android平台支持Java和C/C++语言,是由Google公司开发维护、基于移动设备之上的操作系统,由于移动设备自身的存储空间有限,且移动设备的存储空间越大需要的硬件组件成本越高,大量应用数据的输入输出就只能依赖SD卡来实现,目前,很多手机厂商把SD卡集成到手机中,当然有的手机同时支持可插拔的SD卡,对于该手机而言就出现了内置SD卡和外置SD卡。当手机同时支持内置和外置SD卡时,调用Android系统API得到的是SD卡路径为内置的SD卡路径。由于Android系统的“碎片化”,很多手机厂商处理SD卡的路径都不相同,从而增加了获取自己所需SD的难度,如何在Android平台下找到自己所要操作的外部SD卡是现有技术亟待解决的问题。
本发明的目的是提供一种检索外部SD卡的方法及装置,其可实现在不同版本不同定制的Android平台上来获取外部SD卡的挂载路径,使得在Android操作系统下实现对外部SD卡的检索可不再依懒于API函数来实现,兼容性较好。
为此,根据本发明的一个方面,提供了一种检索外部SD卡的方法,包括:
步骤S1:获取加载路径列表;
步骤S2:将所述加载路径列表中的第一条加载路径作为当前信息记录;
步骤S3:判断当前信息记录是否满足过滤条件,是则执行步骤S4,否则执行步骤S9;
步骤S4:以空格将当前信息记录拆分为多个路径,将第一个路径作为当前信息记录的当前路径;
步骤S5:判断当前路径中是否包含预设字符串,是则执行步骤S6,否则执行步骤S7;
步骤S6:记录当前路径并作为疑似外部SD卡路径,执行步骤S7;
步骤S7:判断当前信息记录中是否还有未处理的路径,是则执行步骤S8,否则执行步骤S9;
步骤S8:将下一个路径作为当前信息记录的当前路径,返回步骤S5;
步骤S9:判断所述加载路径列表中是否还有未处理的加载路径,是则执行步骤S10,否则执行步骤S11;
步骤是S10:将所述加载路径列表中的下一条加载路径作为当前信息记录,返回步骤S3;
步骤S11:判断是否记录有疑似外部SD卡路径,是则执行步骤S12,否则未找到最终的外部SD卡;
步骤S12:判断所述记录的疑似外部SD卡路径中是否有最终的外部SD卡路径,是则找到最终的外部SD卡,否则未找到最终的外部SD卡。
优选地,所述步骤S1具体为:通过mount命令从文件系统表中获取所有加载路径,获取Linux文件系统表中的所有加载路径,根据所述获取到的所有加载路径得到加载路径列表。
优选地,所述步骤S3具体为:判断当前信息记录中是否包含第一预设字符串和第二字符串,是则满足过滤条件,否则不满足过滤条件;
所述步骤S5具体为:判断当前路径中是否包含所述第一预设字符串,是则执行步骤S6,否则执行步骤S7。
优选地,所述步骤S12具体为:
步骤S12-1:将所述记录的第一条疑似外部SD卡路径作为当前疑似外部SD卡路径;
步骤S12-2:判断当前疑似外部SD卡路径是否为最终的外部SD卡路径,是则找到最终的外部SD卡,否则执行步骤S12-3;
步骤S12-3:判断是否处理完所有的疑似外部SD卡路径,是则未找到最终的外部SD卡,否则将所述记录的下一条疑似外部SD卡路径作为当前疑似外部SD卡路径,返回步骤S12-2。
优选地,所述步骤S1具体为:通过mount命令从文件系统表中获取所有加载路径得到加载路径列表;
所述步骤S12判断为否时还包括:
步骤S13:获取Linux文件系统表中的所有加载路径;
步骤S14:将获取的第一条加载路径作为当前信息记录;
步骤S15:判断当前信息记录是否满足所述过滤条件,是则执行步骤S16,否则执行步骤S21;
步骤S16:以空格拆分当前信息记录为多个路径,将第一个路径作为当前信息记录的当前路径;
步骤S17:判断当前路径中是否包含所述预设字符串,是则执行步骤S18,否则执行步骤S19;
步骤S18:记录当前路径并作为疑似外部SD卡路径,执行步骤S19;步骤S19:判断当前信息记录中是否还有未处理的路径,是则执行步骤S20,否则执行步骤S21;
步骤S20:将下一个路径作为当前信息记录的当前路径,返回步骤S17;
步骤S21:判断是否还有未处理的获取到的加载路径,是则执行步骤S22,否则执行步骤S21;
步骤S22:将获取到的下一条加载路径作为当前信息记录,返回步骤S15;
步骤S23:判断是否记录有疑似外部SD卡路径,是则执行步骤S24,否则未找到最终的外部SD卡;
步骤S24:判断所述记录的疑似外部SD卡路径中是否有最终的外部SD卡路径,是则找到最终的外部SD卡,否则未找到最终的外部SD卡。
根据本发明的另外一个方面,提供了一种检索外部SD卡的装置,包括:
获取模块,用于获取加载路径列表;
第一指向模块,用于将所述加载路径列表中的第一条加载路径作为当前信息记录,还用于将所述加载路径列表中的下一条加载路径作为当前信息记录;
第一判断模块,用于判断当前信息记录是否满足过滤条件,是则拆分模块工作,否则第四判断模块工作;
所述拆分模块,用于以空格将当前信息记录拆分为多个路径;
第二指向模块,用于将第一个路径作为当前信息记录的当前路径,还用于将下一个路径作为当前信息记录的当前路径;
第二判断模块,用于判断当前路径中是否包含预设字符串,是则记录模块工作,否则第三判断模块工作;
所述记录模块,用于记录当前路径并作为疑似外部SD卡路径;
所述第三判断模块:用于判断当前信息记录中是否还有未处理的路径,是则所述第二指向模块工作,否则第四判断模块工作;
所述第四判断模块,用于判断所述加载路径列表中是否还有未处理的加载路径,是则所述第一指向模块工作,否则第五判断模块工作;
所述第五判断模块,用于判断是否记录有疑似外部SD卡路径,是则第六判断模块工作,否则未找到最终的外部SD卡;
所述第六判断模块,用于判断所述记录的疑似外部SD卡路径中是否有最终的外部SD卡路径,是则找到最终的外部SD卡,否则未找到最终的外部SD卡。
优选地,所述获取模块包括:
第一获取单元,用于通过mount命令从系统文件中获取所有加载路径;
第二获取单元,用于获取Linux文件系统表中的所有加载路径;
生成单元,用于根据所述第一获取单元获取到的所有加载路径和所述第二获取单元获取到的所有加载路径得到加载路径列表。
优选地,所述第一判断模块具体用于判断当前信息记录中是否包含第一预设字符串和第二字符串,是则所述拆分模块工作,否则所述第四判断模块工作;
所述第二判断模块具体用于判断当前路径中是否包含所述第一预设字符串,是则所述记录模块工作,否则所述第三判断模块工作。
优选地,所述第六判断模块包括:
第一指向单元,用于将所述记录的第一条疑似外部SD卡路径作为当前疑似外部SD卡路径,还用于将所述记录的下一条疑似外部SD卡路径作为当前疑似外部SD卡路径;
第一判断单元,用于判断当前疑似外部SD卡路径是否为最终的外部SD卡路径,是则找到最终的外部SD卡,否则第二判断单元工作;
所述第二判断单元,用于判断是否处理完所有的疑似外部SD卡路径,是则未找到最终的外部SD卡,否则所述第一指向单元工作。
本发明与现有技术相比,具有以下优点:本发明的技术方案是通过Linux的
mount命令从文件系统表(vold.fstab)中获取所有加载路径,再判断这些加载路径中是否有外部SD卡的加载路径,或直接分析Linux文件系统表来获得外部SD卡的加载路径。通过对文件系统表和mount命令进行分析,使用Linux的传统管道技术,在不同版本不同定制的Android平台上来获取外部SD卡的挂载路径,使得在
Android操作系统下实现对外部SD卡的检索可不再依懒于API函数来实现,兼容性较好。
图1为根据本发明实施例1提供的一种检索外部SD卡的方法流程图;
图2-3为根据本发明实施例2提供的一种检索外部SD卡的方法流程图;
图4-5为根据本发明实施例2提供的一种检索外部SD卡的方法的另一种实现方式流程图;
图6为根据本发明实施例3提供的一种检索外部SD卡的装置方框图;
图7为根据本发明实施例3中的第六判断模块的具体实现方框图。
下面将结合本发明实施例中的附图,对本发明的实施例进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域的技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
Android操作系统包括两大块,底层与硬件之间的通讯是通过Linux基金会发布的标准Linux内核的Android剪裁版来实现的,Android剪裁版不仅能运行dalvik程序,以便dalvik程序能够更好的通过Linux内核来管理硬件,而且还能将一些不开放的源代码所涉及商业版权的第三方厂商的硬件驱动映射给Linux内核来管理。Android操作系统与用户实际操作的交互功能都是基于dalvik虚拟机之上的Java语言实现和/或通过C/C++共享库来辅助实现。
实施例1
本发明实施例1提供一种检索外部SD卡的方法,如图1所示,包括:
步骤S1:获取加载路径列表;
在本实施例1中,通过mount命令从文件系统表中获取所有加载路径,获取
Linux文件系统表中的所有加载路径,根据上述获取到的所有加载路径得到加载路径列表;
步骤S2:将加载路径列表中的第一条加载路径作为当前信息记录;
步骤S3:判断当前信息记录是否满足过滤条件,是则执行步骤S4,否则执行步骤S9;
具体地,本实施例1中的过滤条件为:信息记录中包含第一预设字符串和第二预设字符串,优选的,第一预设字符串为mnt或storage,第二预设字符串为vfat;
步骤S4:以空格将当前信息记录拆分为多个路径,将第一个路径作为当前信息记录的当前路径;
步骤S5:判断当前路径中是否包含预设字符串,是则执行步骤S6,否则执行步骤S7;
具体地,本实施例中的预设字符串为第一预设字符串,优选的为mnt或storage;
步骤S6:记录当前路径并作为疑似外部SD卡路径,执行步骤S7;
步骤S7:判断当前信息记录中是否还有未处理的路径,是则执行步骤S8,否则执行步骤S9;
步骤S8:将下一个路径作为当前信息记录的当前路径,返回步骤S5;
步骤S9:判断加载路径列表中是否还有未处理的加载路径,是则执行步骤S10,否则执行步骤S11;
步骤S10:将加载路径列表中的下一条加载路径作为当前信息记录,返回步骤 S3;
步骤S11:判断是否记录有疑似外部SD卡路径,是则执行步骤S12,否则未找到最终的外部SD卡;
步骤S12:判断所述记录的疑似外部SD卡路径中是否有最终的外部SD卡路径,是则找到最终的外部SD卡,否则未找到最终的外部SD卡。
具体地,本实施例1中,步骤S12包括:将记录的疑似外部SD卡路径作为参数,调用接口函数,判断接口函数返回的结果,如为第一预设值则找到最终的外部SD卡,将当前疑似外部SD卡路径确定为最终的外部SD卡路径,如为第二预设值则未找到最终的外部SD卡;
具体地,在本实施例1中,如疑似外部SD卡路径有多条,则依次调用接口函数,以上述疑似外部SD卡路径中一条路径为参数,尝试与疑似外部SD卡路径所对应的SD卡进行通信并返回相应的结果,如返回的结果为第一预设值则通信成功,如返回的结果为第二预设值则通讯不成功;优选的,第一预设值为True,第二预设值为False;尝试与疑似外部SD卡路径所对应的SD卡进行通信具体为:向疑似外部SD卡路径所对应的设备发送初始化指令,并判断是否接收到设备返回的响应,如接收到则通讯成功,否则通讯不成功;
本实施例1中也可以在获取到一条疑似外部SD卡路径后就将其作为参数调用接口函数尝试与对应的设备进行通讯,即去掉步骤S11,步骤S6执行完后执行步骤S12,步骤S12判断为否时执行步骤S7,步骤S9判断为否时未找到最终的外部SD卡路径。
在本实施例1中,找到最终的外部SD卡后还可设置该SD卡所对应的标识或者保存对应的句柄。
实施例2
本发明实施例2提供一种检索外部SD卡的方法,首先通过popen函数打开mount命令,popen()函数通过创建一个管道,调用fork产生一个子进程,执行一个shell以运行命令来开启应用程序;如图2和图3所示,本实施例方法包括:
步骤101:应用程序启动,通过调用mount命令获取文件系统表中的加载路径;
例如,本实施例2中获取的加载路径如下:
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl
(rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
tmpfs /mnt/asec tmpfs rw,relatime /mnt/messtorage
tmpfs rw,nodev
/dev/fuse /storage/sdcard0 fuse(rw,nosuid,nodev,usr
id=1023)devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs
(rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs
(rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
/dev/block/vold/179.9 /storage/sdcard1 vfat
rw,dirsync,nosuid,nodev;
步骤102:将获取的第一条加载路径作为当前信息记录;
步骤103:判断当前信息记录是否满足过滤条件,是则执行步骤104,否则执行步骤109;
具体地,本实施例2中的过滤条件为:信息记录中包含第一预设字符串和第二预设字符串,优选的,第一预设字符串为mnt或storage,第二预设字符串为vfat;
如当前信息记录为/dev/sda1 on / type ext3
(rw,errors=remount-ro),不包含mnt和vfat或包含storage和vfat,则执行步骤109;
如当前信息记录为/dev/block/vold/179.9 /storage/sdcard1 vfat
rw, dirsync, nosuid, nodev,包含storage和vfat则执行步骤104;
步骤104:以空格将当前信息记录拆分为多个路径,将第一个路径作为当前信息记录的当前路径;
例如,在本实施例2中,将/dev/block/vold/179.9 /storage/sdcard1
vfat rw,dirsync,nosuid,nodev拆分为/dev/block/vold/179.9、/storage/sdcard1、vfat
rw,dirsync,nosuid,nodev三个路径;
步骤105:判断当前路径中是否包含预设字符串,是则执行步骤106,否则执行步骤107;
具体地,本实施例2中的预设字符串为第一预设字符串,优选的为mnt或storage;
例如,在本实施例2中,在/dev/block/vold/179.9和vfat rw, dirsync,
nosuid,
nodev这两个路径中不包含mnt或storage,执行步骤107;在/storage/sdcard1这个路径中包含storage,执行步骤106;
步骤106:记录当前路径并作为疑似外部SD卡路径,执行步骤107;具体地,在本实施例中,将/storage/sdcard1作为疑似外部SD卡路径;
步骤107:判断当前信息记录中是否还有未处理的路径,是则执行步骤108,否则执行步骤109;
步骤108:将下一个路径作为当前信息记录的当前路径,返回步骤105;
步骤109:判断加载路径列表中是否还有未处理的加载路径,是则执行步骤110,否则执行步骤111;
步骤110:将下一条加载路径作为当前信息记录,返回步骤103;
步骤111:判断是否记录有疑似外部SD卡路径,是则执行步骤112,否则未找到最终的外部SD卡,执行步骤113;
步骤112:依次将记录的疑似外部SD卡路径作为参数,调用接口函数,判断接口函数返回的结果,如为第一预设值则找到最终的外部SD卡,将当前疑似外部
SD卡路径确定为最终的外部SD卡路径,如为第二预设值则未找到最终的外部SD卡,执行步骤113;
步骤113:获取Linux文件系统表中的所有加载路径;
步骤114:将第一条加载路径作为当前信息记录;
步骤115:判断当前信息记录是否满足过滤条件,是则执行步骤116,否则执行步骤121;
本实施例2中该步骤中的过滤条件与步骤103的相同,在此不再赘述;
步骤116:以空格将当前信息记录拆分为多个路径,将第一个路径作为当前信息记录的当前路径;
步骤117:判断当前路径中是否包含预设字符串,是则执行步骤118,否则执行步骤119;
本实施例2中该步骤中的过滤条件与步骤105的相同,在此不再赘述;
步骤118:记录当前路径并作为疑似外部SD卡路径,执行步骤119;
步骤119:判断当前信息记录中是否还有未处理的路径,是则执行步骤120,否则执行步骤121;
步骤120:将下一个路径作为当前信息记录的当前路径,返回步骤117;
步骤121:判断加载路径列表中是否还有未处理的加载路径,是则执行步骤122,否则执行步骤123;
步骤122:将下一条加载路径作为当前信息记录,返回步骤115;
步骤123:判断是否记录有疑似外部SD卡路径,是则执行步骤124,否则未找到最终的外部SD卡;
步骤124:依次将记录的疑似外部SD卡路径,调用接口函数,判断接口函数返回的结果,如为第一预设值则找到最终的外部SD卡,将当前疑似外部SD卡路径确定为最终的外部SD卡路径,如为第二预设值则未找到最终的外部SD卡;
具体地,在本实施例2中,如疑似外部SD卡路径有多条,则以上述疑似外部SD卡路径中一条路径为参数,调用接口函数,尝试与疑似外部SD卡路径所对应的
SD卡进行通信并返回相应的结果,如返回的结果为第一预设值则通信成功,将当前疑似外部SD卡路径确定为最终的外部SD卡路径,如返回的结果为第二预设值则通讯不成功;优选的,第一预设值为True,第二预设值为False。
本实施例2中是获取到所有的疑似外部SD卡路径后再依次将每条疑似外部SD卡路径作为参数调用接口函数尝试与对应的设备进行通讯,通讯成功则找到最终的SD卡路径;也可以在获取到一条疑似外部SD卡路径后就将其作为参数调用接口函数尝试与对应的设备进行通讯,即去掉步骤111和步骤123,步骤106执行完后执行步骤112,步骤112判断为第二预设值时执行步骤107,步骤109判断为否时执行步骤113;步骤118执行完后执行步骤124,步骤124判断为第二预设值时执行步骤119,步骤121判断为否时未找到最终的外部SD卡,具体实现过程如图4和图5所示。
在本实施例2中,如在通过mount命令获取到的所有加载路径中没有疑似外部
SD卡路径,则再从Linux文件系统表中获取所有加载路径,判断是否有疑似外部SD卡路径,如找到疑似外部
SD卡路径则尝试与该路径对应的设备进行通讯,如通讯成功则说明该路径对应的设备中的SD卡为要找到的外部SD卡。通过本实施例2的方法使得在Android
操作系统下实现对外部SD卡的检索不再依懒于API函数,兼容性较好。
实施例3
本发明实施例3提供一种检索外部SD卡的装置,如图6所示,包括:
获取模块601,用于获取加载路径列表;
具体地,本实施例中的获取模块601包括:
第一获取单元6011,用于通过mount命令从系统文件中获取所有加载路径;
第二获取单元6012,用于获取Linux文件系统表中的所有加载路径;
生成单元6013,用于根据第一获取单元6011获取到的所有加载路径和第二获取单元6012获取到的所有加载路径得到加载路径列表;
第一指向模块602,用于将加载路径列表中的第一条加载路径作为当前信息记录,还用于将加载路径列表中的下一条加载路径作为当前信息记录;
第一判断模块603,用于判断当前信息记录是否满足过滤条件,是则拆分模块
604工作,否则第四判断模块609工作;
具体地,本实施例中的第一判断模块603具体用于判断当前信息记录中是否包含第一预设字符串和第二预设字符串,是则拆分模块604工作,否则第四判断模块609工作;优选的,第一预设字符串为mnt或storage,第二预设字符串为vfat;
拆分模块604,用于以空格拆分当前信息记录为多个路径;
第二指向模块605,用于将第一个路径作为当前信息记录的当前路径,还用于将下一个路径作为当前信息记录的当前路径;
第二判断模块606,用于判断当前路径中是否包含预设字符串,是则记录模块
607工作,否则第三判断模块608工作;
具体地,在本实施例3中,第二判断模块606具体用于判断当前路径中是否包含第一预设字符串,是则记录模块607工作,否则第三判断模块608工作;
记录模块607,用于记录当前路径并作为疑似外部SD卡路径;
第三判断模块608:用于判断当前信息记录中是否还有未处理的路径,是则第二指向模块605工作,否则第四判断模块609工作;
第四判断模块609,用于判断所述加载路径列表中是否还有未处理的加载路径,是则第一指向模块602工作,否则第五判断模块610工作;
第五判断模块610,用于判断是否记录有疑似外部SD卡路径,是则第六判断模块611工作,否则未找到最终的外部SD卡;
第六判断模块611,用于判断记录的疑似外部SD卡路径中是否有最终的外部SD卡路径,是则找到最终的外部SD卡,否则未找到最终的外部SD卡;
如本实施例3中的疑似外部SD卡路径有多条,则第六判断模块611具体用于将一条疑似外部SD卡路径,调用接口函数,判断接口函数返回的结果,如为第一预设值则找到最终的外部SD卡,将当前疑似外部SD卡路径确定为最终的外部SD卡路径,如为第二预设值则未找到最终的外部SD卡。
如图7所示,本实施例中的第六判断模块611包括:
第一指向单元611-1,用于将记录的第一条疑似外部SD卡路径作为当前疑似外部SD卡路径,还用于将记录的下一条疑似外部SD卡路径作为当前疑似外部SD卡路径;
第一判断单元611-2,用于判断当前疑似外部SD卡路径是否为最终的外部SD卡路径,是则找到最终的外部SD卡,否则第二判断单元611-3工作;
第二判断单元611-3,用于判断是否处理完所有的疑似外部SD卡路径,是则未找到最终的外部SD卡,否则第一指向单元611-1工作。
在本发明实施例3中,该装置可以首先记录所有的疑似外部SD卡路径,然后再与其中一条疑似外部SD卡路径所对应的设备进行通讯,通讯成功则找到最终的外部SD卡,如与所有的疑似外部SD卡路径所对应的设备进行通讯都未能成功则未找到最终的外部SD卡。具体实现方式为:获取模块601首先获取加载路径列表,第一指向模块602将加载路径列表中的第一条加载路径作为当前信息记录,第一判断模块603判断当前信息记录是否满足过滤条件,第一判断模块603满足条件则拆分模块604以空格拆分当前信息记录为多个路径,第二指向模块605将第一个路径作为当前信息记录的当前路径,第二判断模块606判断当前路径中是否包含预设字符串,第二判断模块606判断为是时记录模块607记录当前路径并作为疑似外部SD卡路径;第二判断模块606判断为否时第三判断模块608判断当前信息记录中是否还有未处理的路径,第三判断模块
608判断还有未处理的路径时第二指向模块605将下一个路径作为当前信息记录的当前路径;第三判断模块
608判断没有未处理的路径和第一判断模块603判断不满足过滤条件时第四判断模块609判断是否还有未处理的加载路径,第四判断模块609判断还有未处理的加载路径时则第一指向模块602将加载路径列表中的下一条加载路径作为当前信息记录,第四判断模块609判断没有未处理的加载路径时则第五判断模块610用于判断是否记录有疑似外部SD卡路径,第五判断模块610判断为是时第六判断模块611判断记录的疑似外部SD卡路径中是否有最终的外部SD卡路径,是则找到最终的外部SD卡,第五判断模块610和第六判断模块611判断为否时则未找到最终的外部SD卡。
具体地,本实施例3中,也可以首先通过获取模块601中的第一获取单元6011得到加载路径列表,然后第一指向模块602工作,当第五判断模块610和第六判断模块611判断为否时获取模块601中的第二获取单元6012得到加载路径列表,然后第一指向模块602再次工作。本实施例的装置如在通过mount命令获取到的所有加载路径中没有疑似外部SD卡路径,则再从Linux文件系统表中获取所有加载路径,判断是否有疑似外部SD卡路径,如找到疑似外部SD卡路径则尝试与该路径对应的设备进行通讯,如通讯成功则说明该路径对应的设备中的SD卡为要找到的外部SD卡。通过本实施例的方法使得在Android
操作系统下实现对外部SD卡的检索不再依懒于API函数,兼容性较好。
在本实施例3中,该装置检索外部SD卡还有另一种实现方式,即找到一条疑似外部SD卡路径就尝试与其对应的设备进行通讯,如通讯成功则找到最终的外部
SD卡,否则查找下一条疑似外部SD卡路径。具体实现方式为:记录模块607工作之后第六判断模块611判断记录的疑似外部SD卡路径中是否有最终的外部SD卡路径,是则找到最终的外部SD卡,否则第三判断模块608工作,第三判断模块
608判断为否时第四判断模块609工作,第四判断模块609判断为否则未找到最终的外部SD卡。
以上所述,仅为本发明较佳的具体实施方式,但本发明的保护范围并不局限于此,本领域的技术人员在本发明公开的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应该以所附权利要求书的保护范围为准。
Claims (9)
- 一种检索外部SD卡的方法,其特征在于,包括:步骤S1:获取加载路径列表;步骤S2:将所述加载路径列表中的第一条加载路径作为当前信息记录;步骤S3:判断当前信息记录是否满足过滤条件,是则执行步骤S4,否则执行步骤S9;步骤S4:以空格将当前信息记录拆分为多个路径,将第一个路径作为当前信息记录的当前路径;步骤S5:判断当前路径中是否包含预设字符串,是则执行步骤S6,否则执行步骤S7;步骤S6:记录当前路径并作为疑似外部SD卡路径,执行步骤S7;步骤S7:判断当前信息记录中是否还有未处理的路径,是则执行步骤S8,否则执行步骤S9;步骤S8:将下一个路径作为当前信息记录的当前路径,返回步骤 S5;步骤S9:判断所述加载路径列表中是否还有未处理的加载路径,是则执行步骤S10,否则执行步骤S11;步骤是S10:将所述加载路径列表中的下一条加载路径作为当前信息记录,返回步骤S3;步骤S11:判断是否记录有疑似外部SD卡路径,是则执行步骤S12,否则未找到最终的外部SD卡;以及步骤S12:判断所述记录的疑似外部SD卡路径中是否有最终的外部SD卡路径,是则找到最终的外部SD卡,否则未找到最终的外部SD卡。
- 如权利要求1所述的方法,其特征在于,所述步骤S1具体为:通过mount命令从文件系统表中获取所有加载路径,获取Linux文件系统表中的所有加载路径,根据所述获取到的所有加载路径得到加载路径列表。
- 如权利要求1所述的方法,其特征在于,所述步骤S3具体为:判断当前信息记录中是否包含第一预设字符串和第二字符串,是则满足过滤条件,否则不满足过滤条件;所述步骤S5具体为:判断当前路径中是否包含所述第一预设字符串,是则执行步骤S6,否则执行步骤S7。
- 如权利要求1所述的方法,其特征在于,所述步骤S12具体为:步骤S12-1:将所述记录的第一条疑似外部SD卡路径作为当前疑似外部SD卡路径;步骤S12-2:判断当前疑似外部SD卡路径是否为最终的外部SD卡路径,是则找到最终的外部SD卡,否则执行步骤S12-3;以及步骤S12-3:判断是否处理完所有的疑似外部SD卡路径,是则未找到最终的外部SD卡,否则将所述记录的下一条疑似外部SD卡路径作为当前疑似外部SD卡路径,返回步骤S12-2。
- 如权利要求1所述的方法,其特征在于,所述步骤S1具体为:通过mount命令从文件系统表中获取所有加载路径得到加载路径列表;所述步骤S12判断为否时还包括:步骤S13:获取Linux文件系统表中的所有加载路径;步骤S14:将获取的第一条加载路径作为当前信息记录;步骤S15:判断当前信息记录是否满足所述过滤条件,是则执行步骤S16,否则执行步骤S21;步骤S16:以空格拆分当前信息记录为多个路径,将第一个路径作为当前信息记录的当前路径;步骤S17:判断当前路径中是否包含所述预设字符串,是则执行步骤S18,否则执行步骤S19;步骤S18:记录当前路径并作为疑似外部SD卡路径,执行步骤S19;步骤S19:判断当前信息记录中是否还有未处理的路径,是则执行步骤S20,否则执行步骤S21;步骤S20:将下一个路径作为当前信息记录的当前路径,返回步骤S17;步骤S21:判断是否还有未处理的获取到的加载路径,是则执行步骤S22,否则执行步骤S21;步骤S22:将获取到的下一条加载路径作为当前信息记录,返回步骤S15;步骤S23:判断是否记录有疑似外部SD卡路径,是则执行步骤S24,否则未找到最终的外部SD卡;以及步骤S24:判断所述记录的疑似外部SD卡路径中是否有最终的外部SD卡路径,是则找到最终的外部SD卡,否则未找到最终的外部SD卡。
- 一种检索外部SD卡的装置,其特征在于,包括:获取模块,用于获取加载路径列表;第一指向模块,用于将所述加载路径列表中的第一条加载路径作为当前信息记录,还用于将所述加载路径列表中的下一条加载路径作为当前信息记录;第一判断模块,用于判断当前信息记录是否满足过滤条件,是则拆分模块工作,否则第四判断模块工作;所述拆分模块,用于以空格将当前信息记录拆分为多个路径;第二指向模块,用于将第一个路径作为当前信息记录的当前路径,还用于将下一个路径作为当前信息记录的当前路径;第二判断模块,用于判断当前路径中是否包含预设字符串,是则记录模块工作,否则第三判断模块工作;所述记录模块,用于记录当前路径并作为疑似外部SD卡路径;所述第三判断模块:用于判断当前信息记录中是否还有未处理的路径,是则所述第二指向模块工作,否则第四判断模块工作;所述第四判断模块,用于判断所述加载路径列表中是否还有未处理的加载路径,是则所述第一指向模块工作,否则第五判断模块工作;所述第五判断模块,用于判断是否记录有疑似外部SD卡路径,是则第六判断模块工作,否则未找到最终的外部SD卡;以及所述第六判断模块,用于判断所述记录的疑似外部SD卡路径中是否有最终的外部SD卡路径,是则找到最终的外部SD卡,否则未找到最终的外部SD卡。
- 如权利要求6所述的装置,其特征在于,所述获取模块包括:第一获取单元,用于通过mount命令从系统文件中获取所有加载路径;第二获取单元,用于获取Linux文件系统表中的所有加载路径;以及生成单元,用于根据所述第一获取单元获取到的所有加载路径和所述第二获取单元获取到的所有加载路径得到加载路径列表。
- 如权利要求6所述的装置,其特征在于,所述第一判断模块具体用于判断当前信息记录中是否包含第一预设字符串和第二字符串,是则所述拆分模块工作,否则所述第四判断模块工作;所述第二判断模块具体用于判断当前路径中是否包含所述第一预设字符串,是则所述记录模块工作,否则所述第三判断模块工作。
- 如权利要求6所述的装置,其特征在于,所述第六判断模块包括:第一指向单元,用于将所述记录的第一条疑似外部SD卡路径作为当前疑似外部SD卡路径,还用于将所述记录的下一条疑似外部SD卡路径作为当前疑似外部SD卡路径;第一判断单元,用于判断当前疑似外部SD卡路径是否为最终的外部SD卡路径,是则找到最终的外部SD卡,否则第二判断单元工作;以及所述第二判断单元,用于判断是否处理完所有的疑似外部SD卡路径,是则未找到最终的外部SD卡,否则所述第一指向单元工作。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US15/027,446 US10013175B2 (en) | 2013-12-27 | 2014-10-16 | Method and device for indexing external SD card |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310741343.9A CN103699418B (zh) | 2013-12-27 | 2013-12-27 | 一种检索外部sd卡的方法及装置 |
CN201310741343.9 | 2013-12-27 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2015096541A1 true WO2015096541A1 (zh) | 2015-07-02 |
Family
ID=50360957
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2014/088728 WO2015096541A1 (zh) | 2013-12-27 | 2014-10-16 | 一种检索外部sd卡的方法及装置 |
Country Status (3)
Country | Link |
---|---|
US (1) | US10013175B2 (zh) |
CN (1) | CN103699418B (zh) |
WO (1) | WO2015096541A1 (zh) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103699418B (zh) * | 2013-12-27 | 2016-08-24 | 飞天诚信科技股份有限公司 | 一种检索外部sd卡的方法及装置 |
CN104268462B (zh) * | 2014-09-25 | 2017-06-20 | 福建联迪商用设备有限公司 | 一种安卓系统的分区保护方法和装置 |
CN106959824A (zh) * | 2017-03-17 | 2017-07-18 | 广东蜂助手网络技术股份有限公司 | 一种保证获取各种安卓手机外部存储卡路径的方法 |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103699418A (zh) * | 2013-12-27 | 2014-04-02 | 飞天诚信科技股份有限公司 | 一种检索外部sd卡的方法及装置 |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TW200506733A (en) * | 2003-08-15 | 2005-02-16 | Via Tech Inc | Apparatus and method for the co-simulation of CPU and DUT modules |
CN1991735A (zh) * | 2005-12-06 | 2007-07-04 | 美国凹凸微系有限公司 | 一种连接存储卡的系统和方法 |
CN102084357B (zh) * | 2008-07-01 | 2014-06-04 | 富士通株式会社 | 检索装置以及检索方法 |
TW201037530A (en) | 2009-04-14 | 2010-10-16 | Acer Inc | Method for displaying a plugin frame in a web browser, computer readable medium, and computer program product |
-
2013
- 2013-12-27 CN CN201310741343.9A patent/CN103699418B/zh active Active
-
2014
- 2014-10-16 US US15/027,446 patent/US10013175B2/en active Active
- 2014-10-16 WO PCT/CN2014/088728 patent/WO2015096541A1/zh active Application Filing
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103699418A (zh) * | 2013-12-27 | 2014-04-02 | 飞天诚信科技股份有限公司 | 一种检索外部sd卡的方法及装置 |
Non-Patent Citations (1)
Title |
---|
HONG CHAO DE ET AL.: "Searching the loading paths of SD cards in Java and C under Android", 3 January 2013 (2013-01-03), Retrieved from the Internet <URL:http://blog.sina.com.cn/s/blog4c451e0e01014roj.html> * |
Also Published As
Publication number | Publication date |
---|---|
CN103699418A (zh) | 2014-04-02 |
CN103699418B (zh) | 2016-08-24 |
US20160342331A1 (en) | 2016-11-24 |
US10013175B2 (en) | 2018-07-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2018076841A1 (zh) | 数据分享方法、装置、存储介质及服务器 | |
WO2017069595A1 (en) | Electronic device and method for executing function using speech recognition thereof | |
WO2014209078A1 (en) | Method and apparatus for updating application | |
WO2017069489A1 (ko) | 선택적 암호화 방법 및 그를 이용한 전자 장치 | |
WO2017142256A1 (en) | Electronic device for authenticating based on biometric data and operating method thereof | |
WO2020149520A1 (ko) | 펌웨어 업데이트 방법, 이를 위한 전자 장치 및 저장 매체 | |
EP3042267A1 (en) | Method of providing notification and electronic device thereof | |
WO2018076844A1 (zh) | 数据备份的方法、装置、存储介质及电子设备 | |
WO2018201774A1 (zh) | 数据审批方法、装置、设备和计算机可读存储介质 | |
WO2018062894A1 (ko) | 전력을 제어하는 전자 장치 | |
WO2017119662A1 (en) | Electronic device and operating method thereof | |
WO2020256301A1 (en) | Electronic device including storage and method for using the storage | |
EP3539046A1 (en) | Electronic device and method for managing data in electronic device | |
WO2015020417A1 (en) | Method for displaying and an electronic device thereof | |
WO2020027413A1 (ko) | 팩토리 데이터 리셋 기능에 의해 제거된 어플리케이션을 복원하는 장치 및 방법 | |
WO2015096541A1 (zh) | 一种检索外部sd卡的方法及装置 | |
WO2016183721A1 (zh) | 一种终端设备刷机方法、装置和设备 | |
WO2017206879A1 (zh) | 一种移动终端应用程序的处理方法、装置、存储介质及电子设备 | |
WO2017090931A1 (ko) | 이벤트 관리 서비스를 제공하는 전자 장치 및 방법 | |
EP3414954A1 (en) | Method and electronic device for providing wireless communication | |
EP3994571A1 (en) | Method and apparatus for improving runtime performance after application update in electronic device | |
WO2016085256A1 (en) | Electronic device for managing use of data from other electronic device and method for controlling the same | |
WO2015005744A1 (ko) | 디나이얼 발생시 대응 메뉴얼을 제안하는 전자 장치 및 방법 | |
WO2020062615A1 (zh) | 显示面板的伽马值调节方法、装置及显示设备 | |
WO2017026679A1 (en) | Electronic device for controlling file system and operating method thereof |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 14873390 Country of ref document: EP Kind code of ref document: A1 |
|
WWE | Wipo information: entry into national phase |
Ref document number: 15027446 Country of ref document: US |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 14873390 Country of ref document: EP Kind code of ref document: A1 |