CN106445665B - A kind of system file method for down loading and download tool applied to Android system - Google Patents

A kind of system file method for down loading and download tool applied to Android system Download PDF

Info

Publication number
CN106445665B
CN106445665B CN201610831432.6A CN201610831432A CN106445665B CN 106445665 B CN106445665 B CN 106445665B CN 201610831432 A CN201610831432 A CN 201610831432A CN 106445665 B CN106445665 B CN 106445665B
Authority
CN
China
Prior art keywords
downloading
download
system file
file
task
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201610831432.6A
Other languages
Chinese (zh)
Other versions
CN106445665A (en
Inventor
张磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201610831432.6A priority Critical patent/CN106445665B/en
Publication of CN106445665A publication Critical patent/CN106445665A/en
Application granted granted Critical
Publication of CN106445665B publication Critical patent/CN106445665B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a kind of system file method for down loading applied to Android system, the first downloading task for download system file that system development program is sent first is obtained from the task queue with priority ranking, it is then based on the first downloading task and obtains corresponding download parameters, and thus judge whether the data volume of system file is more than preset data amount threshold value.It indicates that the data volume of system file is excessive if being more than, selects first thread to download by batch from thread pool, will not be downloaded using several threads.Due to being the multiple batches being divided into system file less than preset data amount threshold value in downloading, then the file directory of memory is successively downloaded to by batch, and then when restarting the first downloading task, without calling thread to calculate completed task total amount, it just can quickly be searched out at the interruption of system file according to batch, and continue to download.

Description

A kind of system file method for down loading and download tool applied to Android system
Technical field
This application involves the communications field more particularly to a kind of system file method for down loading applied to Android system and Download tool.
Background technique
In the development process of Android, download part is a very common function.
The mode of current downloading file, generally by the way of multi-threading parallel process multiple tasks.And for single Downloading task, then be that single downloading task (file or a compressed package) is divided into several parts, each part It is uploaded or is downloaded using a thread, if encountering network failure, can continue to download since the part downloaded Unfinished part is downloaded from the beginning without necessity.
But the mode of current this downloading task, downloading task is resumed if necessary, is related to then needing first to acquire The task amount downloaded in the per thread of the downloading task, then comprehensive statistics obtains the task total amount downloaded, and obtains Part through downloading then proceedes to start to download.This processing mode needs that the per thread being related to is called to be counted, and locates Reason process is complicated, and needs calculated in advance total amount of going out on missions that can continue to download, if having thread if handling other tasks The inefficiency of file download when may need to turn thread process etc., and then lead to breakpoint transmission.
Summary of the invention
Invention provides a kind of system file method for down loading and download tool applied to Android system, solve Or part file download efficiency low technical problem when solving breakpoint transmission in the prior art.
In order to solve the above technical problems, the present invention provides a kind of system file downloading sides applied to Android system Method, comprising:
What acquisition system development program was sent from the task queue with priority ranking is used for download system file First downloading task;
Corresponding download parameters are obtained based on first downloading task;
Based on the download parameters of first downloading task, judge whether the data volume of the system file is more than present count According to amount threshold value;
If the data volume of the system file is more than the preset data amount threshold value, first thread is chosen from thread pool will The system file is successively downloaded to by batch in the file directory of memory;The every batch of data volume of the system file is less than Or it is equal to the preset data amount threshold value;
When restarting first downloading task, the downloading point of interruption of the system file is searched, from the downloading The point of interruption continues successively to download the part that do not download in the system file by batch.
Preferably, the system file is successively downloaded to memory by batch by the selection first thread from thread pool File directory in, comprising:
The system file is successively downloaded to by batch in the memory of the mobile terminal, while according to respective batch reality When be transferred in the file directory of the memory.
Preferably, it if the data volume of the system file is more than the preset data amount threshold value, is selected from thread pool First thread is taken successively to download to the system file by batch in the file directory of memory, comprising:
If the data volume of the system file is more than the preset data amount threshold value, first thread is chosen from thread pool will The system file successively downloads to by batch in the file directory of memory, and system file described in real-time update is downloaded into Information is spent, the download progress information is used to record the download progress of the system file;
It is described to search the downloading point of interruption of the system file when restarting first downloading task, from described The downloading point of interruption continues successively to download the part that do not download in the system file by batch, comprising:
When restarting first downloading task, calls and downloads the point of interruption described in the download progress information searching, Continue successively to download the part that do not download in the system file by batch from the downloading point of interruption.
Preferably, it if the data volume of the system file is more than the preset data amount threshold value, is selected from thread pool First thread is taken successively to download to the system file by batch in the file directory of memory, and system described in real-time update The download progress information of file, the download progress information are used to record the download progress of the system file, comprising:
The system development program is given using download progress information described in interface real-time informing.
Preferably, the download parameters based on first downloading task judge that the data volume of the system file is It is no be more than preset data amount threshold value after, comprising:
If the data volume of the system file is not above the preset data amount threshold value, institute is chosen from the thread pool It states first thread to download to the system file applied to Android system in the file of the memory, and utilizes institute Result notice will be downloaded to the system development program by stating interface module.
Preferably, what the acquisition system development program from the task queue with priority ranking was sent is used to download Before first downloading task of system file, comprising:
Receive the downloading request for carrying downloading task that the system development program is sent;
Corresponding downloading task is obtained from downloading request;
Corresponding downloading task is requested to be put into the task queue downloading;
The downloading is set to request corresponding downloading task and other downloading tasks in the task queue together according to excellent First grade sequence is ranked up.
Preferably, described that the downloading is made to request corresponding downloading task and other downloading tasks in the task queue It is ranked up together according to priority orders, comprising:
In the task queue, all downloading tasks are ranked up according to the priority of three grades;
In same grade, it is ranked up according to downloading task of the receiving time to same grade.
Preferably, described that the downloading is made to request corresponding downloading task and other downloading tasks in the task queue After being ranked up together according to priority orders, comprising:
Obtain from the task queue according to priority include the first downloading task N number of downloading task, wherein 1≤ N≤5;
Selection includes N number of thread of first thread from thread pool, while handling corresponding downloading task, and real The respective download progress information of Shi Gengxin;
N number of respective download progress of downloading task is notified to the system development program.
Preferably, it is described by N number of respective download progress of downloading task notify to corresponding system development program it Afterwards, comprising:
Judge the thread whether finished with execution task in N number of thread;
If so, the thread process then choosing the second downloading task from the task queue, and being finished using execution task Second downloading task.
The invention discloses a kind of system file download tools applied to Android system, comprising:
First obtains module, the use sent for obtaining system development program from the task queue with priority ranking In the first downloading task of download system file;
Second obtains module, for obtaining corresponding download parameters based on first downloading task;
Judgment module judges the data volume of the system file for the download parameters based on first downloading task It whether is more than preset data amount threshold value;
First chooses module, if the data volume for the system file is more than the preset data amount threshold value, from thread First thread is chosen in pond successively to download to the system file by batch in the file directory of memory;The system file Every batch of data volume be less than or equal to the preset data amount threshold value;
Download module, the downloading for when restarting first downloading task, searching the system file are interrupted Point continues successively to download the part that do not download in the system file by batch from the downloading point of interruption.
One or more technical solution through the invention, the invention has the advantages that advantage:
The invention discloses a kind of system file method for down loading applied to Android system, first arrange from priority The first downloading task for download system file that system development program is sent is obtained in the task queue of sequence, is then based on institute It states the first downloading task and obtains corresponding download parameters, and thus judge whether the data volume of the system file is more than present count According to amount threshold value.It indicates that the data volume of system file is excessive if being more than, needs to transmit by batch.Even if there are other in thread pool Thread also only uses first thread and handles the system file, without being downloaded using several threads.In addition, downloading when be by System file is divided into multiple batches less than preset data amount threshold value, and the memory of mobile terminal is then successively downloaded to by batch File directory in, and then when restarting first downloading task, since the present invention is successively downloaded according to batch, So not having to that thread is called to calculate completed task total amount, system file just can be quickly searched out according to batch At interruption, the part that do not download in download system file is then proceeded to, processing is simple and convenient, can be improved the effect of breakpoint transmission Rate.
Further, the present invention also records and the real-time update download progress information of system file, and then program is opened Hair system, which calls directly download progress information, can know the task amount that system file has been downloaded, and then quickly know system At the interruption of file, the part that do not download in download system file is then proceeded to, processing is simple and convenient, can be improved breakpoint transmission Efficiency.
In addition, the present invention gives the download progress information real-time informing to system development program also in a manner of interface, by It is simple in interface method of calling and be one-to-one notice, distribution processor committed memory will not be will do it as broadcast, even if so The very high timeliness that can also guarantee progress notification of system occupancy.
Further, the present invention is successively downloaded to the system file by batch after the memory of the mobile terminal, The system file in memory can be transferred in the file directory of memory in real time, therefore it is vacant that memory can be made to be always held at State, even if the case where memory spilling will not occur in the big system file of transmitted data amount.
Detailed description of the invention
Fig. 1 is the flow chart for being applied to the system file method for down loading of Android system in the embodiment of the present invention;
Fig. 2 is the specific implementation process figure of download system file in the embodiment of the present invention;
Fig. 3 is the structural schematic diagram for being applied to the system file download tool of Android system in the embodiment of the present invention.
Specific embodiment
In order to make the application the technical staff in the technical field be more clearly understood that the application, with reference to the accompanying drawing, Technical scheme is described in detail by specific embodiment.
OOM: memory overflow (out of memory) it is popular understand be exactly Out of Memory, usually run large software or When game, memory required for software or game is just memory far beyond the born size of memory installed in your host It overflows.
Breakpoint transmission: will download or upload task (file or a compressed package) man-made division is several parts, Each part uploaded or downloaded using a thread, can be from having uploaded or downloaded if encountering network failure Part starts to continue to upload the unfinished part of downloading, uploads downloading from the beginning without necessary.
Thread pool: thread pool is a kind of multiple threads form, and task is added to queue in treatment process, is then being created It builds and starts these tasks after thread automatically.Thread pool threads are all background threads.Per thread all uses the storehouse size of default, It is run with the priority of default, and in multiple thread units.
Url: uniform resource locator is one kind of the position and access method to the resource that can be obtained from internet Succinct expression is the address of standard resource on internet.Each file on internet has a unique URL, it is wrapped The information contained points out how the position of file and browser should handle it.
Regular expression: regular expression, also known as regular expression.(English: Regular Expression, in code In be often abbreviated as regex, regexp or RE), a concept of computer science.Canonical table is usually used to retrieval, replaces that Meet the text of some mode (rule) a bit.
The present invention devises a kind of system file method for down loading and download tool applied to Android system, mainly Original system file is downloaded for system (or software) developer, it is used when mainly including development system program in system file System data.Method for down loading and download tool of the invention is mainly used in being mounted with the mobile terminal of android system, and It is not used in the equipment for being mounted with windows system.The download tool embeddable system is developed in program, is needed in system development program When wanting download system file, the download tool can be called directly and be downloaded.The downloading of this and common application program offer Method is distinguishing.Specifically, common application program such as ' XX thunder ', that face is ordinary user.Under ' XX thunder ' Load mode is by the access address URL download pictures, document, video etc. data.And it is provided by the invention applied to android What the system file method for down loading and download tool of system (Android system) faced is that system (or software) developer is opening Original system file is downloaded when sending out program.
Fig. 1 is please referred to below, is the implementation process for the system file method for down loading that the present invention is applied to Android system Figure.
S1, the transmission of system development program is obtained from the task queue with priority ranking is used for download system file The first downloading task.
In the specific implementation process, the present invention devises task queue and stores all downloading tasks, and under all Load task carries out priority ranking management.
In the specific implementation process, the present invention has pre-defined priority level to downloading task first, and this is excellent First grade grade, which is informed, gives system development program (namely: android (Android) system development program), and then makes system development program After generating downloading task, the calibration of priority can be carried out to downloading task.The present invention can be the calibration of priority Custom tags.For example, defining the priority of 3 grades: low priority low, normal priority normal, high priority high。
System development program can carry out priority mark to the downloading task carried in downloading request when sending downloading request It is fixed, such as low priority low, normal priority normal, high priority high.Downloading task is specified in system development program Later, can 3 flag bits according to the definition of the present invention, the calibration of priority is carried out to downloading task, and then the present invention is locating When managing downloading task, it can be handled in sequence according to the priority of calibration.If do not transmit any priority be defaulted as it is general Logical priority.
In the specific implementation process, obtain what system development program was sent from the task queue with priority ranking Before the first downloading task of download system file, the present embodiment includes:
Receive the downloading request for carrying downloading task that the system development program is sent;
Corresponding downloading task is obtained from downloading request;
Corresponding downloading task is requested to be put into the task queue downloading;
The downloading is set to request corresponding downloading task and other downloading tasks in the task queue together according to excellent First grade sequence is ranked up.
And in specific sequencer procedure, in the task queue, according to the priority of three grades under all Load task is ranked up;In same grade, it is ranked up according to downloading task of the receiving time to same grade.
In the specific implementation process, after receiving downloading task, task can be put into downloading queue first, It resequences to the priority of downloading task, the downloading task of high priority is emitted on queue leading portion priority processing.It will The downloading task of low priority is emitted on queue tail end and finally handles.Queueing discipline is as follows:
1, the downloading task of high priority is arranged in the most leading portion of queue, inside the downloading task of all high priorities Queueing discipline be: arranged according to the sequence of the receiving time for the downloading task for receiving high priority.
2, after the downloading task of normal priority being arranged in high priority, in the downloading task of all normal priorities The queueing discipline in portion is: arranging according to the sequence of the receiving time for the downloading task for receiving normal priority.
3, after the downloading task of low priority being arranged in normal priority, inside the downloading task of all low priorities Queueing discipline be: arranged according to the sequence of the receiving time for the downloading task for receiving low priority.
As a kind of optional embodiment, when carrying task under treatment, the present invention is applied to the system text of Android system Part download tool can carry out multitasking simultaneously, specifically be introduced below.
Obtain from the task queue according to priority include the first downloading task N number of downloading task, wherein 1≤ N≤5。
Selection includes N number of thread of first thread from thread pool, while handling corresponding downloading task, and real The respective download progress information of Shi Gengxin.
N number of respective download progress of downloading task is notified to corresponding system development program.
And it is described N number of respective download progress of downloading task is notified to corresponding system development program after, Judge the thread whether finished with execution task in N number of thread;If so, then being chosen under second from the task queue Load task, and the second downloading task described in the thread process finished using execution task.
In the specific implementation process, come present invention utilizes thread pool while handling multiple downloading tasks.
Because being that multiple downloading tasks are downloaded in request, in order to improve execution efficiency and not influence system operation, present invention benefit Thread is managed with thread pool, rather than simply goes to handle all downloading tasks using a single thread.Certainly, even The multiple downloading tasks of thread pool parallel processing are utilized, but each downloading task is a corresponding thread independent process, without Single downloading task can be divided into several parts and be separately sent to different thread pool processing.When some thread process finishes downloading task Later, it just will start and handle other downloading tasks.Certainly, if downloading task is interrupted during the treatment, then the thread After waiting until the time limit more than the downloading task, it just will start and handle other downloading tasks.
In view of the bearing capacity of android system, the thread that thread pool of the invention is opened simultaneously is up to 5, i.e., most 5 downloading tasks can be mostly handled simultaneously.
When multiple downloading tasks request to handle, then multiple threads are opened using thread pool and go to handle simultaneously, and And it is discharged in time after processing is completed.
There are many modes it can be selected that common several modes are as follows during use for thread pool:
NewCachedThreadPool: creation one can caching thread pond, if thread pond length be more than processing need, Idle thread can be flexibly recycled, if creating thread without recyclable.
NewFixedThreadPool: one fixed length thread pool of creation can control thread maximum number of concurrent, the thread exceeded It can wait in the queue.
NewScheduledThreadPool: one fixed length thread pool of creation supports timing and periodic task to execute.
NewSingleThreadExecutor: the thread pool of one single-threaded of creation, it can only use unique active line Journey executes task, guarantees that all tasks are executed according to specified sequence (FIFO, LIFO, priority).
In order to improve the utilization rate of thread and less influence overhead, we have selected the thread pipe with caching function Device newCachedThreadPool is managed, it is 5 that thread maximum number of tasks, which is arranged, in we, in this way when downloading task comes, It at most may be performed simultaneously 5 downloading tasks to work together, and subsequent coming in for task will not open new thread meeting directly Used caching thread before use.Processing can greatly save the resource loss that system constantly opens thread in this way, also drop Low calculating time of the Garbage Collector to useless resource reclaim.
The efficiency that this processing had both improved processing task can reuse the thread of caching because having used caching, So being also unlikely to that system can be caused excessive pressure, to reach a relatively good counterbalance effect.
Certainly, even if multiple threads handle multiple downloading tasks simultaneously, but per thread handles respective downloading task Process be it is identical, the implementation process of the respective downloading task of single thread process is described below.
S2 obtains corresponding download parameters based on first downloading task.
In the specific implementation process, information of each downloading task containing system file, and then downloading task Parameter is mainly as follows:
1, file download address.After file download address (such as url of system file) transmitting is come in, pass through regular expressions Formula tool filters out last character string, using last character string as the store name of file.
2, file name.
3, file size, this is that calculating download progress is facilitated to use for the later period.File size is reading system text The header information of part is obtained.File constituent in usual computer is divided into 2 parts, header information portion and interior Hold part.Header information portion is mainly the size for recording file, coding, the attributes such as creation time, modification time.Content part It is exactly the content information that file is recorded.File size is then obtained by obtaining the header information of file.
S3 judges whether the data volume of the system file is more than pre- based on the download parameters of first downloading task If data-quantity threshold.
As a kind of optional embodiment, the download parameters based on first downloading task judge the system After whether the data volume of file is more than preset data amount threshold value, comprising:
If the data volume of the system file is not above the preset data amount threshold value, institute is chosen from the thread pool In the file for stating the memory that the system file is downloaded to the mobile terminal by first thread, and utilize the interface module Give downloading result notice to the system development program.
S4 chooses First Line if the data volume of the system file is more than the preset data amount threshold value from thread pool Journey is successively downloaded to the system file by batch in the file directory of memory;The every batch of data volume of the system file Less than or equal to the preset data amount threshold value.
As a kind of optional embodiment, system file can first download to memory, be then transferred into the catalogue of memory. In the specific implementation process, the system file is successively downloaded in memory by batch first, while according to respective batch It is transferred in the file directory of memory in real time.
System file is successively downloaded according to batch, is to guarantee that system file, can be quick in breakpoint transmission The part for continuing not download in download system file at the interruption of system file is searched out according to batch, handles simple and convenient, energy Enough improve the efficiency of breakpoint transmission.
Certainly, the present invention can also generate and update the download progress letter of system file while download system file Breath, the download progress information are used to record the download progress of the system file.
In the specific implementation process, if the data volume of the system file is more than the preset data amount threshold value, from line Cheng Chizhong chooses first thread and successively downloads to the system file by batch in the file directory of memory, and real-time update The download progress information of the system file.So calling the download progress when restarting first downloading task The point of interruption is downloaded described in information searching, is continued successively to download in the system file by batch from the downloading point of interruption and not downloaded Part.The advantage of doing so is that the download progress can be called to believe when restarting first downloading task Breath, finds the point of interruption of system file, quickly from the download progress information to continue successively to download the system by batch The part that do not downloaded in system file.
And when carrying progress msg under treatment, the download progress information can be converted to download progress file, and deposit Storage is in the file directory of the memory.File is generated, system development program is can be convenient and is called.
If the data volume of the system file is more than the preset data amount threshold value, reads and be less than preset data amount threshold value System file be written memory, then judge whether system file is more than preset data amount threshold value, if more than if continue to read it is small Memory is written in the system file of preset data amount threshold value, judges again and reprocesses, until in system file all write-in Until depositing.
In the specific implementation process, detailed process design is as shown in Figure 2:
S21 starts download system file, reads the download parameters of system file.
S22, reading the header information of system file, (file header is the information that file itself has, wherein recording Description information of file, such as file size, file creation time, filemodetime etc.).
S23 judges the size of system file based on preset data amount threshold value, it may be assumed that judges whether the size of system file is small In 1M.
In the specific implementation process, if preset data amount threshold value is set as 1M, if system file is less than 1M, It so executes S24: during directly system file all reads into memory, then storing the file whole one-time write in memory In file directory in device (memory that the memory can be the terminal with Android system).
If system file is more than or equal to 1M, because cannot be disposably all text in the case where system file is bigger During part reads into memory, if very likely resulting in memory overflow exception (OOM) in all reading into memory, and then in order to solve OOM Abnormal appearance takes the strategy read in batches, i.e. execution S25 for big file: obtaining the data of 1M every time into memory. Execute S26:, will be in the file directory in the data write-in memory of 1M after there are the data of 1M in memory.S25 is repeated, It is recycled to system file always and reads completion.
In the circulation of previous step, if last time, which goes reading to be possible to data, is less than 1M, when such case, Although data can be less than 1M, the identifier of the end of file can read.This text is known that by end of file identifier Part has finished on.If reading ends file identifier will directly be written to the data read in memory in file It goes, this when, entire file reading process just completed.
Every time after data download write-in file, download progress information can be updated immediately.Download progress information is stored in In file in SD card, after file is written in certain data every time, then the downloading in download progress information can be updated immediately The data of field, so processing be prepare for breakpoint transmission, if download to half because abnormal cause causes to download It has failed, when reopening downloading again, then can go to read download progress information first, be sent out from download progress information Now the system file has downloaded partial data, then only need data content to server demand file latter half after It resumes studies to take and be written in original file, this makes it possible to the realizations for guaranteeing breakpoint transmission function well.It should be noted that It is that a downloading task of the invention is to go to complete by a thread, other threads will not be switched to and go to complete.Download Same system file is that downloading is gone to complete by a thread, even if there is multiple threads, will not be transferred to other lines Journey goes to handle.System file will not be divided into several parts, different threads is transmitted to respectively and goes to download, this be also the present invention and Where the different difference of the prior art.
If the downloading task is not completed since external cause causes to interrupt, then the meeting break-off of this thread, until Exceed schedule time the instruction for being still not received by and continuing downloading, then the thread will start other downloading tasks.Certainly, if It is subsequently received to re-download the system file, then it will continue to download since being continued the part of interruption.
In addition, successively downloaded to the system file by batch due to the present invention after the memory of the mobile terminal, The system file in memory can be transferred in the file directory of memory in real time, therefore it is vacant that memory can be made to be always held at State, even if the case where memory spilling will not occur in the big system file of transmitted data amount.
It, also can real-time update system text while downloading to system file in memory in actual downloading process The download progress of part, and notice is given system development program in real time.Therefore, system file is transferred to the file mesh of memory Step in record, and the step of updating download progress information are not no precedence relationships.The present invention can be shifted first, update afterwards into Information is spent, and progress msg is notified to give system development program.Can also first update progress msg and by progress msg notify to System development program and then transfer system file are into the file directory of memory.
While system file is downloaded by batch, can real-time update system file progress msg, under system file Progress msg is carried, includes but is not limited to be: filename, file download address, file total size, and downloaded the big of file It is small.In addition, the calculation of download progress information can also be expressed as a percentage, and such as: the part downloaded is divided by total The percentage that file size is downloaded notifies this percent data to give system development program by way of interface, this Sample system development program can according to the percentage send continue downloading download instruction, and the present invention can also according to this hundred Divide the part for not downloading completion than continuing download system file.
This programme can store download progress information, example when system file to be stored to the file directory in memory simultaneously Such as, download progress information is first switched into download progress file, be then stored in the SD card catalogue of mobile phone, and then be breakpoint transmission Reference is provided, after restarting the first downloading task, can be called directly and according to the downloading in download progress file Progress msg continues to download, simple and convenient.
S5 searches the downloading point of interruption of the system file, under described when restarting first downloading task The point of interruption is carried to continue successively to download the part that do not download in the system file by batch.
When continuing downloading, treatment process is identical with the processing mode of the download part of system file, no longer superfluous herein It states.
As an alternative embodiment, the present invention gives the system using download progress information described in interface real-time informing System exploitation program, and the form of broadcast is abandoned, it is that can notify system development journey in real time because the timeliness of interface is high Sequence.And if transmitted in the form of broadcast, system language can be distributed processing to broadcast, and when distribution processor process can occupy Between, if distribution processor process will be very slow when system occupancy is very high, timeliness can not be guaranteed.
This programme Interface design provides 3 functions.
OnError (notice extraneous mistake when downloading occurs abnormal).
OnSuccess (is completed when completion by extraneous).
OnProgress (notifies extraneous download information to have update) when download progress updates.
The present invention is by defining this 3 interfaces, when occurring abnormal in program process, adjustable onError Information is informed that exception occurs in system development program by interface, and the data that system development program is returned by interface are just able to know that production It is raw abnormal.
Download progress information can be informed into the downloading of system development program by onSuccess interface after the completion of executing downloading Succeed, the data that system development program is returned by interface are just able to know that entire downloading process completes.
Download progress information can be informed into system development journey by onProgress interface after executing download progress and updating Sequence current schedules, the data that system development program is returned by interface are just able to know that the current progress msg of downloading process.
It will be notified by way of interface under the system development program system file after system file is downloaded successfully It carries successfully, and can will download successful system file and return to system development program together.If system file is because of abnormal conditions When failed download, system development program failed download can be notified this when by way of interface, and will failure original Because notice gives system development program.
It is a kind of system file method for down loading applied to Android system disclosed by the invention above, specific In implementation process, the present invention can support multitask to download, and thread pool can at most open 5 tasks simultaneously, support most 5 Task is downloaded simultaneously.In addition, download progress of the present invention and download state can Real-time Feedback give system development program, in this programme The progress msg of file download status (download, download batch number, failed download, download and successfully etc. is believed downloading percentage Breath) state can be fed back in real time to system development program by way of interface, system development program can be very convenient The specifying information for getting downloading.Further, downloading task of the present invention have priority management, such as used 3 kinds it is excellent First grade, low, common, high priority effectively can carry out rank sequence to downloading task, be capable of preferential answering high priority Task.Further, it by calling the download progress information under file directory stored in memory, just can quickly seek The part for continuing not download in download system file at the interruption of system file is found, processing is simple and convenient, can be improved breakpoint The efficiency resumed.Further, the big file download of the present invention, such as file is subjected to data and the write-in that fragment downloads 1M every time File is not all of and disposably reads memory property write-in file again, so can be effective when downloading big file The generation for avoiding memory overflow problem.
Based on the same inventive concept, the present invention introduces a kind of system file downloading work applied to Android system below Tool.
Referring to Fig. 3, a kind of data download tool in the present invention, comprising:
First obtains module 31, for obtaining what system development program was sent from the task queue with priority ranking The first downloading task for download system file;
Second obtains module 32, for obtaining corresponding download parameters based on first downloading task;
Judgment module 33 judges the data of the system file for the download parameters based on first downloading task Whether amount is more than preset data amount threshold value;
First chooses module 34, if the data volume for the system file is more than the preset data amount threshold value, from line Cheng Chizhong chooses first thread and successively downloads to the system file by batch in the file directory of memory;The system text The every batch of data volume of part is less than or equal to the preset data amount threshold value;
Download module 35 is used for when restarting first downloading task, in the downloading for searching the system file Breakpoint continues successively to download the part that do not download in the system file by batch from the downloading point of interruption.
One or more embodiment through the invention, the invention has the advantages that advantage:
The invention discloses a kind of system file method for down loading applied to Android system, first arrange from priority The first downloading task for download system file that system development program is sent is obtained in the task queue of sequence, is then based on institute It states the first downloading task and obtains corresponding download parameters, and thus judge whether the data volume of the system file is more than present count According to amount threshold value.It indicates that the data volume of system file is excessive if being more than, needs to transmit by batch.Even if there are other in thread pool Thread also only uses first thread and handles the system file, without being downloaded using several threads.In addition, downloading when be by System file is divided into multiple batches less than preset data amount threshold value, and the memory of mobile terminal is then successively downloaded to by batch File directory in, and then when restarting first downloading task, since the present invention is successively downloaded according to batch, So not having to that thread is called to calculate completed task total amount, system file just can be quickly searched out according to batch At interruption, the part that do not download in download system file is then proceeded to, processing is simple and convenient, can be improved the effect of breakpoint transmission Rate.
Further, the present invention also records and the real-time update download progress information of system file, and then program is opened Hair system, which calls directly download progress information, can know the task amount that system file has been downloaded, and then quickly know system At the interruption of file, the part that do not download in download system file is then proceeded to, processing is simple and convenient, can be improved breakpoint transmission Efficiency.
In addition, the present invention gives the download progress information real-time informing to system development program also in a manner of interface, by It is simple in interface method of calling and be one-to-one notice, distribution processor committed memory will not be will do it as broadcast, even if so The very high timeliness that can also guarantee progress notification of system occupancy.
Further, the present invention is successively downloaded to the system file by batch after the memory of the mobile terminal, The system file in memory can be transferred in the file directory of memory in real time, therefore it is vacant that memory can be made to be always held at State, even if the case where memory spilling will not occur in the big system file of transmitted data amount.
Although the preferred embodiment of the application has been described, but one of ordinary skilled in the art once knows substantially Creative concept, then additional changes and modifications may be made to these embodiments.It is wrapped so the following claims are intended to be interpreted as It includes preferred embodiment and falls into all change and modification of the application range.
Obviously, those skilled in the art can carry out various modification and variations without departing from the essence of the application to the application Mind and range.In this way, if these modifications and variations of the application belong to the range of the claim of this application and its equivalent technologies Within, then the application is also intended to include these modifications and variations.

Claims (8)

1. a kind of system file method for down loading applied to Android system characterized by comprising
First for download system file that system development program is sent is obtained from the task queue with priority ranking Downloading task;
Corresponding download parameters are obtained based on first downloading task;
Based on the download parameters of first downloading task, judge whether the data volume of the system file is more than preset data amount Threshold value;
If the data volume of the system file is more than the preset data amount threshold value, first thread is chosen from thread pool will be described System file is successively downloaded to by batch in the file directory of memory, and the download progress letter of system file described in real-time update Breath gives the system development program using download progress information described in interface real-time informing;The every batch of number of the system file It is less than or equal to the preset data amount threshold value according to amount, the download progress information is for recording being downloaded into for the system file Degree;
If the data volume of the system file is not above the preset data amount threshold value, described is chosen from the thread pool One thread downloads to the system file applied to Android system in the file of the memory, and utilizes interface mould Block will download result notice to the system development program;
When restarting first downloading task, the downloading point of interruption of the system file is searched, is interrupted from the downloading Point continues successively to download the part that do not download in the system file by batch.
2. a kind of system file method for down loading applied to Android system as described in claim 1, which is characterized in that institute It states and is chosen in the file directory that the system file is successively downloaded to memory by batch by first thread from thread pool, packet It includes:
The system file is successively downloaded in the memory of mobile terminal by batch, while being transferred in real time according to respective batch In the file directory of the memory.
3. a kind of system file method for down loading applied to Android system as described in claim 1, which is characterized in that
It is described to search the downloading point of interruption of the system file when restarting first downloading task, from the downloading The point of interruption continues successively to download the part that do not download in the system file by batch, comprising:
When restarting first downloading task, calls and download the point of interruption described in the download progress information searching, from institute The downloading point of interruption is stated to continue successively to download the part that do not download in the system file by batch.
4. a kind of system file method for down loading applied to Android system as described in claim 1, which is characterized in that institute It states under obtain the transmission of system development program in the task queue with priority ranking first for download system file Before load task, comprising:
Receive the downloading request for carrying downloading task that the system development program is sent;
Corresponding downloading task is obtained from downloading request;
Corresponding downloading task is requested to be put into the task queue downloading;
The downloading is set to request corresponding downloading task and other downloading tasks in the task queue together according to priority Sequence is ranked up.
5. a kind of system file method for down loading applied to Android system as claimed in claim 4, which is characterized in that institute Stating makes the downloading request corresponding downloading task and other downloading tasks suitable according to priority together in the task queue Sequence is ranked up, comprising:
In the task queue, all downloading tasks are ranked up according to the priority of three grades;
In same grade, it is ranked up according to downloading task of the receiving time to same grade.
6. a kind of system file method for down loading applied to Android system as claimed in claim 4, which is characterized in that institute Stating makes the downloading request corresponding downloading task and other downloading tasks suitable according to priority together in the task queue After sequence is ranked up, comprising:
Obtain from the task queue according to priority include the first downloading task N number of downloading task, wherein 1≤N≤ 5;
Selection includes N number of thread of first thread from thread pool, while handling corresponding downloading task, and in real time more New respective download progress information;
N number of respective download progress of downloading task is notified to the system development program.
7. a kind of system file method for down loading applied to Android system as claimed in claim 6, which is characterized in that institute It states and notifies N number of respective download progress of downloading task to after corresponding system development program, comprising:
Judge the thread whether finished with execution task in N number of thread;
If so, then choose the second downloading task from the task queue, and described in the thread process finished using execution task Second downloading task.
8. a kind of system file download tool applied to Android system characterized by comprising
First obtains module, for obtaining under being used for that system development program is sent from the task queue with priority ranking First downloading task of loading system file;
Second obtains module, for obtaining corresponding download parameters based on first downloading task;
Judgment module, for the download parameters based on first downloading task, judge the system file data volume whether More than preset data amount threshold value;
First chooses module, if the data volume for the system file is more than the preset data amount threshold value, from thread pool It chooses first thread successively to download to the system file by batch in the file directory of memory, and is described in real-time update The download progress information of system file gives the system development program using download progress information described in interface real-time informing;It is described The every batch of data volume of system file is less than or equal to the preset data amount threshold value, and the download progress information is for recording institute State the download progress of system file;If the data volume for being also used to the system file is not above the preset data amount threshold value, The first thread is chosen from the thread pool, and the system file applied to Android system is downloaded into the storage In the file of device, and result notice will be downloaded to the system development program using interface module;
Download module, for searching the downloading point of interruption of the system file when restarting first downloading task, from The downloading point of interruption continues successively to download the part that do not download in the system file by batch.
CN201610831432.6A 2016-09-19 2016-09-19 A kind of system file method for down loading and download tool applied to Android system Expired - Fee Related CN106445665B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610831432.6A CN106445665B (en) 2016-09-19 2016-09-19 A kind of system file method for down loading and download tool applied to Android system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610831432.6A CN106445665B (en) 2016-09-19 2016-09-19 A kind of system file method for down loading and download tool applied to Android system

Publications (2)

Publication Number Publication Date
CN106445665A CN106445665A (en) 2017-02-22
CN106445665B true CN106445665B (en) 2019-11-15

Family

ID=58165771

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610831432.6A Expired - Fee Related CN106445665B (en) 2016-09-19 2016-09-19 A kind of system file method for down loading and download tool applied to Android system

Country Status (1)

Country Link
CN (1) CN106445665B (en)

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107689979B (en) * 2017-04-26 2019-12-13 平安科技(深圳)有限公司 method and equipment for processing download request
CN107426308A (en) * 2017-07-12 2017-12-01 东软集团股份有限公司 Asynchronous network communication means, device, terminal and server
CN109766131B (en) * 2017-11-06 2022-04-01 上海宝信软件股份有限公司 System and method for realizing intelligent automatic software upgrading based on multithreading technology
CN107896284A (en) * 2017-11-30 2018-04-10 北京酷我科技有限公司 A kind of method of mobile terminal download management
CN108012030A (en) * 2017-11-30 2018-05-08 北京酷我科技有限公司 A kind of mobile terminal downloading management method
CN108322527A (en) * 2018-01-23 2018-07-24 平安科技(深圳)有限公司 Data transmission processing method, device, equipment and computer readable storage medium
CN109032775A (en) * 2018-06-29 2018-12-18 武汉斗鱼网络科技有限公司 A kind of method, terminal device and storage medium obtaining Task Progress
CN108965407A (en) * 2018-07-02 2018-12-07 广东飞企互联科技股份有限公司 A kind of processing implementation method of mobile Internet file download
CN110769016A (en) * 2018-07-27 2020-02-07 亿度慧达教育科技(北京)有限公司 File uploading method and computer storage medium
CN109802952B (en) * 2018-12-28 2021-08-20 视联动力信息技术股份有限公司 Monitoring data synchronization method and device
CN110336871A (en) * 2019-07-01 2019-10-15 江苏满运软件科技有限公司 A kind of document handling method, device, storage medium and electronic equipment
CN111262797A (en) * 2020-01-09 2020-06-09 深圳壹账通智能科技有限公司 File downloading method and related product
CN111930696B (en) * 2020-07-22 2023-08-01 建信金融科技有限责任公司 File transmission processing method and system based on small program
CN112600913A (en) * 2020-12-07 2021-04-02 焦点科技股份有限公司 Download management method based on Android
CN113778673B (en) * 2021-08-27 2024-02-09 深圳市广和通无线股份有限公司 Data processing method, storage medium and apparatus
CN115657537B (en) * 2022-10-20 2024-05-03 中国第一汽车股份有限公司 Calibration data management method, device and medium for vehicle and electronic control unit

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102368833A (en) * 2011-11-29 2012-03-07 乐视网信息技术(北京)股份有限公司 Method for carrying out segment download equalization on video information
CN103237049A (en) * 2013-03-18 2013-08-07 北京易华录信息技术股份有限公司 File transfer method and device
CN103312732A (en) * 2012-03-07 2013-09-18 腾讯科技(深圳)有限公司 Method and device for data file transmission
CN104184789A (en) * 2014-02-24 2014-12-03 无锡天脉聚源传媒科技有限公司 File downloading method and device
CN105187564A (en) * 2015-10-14 2015-12-23 中科宇图天下科技有限公司 Method for breakpoint resuming of mobile phone side file

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101383751B (en) * 2008-07-24 2011-06-22 四川长虹电器股份有限公司 Network downloading method
US20140344816A1 (en) * 2013-05-14 2014-11-20 Dennis Nadeau System and method for running php instances

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102368833A (en) * 2011-11-29 2012-03-07 乐视网信息技术(北京)股份有限公司 Method for carrying out segment download equalization on video information
CN103312732A (en) * 2012-03-07 2013-09-18 腾讯科技(深圳)有限公司 Method and device for data file transmission
CN103237049A (en) * 2013-03-18 2013-08-07 北京易华录信息技术股份有限公司 File transfer method and device
CN104184789A (en) * 2014-02-24 2014-12-03 无锡天脉聚源传媒科技有限公司 File downloading method and device
CN105187564A (en) * 2015-10-14 2015-12-23 中科宇图天下科技有限公司 Method for breakpoint resuming of mobile phone side file

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
单线程下载软件NetMolesDownloader2.4;keyatutu;《软件天地》;20020828(第35期);全文 *
基于单线程的文件复制断点续传的设计与实现;程哲等;《科技创业月刊》;20101210(第12期);全文 *

Also Published As

Publication number Publication date
CN106445665A (en) 2017-02-22

Similar Documents

Publication Publication Date Title
CN106445665B (en) A kind of system file method for down loading and download tool applied to Android system
CN106657213B (en) File transmission method and device
CN110221901A (en) Container asset creation method, apparatus, equipment and computer readable storage medium
CN102096603B (en) Task decomposition control method in MapReduce system and scheduling node equipment
CN107689976B (en) File transmission method and device
WO2005069155A2 (en) Method and apparatus for task schedulin in a multi-processor system based on memory requirements
JP2003316591A (en) Communication equipment, communication system, plug-in module control method, program to be executed by computer and computer readable recording medium with the same program
CN103345664A (en) Method and system for adaptation between workflow and task scheduling
RU2008117381A (en) RELEASING A PORTABLE COMMUNICATION DEVICE USING MULTIMEDIA DATA FILES
EP4123449A1 (en) Resource scheduling method and related device
CN108519987A (en) A kind of data persistence method and apparatus
CN113986791A (en) Intelligent network card rapid DMA design method, system, equipment and terminal
WO2024113996A1 (en) Optimization method and apparatus for host io processing, device, and nonvolatile readable storage medium
WO2024156239A1 (en) Video streaming transmission method and apparatus, electronic device, and storage medium
CN109327321A (en) Network model business executes method, apparatus, SDN controller and readable storage medium storing program for executing
CN116760821A (en) Distributed file downloading method, system, electronic equipment and storage medium
CN110069217A (en) A kind of date storage method and device
CN110971962B (en) Slice caching method and device and storage medium
CN111414339B (en) File processing method, system, device, equipment and medium
CN112395337A (en) Data export method and device
US8832176B1 (en) Method and system for processing a large collection of documents
CN103428231B (en) Offline download method and system
US20050183085A1 (en) Method of and apparatus for managing task, and computer product
CN114675954A (en) Task scheduling method and device
CN112600913A (en) Download management method based on Android

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20191115