CN106445665A - Method and tool for system file downloading applied to android system - Google Patents

Method and tool for system file downloading applied to android system Download PDF

Info

Publication number
CN106445665A
CN106445665A CN201610831432.6A CN201610831432A CN106445665A CN 106445665 A CN106445665 A CN 106445665A CN 201610831432 A CN201610831432 A CN 201610831432A CN 106445665 A CN106445665 A CN 106445665A
Authority
CN
China
Prior art keywords
download
system file
file
downloading task
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.)
Granted
Application number
CN201610831432.6A
Other languages
Chinese (zh)
Other versions
CN106445665B (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
Active 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]

Abstract

The invention discloses a method and tool for system file downloading applied to an android system. First a first download task sent by a system development program and used for downloading a system file is obtained from a task queue having priority orders, a corresponding download parameter is obtained based on the first download task, and accordingly it is determined whether the data size of the system file exceeds a preset data size threshold; if the data size of the system file exceeds the preset data size threshold, it is indicated that the data size of the system file is too large, a first thread is selected from a thread pool to perform downloading by batch, and a plurality of threads are not utilized to perform downloading. Since during downloading, the system file is divided into a plurality of batches smaller than the preset data size threshold and then the system file is sequentially downloaded to a file catalog of a memory by batch, when the first download task is restarted, the threads do not need to be called to calculate the overall task load having been finished, and the interrupt position of the system file can be quickly searched by batch to continue the downloading.

Description

A kind of system file method for down loading being applied to Android system and download tool
Technical field
The application is related to the communications field, more particularly, to a kind of system file method for down loading being applied to Android system and Download tool.
Background technology
In the development process of Android, download part is a very conventional function.
The mode of current download file, typically by the way of multi-threading parallel process multiple tasks.And it is directed to single Downloading task, then be that single downloading task (file or a compressed package) is divided into several parts, each part Being uploaded using a thread or downloaded, if encountering network failure, can start to continue to download from the part downloaded Undone part, starts anew to download without necessity.
But the mode of this downloading task at present, resumes downloading task if necessary, then need first to gather and be related to The task amount of download on each thread of this downloading task, then the task total amount of comprehensive statistics acquisition download, obtains Part through downloading, then proceedes to start to download.This processing mode needs to call each thread being related to be counted, place Reason process is complicated, and needs calculated in advance total amount of going out on missions can continue to download, if having thread processing other tasks, May need to turn thread process etc., and then lead to the inefficiency of file download during breakpoint transmission.
Content of the invention
Invention provides a kind of system file method for down loading being applied to Android system and download tool, solve Or part solves file download efficiency low technical problem when the prior art point of interruption resumes.
For solving above-mentioned technical problem, the invention provides a kind of system file download side being applied to Android system Method, including:
Obtain that system development program sends from the task queue with prioritization for download system file First downloading task;
Corresponding download parameters are obtained based on described first downloading task;
Based on the download parameters of described first downloading task, judge whether the data volume of described system file exceedes present count According to amount threshold value;
If the data volume of described system file exceedes described preset data amount threshold value, choosing first thread from thread pool will Described system file is downloaded in the file directory of memory successively by batch;Every lot data amount of described system file is less than Or it is equal to described preset data amount threshold value;
When restarting described first downloading task, search the download point of interruption of described system file, from described download The point of interruption continues to download, by batch, the part do not downloaded in described system file successively.
Preferably, described system file is downloaded to memory by batch by described first thread of choosing from thread pool successively File directory in, including:
Described system file is downloaded in the internal memory of described mobile terminal by batch successively, simultaneously real according to respective batch When transfer in the file directory of described memory.
Preferably, if the data volume of described system file exceedes described preset data amount threshold value, select from thread pool First thread is taken to download in the file directory of memory described system file successively by batch, including:
If the data volume of described system file exceedes described preset data amount threshold value, choosing first thread from thread pool will Described system file is downloaded in the file directory of memory successively by batch, and being downloaded into of system file described in real-time update Degree information, described download progress information is used for recording the download progress of described system file;
Described when restarting described first downloading task, search described system file the download point of interruption, from described Download the point of interruption to continue to download, by batch, the part do not downloaded in described system file successively, including:
When restarting described first downloading task, call the download point of interruption described in described download progress information searching, Continue to download, by batch, the part do not downloaded described system file successively from the described download point of interruption.
Preferably, if the data volume of described system file exceedes described preset data amount threshold value, select from thread pool First thread is taken to download in the file directory of memory described system file successively by batch, and system described in real-time update The download progress information of file, described download progress information is used for recording the download progress of described system file, including:
Give described system development program using download progress information described in interface real-time informing.
Preferably, the described download parameters based on described first downloading task, judge that the data volume of described system file is No exceed preset data amount threshold value after, including:
If the data volume of described system file is not above described preset data amount threshold value, choose institute from described thread pool State first thread to download to the described system file being applied to Android system in the file of described memory, and utilize institute State interface module and will download result and notify to described system development program.
Preferably, described from the task queue with prioritization obtain system development program send for downloading Before first downloading task of system file, including:
Receive the download request carrying downloading task that described system development program sends;
Corresponding downloading task is obtained from described download request;
Corresponding for described download request downloading task is put in described task queue;
Make the corresponding downloading task of described download request and other downloading task in the lump according to excellent in described task queue First level order is ranked up.
Preferably, described the corresponding downloading task of described download request and other downloading task are made in described task queue It is ranked up according to priority orders in the lump, including:
In described task queue, the priority according to Three Estate is ranked up to all of downloading task;
In same grade, according to the reception time, the downloading task of same grade is ranked up.
Preferably, described the corresponding downloading task of described download request and other downloading task are made in described task queue After being ranked up according to priority orders in the lump, including:
Obtain according to priority from described task queue and include N number of downloading task of the first downloading task, wherein 1≤ N≤5;
Choose, from thread pool, the N number of thread including first thread, process each self-corresponding downloading task simultaneously, and real Shi Gengxin respective download progress information;
Respective for described N number of downloading task download progress is notified to described system development program.
Preferably, described by respective for described N number of downloading task download progress notify to corresponding system development program it Afterwards, including:
Judge, in described N number of thread, whether there is the thread that execution task finishes;
If having, choose the second downloading task, and the thread process finishing using execution task from described task queue Described second downloading task.
The invention discloses a kind of system file download tool being applied to Android system, including:
First acquisition module, for obtaining the use that system development program sends from the task queue have prioritization The first downloading task in download system file;
Second acquisition module, for obtaining corresponding download parameters based on described first downloading task;
Judge module, for the download parameters based on described first downloading task, judges the data volume of described system file Whether exceed preset data amount threshold value;
First selection module, if the data volume for described system file exceedes described preset data amount threshold value, from thread Choose first thread in pond to download in the file directory of memory described system file successively by batch;Described system file Every lot data amount be less than or equal to described preset data amount threshold value;
Download module, the download for when restarting described first downloading task, searching described system file is interrupted Point, continues to download, by batch, the part do not downloaded described system file successively from the described download point of interruption.
By one or more technical scheme of the present invention, the invention has the advantages that or advantage:
The invention discloses a kind of system file method for down loading being applied to Android system, first from having priority row Obtain, in the task queue of sequence, the first downloading task for download system file that system development program sends, be then based on institute State the first downloading task and obtain corresponding download parameters, and thus judge whether the data volume of described system file exceedes present count According to amount threshold value.If exceeding, representing that the data volume of system file is excessive, needing to transmit by batch.Even if there are other in thread pool Thread, also only processes this system file using first thread, without being downloaded using several threads.In addition, download when be by System file is divided into the multiple batches less than preset data amount threshold value, then downloads to the memory of mobile terminal successively by batch File directory in, and then when restarting described first downloading task, because the present invention is to download successively according to batch, So without calling thread to calculate completed task total amount, just can quickly search out system file according to batch At interruption, then proceed to the part do not downloaded in download system file, process simple and convenient, it is possible to increase 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 The system of sending out directly invokes the task amount that download progress information just can know system file download, and then quickly knows system At the interruption of file, then proceed to the part do not downloaded in download system file, process simple and convenient, it is possible to increase breakpoint transmission Efficiency.
In addition, the present invention also in the way of interface by described download progress information real-time informing to system development program, by Simply and it is man-to-man notice in interface interchange mode, can will not be distributed processing committed memory as broadcast, even if so System occupancy is very high also to ensure that the ageing of progress notification.
Further, after described system file is downloaded to the internal memory of described mobile terminal by batch by the present invention successively, Can in real time the system file in internal memory be transferred in the file directory of memory, vacant therefore, it is possible to make internal memory be always held at State, even if the big system file of transmitted data amount is also not in the situation that internal memory overflows.
Brief description
Fig. 1 is the flow chart of the system file method for down loading being applied to 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 representation of the system file download tool being applied to Android system in the embodiment of the present invention.
Specific embodiment
In order that the application the technical staff in the technical field is more clearly understood that the application, below in conjunction with the accompanying drawings, By specific embodiment, technical scheme is described in detail.
OOM:Internal memory overflow (out of memory) popular understanding be exactly Out of Memory, generally run large software or During game, the internal memory required for software or game, far beyond the born size of internal memory installed in your main frame, is just internal memory Overflow.
Breakpoint transmission:To download or upload task (file or a compressed package) man-made division is several parts, Each part uploaded using a thread or downloaded, if encountering network failure, from having uploaded or can download Part starts to continue to upload to download the part not completed, and starts anew to upload without necessity and downloads.
Thread pool:Thread pool is a kind of multiple threads form, in processing procedure, task is added to queue, then in wound Build these tasks of automatic after thread.Thread pool threads are all background thread.Each thread using acquiescence storehouse size, Run with the priority of acquiescence, and be in multiple thread units.
Url:URL is one kind of position to the resource that can obtain from internet and access method Succinct expression, is the address of standard resource on internet.Each file on internet has a unique URL, and it wraps The information containing points out how the position of file and browser should process 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 certain pattern (regular) a bit.
The present invention devises a kind of system file method for down loading being applied to Android system and download tool, mainly Download original system file for system (or software) developer, mainly comprise used during development system program in system file System data.The method for down loading of the present invention and download tool are mainly used in being mounted with the mobile terminal of android system, and It is not used in the equipment being mounted with windows system.In this download tool embeddable system exploitation program, need in system development program When wanting download system file, this download tool can be directly invoked and be downloaded.This download providing with common application program Method is distinguishing.Specifically, common application program such as ' XX thunder ', faced by be domestic consumer.Under ' XX thunder ' Load mode is by accessing URL address download pictures, document, video etc. data.And the present invention provide be applied to android Faced by the system file method for down loading of system (Android system) and download tool is that system (or software) developer is opening Original system file is downloaded during the program of sending out.
Refer to Fig. 1 below, be the implementation process of the system file method for down loading that the present invention is applied to Android system Figure.
S1, from the task queue with prioritization obtain system development program send for download system file The first downloading task.
In specific implementation process, the present invention devises task queue and stores all downloading task, and under all Load task carries out prioritization management.
In specific implementation process, the present invention has pre-defined priority level to downloading task first, and this is excellent First level grade inform to system development program (namely:Android (Android) system development program), and then make system development program After generating downloading task, the demarcation of priority can be carried out to downloading task.The present invention to the demarcation of priority can be Custom tags.For example, define the priority of 3 grades:Low priority low, normal priority normal, high priority high.
System development program, when sending download request, can carry out priority mark to the downloading task carrying in download request Fixed, such as low priority low, normal priority normal, high priority high.Specify downloading task in system development program Afterwards, can 3 flag bits according to the definition of the present invention, downloading task is carried out with the demarcation of priority, and then the present invention is at place During reason downloading task, can be processed in order according to the priority demarcated.If do not transmit any priority be defaulted as general Logical priority.
In specific implementation process, obtain what system development program sent from the task queue with prioritization Before the first downloading task of download system file, the present embodiment includes:
Receive the download request carrying downloading task that described system development program sends;
Corresponding downloading task is obtained from described download request;
Corresponding for described download request downloading task is put in described task queue;
Make the corresponding downloading task of described download request and other downloading task in the lump according to excellent in described task queue First level order is ranked up.
And in specific sequencer procedure, in described task queue, according to Three Estate priority under all of Load task is ranked up;In same grade, according to the reception time, the downloading task of same grade is ranked up.
In specific implementation process, after receiving downloading task, task can be put in download queue first, The priority of downloading task is resequenced, the downloading task of high priority is emitted on queue leading portion priority treatment.Will The downloading task of low priority is emitted on queue tail end and finally processes.Queueing discipline is as follows:
1st, the downloading task of high priority is arranged in the leading portion of queue, inside the downloading task to all high priorities Queueing discipline be:Order according to the reception time of the downloading task receiving high priority to arrange.
2nd, the downloading task of normal priority is arranged in after high priority, in the downloading task to all normal priorities The queueing discipline in portion is:Order according to the reception time of the downloading task receiving normal priority to arrange.
3rd, the downloading task of low priority is arranged in after normal priority, inside the downloading task to all low priorities Queueing discipline be:Order according to the reception time of the downloading task receiving low priority to arrange.
As a kind of optional embodiment, when carrying task under treatment, the present invention is applied to the system literary composition of Android system Part download tool can carry out multitasking simultaneously, is specifically introduced below.
Obtain according to priority from described task queue and include N number of downloading task of the first downloading task, wherein 1≤ N≤5.
Choose, from thread pool, the N number of thread including first thread, process each self-corresponding downloading task simultaneously, and real Shi Gengxin respective download progress information.
Respective for described N number of downloading task download progress is notified to corresponding system development program.
And described respective for described N number of downloading task download progress is notified to corresponding system development program after, Judge, in described N number of thread, whether there is the thread that execution task finishes;If having, choose under second from described task queue Load task, and the second downloading task described in thread process being finished using execution task.
In specific implementation process, present invention utilizes thread pool to process multiple downloading task simultaneously.
Because being that multiple downloading task are downloaded in request, in order to improve execution efficiency and not affect system operation, present invention profit Manage thread with thread pool, rather than simply go to process all of downloading task using a single thread.Certainly, even Make use of the multiple downloading task of thread pool parallel processing, but each downloading task is a corresponding thread independent process, and not Single downloading task can be divided into several parts and be separately sent to different thread pools process.When certain thread process finishes downloading task Afterwards, other downloading task of process can just be started.Certainly, if downloading task is interrupted during processing, then this thread is then After the time limit exceeding this downloading task being waited until, just can start other downloading task of process.
In view of the bearing capacity of android system, the thread that the thread pool of the present invention is opened simultaneously is up to 5, that is, How 5 downloading task can be processed simultaneously.
When the request of multiple downloading task is processed, then can be utilized thread pool to open multiple threads and go to process simultaneously, and And discharged in time after processing is completed.
Thread pool has various modes can select during using, and common several modes are as follows:
newCachedThreadPool:Create one can caching thread pond, if thread pond length exceed process needs, Flexibly idle thread can be reclaimed, if no recyclable, newly-built thread.
newFixedThreadPool:Create a fixed length thread pool, controllable thread maximum number of concurrent, the thread exceeding Can wait in queue.
newScheduledThreadPool:Create a fixed length thread pool, support timing and periodic task execution.
newSingleThreadExecutor:Create the thread pool of a single-threaded, it only can use unique active line Journey come to execute task it is ensured that all tasks according to specified order (FIFO, LIFO, priority) execute.
In order to improve the utilization rate of thread and less affect overhead, we have selected the thread pipe with caching function Reason device newCachedThreadPool, we arrange thread maximum number of tasks and are 5, so when downloading task comes, 5 downloading task at most can be executed work together simultaneously, and subsequently coming in of task will not open new thread meeting directly Using used caching thread before.So process and can greatly save the resource loss that system constantly opens thread, also drop The low calculating time to useless resource reclaim for the Garbage Collector.
This process had both improve the efficiency of process task, because employing caching, can reuse the thread of caching, So being also unlikely to cause excessive pressure to system, thus having reached a reasonable counterbalance effect.
Certainly, even if multiple thread processes multiple downloading task simultaneously, but the respective downloading task of each thread process Process be identical, the implementation process of single thread process respective downloading task is described below.
S2, obtains corresponding download parameters based on described first downloading task.
In specific implementation process, the information containing system file for each downloading task, and then downloading task Parameter is mainly as follows:
1st, file download address.After file download address (url of such as system file) transmission is come in, by regular expressions Formula instrument filters out last character string, using last character string as file store name.
2nd, file name.
3rd, file size, this is to calculate download progress in order to the later stage is convenient to use.File size is reading system literary composition The header information of part is being obtained.The generally file constituent in computer is divided into 2 parts, header information portion and interior Hold part.Header information portion is mainly the size of log file, coding, the attribute 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, based on the download parameters of described first downloading task, judges whether the data volume of described system file exceedes pre- If data-quantity threshold.
As a kind of optional embodiment, the described download parameters based on described first downloading task, judge described system After whether the data volume of file exceedes preset data amount threshold value, including:
If the data volume of described system file is not above described preset data amount threshold value, choose institute from described thread pool State in the file of memory that described system file is downloaded to described mobile terminal by first thread, and utilize described interface module Result will be downloaded notify to described system development program.
S4, if the data volume of described system file exceedes described preset data amount threshold value, chooses First Line from thread pool Described system file is downloaded to successively in the file directory of memory by journey by batch;Every lot data amount of described system file Less than or equal to described preset data amount threshold value.
As a kind of optional embodiment, system file can first download to internal memory, be then transferred in the catalogue of memory. In specific implementation process, first described system file is downloaded in internal memory successively by batch, simultaneously according to respective batch Transfer in real time in the file directory of memory.
System file is downloaded successively according to batch, is to ensure that system file, can be quick in breakpoint transmission Search out the part continuing at the interruption of system file not downloading in download system file according to batch, process simple and convenient, energy Enough improve the efficiency of breakpoint transmission.
Certainly, the present invention while download system file, can also generate and update the download progress letter of system file Breath, described download progress information is used for recording the download progress of described system file.
In specific implementation process, if the data volume of described system file exceedes described preset data amount threshold value, from line Cheng Chizhong chooses first thread and downloads in the file directory of memory described system file by batch successively, and real-time update The download progress information of described system file.So when restarting described first downloading task, calling described download progress Download the point of interruption described in information searching, continue to download successively described system file by batch not downloading from the described download point of interruption Part.Advantage of this is that, described download progress letter when restarting described first downloading task, can called Breath, quickly finds the point of interruption of system file from described download progress information, to continue to download described system successively by batch The part do not downloaded in system file.
And when carrying progress msg under treatment, described download progress information can be converted to download progress file, and deposit Storage is in the file directory of described memory.Generated file, system development program can be facilitated to call.
If the data volume of described system file exceedes described preset data amount threshold value, read and be less than preset data amount threshold value System file write internal memory, then judge whether system file exceedes preset data amount threshold value, if exceeding, continue reading little System file in preset data amount threshold value writes internal memory, judges again and repeat to process, in system file all write Till depositing.
In specific implementation process, idiographic flow design is as shown in Figure 2:
S21, starts download system file, reads the download parameters of system file.
S22, (file header is the information that file has in itself to the header information of reading system file, wherein records The description information of file, such as file size, file creation time, filemodetime etc.).
S23, based on the size of preset data amount threshold decision system file, that is,:Judge whether the size of system file is little In 1M.
In specific implementation process, if preset data amount threshold value is set to 1M, then if system file less than 1M, So execute S24:In directly system file all reading into memory, then whole for the file in internal memory one-time writes are stored In file directory in device (this memory can be the memory of the terminal with Android system).
If system file is more than or equal to 1M, because can not be disposably all literary composition than in the case of larger in system file During part reads into memory, if very likely resulting in internal memory overflow exception (OOM) in all reading into memory, and then in order to solve OOM Abnormal appearance, takes, for big file, the strategy in batches reading, that is, execute S25:The data obtaining 1M every time is entered in internal memory. Execution S26:After having the data of 1M in internal memory, the data of 1M is write in the file directory in memory.Repeat S25, It is recycled to system file reading always to complete.
In the circulation of previous step, if going reading to be possible to data be for the last time less than 1M, when this situation, Although data can be less than 1M, the identifier of the end of file can be read.It is known that this literary composition by end of file indications Part has finished on.If reading ends file indications will directly the data reading in internal memory be written in file Go, this when, whole file reading process just completed.
Every time after data downloads write file, download progress information can be updated immediately.Download progress information is stored in In file in SD card, every time certain data is write after file, then can update the download in download progress information immediately The data of field, so processes and prepares for breakpoint transmission, if downloading to half because abnormal cause leads to download Have failed, when reopening download again, then can go first to read download progress information, send out from download progress information Now this system file has downloaded partial data, then only need to continue to the data content of server request file latter half Resume studies to take and be written in original file, this makes it possible to ensure the realization of breakpoint transmission function well.Should be noted It is that a downloading task of the present invention goes to complete by a thread, will not be switched to other threads and go to complete.Download Same system file, goes to download by a thread and completes, even if there being multiple threads, also will not be transferred to other lines Journey goes to process.Also system file will not be divided into several parts, pass to respectively different threads go download, this be also the present invention and The different difference of prior art is located.
If this downloading task leads to interrupt not completing due to external cause, then the meeting break-off of this thread, until Exceed schedule time the instruction being still not received by continuing to download, then this thread can start other downloading task.Certainly, if Subsequently received re-download this system file, then may proceed to continue to start to download from the part interrupted.
Further, since after described system file is downloaded to the internal memory of described mobile terminal by batch by the present invention successively, Can in real time the system file in internal memory be transferred in the file directory of memory, vacant therefore, it is possible to make internal memory be always held at State, even if the big system file of transmitted data amount is also not in the situation that internal memory overflows.
In actual downloading process, while system file is downloaded in internal memory, also can real-time update system literary composition The download progress of part, and notify in real time to system development program.Therefore, system file is transferred to the file mesh of memory Step in record, and update download progress information step there is no precedence relationship.The present invention can first shift, update afterwards into Degree information, and progress msg is notified to system development program.Can also first update progress msg and by progress msg notify to After system development program, retransfer system file in the file directory of memory.
While system file is pressed batch download, the progress msg of meeting real-time update system file, under system file Carry progress msg, be including but not limited to:Filename, file download address, file total size, and downloaded the big of file Little.In addition, the calculation of download progress information can also be expressed as a percentage, such as:The part downloaded is divided by total File size obtains the percentage downloaded, and this percent data is notified to system development program by the form of interface, this Sample system development program just can according to this percentage send continue download download instruction, and the present invention can also according to this hundred Divide and do not download, than continuation download system file, the part completing.
This programme, when system file is stored in the file directory of memory, can store download progress information, example simultaneously As first download progress information switched to download progress file, then leaving in the SD card catalogue of mobile phone, and then be breakpoint transmission Provide reference, after restarting the first downloading task, can directly invoke and according to the download in download progress file Progress msg continues to download, simple and convenient.
S5, when restarting described first downloading task, searches the download point of interruption of described system file, from described Carry the point of interruption to continue to download, by batch, the part do not downloaded in described system file successively.
When continuing to download, processing procedure is identical with the processing mode of the download part of system file, no longer superfluous herein State.
As a kind of optional embodiment, the present invention utilizes download progress information described in interface real-time informing to described system System exploitation program, and abandon the form of broadcast, it is because the ageing height of interface, system development journey can be notified in real time Sequence.And if transmitted in the form of broadcasting, system language can be distributed to broadcast processing, and when distribution processor process can take Between, if when system occupancy is very high distribution processor process will very slow it is impossible to ensure to ageing.
This programme Interface design provides 3 functions.
OnError (downloads and notifies extraneous mistake when abnormal).
OnSuccess (is completed by the external world when completing).
OnProgress (notifies extraneous download information to have renewal) when download progress updates.
The present invention by defining this 3 interfaces, when abnormal occurring in program process, adjustable onError It is abnormal that information is informed that system development program occurs by interface, and the data that system development program is returned by interface is just able to know that product Raw abnormal.
Download progress information can be informed by system development download program by onSuccess interface after the completion of execution is downloaded Success, the data that system development program is returned by interface is just able to know that whole downloading process completes.
Download progress information can be informed by system development journey by onProgress interface after execution download progress updates Sequence current schedules, the data that system development program is returned by interface is just able to know that the current progress msg of downloading process.
Will be notified under this system file of system development program by the form of interface after system file downloads success Carry successfully, and system development program can be returned in the lump by downloading successful system file.If system file is because abnormal conditions When failed download, this when can notify system development download program have failed by the form of interface, and will be unsuccessfully former Because notifying to system development program.
It is more than a kind of system file method for down loading being applied to Android system disclosed by the invention, specific In implementation process, the present invention can support that multitask is downloaded, and thread pool can at most open 5 tasks simultaneously, supports most 5 Task is downloaded simultaneously.In addition, download progress of the present invention and download state can Real-time Feedback to system development program, in this programme The progress msg of file download status (download, download percentage, download batch number of times, failed download, download and successfully etc. believe Breath) state can be fed back in real time by system development program by the form of interface, system development program can be very convenient The specifying information getting download.Further, downloading task of the present invention has priority management, for example employ 3 kinds excellent First level, low, common, high priority, effectively rank sequence can be carried out to downloading task, be capable of preferential answering high priority Task.Further, by calling the download progress information under storage file directory in memory, just can quickly seek Find the part continuing at the interruption of system file not downloading in download system file, process simple and convenient, it is possible to increase breakpoint The efficiency resuming.Further, the big file download of the present invention, for example, carry out burst by file and download the data of 1M every time and write File, is not all of disposably reading internal memory property write file again, it is possible to effective when downloading big file The generation avoiding internal memory overflow problem.
Based on same inventive concept, below the present invention introduce a kind of system file being applied to Android system and download work Tool.
Referring to Fig. 3, a kind of data download tool in the present invention, including:
First acquisition module 31, for obtaining what system development program sent from the task queue have prioritization The first downloading task for download system file;
Second acquisition module 32, for obtaining corresponding download parameters based on described first downloading task;
Judge module 33, for the download parameters based on described first downloading task, judges the data of described system file Whether amount exceedes preset data amount threshold value;
First selection module 34, if the data volume for described system file exceedes described preset data amount threshold value, from line Cheng Chizhong chooses first thread and downloads in the file directory of memory described system file by batch successively;Described system literary composition Every lot data amount of part is less than or equal to described preset data amount threshold value;
Download module 35, for when restarting described first downloading task, searching in the download of described system file Breakpoint, continues to download, by batch, the part do not downloaded described system file successively from the described download point of interruption.
By one or more embodiment of the present invention, the invention has the advantages that or advantage:
The invention discloses a kind of system file method for down loading being applied to Android system, first from having priority row Obtain, in the task queue of sequence, the first downloading task for download system file that system development program sends, be then based on institute State the first downloading task and obtain corresponding download parameters, and thus judge whether the data volume of described system file exceedes present count According to amount threshold value.If exceeding, representing that the data volume of system file is excessive, needing to transmit by batch.Even if there are other in thread pool Thread, also only processes this system file using first thread, without being downloaded using several threads.In addition, download when be by System file is divided into the multiple batches less than preset data amount threshold value, then downloads to the memory of mobile terminal successively by batch File directory in, and then when restarting described first downloading task, because the present invention is to download successively according to batch, So without calling thread to calculate completed task total amount, just can quickly search out system file according to batch At interruption, then proceed to the part do not downloaded in download system file, process simple and convenient, it is possible to increase 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 The system of sending out directly invokes the task amount that download progress information just can know system file download, and then quickly knows system At the interruption of file, then proceed to the part do not downloaded in download system file, process simple and convenient, it is possible to increase breakpoint transmission Efficiency.
In addition, the present invention also in the way of interface by described download progress information real-time informing to system development program, by Simply and it is man-to-man notice in interface interchange mode, can will not be distributed processing committed memory as broadcast, even if so System occupancy is very high also to ensure that the ageing of progress notification.
Further, after described system file is downloaded to the internal memory of described mobile terminal by batch by the present invention successively, Can in real time the system file in internal memory be transferred in the file directory of memory, vacant therefore, it is possible to make internal memory be always held at State, even if the big system file of transmitted data amount is also not in the situation that internal memory overflows.
Although having been described for the preferred embodiment of the application, one of ordinary skilled in the art once knows substantially Creative concept, then can make other change and modification to these embodiments.So, claims are intended to be construed to wrap Include preferred embodiment and fall into being had altered and changing of the application scope.
Obviously, those skilled in the art can carry out the various changes and modification essence without deviating from the application to the application God and scope.So, if these modifications of the application and modification belong to the scope of the application claim and its equivalent technologies Within, then the application is also intended to comprise these changes and modification.

Claims (10)

1. a kind of system file method for down loading being applied to Android system is it is characterised in that include:
Obtain that system development program sends from the task queue with prioritization for the first of download system file Downloading task;
Corresponding download parameters are obtained based on described first downloading task;
Based on the download parameters of described first downloading task, judge whether the data volume of described system file exceedes preset data amount Threshold value;
If the data volume of described system file exceedes described preset data amount threshold value, choosing first thread from thread pool will be described System file is downloaded in the file directory of memory successively by batch;Every lot data amount of described system file is less than or waits In described preset data amount threshold value;
When restarting described first downloading task, search the download point of interruption of described system file, interrupt from described download Point continues to download, by batch, the part do not downloaded in described system file successively.
2. as claimed in claim 1 a kind of system file method for down loading being applied to Android system it is characterised in that institute State selection first thread from thread pool to download in the file directory of memory described system file successively by batch, bag Include:
Described system file is downloaded in the internal memory of described mobile terminal successively by batch, turns in real time according to respective batch simultaneously Move on in the file directory of described memory.
3. as claimed in claim 1 a kind of system file method for down loading being applied to Android system it is characterised in that
If the data volume of described system file exceedes described preset data amount threshold value, choosing first thread from thread pool will Described system file is downloaded in the file directory of memory successively by batch, including:
If the data volume of described system file exceedes described preset data amount threshold value, choosing first thread from thread pool will be described System file is downloaded in the file directory of memory successively by batch, and the download progress letter of system file described in real-time update Breath, described download progress information is used for recording the download progress of described system file;
Described when restarting described first downloading task, search described system file the download point of interruption, from described download The point of interruption continues to download, by batch, the part do not downloaded in described system file successively, including:
When restarting described first downloading task, call the download point of interruption described in described download progress information searching, from institute State the download point of interruption to continue to download, by batch, the part do not downloaded in described system file successively.
4. as claimed in claim 3 a kind of system file method for down loading being applied to Android system it is characterised in that institute If the data volume stating described system file exceedes described preset data amount threshold value, choose first thread from thread pool by described system System file is downloaded in the file directory of memory successively by batch, and the download progress letter of system file described in real-time update Breath, described download progress information is used for recording the download progress of described system file, including:
Give described system development program using download progress information described in interface real-time informing.
5. as claimed in claim 1 a kind of system file method for down loading being applied to Android system it is characterised in that institute State the download parameters based on described first downloading task, judge whether the data volume of described system file exceedes preset data amount threshold After value, including:
If the data volume of described system file is not above described preset data amount threshold value, choose described from described thread pool One thread downloads to the described system file being applied to Android system in the file of described memory, and is connect using described Mouth module will be downloaded result and notify to described system development program.
6. as claimed in claim 1 a kind of system file method for down loading being applied to Android system it is characterised in that institute State under for download system file first of acquisition system development program transmission from the task queue with prioritization Before load task, including:
Receive the download request carrying downloading task that described system development program sends;
Corresponding downloading task is obtained from described download request;
Corresponding for described download request downloading task is put in described task queue;
Make the corresponding downloading task of described download request and other downloading task in the lump according to priority in described task queue Order is ranked up.
7. as claimed in claim 6 a kind of system file method for down loading being applied to Android system it is characterised in that institute State and make the corresponding downloading task of described download request and other downloading task suitable according to priority in the lump in described task queue Sequence is ranked up, including:
In described task queue, the priority according to Three Estate is ranked up to all of downloading task;
In same grade, according to the reception time, the downloading task of same grade is ranked up.
8. as claimed in claim 6 a kind of system file method for down loading being applied to Android system it is characterised in that institute State and make the corresponding downloading task of described download request and other downloading task suitable according to priority in the lump in described task queue After sequence is ranked up, including:
Obtain according to priority from described task queue and include N number of downloading task of the first downloading task, wherein 1≤N≤ 5;
Choose, from thread pool, the N number of thread including first thread, process each self-corresponding downloading task simultaneously, and in real time more Newly respective download progress information;
Respective for described N number of downloading task download progress is notified to described system development program.
9. as claimed in claim 8 a kind of system file method for down loading being applied to Android system it is characterised in that institute State after notifying respective for described N number of downloading task download progress to corresponding system development program, including:
Judge, in described N number of thread, whether there is the thread that execution task finishes;
If having, choose the second downloading task from described task queue, and described in the thread process being finished using execution task Second downloading task.
10. a kind of system file download tool being applied to Android system is it is characterised in that include:
First acquisition module, for obtaining under being used for that system development program sends from the task queue have prioritization First downloading task of loading system file;
Second acquisition module, for obtaining corresponding download parameters based on described first downloading task;
Whether judge module, for the download parameters based on described first downloading task, judge the data volume of described system file Exceed preset data amount threshold value;
First selection module, if the data volume for described system file exceedes described preset data amount threshold value, from thread pool Choose first thread to download in the file directory of memory described system file successively by batch;Described system file every Lot data amount is less than or equal to described preset data amount threshold value;
Download module, for when restarting described first downloading task, searching the download point of interruption of described system file, from The described download point of interruption continues to download, by batch, the part do not downloaded in described system file successively.
CN201610831432.6A 2016-09-19 2016-09-19 A kind of system file method for down loading and download tool applied to Android system Active 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 true CN106445665A (en) 2017-02-22
CN106445665B CN106445665B (en) 2019-11-15

Family

ID=58165771

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610831432.6A Active 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)

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107426308A (en) * 2017-07-12 2017-12-01 东软集团股份有限公司 Asynchronous network communication means, device, terminal and server
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
WO2018196459A1 (en) * 2017-04-26 2018-11-01 平安科技(深圳)有限公司 Download request processing method and apparatus, processing device and medium
CN108965407A (en) * 2018-07-02 2018-12-07 广东飞企互联科技股份有限公司 A kind of processing implementation method of mobile Internet file download
CN109032775A (en) * 2018-06-29 2018-12-18 武汉斗鱼网络科技有限公司 A kind of method, terminal device and storage medium obtaining Task Progress
CN109766131A (en) * 2017-11-06 2019-05-17 上海宝信软件股份有限公司 The system and method for the intelligent automatic upgrading of software is realized based on multithreading
CN109802952A (en) * 2018-12-28 2019-05-24 视联动力信息技术股份有限公司 Monitoring data synchronous method and device
CN110336871A (en) * 2019-07-01 2019-10-15 江苏满运软件科技有限公司 A kind of document handling method, device, storage medium and electronic equipment
CN110769016A (en) * 2018-07-27 2020-02-07 亿度慧达教育科技(北京)有限公司 File uploading method and computer storage medium
CN111262797A (en) * 2020-01-09 2020-06-09 深圳壹账通智能科技有限公司 File downloading method and related product
CN111930696A (en) * 2020-07-22 2020-11-13 中国建设银行股份有限公司 File transmission processing method and system based on small program
CN112600913A (en) * 2020-12-07 2021-04-02 焦点科技股份有限公司 Download management method based on Android
CN113778673A (en) * 2021-08-27 2021-12-10 深圳市广和通无线股份有限公司 Data processing method, storage medium and device
CN115657537A (en) * 2022-10-20 2023-01-31 中国第一汽车股份有限公司 Calibration data management method, apparatus and medium for vehicle and electronic control unit

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101383751A (en) * 2008-07-24 2009-03-11 四川长虹电器股份有限公司 Network downloading method
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
US20140344816A1 (en) * 2013-05-14 2014-11-20 Dennis Nadeau System and method for running php instances
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

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101383751A (en) * 2008-07-24 2009-03-11 四川长虹电器股份有限公司 Network downloading method
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
US20140344816A1 (en) * 2013-05-14 2014-11-20 Dennis Nadeau System and method for running php instances
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
KEYATUTU: "单线程下载软件 NetMoles Downloader 2.4", 《软件天地》 *
程哲 等: "基于单线程的文件复制断点续传的设计与实现", 《科技创业月刊》 *

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018196459A1 (en) * 2017-04-26 2018-11-01 平安科技(深圳)有限公司 Download request processing method and apparatus, processing device and medium
CN107426308A (en) * 2017-07-12 2017-12-01 东软集团股份有限公司 Asynchronous network communication means, device, terminal and server
CN109766131A (en) * 2017-11-06 2019-05-17 上海宝信软件股份有限公司 The system and method for the intelligent automatic upgrading of software is realized based on multithreading
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
CN109802952A (en) * 2018-12-28 2019-05-24 视联动力信息技术股份有限公司 Monitoring data synchronous 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
CN111930696A (en) * 2020-07-22 2020-11-13 中国建设银行股份有限公司 File transmission processing method and system based on small program
CN112600913A (en) * 2020-12-07 2021-04-02 焦点科技股份有限公司 Download management method based on Android
CN113778673A (en) * 2021-08-27 2021-12-10 深圳市广和通无线股份有限公司 Data processing method, storage medium and device
CN113778673B (en) * 2021-08-27 2024-02-09 深圳市广和通无线股份有限公司 Data processing method, storage medium and apparatus
CN115657537A (en) * 2022-10-20 2023-01-31 中国第一汽车股份有限公司 Calibration data management method, apparatus and medium for vehicle and electronic control unit
CN115657537B (en) * 2022-10-20 2024-05-03 中国第一汽车股份有限公司 Calibration data management method, device and medium for vehicle and electronic control unit

Also Published As

Publication number Publication date
CN106445665B (en) 2019-11-15

Similar Documents

Publication Publication Date Title
CN106445665A (en) Method and tool for system file downloading applied to android system
CN103716719B (en) A kind of method for down loading of multimedia file and user terminal
CN110096336B (en) Data monitoring method, device, equipment and medium
CN102012831B (en) Over-the-air technology (OTA) upgrading method based on Linux platform
CN105159718B (en) Firmware upgrade method and device
CN110489217A (en) A kind of method for scheduling task and system
CN111045715B (en) Cloud game hot updating method, system and readable storage medium
CN105430478B (en) A kind of network video buffered play method, apparatus and television set
CN101014022A (en) Method, apparatus and system for transmitting files in instant messaging tool
CN103186391A (en) Browser upgrading method and system and upgrading server
CN109857548A (en) Memory space optimization method, device, computer equipment and storage medium
CN101588287B (en) Method, device and system for scheduling and downloading peer-to-peer network data
CN113157467B (en) Multi-process data output method
CN105450769A (en) File transmission method and device
CN102420709A (en) Method and equipment for managing scheduling task based on task frame
CN101170435A (en) A method for solving non-symmetric digital user line modulation and demodulation software loss
CN115086298A (en) File transmission method and device
CN110120965A (en) Method for down loading, tutoring system and the storage medium of courseware
CN107329738A (en) Component update method and device
CN110971962B (en) Slice caching method and device and storage medium
CN112153060A (en) Communication control method and system of SMB protocol server and related components
CN103685295A (en) Method, terminal and system for downloading multimedia files
CN105898399A (en) Video resource loading method and device and smart television
CN112600913A (en) Download management method based on Android
CN114116158A (en) Task scheduling method and system based on SD-WAN system

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