CN117061594A - Resource pre-downloading method and device, electronic equipment and storage medium - Google Patents

Resource pre-downloading method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117061594A
CN117061594A CN202311246378.5A CN202311246378A CN117061594A CN 117061594 A CN117061594 A CN 117061594A CN 202311246378 A CN202311246378 A CN 202311246378A CN 117061594 A CN117061594 A CN 117061594A
Authority
CN
China
Prior art keywords
file
application program
downloading
application
download
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.)
Pending
Application number
CN202311246378.5A
Other languages
Chinese (zh)
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202311246378.5A priority Critical patent/CN117061594A/en
Publication of CN117061594A publication Critical patent/CN117061594A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles
    • H04L67/303Terminal profiles
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • 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]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the application provides a method and a device for pre-downloading resources, electronic equipment and a computer readable storage medium, and relates to the technical field of communication. The method comprises the following steps: when the second application program pauses downloading the resource, determining the downloading records of the first application program and the second application program to the first file; determining an execution strategy of the first file according to the download records of the first application program and the second application program on the first file; the first file is a file except a second file in the resource, and the second file is a file downloaded by a resource loader. The embodiment of the application saves time cost, reduces the downloading flow and reduces CDN bandwidth cost brought by downloading.

Description

Resource pre-downloading method and device, electronic equipment and storage medium
The application relates to a method and a device for pre-downloading resources, electronic equipment and a storage medium for patent application with the application date of 2023, 06, 02 and the application number of 2023106495524.
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method, an apparatus, an electronic device, a computer readable storage medium, and a computer program product for pre-downloading resources.
Background
Before the application program issues the new version, the relevant resources of the new version are downloaded to the terminal in advance, which is called pre-download. By pre-downloading, the resource downloaded in advance can be directly loaded at the time point when the resource is allowed to be loaded to update the version of the application program, and compared with the method that after the new version is released, the user starts the application program and then starts to download the related resource of the new version, the waiting time of the user for perceiving the updated version can be avoided.
In the related art, the resource of the pre-downloaded application program may be executed by the application program itself, or may be executed by an application program for application distribution, such as an application store, where the situation that the resource is re-downloaded due to the interruption of the pre-downloaded program often occurs, which affects the user experience.
Disclosure of Invention
Embodiments of the present application provide a method, apparatus, electronic device, computer readable storage medium and computer program product for pre-downloading resources, which can solve the above-mentioned problems of the prior art. The technical scheme is as follows:
according to an aspect of an embodiment of the present application, there is provided a method for pre-downloading a resource, applied to a first application program, the resource including at least one file, the method including:
When the second application program pauses downloading the resource, determining the downloading records of the first application program and the second application program to the first file;
determining an execution strategy of the first file according to the download records of the first application program and the second application program on the first file;
the first file is a file except a second file in the resource, and the second file is a file downloaded by a resource loader.
As an alternative embodiment, the download record includes at least one of a download status and a download progress;
wherein, the download status is not downloaded, in download or already downloaded.
As an alternative embodiment, the processing policy of the first file includes at least one of:
downloading the first file when the downloading states of the first application program and the second application program to the first file are not downloaded;
and when the downloading state of the first application program to the first file is in downloading, and the downloading state of the second application program to the first file is not in downloading, continuing to download the first file according to the downloading progress of the first application program to the first file.
As an alternative embodiment, the first application program is a resource loader, and the second application program is an application distribution program for application distribution.
As an alternative embodiment, the processing policy of the first file further includes at least one of the following:
when the download states of the first application program and the second application program to the first file are in the downloading process, continuing to download the parts except the reference part in the first file, wherein the reference part is the merging result of the downloaded parts of the first application program and the second application program;
when the downloading state of the first application program to the first file is not downloaded, and the downloading state of the second application program to the first file is downloaded, moving the downloaded first file to a preset storage position of the first application program;
and when the downloading state of the first application program to the first file is not downloaded and the downloading state of the second application program to the first file is in the downloading process, moving the part of the first file downloaded by the second application program to the preset storage position, and continuing to download the first file according to the downloading progress of the second application program to the first file.
As an alternative embodiment, when there is no overlapping content in the first portion and the second portion, the result of merging the downloaded portions is a result of splicing the first portion and the second portion;
when the first part and the second part have coincident content, the combination result of the downloaded part is the result of splicing the third part and the fourth part;
the first part is a part of the first file downloaded by the first application program, and the second part is a part of the first file downloaded by the second application program;
the third part is one part of the first part and the second part, the part remained after the superposition of the first part and the second part is deleted, and the fourth part is the other part of the first part and the second part.
As an alternative embodiment, the first file is determined by:
determining the second file according to the download record of each file;
and taking the identification except the file identification of the second file in the configuration information of the resource as the identification of the first file.
As an alternative embodiment, further comprising:
Executing the execution strategy to obtain a first file with a downloaded state;
carrying out integrity and accuracy check on the downloaded first file;
if the verification is passed, the downloaded first file is reserved;
if the verification is not passed, deleting the downloaded first file and re-downloading the first file.
As an alternative embodiment, further comprising:
and if all the files of the resource are downloaded and all the files pass the verification, loading the resource.
As an alternative embodiment, determining the download record of the first file by the second application program includes:
obtaining configuration information of the resource, wherein the configuration information comprises file identifiers of all files in the resource;
and determining the download record of the second application program to the first files with corresponding identifications to the second application program according to the file identifications of the first files by using a cross-program data sharing mechanism.
As an alternative implementation, the method is executed by a target SDK in the resource loader;
the determining the download records of the first application program and the second application program to the first file further comprises determining that at least one of the following conditions is met:
The first application program calls the target SDK;
the second application program calls the target SDK;
and the target SDK senses that the first application program is in an operation state that the load of the terminal where the first application program is positioned is smaller than a preset threshold value.
As an alternative implementation, the first application program is the application distribution program, and the second application program is the resource loader.
As an optional implementation manner, the processing policy of the first file further includes:
the downloading states of the first application program and the second application program to the first file are in downloading, the downloading progress of the first application program to the first file is not greater than the downloading progress of the second application program to the first file, the part of the first application program, which downloads the first file, is deleted, and the first file is continuously downloaded according to the downloading progress of the second application program to the first file;
the downloading states of the first application program and the second application program to the first file are in downloading, the downloading progress of the first application program to the first file is larger than the downloading progress of the second application program to the first file, and the first file is continuously downloaded according to the downloading progress of the first application program to the first file.
As an optional implementation manner, the determining the download record of the second application program to the first file includes:
transmitting a first request to the second application program by using a cross-program data sharing mechanism, wherein the first request comprises a file identifier of at least one file of the resource, and the first request is used for requesting a download record of the file of the corresponding file identifier;
and determining the download record of the first file according to the download record of the file identified by the corresponding file returned by the second application program.
According to another aspect of an embodiment of the present application, there is provided a pre-download apparatus for a resource, applied to a first application program, the resource including at least one file, the apparatus including:
the file determining module is used for determining the downloading records of the first application program and the second application program to the first file when the second application program pauses downloading the resource;
the strategy determining module is used for determining an execution strategy of the first file according to the download records of the first application program and the second application program on the first file;
the first file is a file except a second file in the resource, and the second file is a file downloaded by a resource loader.
According to another aspect of an embodiment of the present application, there is provided an electronic apparatus including: a memory, a processor and a computer program stored on the memory, the processor executing the computer program to carry out the steps of the above method.
According to a further aspect of embodiments of the present application, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the above method.
According to an aspect of an embodiment of the present application, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the steps of the above method.
The technical scheme provided by the embodiment of the application has the beneficial effects that:
the resource pre-downloading method is executed by the first application program, the first application program can be applied to the resource loading program and the application distribution program, the downloading main body can be switched at any time, the purposes of downloading record interaction between the first application program and the second application program are achieved by determining the second application program to pause the downloading resource and determining the downloading record of each first file in the first file set by the first file set and the second application program, and the processing strategy of the first file is determined based on the downloading record of each first file by the two application programs, so that the repeated downloading of files which are not downloaded or are being downloaded by different downloading main bodies can be avoided, the time cost is saved, the downloading flow is reduced, and the CDN bandwidth cost caused by downloading is reduced.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings that are required to be used in the description of the embodiments of the present application will be briefly described below.
FIG. 1 is a schematic diagram of a system architecture of a resource pre-download system according to an embodiment of the present application;
FIG. 2a is a schematic flow chart of a method for pre-downloading resources according to an embodiment of the present application;
FIG. 2b is an interactive schematic diagram of a resource pre-downloading method performed by a resource loader as a downloading main body according to an embodiment of the present application;
fig. 2c is an interaction schematic diagram of a resource pre-downloading method performed by using an application distribution program as a downloading main body according to an embodiment of the present application;
FIG. 3 is a schematic diagram of 3 merging modes according to an embodiment of the present application;
FIG. 4 is an interactive schematic diagram of a resource pre-downloading method performed by a resource loader as a downloading main body according to an embodiment of the present application;
FIG. 5 is an interaction schematic diagram of a resource pre-downloading method performed by an application distribution program as a downloading main body according to an embodiment of the present application;
FIG. 6 is an interaction diagram in a pre-download scenario for game resources according to an embodiment of the present application;
FIG. 7 is a schematic structural diagram of a device for pre-downloading resources according to an embodiment of the present application;
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described below with reference to the drawings in the present application. It should be understood that the embodiments described below with reference to the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application, and the technical solutions of the embodiments of the present application are not limited.
As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless expressly stated otherwise, as understood by those skilled in the art. It will be further understood that the terms "comprises" and "comprising," when used in this specification, specify the presence of stated features, information, data, steps, operations, elements, and/or components, but do not preclude the presence or addition of other features, information, data, steps, operations, elements, components, and/or groups thereof, all of which may be included in the present specification. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein indicates that at least one of the items defined by the term, e.g., "a and/or B" may be implemented as "a", or as "B", or as "a and B".
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail with reference to the accompanying drawings.
First, several terms related to the present application are described and explained:
pre-download: before the application program issues the new version, the relevant resources of the new version are downloaded to the terminal in advance, which is called pre-download. By pre-downloading, the resource downloaded in advance can be directly loaded at the time point when the resource is allowed to be loaded to update the version of the application program, and compared with the method that after the new version is released, the user starts the application program and then starts to download the related resource of the new version, the waiting time of the user for perceiving the updated version can be avoided.
Channel pre-download: the manufacturer of the application program downloads the new version of the resource in advance before the new version of the application program is released through the application distribution program (i.e. the program for application distribution), such as an application store, and the downloaded file is stored in a private directory of the application distribution program, or may be an externally stored public directory.
In the game: refers to the running of a process of a game application, including the following: 1. the game application runs on a main interface of the terminal; 2. the game application interface is closed, but the game progress is not killed. In summary, the logical code running on a game process is referred to as an in-game scenario.
Breakpoint continuous transmission: when downloading or uploading, the downloading or uploading task (a file or a compressed packet) is divided into a plurality of parts, each part is uploaded or downloaded by adopting one thread, each thread can be executed in parallel or sequentially, if a network fault is encountered, the part which is already uploaded or downloaded can be continuously uploaded and the part which is not yet downloaded is not yet completely downloaded, and the part which is not yet completely downloaded is not necessarily uploaded from the beginning, so that the time is saved and the speed is increased.
File merging: referring to 2 or more files, basic file-based operations include: file splicing, file coverage, file cropping, etc., to form a new complete file. In the process of merging files, the files to be merged are mainly related to the position information of the complete files. In the embodiment of the present application, the merging between 2 files is mainly discussed, and the merging is illustrated by way of example:
for example, file 1, with a start position of 0 and an end position of 100, representing that file 1 is in the data position of 0 to 100 bytes of the complete file; file 2, with a start position of 101 and an end position of 200, represents file 2 in a data position of 101 to 200 bytes of the complete file. When the file merging is executed, the file 2 is spliced to the file 1 according to the position information of the 2 files, so that a complete file with a starting position of 0 and an ending position of 200 is formed.
ContentProvider shared data update notification mechanism: supporting storing and reading data in multiple applications. The mechanism is based on a uniform resource identifier (Uniform Resource Identifier, URI) by which the sender and receiver of notifications are associated, the notification registry of the mechanism is impersonated by the contentdervice service, and the class responsible for receiving data update notifications must inherit the contentdonserver class.
The method, the device, the electronic equipment, the computer readable storage medium and the computer program product for pre-downloading the resources aim to solve the technical problems in the prior art, so that a resource loading program for loading the resources and an application distribution program for application distribution can both have opportunities to pre-download the resources, and a processing strategy for determining a first file based on the downloading state and the downloading progress of a first file by two application programs respectively can avoid repeated downloading of files which are not downloaded or are being downloaded by different downloading bodies, save time cost, reduce the downloading flow, reduce CDN bandwidth cost caused by downloading, and only load the resources under the condition that all files are completely downloaded and all files pass verification.
The technical solutions of the embodiments of the present application and technical effects produced by the technical solutions of the present application are described below by describing several exemplary embodiments. It should be noted that the following embodiments may be referred to, or combined with each other, and the description will not be repeated for the same terms, similar features, similar implementation steps, and the like in different embodiments.
The following describes a resource pre-downloading system provided by the embodiment of the application. Referring to fig. 1, fig. 1 is a schematic architecture diagram of a resource pre-download system according to an embodiment of the present application, in order to support an exemplary application, a terminal (a terminal 400-1 and a terminal 400-2 are shown in an exemplary manner) are connected to a server 200 through a network 300, where the network 300 may be a wide area network or a local area network, or a combination of the two, and a wireless or wired link is used to implement data transmission.
The terminals (such as the terminal 400-1 and the terminal 400-2) are provided and operated with the client side of the application program, and are used for receiving the update notification issued by the server in the operation process of the application program, pre-downloading the resources corresponding to the application program from the server, and storing the resources in a local storage space (such as an SD card of the mobile terminal).
At least two application programs are provided in terminals (such as the terminal 400-1 and the terminal 400-2), one application program for loading the resource (hereinafter, the embodiment is simply referred to as a resource loading program), and the other application program for application distribution (hereinafter, the embodiment is simply referred to as an application distribution program), and the application distribution program according to the embodiment of the present application can be colloquially understood as an application store, that is, a program for downloading and updating the application program.
The resource loading program and the application distribution program in the embodiment of the application both support the pre-downloading of the resource, a downloading main body for pre-downloading is called a first application program, another application program is called a second application program, the first application program determines that the second application program pauses to download the resource, a first file set and a downloading record of the second application program for each first file in the first file set are also determined, the first file is a file except the second file set in the resource, and the second file in the second file set is a file downloaded by the resource loading program for loading the resource; and for each first file, determining a downloading record of the first application program to the first file, and determining and executing a processing strategy of the first file according to the downloading records of the first application program and the second application program to the first file.
The server 200 is configured to receive a resource of a resource loader uploaded by a development end during an application running process, and send an update notification to a terminal installed with the application to notify each terminal that the application has an update resource; and meanwhile, the method is also used for receiving a downloading request of the resource of the application program sent by the downloading main body and sending the resource to the terminals (such as the terminal 400-1 and the terminal 400-2) sending the downloading request.
In some embodiments, the server 200 may be a stand-alone physical server, a server cluster or a distributed system formed by a plurality of physical servers, or may be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content distribution Network (CDN, contentDelivery Network), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal 400 may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, etc. The terminal and the server may be directly or indirectly connected through wired or wireless communication, which is not limited in the embodiment of the present application.
The embodiment of the application can be realized by means of Cloud Technology (Cloud Technology), wherein the Cloud Technology refers to a hosting Technology for integrating serial resources such as hardware, software, network and the like in a wide area network or a local area network to realize calculation, storage, processing and sharing of data.
The cloud technology is a generic term of network technology, information technology, integration technology, management platform technology, application technology and the like based on cloud computing business model application, can form a resource pool, and is flexible and convenient as required. Cloud computing technology will become an important support. Background services of technical network systems require a large amount of computing and storage resources. Along with the high development and application of the internet industry, each article possibly has an own identification mark in the future, the identification mark needs to be transmitted to a background system for logic processing, data of different levels can be processed separately, and various industry data needs strong system rear shield support and can be realized through cloud computing.
The embodiment of the application provides a resource pre-downloading method, which is applied to a first application program, wherein the first application program can be a resource loading program or an application distribution program. Taking a resource loader as an example of a game application program, the resource can be a game resource, and it can be understood that the type of the resource can be different according to the application type of the resource loader.
As shown in fig. 2a, the method for pre-downloading the resource includes the following steps:
s2011, when the second application program pauses downloading the resource, determining the downloading records of the first application program and the second application program to the first file.
The first file in the embodiment of the present application refers to a file in a resource other than the second file, where the second file refers to a file that has been downloaded by a resource loader, that is, whether the execution subject of the present application is the resource loader or the application distributor, it is necessary to determine the file that has been downloaded by the resource loader, that is, the second file, and then use the file other than the second file in the resource as the first file. It may be understood that the number of each of the first file and the second file in the embodiment of the present application may be one or more, and the set formed by the first file and the second file is all files of the resource.
The download record of the embodiment of the application can comprise at least one of a download state and a download progress, wherein the download state can comprise three types of downloaded, un-downloaded and downloaded.
In some embodiments, the downloading progress is the progress of file downloading, the value of the downloading progress ranges from 0 to 100%, when the downloading progress is 0, it indicates that no downloading is performed, when the downloading progress is 100%, it indicates that downloading is performed, and when the downloading progress is any number between 0 and 100%, it indicates that downloading is performed. That is, in the embodiment of the present application, the download record of a file may only include the download progress.
In other embodiments, the downloading progress may refer to the progress of downloading the file when the downloading status is in downloading, that is, the downloading progress may be only when a file starts to be downloaded, and when a file is not downloaded, the downloading progress is 0, which may be regarded as no downloading progress. If a file has no download record or the download record is empty, it indicates that the file has not been started to be downloaded.
It should be understood that downloaded in the embodiment of the present application refers to having downloaded the entire content of a file, for example, a file size of 3000 bytes, and only having downloaded the entire 3000 bytes is referred to as having downloaded the file, and when downloading a file is started, but the entire content of a file is not downloaded, it is referred to as downloading, that is, in the downloading in the embodiment of the present application, not the stage between when the file is being downloaded at one time, but not downloaded and downloaded. When downloading of a file is not started, the downloading state of the file is called as not downloaded, for example, the size of one file is 3000 bytes, 1 byte which is not downloaded is called as not downloaded, and the stages from downloading the first byte to downloading to 2999 bytes are called as downloading as long as the downloading of the bytes is started. The downloading state of a file at a moment in time can be not downloaded, in downloading or already downloaded. That is, the first file of the present application refers to a file in a resource that is not downloaded or is being downloaded by a resource loader.
It should be understood that when the download subject is different, there is a difference in the storage location of the downloaded file, for example, when the download subject is a resource loader, the resource loader will download the file to its own private directory, and possibly a public directory (first public directory), and when the download subject is an application distributor, the application distributor will download the file to its own private directory, and possibly a public directory (first public directory), and in general, the private directories of different download subjects are different, and the designated public directories are also different.
Therefore, if the download subject of the present application, i.e. the first application program, is a resource loader, the resource loader can determine the first file according to which files have been downloaded by itself, and by combining the file information of all files that the resource needs to download.
If the download subject of the present application, i.e., the first application, is an application distribution program, the application distribution program also needs to request the resource loader to obtain the file information of the second file or the first file information. For example, in some embodiments, the resource loader may send file information of the second file to the application distribution program, where the application distribution program obtains file information of all files that the resource needs to download, and determines the first file by an exclusion method; in other embodiments, the resource loader may determine the first file and then inform the application distributor directly.
The first file is determined according to the embodiment of the present application, because the final resource is stored in the preset storage location of the resource loading application and the resource loading program loads the resource, whether the file needs to be downloaded is based on whether the resource loading application has downloaded the file. It should be noted that when a file is downloaded by the application distribution program, the file needs to be moved to a preset storage location of the resource loader, and after being moved to the preset storage location, the file is considered to be downloaded by the resource loader. That is, whether the download subject is the resource loader or the application distributor, the embodiment of the application skips the processing of the files downloaded by the resource loader, thereby improving the overall download efficiency of the resources. For example, when the first application is an application distributor, determining the first set of files and processing the first files in the first set of files means that processing the second files is skipped.
When determining the first file set, the embodiment of the application also needs to determine that the second application program has stopped downloading resources so as to ensure that only one downloading main body exists at one moment, if the first application program determines that the second application program is still downloading resources before the first file set, the embodiment of the application indicates the second application program to temporarily download resources, which means that the downloading main body is switched to the first application program at the moment, and the first application program continues to download the files which are not yet downloaded by the resource application program, thereby avoiding the waste of flow and terminal storage space caused by simultaneously downloading the files, determining that the second application program stops downloading resources, and being convenient for the first application program to accurately determine the downloading breakpoint so as to perform breakpoint continuous transmission.
In some embodiments, the first application may send a first request to the second application requesting a query of whether the second application is downloading resources, the second application, in response to the first request, returning a status code to the first application indicating whether the second application is downloading resources, wherein the first status code is used to indicate that the second application is downloading resources, and the second status code is used to indicate that the second application is not downloading resources.
In some embodiments, the first application may send the first request to the second application through a cross-program data sharing mechanism, such as a ContenProvider mechanism.
In some embodiments, a first application may query, through a Service component, whether a second application is downloading resources. Service (Service) is one of the important components in the Android system. Services are mainly used for two purposes: background run and cross-process access. By starting a service, the designated task can be operated in the background on the premise of not displaying an interface, so that the terminal can be not influenced to execute other tasks.
Specifically, the first application program of the embodiment of the present application may query, through a Service (Service) component, whether the second application program is downloading resources, and may include the following steps:
Creating a Service component by the second application program;
the second application program returns a communicable IBinder object in the onBind method of the Service component, wherein the IBinder object comprises information of whether the second application program is downloading resources or not;
after the first application program binds the Service component, the IBinder object is obtained in the onServiceConnected method, and the IBinder object is called to determine whether the second application program is downloading the resource.
S2012, determining an execution strategy of the first file according to the download records of the first application program and the second application program on the first file.
For each first file, since the first application program of the present application may be either a resource loader or an application distributor, when the first application program is a resource loader, it is obvious that the download status of the first application program for the first file may be only in download or not in download, and the download status of the second application program for the first file may be in download, in download or not in download.
For example, the application distribution program starts downloading resources at a first time of a day, and 3 files have been downloaded at a second time: file 1, file 2 and file 3, there are 2 files in download: file 4 and file 5, there are 1 file not downloaded: and the file 6 starts the resource loading program by the third moment and starts to execute the pre-downloading method of the application, at the moment, the resource loading program does not download any file yet, the resource loading program instructs the application distribution program to stop downloading the resource, and then the downloading state of each file (because all the files are the first file) is determined, so that the downloading state of the first file is found to be downloaded, and the downloading state of the first file is found to be in downloading, and the downloading state is found to be not downloaded.
When the first application program is an application distribution program, the second application program is a resource loading program, obviously, the downloading state of the second application program to the first file may be in downloading or not downloading, and the downloading state of the first application program to the first file may be in downloading or not downloading, but not in downloading, because all files are summarized to the preset storage position of the resource loading program, and the application distribution program firstly determines which files the resource loading program has downloaded, so that the application distribution program is not necessarily downloaded as long as the resource loading program has not downloaded the file.
According to the embodiment of the application, for each first file, the processing strategy of the first file is determined according to the download records of the first file by the first application program and the second application program, so that the problem of repeated downloading of the first file caused by lack of interaction of the two application programs can be avoided. It should be understood that the repeated downloading of the present application includes both the case of downloading the first file from which the second application has been downloaded and the case of downloading the portion of the first file from which the second application has been downloaded when the second application downloads the portion of the first file.
The embodiment of the application can obtain the download address of each file in the resource in advance, so that when the processing strategy is to download the file, the downloading is carried out based on the download address of the file.
The download subject of the embodiments of the present application supports single-threaded or multi-threaded downloads, whether it is a resource loader or an application distributor. In the multithread downloading mode, random reading and writing are needed to be carried out on the file, and when a plurality of threads write data to the file at the same time, the range of writing byte data to the file by each thread is determined after the file length is equally divided according to a certain rule.
In some embodiments, during each thread downloading the file, it is also necessary to record the downloading progress of the file to disk. The main content of the download progress includes:
the beginning item: the starting byte position written by the current thread;
the end term is expected: the current thread downloads the completed byte position;
actual end item: the end position of the byte actually downloaded by the current thread.
It will be appreciated that the actual end of download progress is updated in real time as the download step proceeds.
It should be noted that, the pre-download method of the embodiment of the present application may be applied to both the resource loader and the application distributor, which means that there are some special cases where a certain file is downloaded by the resource loader first, and after a part of the file is downloaded by the application distributor, and after a part of the file is downloaded, the file is switched to the resource loader to perform similar operations of switching the download main body, such as downloading, but no matter which application the download main body is at one moment, the pre-download method of the embodiment of the present application is applicable, and the present application can realize the effects of switching the download main body at any moment and not repeating the downloading of the file.
When executing the processing strategy of the first file, the embodiment of the application needs to update the download record of the first file in real time, so that when switching the download main body, a new download main body can determine a new processing strategy according to the download record of the first file from the previous download main body.
Referring to fig. 2b, an interaction diagram of a pre-download method when a first application is a resource loader according to an embodiment of the present application is shown, where the interaction diagram includes:
s2021, determining file information of all files of the resource and file information of a second file;
s2022, determining file information of the first file according to file information of all files of the resource and file information of the second file;
s2023, according to the file information of the first file, indicating the second application program, namely the application distribution program, to pause downloading resources and returning a downloading record of the application distribution program to the first file;
s2024, determining a download record of the resource loader to the first file;
s2025, determining a download record of the first application program to the first file, and determining and executing a processing strategy of the first file according to the download records of the first application program and the second application program to the first file respectively.
It should be noted that, the download main body of the embodiment of the present application is a resource loader, firstly, file information of a first file is determined by determining file information of all files of a resource and file information of a downloaded file (a second file), and a second application program is instructed to pause downloading the resource and return a download record of each first file, and then, a processing policy of the first file is determined and executed in combination with the download record of each first file. The order of steps S2021 to S2023 in the embodiment of the present application is not particularly limited.
It should be noted that, step S2023 may further include a step of the first application program querying whether the second application program is downloading the resource, if the second application program is downloading the resource, step S2023 is executed, and if the second application program does not download the loading resource, the second application program is only required to be instructed to return the download record of each first file in the first files.
Referring to fig. 2c, an interaction diagram of a pre-download method when a first application program is an application distribution program according to an embodiment of the present application is shown, where the interaction diagram includes:
s2031, indicating a second application program, namely a resource loader, to pause downloading resources and returning a downloading record of a first file;
S2032, determining a download record of the application distribution program itself to the first file;
s2033, determining a downloading record of the first application program to the first file, and determining and executing a processing strategy of the first file according to the downloading record of the first application program and the second application program to the first file.
The sequence of steps S2031 to S2033 in the embodiment of the application is not particularly limited.
It should be noted that, before the step S2031, the step S2031 may further include a step of the first application program querying whether the second application program is downloading the resource, if the second application program is downloading the resource, the step S2031 is executed, and if the second application program does not download the loading resource, the step S2031 is executed only by indicating that the second application program returns the download record of each first file.
In some embodiments. Step S2031 may be:
instructing the resource loader to pause downloading the resource and returning file information of the second file;
determining file information of all files of the resource;
determining file information of a first file according to file information of all files and file information of a second file;
the resource loader is instructed to return a download record of the first file.
It should be noted that in the embodiments corresponding to fig. 2b and 2c, the download subject may also include the file identifier and the download address of the file before executing the processing policy of the first file, for example, in some embodiments, the file information. So that the download subject knows the download address of the file when obtaining the file information.
Based on the foregoing embodiments, as an alternative embodiment, the download record includes a download status, and as can be seen from the foregoing embodiments, the download status in the embodiments of the present application includes three cases of downloaded, not downloaded and downloaded, and specific definitions may refer to the foregoing embodiments, for example, descriptions in steps S2011 and S2012, etc., which are not repeated herein.
Determining a processing strategy of the first file according to the download records of the first application program and the second application program on the first file, wherein the processing strategy comprises the following steps:
and determining the processing strategy of the first file as downloading the first file according to the fact that the downloading states of the first application program and the second application program to the first file are not downloaded.
For a first file that neither application program starts downloading, the processing strategy of the first application program for the first file is to download the first file. When executing the processing strategy, the first application program records the download state in the download record of the first file as the download state, and updates the download progress of the first file in real time.
It should be noted that, whether the download subject, i.e., the first application program, is a resource loader or an application distributor, if it is determined that neither program downloads a certain first file, the first file is directly downloaded, and the download record of the first file is updated, so that when the download subject is subsequently switched, the download status and the download progress of the first file can be determined through the download record, so as to determine the processing policy.
When the first application program downloads the first file, the downloaded first file is stored in a preset storage position of the first application program in real time, wherein the preset storage position can be a private directory or a preset public directory of the first application program.
It should be noted that, when the first application program downloads the first file, the downloading progress of the first file is updated in real time, and when the downloading progress reaches 100%, that is, it is determined that the entire content of the first file has been downloaded, then the downloading state of the first file needs to be updated from downloading to downloading.
On the basis of the above embodiments, as an alternative embodiment, the download record includes at least one of a download status and a download progress. As can be seen from the above embodiments, the download status of the embodiment of the present application includes three situations of downloaded, not downloaded and downloaded, and specific definitions can refer to the above embodiments, for example, the descriptions of steps S2011 and S2012 are omitted herein.
Determining a processing strategy of the first file according to the download records of the first application program and the second application program on the first file, wherein the processing strategy comprises the following steps:
And determining a processing strategy of the first file to continuously download the first file according to the downloading progress of the first application program on the first file according to the downloading state of the first application program on the first file in downloading and the downloading state of the second application program on the first file in not downloading.
That is, whether the first application program is a resource loader or an application distributor, when determining that the download status of the first application program itself is in the process of downloading, but the second application program does not start downloading the first file, the first file is continuously downloaded according to the download progress of the first application program itself.
For example, the total byte number of a first file is 100, the downloading progress of the first application program for downloading the first file is 0-40%, i.e. the 1 st-40 th byte is downloaded, and the second application program does not download the first file, then the first application program continues to download the first file from the 41 st byte.
It should be noted that, when the first application program continues to download the first file, the downloading progress of the first file is updated in real time, and when the downloading progress reaches 100%, that is, it is determined that the entire content of the first file has been downloaded, the downloading status of the first file needs to be updated from downloading to downloading.
Based on the foregoing embodiments, as an optional embodiment, the determining that the second application program pauses the downloading resource, determining the first file and the downloading record of the second application program to the first file, and before further includes:
and obtaining configuration information of the resource, wherein the configuration information comprises file identifiers of all files in the resource.
When the first application program is a resource loader, configuration information of the resource can be obtained through a server corresponding to the resource loader.
When the first application program is an application distribution program, configuration information of resources can be obtained by a server corresponding to the application distribution program.
It should be understood that after the resource is created by the developer of the resource, the resource is uploaded to the server corresponding to the resource loader and the server corresponding to the application distributor.
In some embodiments, the configuration information includes a file identification and download address for each file in the resource.
In some embodiments, the file identification may include a file name, an information digest of the file, and the like.
In some embodiments, the information summary of the file may be determined by an MD5 information summary Algorithm (MD 5 Message-Digest Algorithm).
The embodiment of the application determines the download record of the second application program to each first file, and comprises the following steps:
and determining the download record of the second application program to the first file with the corresponding identifier to the second application program according to the file identifier of each first file by using a ContentProvider mechanism.
It should be noted that, since the communication between the first application program and the second application program is in different processes, the communication belongs to the inter-process communication range, and the communication adopts a ContentProvider mechanism, which may be initiated by the resource loader to distribute information to the application to obtain a file record, or may be initiated by the application distribution information to obtain a file record from the resource loader.
In particular, the second application may provide a download record of some first files, the first application needs to obtain the download record of these first files,
firstly, an SQLite database is created, and the download record of the first file is stored in the database.
Thereafter, a Provider class is created that inherits the ContentProvider.
The embodiment of the application can realize six abstract methods of ContentProvider. In the onCreate method, a ContentProvider is created, where the database is initialized, while in the getType method, the MIME type corresponding to the Uri request is returned, and then the corresponding CRUD operation, that is, the data adding, deleting and checking function is performed in the remaining four methods.
Further, the above ContentProvider needs to be registered in android management, and the registration process involves creating three attributes of ContentProvider:
authentications-this attribute is the unique identification of the ContentProvider by which external applications can access the ContentProvider, i.e., authentications are unique. And this authenticates are also authenticates within the URI;
export, set to true, indicates that the current ContentProvider can be used by other applications. Any application may use Provider to obtain it through a URI, or may use Provider through the corresponding rights. When set to false, indicates that the current ContentProvider cannot be used by other applications;
permission set permissions for ContentProvider to avoid any application having access to ContentProvider.
And setting the authority of the second application program, wherein the application program is started only by creating a blank Activity, and no operation is needed in the Activity.
The process of the first application program obtaining the data in the ContentProvider is as follows:
creating an entity class associated with the first file;
methods for editing data based on ContentProvider may be used in the Activity.
On the basis of the above embodiments, as an alternative embodiment, the download subject, that is, the first application, is a resource loader;
the download record comprises at least one of a download status and a download progress;
determining a processing strategy of the first file according to the download records of the first application program and the second application program on the first file, wherein the processing strategy comprises the following steps:
determining a processing strategy of the first file as follows according to the download states of the first application program and the second application program to the first file in the process of downloading:
combining the downloaded parts of the first file by the first application program and the second application program according to the downloading progress of the first file by the first application program and the second application program, and obtaining and storing a combined result of the downloaded parts of the first file;
and continuing to download the part except the merging result of the download part in the first file.
It should be noted that, when the download states of the first application program and the second application program for a first file are both in downloading, the download progress of the first file by the two application programs needs to be considered, and based on the download progress of the first file by the two application programs, the download parts of the first file by the two application programs are respectively combined, so as to obtain the combination result of the download parts of the first file.
In some embodiments, when the first application program merges the downloaded portion of the first file, the downloaded portion of the second application program is first moved to the preset storage location of the first application program, so that the preset storage location of the second application program does not have the downloaded portion of the first file, and then the first application program merges the downloaded portion of the first application program and the downloaded portion of the moved second application program, where the specific manners of merging include stitching, overlaying and clipping, please refer to fig. 3, which schematically illustrates a schematic diagram of 3 merging manners provided by the embodiments of the present application, and as shown in the following:
the splicing is the most easily understood merging mode, that is, the next field of the end field of the downloaded part of an application program is the initial field of the downloaded part of another application program, for example, the total byte number of a certain first file is 100, the downloading progress of the first application program for downloading the first file is 0-30%, that is, the downloading progress of the first application program for downloading the first file is 1-30 bytes in the figure, the downloading progress of the second application program for downloading the first file is 30-60%, that is, the downloading progress of the second application program for downloading the first file is 31-60 bytes, that is, the two downloaded parts are merged, that is, the merging result is 0-60% of the first file, that is, 1-60 bytes of the first file, that is, the first application program for downloading from 61 th byte is continued.
Covering, that is, the downloaded part of one application program includes the downloaded part of another application program, the downloaded part of one application program is covered with the downloaded part of another application program, for example, the total byte number of a certain first file is 100, the downloading progress of the first file downloaded by the first application program is 0-60%, that is, the downloading progress of the first file downloaded by the first application program is 1-60 bytes, such as file 4 in the figure, the downloading progress of the first file downloaded by the second application program is 0-30%, that is, the downloading progress of the first file is 1-30 bytes, such as file 5 in the figure, the downloaded part of the first application program is: bytes 1-60 cover the part of the second application download: since the progress of the file 5 in fig. 3 is completely covered by the file 4, the filling diagonal line is added to the whole area of the file 5, and the obtained merging result is 0-60% of the first file, i.e. 1-60 bytes of the first file, such as the file 6 in the figure, and the first application program continues to download from the 61 st byte.
When there is a partial overlap between the downloaded portion of one application program and the downloaded portion of another application program, it is necessary to determine that the two application programs are not overlapped, and then splice with the overlapped portions in byte order, for example, the total byte number of a certain first file is 100, the downloading progress of the first application program downloading the first file is 0-40%, i.e. 1-40 bytes are downloaded, for example, file 7 in the figure, the downloading progress of the second application program downloading the first file is 30-60%, i.e. 30-60 bytes are downloaded, for example, file 8 in the figure, it is determined that the partially overlapped contents are 30-40 bytes, the non-overlapped portions are 1-29 bytes and 41-60 bytes, the overlapped contents of file 7 and file 8 are added with filling oblique lines in the file 8 in the byte order, the 30-40 bytes in the file 8 are deleted, and then the remaining contents of file 7 and file 8 are deleted in the byte order: the 41 st to 60 th bytes are spliced to obtain 1 st to 60 th bytes, namely the file 9 in the figure, and the first application program continues to download from the 61 st byte.
It should be noted that, when the first application program continues to download the first file, the downloading progress of the first file is updated in real time, and when the downloading progress reaches 100%, that is, it is determined that the entire content of the first file has been downloaded, then the downloading status of the first file needs to be updated from downloading to downloading.
On the basis of the above embodiments, as an alternative embodiment, for the purpose of facilitating understanding, the embodiment of the present application refers to a portion of the first application program downloaded to the first file simply as a first portion, and refers to a portion of the second application program downloaded to the first file simply as a second portion.
According to the downloading progress of the first application program and the second application program to the first file, merging the downloaded parts of the first file by the first application program and the second application program to obtain and save the merged parts of the first file, including:
a) If the first part and the second part do not have the coincident content, splicing the first part and the second part according to the downloading progress of the first application program and the second application program on the first file respectively, and obtaining and storing a merging result of the downloading part of the first file;
B) If the first part and the second part have overlapped contents, deleting the overlapped contents of one part of the first part and the second part to obtain the residual contents of one part;
and splicing the residual content of one part with the other part according to the downloading progress of the first application program and the second application program to the first file, so as to obtain and store the merging result of the downloading part of the first file.
It should be understood that the above-mentioned mode a is a splicing mode, and the mode B is a covering or cutting mode.
On the basis of the above embodiments, as an alternative embodiment, the first application program is a resource loader;
the download record includes a download status;
determining a processing strategy of the first file according to the download records of the first application program and the second application program on the first file, wherein the processing strategy comprises the following steps:
according to the fact that the first application program downloads the first file in a non-downloaded state, the second application program downloads the first file in a downloaded state, and the processing strategy of the first file is determined to be:
and moving the first file downloaded by the first file to a preset storage position of the first application program.
When the download main body, namely the first application program is the resource loading program, if one first file resource loading program is not downloaded and the application distribution program is downloaded, the resource loading program does not need to download the first file again, but moves the first file downloaded by the application distribution program to a preset storage position of the first application program.
On the basis of the above embodiments, as an alternative embodiment, the first application program is a resource loader;
the download record comprises a download state and a download progress;
determining a processing strategy of the first file according to the download records of the first application program and the second application program on the first file, wherein the processing strategy comprises the following steps:
according to the condition that the first application program downloads the first file as not downloaded, the second application program determines the processing strategy of the first file as in the process that the second application program downloads the first file as downloaded:
moving the part of the first file downloaded by the second application program to a preset storage position of the first application program;
and continuing to download the first file according to the downloading progress of the second application program to the first file.
When the download subject, i.e. the first application program, is the resource loader, if a first file resource loader is not downloaded and the application distribution program has downloaded a part, the resource loader does not need to download the first file again, but moves the part of the application distribution program downloaded to the first file to the preset storage position of the first application program, and then continues to download the first file based on the download progress of the application distribution program to the first file. The embodiment of the application avoids repeated downloading of the file and improves the efficiency of the resource loader to obtain the file of the resource.
It should be understood that, when the resource loader continues to download the first file, the downloaded content will be downloaded in the preset storage location, specifically, the resource loader will determine the storage interval of the preset storage location according to the size of the storage space occupied by the first file, for example, the storage interval of the first file is 10000-12000 bytes, and when the part downloaded by the application distributor occupies 10000-11000 bytes after storing the part downloaded by the application distributor in the storage interval, the content of the first file that is continuously downloaded will be stored from 11001 bytes until the content is stored to 12000 bytes.
On the basis of the foregoing embodiments, as an alternative embodiment, determining at least one first file includes:
determining a second file according to the download records of the files;
and determining the first file from the configuration information according to the file identification of the second file.
In some embodiments, when the first application program is a resource loader, the resource loader determines that the first file does not need to interact with the application distribution program, only needs to determine the file identifier of each downloaded second file from the preset storage position used for storing the second file, and then uses the files except the second file as the first file from the configuration information by removing the method.
In other embodiments, the resource loader of the embodiment of the present application updates the download record of the file when downloading the file, where the download record includes a download status, and the resource loader may directly determine the second file according to the download status of each file.
On the basis of the foregoing embodiments, as an alternative embodiment, when the first application is a resource loader, determining and executing a processing policy of the first file further includes:
carrying out integrity and accuracy check on the downloaded first file;
if the verification is passed, the first file is reserved;
if the verification is not passed, deleting the first file and re-downloading the first file.
After each first file is downloaded, the resource loading program of the application carries out integrity and accuracy check on the first file, wherein the integrity check is to check whether the first file downloads complete content or not, and the accuracy check is to check whether the data of the first file is standard or not and carry out corresponding logic processing on wrong information, such as non-empty judgment, whether values are in an enumeration/data dictionary range, whether the data meet related regular expression rules or not, and the like.
If the first file passes the integrity and accuracy check, the first file is reserved, the downloading state of the first file is updated to be downloaded, and after all files of the resource are downloaded, the resource is loaded. If the first file does not pass any one of the integrity and accuracy checks, deleting the first file and re-downloading the first file, and updating the downloading state of the first file into downloading and updating the downloading progress when the first file is re-downloaded.
In the related art, when an application distribution program downloads a resource, if a user starts a resource loading program when the resource is not downloaded, verification is not passed because the resource downloaded by the application distribution program is incomplete, and then the application distribution program downloads files again, so that flow waste is caused.
On the basis of the above embodiments, as an alternative embodiment, when the download subject is a resource loader, the method is specifically executed by a target SDK in the resource loader.
It should be noted that, the target SDK in the embodiment of the present application is an SDK built in the resource loader. When the resource loader is started, the resource loader initializes the target SDK, and the target SDK pulls configuration information of the resource to a server of the resource loader.
In some embodiments, the target SDK determines to instruct the second application to pause downloading resources only if any of the following conditions are met, determines the first files, and determines a download record for each of the first files by the second application. The conditions of the embodiment of the application include:
condition 1: the first application program calls a target SDK;
condition 2: the second application program calls the target SDK;
condition 3: the target SDK senses that the first application program is in an operating state in which the load of the terminal is smaller than a preset threshold value.
From the above three conditions, when the target SDK is called by the first application program or the second application program, the second application program is instructed to pause the downloading resource, and the first files and the downloading records of the second application program to each first file are determined.
In some embodiments, the time when the resource loader of the embodiment of the present application calls the target SDK may be a non-core scene when the host process of the resource loader detects that the current running scene of the program is a non-core scene or a scene with low requirements on terminal performance and bandwidth flow, and taking the resource loader as an example of a game application program, when the current running scene of the resource loader is a scene with many static virtual objects such as a game hall, a game store, etc., the resource loader is determined to be in a non-core scene, which is also a scene with low requirements on terminal performance and bandwidth flow.
In some embodiments, the resource loader has a service interface built therein for binding communication by other processes, and when the resource loader is not running in the terminal or the load of the terminal is small, other processes, such as the second application, can call the target SDK through the binding service interface.
It should be noted that, in some embodiments, the target SDK may sense a current running scenario of the first application or sense a load of the terminal, and determine that the second application pauses the downloading resource when sensing that the first application is in a running state where the load of the terminal is less than a preset threshold, and determine the first file and a downloading record of the first file by the second application.
In some embodiments, when the target SDK senses that the first application is in an operating state in which the terminal load is less than the preset threshold, the target SDK starts downloading the resources, and when the target SDK senses that the first application is no longer in an operating state in which the terminal load is less than the preset threshold, the target SDK automatically pauses downloading the resources, thereby reducing the peak value of the terminal load.
Referring to fig. 4, an interaction diagram of a first application program according to an embodiment of the present application when the first application program is a resource loader is shown, where the interaction flow includes:
s401, a user clicks an icon of a resource loader on the terminal, the resource loader is opened, and the resource loader initializes a target SDK in an initialization stage. In the initialization process, the target SDK pulls configuration information of the resource from a server of the resource loader, wherein the configuration information comprises identifiers and download addresses of all files of the resource;
s402, a server of the resource loader returns configuration information of resources to a target SDK;
s403, the target SDK starts pre-downloading, and the target SDK filters files (namely second files) which are already downloaded and exist in the private directory of the resource loader, and only downloads files (namely first files) which are not started to be downloaded or are partially downloaded.
S404, obtaining a download record of the first file from the application distribution program through a ContentProvider mechanism, wherein for each first file, the download record of the first file is divided into the following cases according to the application distribution program and the resource loader:
case one: the application distribution program does not download the first file: the target SDK directly starts the downloading process of the first file, or if the target SDK has downloaded a part of the first file, starting breakpoint continuous transmission at the moment, and continuing to download subsequent contents according to the downloading progress of the first file.
And a second case: the application distribution program has downloaded the first file, and the target SDK moves the file to the private directory of the resource loader through a ContentProvider mechanism and remains after verification passes.
And a third case: the target SDK moves the part of the first file downloaded by the application distribution program to the private directory of the resource loading program through a ContentProvider mechanism, and meanwhile, the downloading progress of the application distribution program to the first file is also known. At this time, the target SDK may be discussed in terms of whether the resource loader begins to pre-download the first file, as follows:
Case one, the resource loader has already begun to pre-download the first file: and merging the files according to the downloading progress of the first file by the resource loading program and the application distribution program, and continuing downloading at the latest breakpoint of the new file after merging.
In case two, the resource loader has not yet started pre-downloading the file: and directly carrying out breakpoint continuous transmission on the basis of the downloading progress of the application distribution program, continuously downloading the byte data after the breakpoint, and writing the byte data into the file.
On the basis of the above embodiments, when the download subject, that is, the first application program is an application distribution program, determining, according to the download records of the first application program and the second application program on the first file, a processing policy of the first file includes:
determining a processing strategy of the first file as follows according to the download state of the second application program to the first file in the process of downloading:
if the downloading progress of the first application program to the first file is not greater than the downloading progress of the second application program to the first file, deleting the part of the first application program to download the first file, and continuing to download the first file according to the downloading progress of the second application program to the first file;
If the downloading progress of the first application program to the first file is larger than the downloading progress of the second application program to the first file, continuing to download the first file according to the downloading progress of the first application program to the first file.
When the download subject is an application distribution program, if for a first file, both applications download portions of the first file, the processing policy of the first file is determined by comparing the sizes of the download progress of the first file by the two applications.
For example, if the total byte data size of a certain first file is 200 bytes and the downloading progress of the resource loader is 1 st to 140 th bytes, if the downloading progress of the application distribution program is less than 140 th bytes, for example, 1 st to 100 th bytes, the application distribution program deletes the part of the first file downloaded by itself, and then continues to download from 141 th bytes; if the progress of the application distribution program download is greater than 140 bytes, such as 1 st to 150 th bytes, the application distribution program deletes the portion of the first file downloaded by itself and then continues the download starting from 151 th byte.
It should be noted that, when the first application program downloads the first file, the downloading progress of the first file is updated in real time, and when the downloading progress reaches 100%, that is, it is determined that the entire content of the first file has been downloaded, then the downloading state of the first file needs to be updated from downloading to downloading.
On the basis of the above embodiments, when the download subject, that is, the first application program is an application distribution program, determining a download record of the first file by the second application program includes:
transmitting a first request to the second application program by using a ContentProvider mechanism, wherein the first request comprises a file identifier of at least one file of the resource, and the first request is used for requesting a download record of the file of the corresponding file identifier;
and determining the first file and the download record of the second application program on the first file according to the download record of the file corresponding to the file identifier returned by the second application program.
The application distribution program of the embodiment of the application utilizes the ContentProvider mechanism to send a first request to a second application program, namely a resource loading program, wherein the first request comprises a file identifier of at least one file of a resource, the first request is used for requesting the resource loading program to return a downloading record of the file with the corresponding file identifier, and the downloading record comprises the downloading state of the resource loading program to each file, so that the downloading record of the file with the corresponding file identifier returned by the resource loading program can know which files are downloaded by the resource loading program and which files are downloaded by the resource loading program or are not downloaded by the resource loading program, thereby determining the downloading record of the first file and the second application program to the first file.
Referring to fig. 5, an interaction diagram of a first application program according to an embodiment of the present application when the first application program is an application distribution program is shown, where the interaction flow includes:
s501, uploading configuration information of resources to a server of an application distribution program by a resource developer;
s502, when the application distribution program senses that the terminal load is smaller than a preset threshold value, the application distribution program acquires configuration information from a server of the application distribution program;
s503, traversing configuration information by the application distribution program, inquiring a download record of each file from a target SDK of the resource loader, and assuming that the file traversed currently is a file A (other files in a file list are also similar to the description processing A of the file A). The following 3 cases can be discussed according to different download states of the file a returned by the target SDK:
a. file a has been downloaded in the resource loader: the application distribution program directly skips the pre-download of the file;
b. file a does not open a download in the resource loader: the application distribution program directly starts downloading the file A, and the downloading at this time can be the breakpoint continuous transmission of the application distribution program to the file A, namely, the file A which is not downloaded last time by the application distribution program is continuously downloaded.
c. File a is downloaded to a portion in the resource loader: the application distribution program starts breakpoint continuous transmission according to the returned file downloading record, and downloads file contents after the breakpoint, and the application distribution program further comprises two conditions:
c1. if the downloading progress of the first application program to the first file is not greater than the downloading progress of the second application program to the first file, deleting the part of the first application program to download the first file, and continuing to download the first file according to the downloading progress of the second application program to the first file;
c2. if the downloading progress of the first application program to the first file is larger than the downloading progress of the second application program to the first file, continuing to download the first file according to the downloading progress of the first application program to the first file.
It should be noted that, the application distribution program in the embodiment of the present application can sense the operation load of the terminal, so that when the operation load of the terminal is sensed to be smaller than the preset threshold, the method for pre-downloading the execution resource of the first application program starts.
In some embodiments, considering that the resources are finally used (i.e. loaded) by the resource loader, when the application distribution program senses that the first application program is downloading the resources, even if the operation load of the terminal is sensed to be smaller than the preset threshold value, the first application program is not instructed to pause downloading the resources, but the first application program waits for the first application program to pause downloading the resources autonomously, and then a sufficient pre-downloading flow is started.
Referring to fig. 6, an architecture diagram of a pre-download scenario of a game resource according to the present application is shown, that is, the resource according to the embodiment of the present application is a game resource, and the resource loader is a game application, and in some embodiments, the resource loader may also have a non-game application with a game function, such as a chat application, an audio/video playing application, a news information application, a browser application, and so on.
The system architecture of the embodiment of the application relates to a game performance improvement (Game Performance Amelioration, GPA) platform 601, wherein the GPA platform 601 focuses on the performance optimization work of a game, and a unified performance optimization scheme is established by cooperation with each terminal manufacturer. GPA realizes unified game performance solution by deeply analyzing game scenes, wherein the upper layer is in unified butt joint with each game, and the bottom layer is in butt joint with different manufacturers.
In the embodiment of the present application, the GPA platform 601 can update the game resources periodically or aperiodically according to the higher requirements of the player on the image quality and the frame rate, so as to meet the requirements of the player on the performance experience. After developing new resources for the game, GPA platform 601 issues the resources to game server 603 and store server 604, respectively. The game server 603 is a server for providing services to the game program 6021, and specific services may include game version update, network access, game data loading, and the like. Store server 604 allows end users to download and update applications that include resources of an update application (e.g., game program 6021), and in some embodiments, updating the resources of the game via store server 604 may also provide personalized rewards to players.
The terminal 602 used by the player loads at least the client of the game program 6021 and the application distribution program 6022, which is the client of the application store. In the embodiment of the present application, for convenience of description, the resource illustratively includes 2 files: file 1 and file 2, the first download subject is a game program, and the overall pre-download process may include:
the game program 6021 obtains configuration information of the resource from the game server 603, the configuration information including file identifications of the file 1 and the file 2 and download addresses at the resource database 604;
the game program 6021 determines the file 1 and the file 2 as the first file, determines that the application distribution program 6022 pauses the downloading of the resource and determines the downloading record of the application distribution program 6022 to the first file, and obviously, the application distribution program does not download the two files at this time;
the game program 6021 starts to download the file 1 and the file 2 simultaneously, creates download records of the file 1 and the file 2, and updates download progress of the file 1 and the file 2 in real time as the file 1 and the file 2 are downloaded;
the game program 6021 stops downloading the file 1 and the file 2 due to being closed by the user, the download progress at the time of stopping downloading the file 1 is 50%, and the download progress of the file 2 is 30%;
After a period of time has elapsed, the application distribution program 6022 starts a pre-download flow, and the application distribution program 6022 obtains configuration information of the resource from the store server 604, the configuration information including file identifiers of the file 1 and the file 2 and a download address;
the application distribution program 6022 instructs the game program 6021 to pause the download resource and determines that the game program 6021 has not completed any one of the files yet, and the application distribution program 6022 continues the download from 50% of the download progress for the file 1 and from 30% of the download progress for the file 1;
the application distribution program 6022 stops downloading the file 1 and the file 2 for some reason, the download progress at the time of stopping downloading the file 1 is 70%, and the download progress of the file 2 is 100%;
after a period of time, the game program 6021 starts a pre-downloading flow, the game program 6021 instructs the application distribution program 6022 to pause downloading resources for the file 1, firstly, the part of the application distribution program 6022 downloaded for the file 1 is moved to a preset storage position, then the part of the application distribution program 6022 downloaded for the file 1 is combined with the part of the application distribution program 6022 downloaded for the file 1, the file with 70% of downloading progress is obtained, then the downloading is continued from 70% of downloading progress, and the game program 6021 directly moves the file 2 to the preset storage position for the file 2;
After a period of time has elapsed, the application distribution program 6022 switches again to the download subject, instructing the game program 6021 to pause downloading of the resource for the file 1, at which time the progress of downloading of the file 1 by the game program 6021 is 90%, and the application distribution program continues to download from 90% to completion;
after a period of time, the game program 6021 switches to the download subject again, and the application distribution program downloads the portion of the first file: the progress is moved to a preset storage position by 90% -100% of data content, then the parts of the first file downloaded last time are combined to obtain a complete first file, the game program checks the first file and the second file, and after the check is passed, game resources are loaded, so that players can experience new versions of games in time.
When a player plays a new version of game, the game program 6021 collects running data of the terminal in real time, such as a frame rate, a CPU occupation rate, a game duration and the like, and when the player is idle, the running data is fed back to the GPA platform 601, so that an operator of the GPA platform 601 can further optimize the game program 6021 according to load information.
The embodiment of the application provides a device for pre-downloading resources, which is applied to a first application program, wherein the resources comprise at least one file, and as shown in fig. 7, the device for pre-downloading the resources can comprise: a file determination module 701, and a policy determination module 702, wherein,
A file determining module 701, configured to determine, when the second application program pauses downloading the resource, a download record of the first file by the first application program and the second application program;
the policy determining module 702 is configured to determine an execution policy of the first file according to a download record of the first application program and the second application program to the first file.
The device of the embodiment of the present application may perform the method provided by the embodiment of the present application, and its implementation principle is similar, and actions performed by each module in the device of the embodiment of the present application correspond to steps in the method of the embodiment of the present application, and detailed functional descriptions of each module of the device may be referred to the descriptions in the corresponding methods shown in the foregoing, which are not repeated herein.
Compared with the related art, the method for pre-downloading the resources is executed by the first application program, the first application program can be applied to the resource loading program and the application distribution program, the switching of the downloading main body can be carried out at any time, the purposes of interaction of the downloading records of the first application program and the second application program on the first file are achieved by determining the second application program to pause the downloading resources and determining the downloading records of the first file and the second application program, and the processing strategy of the first file is determined based on the downloading records of the first file by the two application programs respectively.
In an alternative embodiment, there is provided an electronic device, as shown in fig. 8, the electronic device 4000 shown in fig. 8 includes: a processor 4001 and a memory 4003. Wherein the processor 4001 is coupled to the memory 4003, such as via a bus 4002. Optionally, the electronic device 4000 may further comprise a transceiver 4004, the transceiver 4004 may be used for data interaction between the electronic device and other electronic devices, such as transmission of data and/or reception of data, etc. It should be noted that, in practical applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 is not limited to the embodiment of the present application.
The processor 4001 may be a CPU (Central Processing Unit ), general purpose processor, DSP (Digital Signal Processor, data signal processor), ASIC (Application Specific Integrated Circuit ), FPGA (Field Programmable Gate Array, field programmable gate array) or other programmable logic device, transistor logic device, hardware components, or any combination thereof. Which may implement or perform the various exemplary logic blocks, modules and circuits described in connection with this disclosure. The processor 4001 may also be a combination that implements computing functionality, e.g., comprising one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
Bus 4002 may include a path to transfer information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus or an EISA (Extended Industry Standard Architecture ) bus, or the like. The bus 4002 can be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in fig. 8, but not only one bus or one type of bus.
Memory 4003 may be, but is not limited to, ROM (Read Only Memory) or other type of static storage device that can store static information and instructions, RAM (Random Access Memory ) or other type of dynamic storage device that can store information and instructions, EEPROM (Electrically Erasable Programmable Read Only Memory ), CD-ROM (Compact Disc Read Only Memory, compact disc Read Only Memory) or other optical disk storage, optical disk storage (including compact discs, laser discs, optical discs, digital versatile discs, blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store a computer program and that can be Read by a computer.
The memory 4003 is used for storing a computer program for executing an embodiment of the present application, and is controlled to be executed by the processor 4001. The processor 4001 is configured to execute a computer program stored in the memory 4003 to realize the steps shown in the foregoing method embodiment.
Embodiments of the present application provide a computer readable storage medium having a computer program stored thereon, which when executed by a processor, implements the steps of the foregoing method embodiments and corresponding content.
The embodiment of the application also provides a computer program product, which comprises a computer program, wherein the computer program can realize the steps and corresponding contents of the embodiment of the method when being executed by a processor.
The terms "first," "second," "third," "fourth," "1," "2," and the like in the description and in the claims and in the above figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate, such that the embodiments of the application described herein may be implemented in other sequences than those illustrated or otherwise described.
It should be understood that, although various operation steps are indicated by arrows in the flowcharts of the embodiments of the present application, the order in which these steps are implemented is not limited to the order indicated by the arrows. In some implementations of embodiments of the application, the implementation steps in the flowcharts may be performed in other orders as desired, unless explicitly stated herein. Furthermore, some or all of the steps in the flowcharts may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or phases may be performed at the same time, or each of these sub-steps or phases may be performed at different times, respectively. In the case of different execution time, the execution sequence of the sub-steps or stages can be flexibly configured according to the requirement, which is not limited by the embodiment of the present application.
The foregoing is only an optional implementation manner of some implementation scenarios of the present application, and it should be noted that, for those skilled in the art, other similar implementation manners based on the technical ideas of the present application are adopted without departing from the technical ideas of the scheme of the present application, which also belongs to the protection scope of the embodiments of the present application.

Claims (17)

1. A method of pre-downloading a resource, the resource comprising at least one file, for application to a first application, the method comprising:
when the second application program pauses downloading the resource, determining the downloading records of the first application program and the second application program to the first file;
determining an execution strategy of the first file according to the download records of the first application program and the second application program on the first file;
the first file is a file except a second file in the resource, and the second file is a file downloaded by a resource loader.
2. The method of claim 1, wherein the download record includes at least one of a download status and a download progress;
wherein, the download status is not downloaded, in download or already downloaded.
3. The method according to claim 1 or 2, wherein the processing policy of the first file comprises at least one of:
downloading the first file when the downloading states of the first application program and the second application program to the first file are not downloaded;
and when the downloading state of the first application program to the first file is in downloading, and the downloading state of the second application program to the first file is not in downloading, continuing to download the first file according to the downloading progress of the first application program to the first file.
4. A method according to any of claims 1-3, wherein the first application is a resource loader and the second application is an application distribution program for application distribution.
5. The method of claim 4, wherein the processing policy of the first file further comprises at least one of:
when the download states of the first application program and the second application program to the first file are in the downloading process, continuing to download the parts except the reference part in the first file, wherein the reference part is the merging result of the downloaded parts of the first application program and the second application program;
when the downloading state of the first application program to the first file is not downloaded, and the downloading state of the second application program to the first file is downloaded, moving the downloaded first file to a preset storage position of the first application program;
and when the downloading state of the first application program to the first file is not downloaded and the downloading state of the second application program to the first file is in the downloading process, moving the part of the first file downloaded by the second application program to the preset storage position, and continuing to download the first file according to the downloading progress of the second application program to the first file.
6. The method of claim 5, wherein the step of determining the position of the probe is performed,
when the first part and the second part do not have coincident content, the combination result of the downloaded part is the result of splicing the first part and the second part;
when the first part and the second part have coincident content, the combination result of the downloaded part is the result of splicing the third part and the fourth part;
the first part is a part of the first file downloaded by the first application program, and the second part is a part of the first file downloaded by the second application program;
the third part is one part of the first part and the second part, the part remained after the superposition of the first part and the second part is deleted, and the fourth part is the other part of the first part and the second part.
7. The method according to any of claims 4-6, wherein the first file is determined by:
determining the second file according to the download record of each file;
and taking the identification except the file identification of the second file in the configuration information of the resource as the identification of the first file.
8. The method according to any one of claims 4-7, further comprising:
executing the execution strategy to obtain a first file with a downloaded state;
carrying out integrity and accuracy check on the downloaded first file;
if the verification is passed, the downloaded first file is reserved;
if the verification is not passed, deleting the downloaded first file and re-downloading the first file.
9. The method as recited in claim 8, further comprising:
and if all the files of the resource are downloaded and all the files pass the verification, loading the resource.
10. The method according to any of claims 4-9, wherein determining a download record of the first file by the second application program comprises:
obtaining configuration information of the resource, wherein the configuration information comprises file identifiers of all files in the resource;
and determining the download record of the second application program to the first files with corresponding identifications to the second application program according to the file identifications of the first files by using a cross-program data sharing mechanism.
11. The method of any of claims 4-10, performed by a target SDK in the resource loader;
The determining the download records of the first application program and the second application program to the first file further comprises determining that at least one of the following conditions is met:
the first application program calls the target SDK;
the second application program calls the target SDK;
and the target SDK senses that the first application program is in an operation state that the load of the terminal where the first application program is positioned is smaller than a preset threshold value.
12. A method according to any of claims 1-3, wherein the first application is the application distribution program and the second application is the resource loader.
13. The method of claim 12, wherein the processing policy of the first file further comprises:
the downloading states of the first application program and the second application program to the first file are in downloading, the downloading progress of the first application program to the first file is not greater than the downloading progress of the second application program to the first file, the part of the first application program, which downloads the first file, is deleted, and the first file is continuously downloaded according to the downloading progress of the second application program to the first file;
The downloading states of the first application program and the second application program to the first file are in downloading, the downloading progress of the first application program to the first file is larger than the downloading progress of the second application program to the first file, and the first file is continuously downloaded according to the downloading progress of the first application program to the first file.
14. The method according to claim 12 or 13, wherein determining a download record of the first file by the second application program comprises:
transmitting a first request to the second application program by using a cross-program data sharing mechanism, wherein the first request comprises a file identifier of at least one file of the resource, and the first request is used for requesting a download record of the file of the corresponding file identifier;
and determining the download record of the first file according to the download record of the file identified by the corresponding file returned by the second application program.
15. A pre-download apparatus for a resource, the resource comprising at least one file, applied to a first application, the apparatus comprising:
the file determining module is used for determining the downloading records of the first application program and the second application program to the first file when the second application program pauses downloading the resource;
The strategy determining module is used for determining an execution strategy of the first file according to the download records of the first application program and the second application program on the first file;
the first file is a file except a second file in the resource, and the second file is a file downloaded by a resource loader.
16. An electronic device comprising a memory, a processor and a computer program stored on the memory, characterized in that the processor executes the computer program to carry out the steps of the method of any one of claims 1-14.
17. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1-14.
CN202311246378.5A 2023-06-02 2023-06-02 Resource pre-downloading method and device, electronic equipment and storage medium Pending CN117061594A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311246378.5A CN117061594A (en) 2023-06-02 2023-06-02 Resource pre-downloading method and device, electronic equipment and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202310649552.4A CN116405540B (en) 2023-06-02 2023-06-02 Resource pre-downloading method and device, electronic equipment and storage medium
CN202311246378.5A CN117061594A (en) 2023-06-02 2023-06-02 Resource pre-downloading method and device, electronic equipment and storage medium

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202310649552.4A Division CN116405540B (en) 2023-06-02 2023-06-02 Resource pre-downloading method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117061594A true CN117061594A (en) 2023-11-14

Family

ID=87014515

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202310649552.4A Active CN116405540B (en) 2023-06-02 2023-06-02 Resource pre-downloading method and device, electronic equipment and storage medium
CN202311246378.5A Pending CN117061594A (en) 2023-06-02 2023-06-02 Resource pre-downloading method and device, electronic equipment and storage medium

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202310649552.4A Active CN116405540B (en) 2023-06-02 2023-06-02 Resource pre-downloading method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (2) CN116405540B (en)

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004355585A (en) * 2003-03-31 2004-12-16 Culture Com Technology Macao Ltd File downloading method and system
CN102164317A (en) * 2011-02-14 2011-08-24 上海高智科技发展有限公司 Internet protocol (IP) set-top box-oriented multi-server segmented downloading system
CN109167820A (en) * 2018-08-13 2019-01-08 彩讯科技股份有限公司 A kind of method for down loading of application program, device, storage medium and terminal
CN110247985B (en) * 2019-06-28 2022-06-03 北京奇艺世纪科技有限公司 Resource downloading method and device, electronic equipment and medium
CN111352633B (en) * 2020-02-24 2020-12-11 腾讯科技(深圳)有限公司 Resource downloading method and device of application program, terminal and storage medium
CN113395353B (en) * 2021-06-30 2022-08-02 北京字节跳动网络技术有限公司 File downloading method and device, storage medium and electronic equipment
CN117331576A (en) * 2023-03-03 2024-01-02 腾讯科技(深圳)有限公司 Application pre-download method, device, computer and storage medium

Also Published As

Publication number Publication date
CN116405540A (en) 2023-07-07
CN116405540B (en) 2023-08-04

Similar Documents

Publication Publication Date Title
CN110489382B (en) Processing method, system and storage medium for cloud mobile phone game progress data
US7698223B2 (en) Pluggable file-based digital rights management API layer for applications and engines
CN102685729B (en) For moving the background transfer services of the application in equipment
CN100463549C (en) Method for down loading network resource using mobile terminal
CN110096302B (en) Software data storage and upgrading method, device, equipment and storage medium
WO2015062399A1 (en) Cloud service platform middleware and cloud uploading method
KR102087526B1 (en) Method and apparatus, device and storage medium for data processing between terminals
US20170168807A1 (en) Method and electronic device for updating application program
US20230084369A1 (en) Configuration updating method and apparatus, device and storage medium
CN109167820A (en) A kind of method for down loading of application program, device, storage medium and terminal
CN108399331A (en) Application process trial method and system
US20170163787A1 (en) Method and electronic device for upgrading or downgrading system
CN114139135B (en) Equipment login management method, device and storage medium
CN114501134B (en) iOS cross-page video playing method, device, equipment and storage medium
CN106934272B (en) Application information verification method and device
CN112202834A (en) Data processing method, data processing device and node server
CN115039082A (en) Log writing method and device, electronic equipment and storage medium
CN109766317B (en) File deletion method, device, equipment and storage medium
CN116405540B (en) Resource pre-downloading method and device, electronic equipment and storage medium
CN107305608A (en) The management method and device of terminal device
US11481142B2 (en) Method and device for downloading resources
CN115878138A (en) Application pre-downloading method and device, computer and storage medium
CN112915545A (en) Data processing method and system
CN108733805B (en) File interaction method, system, computer equipment and storage medium
WO2021102849A1 (en) Resource acquisition method and apparatus, and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination