Abnormity recovery method, abnormity recovery device and mobile terminal
Technical Field
The present application belongs to the field of data processing technologies, and in particular, to an exception recovery method, an exception recovery apparatus, a mobile terminal, and a computer-readable storage medium.
Background
Currently, after downloading an installation package of an application, application distribution software (such as a software store) verifies the integrity of the installation package. In the existing method, a hash algorithm is often adopted at a server side in advance to calculate a check value of an installation package, and after downloading is completed, a client side judges the integrity of the downloaded installation package by using the check value. Generally speaking, the check value is used to check the integrity of the entire installation package, and if the check is successful, the installation is performed, and if the check is failed, the entire installation package needs to be downloaded again, which results in consumption of traffic.
Disclosure of Invention
The application provides an exception recovery method, an exception recovery device, a mobile terminal and a computer readable storage medium, so that when a downloaded file is abnormal, only the abnormal segment is selectively downloaded again, full downloading is not needed any more, and consumption of flow is avoided.
A first aspect of the present application provides an exception recovery method, including:
after a file is obtained through downloading of a node of a content distribution network, whether an abnormal segment exists in the file is detected;
when the abnormal fragment exists in the file, the current network connection state of the mobile terminal is obtained;
if the current network connection state of the mobile terminal is not matched with a preset state, updating the network of the mobile terminal based on the preset state;
after the network of the mobile terminal is updated or if the current network connection state is matched with the preset state, a retransmission request is sent to the node based on the abnormal segment so as to download the segment corresponding to the abnormal segment again;
and replacing the corresponding abnormal segment by the downloaded segment to recover the abnormal segment.
A second aspect of the present application provides an abnormality recovery apparatus including:
the system comprises an abnormality detection unit, a content distribution unit and a content distribution unit, wherein the abnormality detection unit is used for detecting whether an abnormal segment exists in a file after the file is downloaded through a node of a content distribution network;
the state acquisition unit is used for acquiring the current network connection state of the mobile terminal when the abnormal fragment exists in the file;
a network updating unit, configured to update a network of the mobile terminal based on a preset state if a current network connection state of the mobile terminal is not matched with the preset state;
a segment retransmission unit, configured to initiate a retransmission request to the node based on the abnormal segment to download a segment corresponding to the abnormal segment again after the network of the mobile terminal is updated or if the current network connection state matches the preset state;
and the segment replacing unit is used for replacing the corresponding abnormal segment by the re-downloaded segment so as to recover the abnormal segment.
A third aspect of the present application provides a mobile terminal comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method according to the first aspect when executing the computer program.
A fourth aspect of the present application provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of the first aspect as described above.
A fifth aspect of the application provides a computer program product comprising a computer program which, when executed by one or more processors, performs the steps of the method as described in the first aspect above.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic flowchart of an implementation flow of an exception recovery method provided in an embodiment of the present application;
fig. 2 is a schematic structural diagram of an installation package with a signature version of a second version v2 in the exception recovery method provided in the embodiment of the present application;
fig. 3 is a block diagram of an exception recovery apparatus according to an embodiment of the present application;
fig. 4 is a schematic diagram of a mobile terminal provided in an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
In order to explain the technical solution of the present application, the following description will be given by way of specific examples.
Example 1
Referring to fig. 1, a method for recovering an exception provided in an embodiment of the present application is described below, where the method for recovering an exception includes:
in step 101, after a file is downloaded through a node of a content distribution network, detecting whether an abnormal segment exists in the file;
in this embodiment of the present application, the mobile terminal may establish a connection with any available node of the content distribution network to download a required file, where the file may be an installation package of an application, or may also be a picture, a video, an audio, or the like, and the type of the file is not limited here. After the file is downloaded, whether the file has an abnormal segment or not can be detected, so that the integrity of the file can be checked.
Optionally, when the file is an installation package of an application, considering that the installation package of the current android application has two different signature modes, a signature version of the installation package may be obtained first, and then whether an abnormal fragment exists in the installation package may be detected based on the signature version of the installation package. The description of the signature version of the installation package is provided first: the signed versions of the installation package of the android application comprise a first version v1 and a second version v2, wherein the first version is a universal signed version, and specifically is used for signing jar; while the second version can only be used on android7.0 (android7.0) and above, which specifically signs the entire apk installation package. That is, the first version may be considered to be decompressing file contents in the archive file, while the second version is computed and verified over the binary contents of the entire apk installation package.
Based on this, in an application scenario, if the signature version of the installation package is the first version, whether an abnormal segment exists in the installation package may be detected based on a Cyclic Redundancy Check (CRC), including:
a1, analyzing the installation package, and reading a target cyclic redundancy check value of each subfile contained in the installation package;
a2, calculating the real cyclic redundancy check value of each subfile based on the analyzed installation package;
and A3, determining whether the installation package has abnormal fragments according to the target cyclic redundancy check value and the real cyclic redundancy check value of each subfile.
The installation package is a compressed file obtained by compressing files related to android applications, such as executable files (dex files), manifest files, resource files and the like, so that the installation package can be analyzed as the compressed file to obtain sub-files compressed by the installation package, and a target CRC of each sub-file carried by the installation package is read; then, calculating the real CRC of each subfile based on the analyzed installation package; if the target CRC and the real CRC of one subfile are not consistent, recording the starting position and the ending position of the subfile in the installation package; and traversing all subfiles contained in the installation package based on the comparison mode, so that all subfiles with abnormity can be screened out. In this embodiment of the present application, in order to avoid false detection of an abnormal segment, when N sub-files with abnormalities continuously appear (N is a preset value, for example, N may be 3), or when a ratio of a size occupied by all sub-files with abnormalities in the installation package to a total size of the installation package reaches a preset ratio (for example, 50%), it is determined that abnormal segments exist in the installation package, and the sub-files with abnormalities are determined as abnormal segments.
The following is illustrated by way of an example: if the signature version adopted by the downloaded installation package apk1 is the first version v1, analyzing the apk1 to obtain subfiles 1, 2, 3 and n; supposing that all subfiles 1, 2 and 3 are subfiles with abnormality through comparison of the target CRC and the real CRC, it can be known that 3 subfiles with abnormality continuously appear, at this time, it can be determined that the installation package apk1 has an abnormal fragment, and the subfiles 1, 2 and 3 are determined as abnormal fragments; or, assuming that the subfile 3 and the subfile n are subfiles with abnormality, and detecting that the size of the subfile 3 and the subfile n in the installation package apk1 is 20 m (that is, the compressed subfile 3 and the subfile n are 20 m), and the total size of the installation package apk1 is 30 m, it is determined that the ratio of the size of all subfiles with abnormality in the installation package to the total size of the installation package is 66.7%, and a preset ratio is reached, at this time, it may be determined that an abnormal fragment exists in the installation package apk1, and the subfile 3 and the subfile n are determined to be abnormal fragments; or, assuming that the subfiles 1, 2 and n are subfiles with abnormal content, detecting that the size of the subfiles 1, 2 and n in the installation package apk1 is 5 m (that is, the size of the compressed subfiles 1, 2 and n is 5 m), and the total size of the installation package apk1 is 30 m, determining that the ratio of the sizes of all subfiles with abnormal content in the installation package to the total size of the installation package is 16.7%, and the ratio does not reach a preset ratio, and the subfiles 1, 2 and n are discontinuous subfiles, and at this time, determining that the installation package apk1 does not have abnormal content.
In another application scenario, if the signature version of the installation package is the second version, detecting whether an abnormal fragment exists in the installation package based on the hash value includes:
b1, analyzing the installation package, and reading the target hash value of each block divided by the installation package;
b2, calculating the real hash value of each block based on the analyzed installation package;
and B3, determining whether the abnormal segment exists in the installation package according to the target hash value and the real hash value of each block.
Referring to fig. 2, fig. 2 is a schematic structure of an installation package with a signature version of a second version. A common installation package file has three parts, namely a data area, a central directory and a central directory ending record; when the second version is adopted for signature, a part named as an apk signature block is newly added in the installation package. The "apk signature block" precedes and is adjacent to the portion of the "central directory". In addition to the "apk signature block" portion, each of the other portions is split into a plurality of 1 mega continuous blocks, and the last block of each portion may be shorter. When signing is carried out, hash operation is carried out on each block, the hash value of each block is obtained and used as a summary (namely, a target hash value), and the summaries are stored in the apk signature blocks. Based on this, when the signature version of the installation package is the second version, the installation package can be analyzed to read the digest of each block (i.e. the target hash value of each block) stored in the "apk signature block" of the installation package, and at the same time, the real hash value of each block is further calculated, and the target hash value of each block stored in the "apk signature block" is compared with the real hash value of each block obtained by calculation to determine whether the block is abnormal; if the target hash value and the real hash value of a block are not consistent, recording the starting position and the ending position of the block in the installation package; and traversing all the blocks divided by the installation package based on the comparison mode, and screening all the blocks with abnormity. Similarly, in the embodiment of the present application, in order to avoid false detection of an abnormal segment, when N blocks with an abnormality continuously occur (N is a preset value, for example, N may be 3), or when a ratio of a size occupied by all blocks with an abnormality in the installation package to a total size of the installation package reaches a preset ratio (for example, 50%), it is determined that an abnormal segment exists in the installation package, and these blocks with an abnormality are determined as abnormal segments. In fact, since the sizes of the other blocks are fixed except the last block of each part and are all 1 million, the number of the blocks with the abnormality in the installation package may be directly counted, and if the ratio of the number of all the blocks with the abnormality to the total number of all the blocks in the installation package reaches a preset ratio, it may be determined that the abnormal segments exist in the installation package, and the blocks with the abnormality may be determined as the abnormal segments.
The following is illustrated by way of an example: if the signature version adopted by the downloaded installation package apk2 is the first version v2, analyzing the apk2 to obtain the divided blocks 1, 2, 3 to n; supposing that the true hash values of the blocks 1, 2 and 3 to n are obtained through calculation, and the target hash values of the blocks 1, 2 and 3 to n are obtained by reading the 'apk signature blocks' of the apk2, and finding that the blocks 1, 2 and 3 are all abnormal blocks through comparison of the target hash values and the true hash values, and the blocks 1, 2 and 3 all belong to the central directory part, it can be known that 3 abnormal blocks continuously appear at present, at this time, it can be determined that the abnormal segments exist in the installation package apk1, and the blocks 1, 2 and 3 are determined to be abnormal segments; or, assuming that 20 blocks in the installation package are abnormal and the total number of the divided blocks in the installation package is 30, the ratio of the number of all the abnormal blocks to the total number of all the blocks in the installation package may be considered to be 66.7%, and considering that the size of most of the blocks is 1 megabyte, the ratio of the size of all the abnormal blocks in the installation package to the total size of the installation package may also be considered to be about 66.7%, and when the preset ratio is reached, it may be determined that an abnormal fragment exists in the installation package apk2, and all the abnormal blocks are determined to be abnormal fragments.
In step 102, when the file has an abnormal segment, acquiring the current network connection state of the mobile terminal;
in the embodiment of the present application, it is generally assumed that an abnormal segment occurs in a downloaded file when a certain problem exists in the network connection of the mobile terminal. Based on this, when the abnormal segment exists in the file, the current network connection state of the mobile terminal is obtained first, and the current network connection state is matched with the preset state so as to judge whether the network connection of the mobile terminal has a certain problem.
In step 103, if the current network connection state of the mobile terminal does not match a preset state, updating the network of the mobile terminal based on the preset state;
in this embodiment, when the current network connection state of the mobile terminal is not matched with the preset state, the network of the mobile terminal may be updated based on the preset state, so that the updated network connection state of the mobile terminal is matched with the preset state.
In an application scenario, if an abnormal segment may occur in a downloaded file due to a network connected to the mobile terminal, step 102 specifically includes:
if the mobile terminal has access to a wireless local area network currently, detecting whether the wireless local area network is an authentication network;
accordingly, the preset state is a state in which the wlan is a non-authentication network, and the step 103 specifically includes:
and if the wireless local area network is the authentication network, outputting a reminding message to prompt the user to carry out identity authentication.
The authentication network is a network which can be accessed after the user performs identity authentication. When the wireless local area network accessed by the mobile terminal is a non-authentication network, the wireless local area network generally does not influence the downloading quality of the mobile terminal; when the mobile terminal is connected to the authentication network, the user needs to perform authentication operation first, and then the mobile terminal can access the external network through the authentication network. Based on this, whether the wireless local area network is the authentication network or not can be detected, when the wireless local area network is the authentication network, a reminding message can be output, and the user is prompted to perform identity authentication through the reminding message, so that the phenomenon that abnormal fragments occur in file downloading due to the fact that the mobile terminal is connected with the authentication network which is not logged in the downloading process is avoided.
In another application scenario, if an abnormal segment occurs in the downloaded file due to a connection mode between the mobile terminal and the node, the step 102 specifically includes:
detecting whether the mobile terminal establishes connection with the node through an agent;
accordingly, the preset state is a state in which the mobile terminal is directly connected to the node, and step 103 specifically includes:
if the mobile terminal establishes connection with the node through the proxy, the mobile terminal is disconnected from the proxy, and the direct connection between the mobile terminal and the node is reestablished.
When the mobile terminal establishes connection with the node through the proxy, all data sent by the node and received by the mobile terminal depend on the forwarding of the proxy, so that the working state of the proxy directly influences the connection state of the mobile terminal and the node. Based on this, when the abnormal segment exists in the downloaded file, when it is detected that the mobile terminal establishes a connection with the node through the proxy, there is a high possibility that the proxy is unstable and the download quality is affected, so that it is necessary to disconnect the mobile terminal from the proxy first and reestablish a direct connection between the mobile terminal and the node; namely, the mobile terminal is directly connected with the node, data are not forwarded through the proxy any more, and abnormal fragments caused by the instability of the proxy connected with the mobile terminal in file downloading are avoided.
In a third application scenario, if an abnormal segment occurs in the downloaded file due to a connection protocol adopted by the mobile terminal, step 102 specifically includes:
detecting whether the mobile terminal establishes connection with the node through a hypertext transfer protocol;
correspondingly, the preset state is a state in which the mobile terminal establishes a connection with the node through a hypertext transfer security protocol, and step 103 specifically includes:
if the mobile terminal is connected with the node through the hypertext transfer protocol, the mobile terminal is disconnected with the node, and the mobile terminal is reestablished with the node through the hypertext transfer security protocol.
When detecting that the mobile terminal is connected with the node through a hypertext Transfer Protocol (HTTP), the mobile terminal may be switched to a hypertext Transfer security Protocol (hypertext Transfer Protocol over Secure Socket Layer), and all requests initiated by subsequent mobile terminals to the node are HTTPs requests.
It should be noted that the above three application scenarios can be selected and executed as required; alternatively, the operations may be performed in parallel (e.g., sequentially), and are not limited herein.
In step 104, after the network of the mobile terminal is updated or if the current network connection state matches the preset state, a retransmission request is initiated to the node based on the abnormal segment to re-download the segment corresponding to the abnormal segment;
in the embodiment of the present application, if the current network connection state matches the preset state, it is determined that the network connection of the current mobile terminal does not have a problem, and at this time, a retransmission request may be directly initiated to the node based on the abnormal segment. Or, after the network of the mobile terminal is updated, that is, the mobile terminal (in the case that the registered wlan is an authentication network) has registered in the connected authentication network, and the mobile terminal is directly connected to the node, and the mobile terminal establishes an HTTPS connection with the node, at this time, a retransmission request is initiated to the node based on the abnormal segment, so as to download the segment corresponding to the abnormal segment again. Specifically, when the file is an installation package, the mobile terminal records the start and stop positions of the abnormal segments in the installation package, so that the retransmission request initiated by the mobile terminal may carry the start and stop positions of each abnormal segment in the installation package, and the segment corresponding to the abnormal segment is downloaded from the node again through a continuous transmission technology.
In step 105, the corresponding abnormal segment is replaced by the newly downloaded segment, so as to recover the abnormal segment.
In the embodiment of the present application, the segments downloaded again correspond to the abnormal segments in the file one to one, so that the corresponding abnormal segments can be replaced by the segments downloaded again, and after all the abnormal segments in the file are replaced, as long as there is no abnormality in the segments downloaded again, the recovery of the abnormal segments included in the file can be realized. Optionally, after replacing the corresponding abnormal segment by the segment downloaded again, it may further detect whether there is an abnormal segment in the replaced file, and if there is still an abnormal segment in the replaced file, it is considered that a problem may occur in a node of a content distribution network to which the mobile terminal is connected, at this time, a node switching the content distribution network to which the mobile terminal is connected may be selected, and the replaced file is deleted at the same time, and a full download request is initiated to the switched node to download the file again.
Therefore, according to the scheme, the mobile terminal can perform sectional type verification on the downloaded file to screen out the abnormal fragments existing in the file, only the abnormal fragments can be continuously transmitted when the file is recovered through the positions of the abnormal fragments in the file, and full re-downloading is avoided.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Example 2
An embodiment 2 of the present application provides an abnormality recovery apparatus, which may be integrated in a mobile terminal, as shown in fig. 3, an abnormality recovery apparatus 300 in the embodiment of the present application includes:
an anomaly detection unit 301, configured to detect whether an anomalous segment exists in a file after the file is downloaded by a node of a content distribution network;
a state obtaining unit 302, configured to obtain a current network connection state of the mobile terminal when an abnormal segment exists in the file;
a network updating unit 303, configured to update a network of the mobile terminal based on a preset state if a current network connection state of the mobile terminal is not matched with the preset state;
a segment retransmission unit 304, configured to initiate a retransmission request to the node based on the abnormal segment to re-download a segment corresponding to the abnormal segment after the network of the mobile terminal is updated or if the current network connection state matches the preset state;
a segment replacing unit 305, configured to replace the corresponding abnormal segment with the re-downloaded segment, so as to recover the abnormal segment.
Optionally, if the file is an installation package, the abnormality detecting unit 301 includes:
a version acquiring subunit, configured to acquire a signature version of the installation package;
and the abnormity detection subunit is used for detecting whether an abnormal fragment exists in the installation package based on the signature version of the installation package.
Optionally, the abnormality detection subunit includes:
a first detecting subunit, configured to detect, if the signature version of the installation package is a first version, whether an abnormal segment exists in the installation package based on a cyclic redundancy check value;
and the second detection subunit is used for detecting whether the installation package has an abnormal fragment or not based on the hash value if the signature version of the installation package is the second version.
Optionally, the first detecting subunit includes:
a target cyclic redundancy check value reading subunit, configured to parse the installation package, and read a target cyclic redundancy check value of each subfile included in the installation package;
the real cyclic redundancy check value operator unit is used for calculating the real cyclic redundancy check value of each subfile based on the analyzed installation package;
and the abnormal segment first determining subunit is used for determining whether the abnormal segment exists in the installation package according to the target cyclic redundancy check value and the real cyclic redundancy check value of each subfile.
Optionally, the second detecting subunit includes:
a target hash value reading subunit, configured to parse the installation package, and read a target hash value of each block divided by the installation package;
the real hash value operator unit is used for calculating the real hash value of each block based on the analyzed installation package;
and the abnormal segment second determining subunit determines whether the abnormal segment exists in the installation package according to the target hash value and the real hash value of each block.
Optionally, the state obtaining unit 302 is specifically configured to detect whether the wireless local area network is an authentication network if the mobile terminal has currently accessed the wireless local area network, where the authentication network is a network that can only perform network access after performing identity authentication on a user;
correspondingly, the preset state is a state in which the wlan is a non-authentication network, and the network updating unit 303 is specifically configured to output a prompt message to prompt the user to perform identity authentication if the wlan is an authentication network.
Optionally, the state obtaining unit 302 is further configured to detect whether the mobile terminal establishes a connection with the node through an agent;
accordingly, the preset state is a state in which the mobile terminal is directly connected to the node, and the network updating unit 303 is further configured to disconnect the mobile terminal from the proxy and reestablish the direct connection between the mobile terminal and the node if the mobile terminal establishes a connection with the node through the proxy.
Optionally, the state obtaining unit 302 is further configured to detect whether the mobile terminal establishes a connection with the node through a hypertext transfer protocol;
correspondingly, the preset state is a state in which the mobile terminal establishes a connection with the node through a hypertext transfer security protocol, and the network updating unit 303 is further specifically configured to disconnect the mobile terminal from the node and reestablish the connection between the mobile terminal and the node through the hypertext transfer security protocol if the mobile terminal establishes a connection with the node through the hypertext transfer protocol.
Optionally, the abnormality detecting unit 301 is further configured to detect whether there is an abnormal segment in the replaced file;
the above-described abnormality recovery apparatus 300 further includes:
a node switching unit configured to switch a node of a content distribution network to which the mobile terminal is connected if an abnormal segment exists in the replaced file;
a file deleting unit for deleting the replaced file;
and the file downloading unit is used for initiating a full downloading request to the switched node so as to download the file again.
Therefore, according to the scheme, the mobile terminal can perform sectional type verification on the downloaded file to screen out the abnormal fragments existing in the file, only the abnormal fragments can be continuously transmitted when the file is recovered through the positions of the abnormal fragments in the file, and full re-downloading is avoided.
Example 3
An embodiment 3 of the present application provides a mobile terminal, please refer to fig. 4, where the mobile terminal in the embodiment of the present application includes: a memory 401, one or more processors 402 (only one shown in fig. 4), and a computer program stored on the memory 401 and executable on the processors. Wherein: the memory 401 is used for storing software programs and modules, and the processor 402 executes various functional applications and data processing by operating the software programs and units stored in the memory 401, so as to acquire resources corresponding to the preset events. Specifically, the processor 402, by running the above-mentioned computer program stored in the memory 401, implements the steps of:
after a file is obtained through downloading of a node of a content distribution network, whether an abnormal segment exists in the file is detected;
when the abnormal fragment exists in the file, the current network connection state of the mobile terminal is obtained;
if the current network connection state of the mobile terminal is not matched with a preset state, updating the network of the mobile terminal based on the preset state;
after the network of the mobile terminal is updated or if the current network connection state is matched with the preset state, a retransmission request is sent to the node based on the abnormal segment so as to download the segment corresponding to the abnormal segment again;
and replacing the corresponding abnormal segment by the downloaded segment to recover the abnormal segment.
In a second possible implementation manner provided based on the first possible implementation manner, if the file is an installation package, the detecting whether an abnormal fragment exists in the file includes:
acquiring a signature version of the installation package;
and detecting whether the installation package has abnormal fragments or not based on the signature version of the installation package.
In a third possible implementation manner provided as a basis for the second possible implementation manner, the detecting whether an abnormal fragment exists in the installation package based on the signed version of the installation package includes:
if the signature version of the installation package is a first version, detecting whether an abnormal fragment exists in the installation package based on a cyclic redundancy check value;
and if the signature version of the installation package is a second version, detecting whether an abnormal fragment exists in the installation package based on the hash value.
In a fourth possible implementation manner provided as a basis for the third possible implementation manner, the detecting whether an abnormal fragment exists in the installation package based on a cyclic redundancy check value includes:
analyzing the installation package, and reading a target cyclic redundancy check value of each subfile contained in the installation package;
calculating a real cyclic redundancy check value of each subfile based on the analyzed installation package;
and determining whether the installation package has abnormal fragments or not according to the target cyclic redundancy check value and the real cyclic redundancy check value of each subfile.
In a fifth possible implementation manner provided as a basis for the third possible implementation manner, the detecting whether an abnormal fragment exists in the installation package based on the hash value includes:
analyzing the installation package, and reading a target hash value of each block divided by the installation package;
calculating a real hash value of each block based on the analyzed installation package;
and determining whether the abnormal segment exists in the installation package according to the target hash value and the real hash value of each block.
In a sixth possible implementation manner provided on the basis of the first possible implementation manner, the second possible implementation manner, the third possible implementation manner, the fourth possible implementation manner, or the fifth possible implementation manner, the obtaining the current network connection state of the mobile terminal includes:
if the mobile terminal has access to a wireless local area network currently, detecting whether the wireless local area network is an authentication network, wherein the authentication network is a network which can be accessed by a user after identity authentication;
accordingly, the updating the network of the mobile terminal based on the preset state if the current network connection state of the mobile terminal is not matched with the preset state includes:
and if the wireless local area network is the authentication network, outputting a reminding message to prompt the user to carry out identity authentication.
In a seventh possible implementation manner provided on the basis of the first possible implementation manner, the second possible implementation manner, the third possible implementation manner, the fourth possible implementation manner, or the fifth possible implementation manner, the obtaining the current network connection state of the mobile terminal includes:
detecting whether the mobile terminal establishes connection with the node through an agent;
accordingly, the updating the network of the mobile terminal based on the preset state if the current network connection state of the mobile terminal is not matched with the preset state includes:
if the mobile terminal establishes connection with the node through the proxy, the mobile terminal is disconnected from the proxy, and the direct connection between the mobile terminal and the node is reestablished.
In an eighth possible implementation manner provided on the basis of the first possible implementation manner, the second possible implementation manner, the third possible implementation manner, the fourth possible implementation manner, or the fifth possible implementation manner, the acquiring the current network connection status of the mobile terminal includes:
detecting whether the mobile terminal establishes connection with the node through a hypertext transfer protocol;
correspondingly, the aforementioned preset state is a state in which the mobile terminal establishes a connection with the node through a hypertext transfer security protocol, and if the current network connection state of the mobile terminal is not matched with the preset state, the updating of the network of the mobile terminal based on the preset state includes:
if the mobile terminal is connected with the node through the hypertext transfer protocol, the mobile terminal is disconnected with the node, and the mobile terminal is reestablished with the node through the hypertext transfer security protocol.
In a ninth possible implementation manner provided on the basis of the first possible implementation manner, the second possible implementation manner, the third possible implementation manner, the fourth possible implementation manner, or the fifth possible implementation manner, after replacing the corresponding abnormal segment by the re-downloaded segment, the processor 402 further implements the following steps by running the computer program stored in the memory 401:
detecting whether the replaced file has abnormal segments or not;
if the replaced file has an abnormal segment, switching a node of a content distribution network connected with the mobile terminal;
and deleting the replaced file, and initiating a full-amount downloading request to the switched node to download the file again.
Further, as shown in fig. 4, the mobile terminal may further include: one or more input devices 403 (only one shown in fig. 4) and one or more output devices 404 (only one shown in fig. 4). The memory 401, processor 402, input device 403, and output device 404 are connected by a bus 405.
It should be understood that in the embodiments of the present Application, the Processor 402 may be a Central Processing Unit (CPU), and the Processor may be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The input device 403 may include a keyboard, a touch pad, a fingerprint sensor (for collecting fingerprint information of a user and direction information of the fingerprint), a microphone, etc., and the output device 404 may include a display, a speaker, etc.
Memory 401 may include both read-only memory and random-access memory, and provides instructions and data to processor 402. Some or all of memory 401 may also include non-volatile random access memory. For example, the memory 401 may also store device type information.
Therefore, according to the scheme, the mobile terminal can perform sectional type verification on the downloaded file to screen out the abnormal fragments existing in the file, only the abnormal fragments can be continuously transmitted when the file is recovered through the positions of the abnormal fragments in the file, and full re-downloading is avoided.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned functions may be distributed as different functional units and modules according to needs, that is, the internal structure of the apparatus may be divided into different functional units or modules to implement all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art would appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of external device software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described system embodiments are merely illustrative, and for example, the division of the above-described modules or units is only one logical functional division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The integrated unit may be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as a separate product. Based on such understanding, all or part of the flow in the method of the embodiments described above may be implemented by a computer program, which may be stored in a computer readable storage medium and used by a processor to implement the steps of the embodiments of the methods described above. The computer program includes computer program code, and the computer program code may be in a source code form, an object code form, an executable file or some intermediate form. The computer-readable storage medium may include: any entity or device capable of carrying the above-described computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer readable Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signal, telecommunication signal, software distribution medium, etc. It should be noted that the computer readable storage medium may contain other contents which can be appropriately increased or decreased according to the requirements of the legislation and the patent practice in the jurisdiction, for example, in some jurisdictions, the computer readable storage medium does not include an electrical carrier signal and a telecommunication signal according to the legislation and the patent practice.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.