Summary of the invention
Based on this, it is necessary to for above-mentioned technical problem, it is provided that a kind of can realize software mourn in silence upgrading the method for upgrading software based on Android system and device.
A kind of method for upgrading software based on Android system, described method includes:
Obtain and update bag check value;
Verify described renewal bag check value, if being verified, then by updating in the add-on file folder that bag migrates in the application data catalogue that software is corresponding in temporary folder;
Decompressing described renewal bag to obtain updating file, described renewal file includes: local update storehouse, class update file and resource updates file;
Running software attribute adds the store path pointing to local update storehouse;
Software start after store path according to described interpolation, call the local file in local update storehouse;
Class described in dynamic load updates file and resource updates file.
Wherein in an embodiment, class described in described dynamic load updates the step of file and resource updates file and includes:
Update the class file in file by Classloader loading classes, and perform described class file;
Resource file in resource updates file is loaded in resource object, accesses described resource file by described resource object.
Wherein in an embodiment, described renewal bag check value is update the informative abstract value that bag is corresponding, the step of the described renewal bag check value of described checking, including:
Obtain add-on file clip pack under application data catalogue containing informative abstract value corresponding to plug-in unit;
The informative abstract value that informative abstract value corresponding for described plug-in unit is corresponding with updating bag is contrasted one by one;
If being absent from the informative abstract value that the identical plug-in unit of the informative abstract value corresponding with updating bag is corresponding, being then verified, otherwise, checking can't pass.
Wherein in an embodiment, before obtaining renewal bag check value step, described method also includes the step obtaining more new data;Specifically include:
To sending software upgrading request;
Receiving the software update information returned according to described software upgrading request, described software update information includes updating chained address corresponding to bag and updating bag check value;
Described renewal bag check value is preserved to local;
It is downloaded to updating bag in the temporary folder of this locality according to chained address.
Wherein in an embodiment, before the described step that renewal bag is downloaded to local temporary files folder according to chained address, described method also includes:
Detection current network conditions;
Judge whether current network conditions meets pre-conditioned, if so, then enter and be downloaded to updating bag in the step of temporary folder of this locality according to chained address.
A kind of software updating apparatus based on Android system, described device includes:
Check value acquisition module, is used for obtaining renewal bag check value;
Authentication module, is used for verifying described renewal bag check value;
Update bag transferring module, for when authentication module the result be by time, then the bag that updates in temporary folder is migrated to during add-on file in the application data catalogue that software is corresponding presss from both sides;
Updating bag decompression module, be used for decompressing described renewal bag and obtain updating file, described renewal file includes: class updates file, local update storehouse and resource updates file;
Module is added in path, for adding the store path pointing to local update storehouse in running software attribute;
Library file calling module, store path according to described interpolation after starting for software, calls the local file in local update storehouse;
File load module, described in dynamic load, class updates file and resource updates file.
Wherein in an embodiment, file load module includes:
Class file performs module, for being updated the class file in file by Classloader loading classes, and performs described class file;
Resource file access modules, for being loaded in resource object by the resource file in resource updates file, accesses described resource file by described resource object.
Wherein in an embodiment, described renewal bag check value is update the informative abstract value that bag is corresponding, described authentication module be additionally operable to obtain under application data catalogue add-on file clip pack containing informative abstract value corresponding to plug-in unit;The informative abstract value that informative abstract value corresponding for described plug-in unit is corresponding with updating bag is contrasted one by one;If being absent from the informative abstract value that the identical plug-in unit of the informative abstract value corresponding with updating bag is corresponding, being then verified, otherwise, checking can't pass.
Wherein in an embodiment, described device also includes updating data acquisition module, is used for obtaining more new data;The shown data acquisition module that updates includes:
Upgrade request module, for sending software upgrading request;
Information receiving module, for receiving the software update information returned according to described software upgrading request, described software update information includes updating chained address corresponding to bag and updating bag check value;
Check value preserves module, for preserving described renewal bag check value to local;
Update bag download module, for being downloaded to updating bag in the temporary folder of this locality according to chained address.
Wherein in an embodiment, described renewal data acquisition module also includes:
Network detection module, is used for detecting current network conditions;
Network judge module, is used for judging whether current network conditions meets pre-conditioned;
When the judged result of network judge module is for being, then enters and update bag download module.
The above-mentioned method for upgrading software based on Android system and device, it may not be necessary to install and update bag, be modified running software attribute dynamic load can update file after software starts.Owing to amendment running software attribute need not obtain the highest weight limit of Android system, thus this method and device realize the upgrading of mourning in silence to software.
Detailed description of the invention
In order to make the purpose of the present invention, technical scheme and advantage clearly understand, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein is only in order to explain the present invention, is not intended to limit the present invention.
As it is shown in figure 1, in one embodiment, it is provided that a kind of method for upgrading software based on Android system, the method comprises the steps:
Step 101, obtains and updates bag check value.
Step 102, checking updates bag check value.
It is arranged on what the software of Android system was made up of the plug-in unit realizing functional module, software upgrading is also had only to the renewal bag that download plug-in is corresponding, without the software downloading whole redaction, saved the data traffic needed for software upgrading.In the present embodiment, software has saved updating bag check value and being downloaded to local temporary folder by updating bag in server.Update bag check value can be used to judge to identify renewal bag when whether renewal bag is completely downloaded and software starts.If checking updates after bag check value passes through, then show that the renewal bag that plug-in unit is corresponding is successfully downloaded to this locality, upper once start time need to run and update bag.
In one embodiment, updating bag check value is update the informative abstract value that bag is corresponding, step 102, and checking updates bag check value and includes: obtain add-on file clip pack under application data catalogue containing informative abstract value corresponding to plug-in unit;The informative abstract value that informative abstract value corresponding for plug-in unit is corresponding with updating bag is contrasted one by one;If being absent from the informative abstract value that the informative abstract value corresponding with updating bag is identical, being then verified, otherwise, checking can't pass.
In the present embodiment, the informative abstract value that plug-in unit is corresponding refers to and plug-in unit is carried out the character string that digest algorithm obtains.Concrete, informative abstract value is MD5 (_ MessageDigestAlgorithm5, Message Digest 5 the 5th edition), wherein MD5 value stores with the form of key-value pair (key-value), before updating bag download, preserve the MD5 value updating bag correspondence that server returns, after down loading updating bag completes, software can scan after starting has existed the MD5 value that plug-in unit is corresponding, the MD5 value one by one comparison corresponding with updating bag by MD5 value corresponding for plug-in unit, if there is inconsistent MD5 value, then represent in temporary folder that being successfully downloaded to renewal bag needs to run when upper once software starts to update bag.
Step 103, if being verified, by updating in the add-on file folder that bag migrates under the application data catalogue that software is corresponding in temporary folder.
Update bag and refer to the plug-in unit increasing New function into software, or to the plug-in unit that original plug-in unit is upgraded.Add-on file folder is used for program file and resource file essential to storage running plug-in unit.The renewal bag downloaded leaves in temporary folder.Concrete, temporary folder refers to the download folder under the application data catalogue that software is corresponding.If being verified, content in bag can be updated by normal call by updating when bag ensure that running software from the add-on file folder that temporary folder migrates to application data catalogue.
Step 104, decompression updates bag and obtains updating file, updates file and includes: class updates file, local update storehouse and resource updates file.
In the present embodiment, obtain updating file by decompressing the renewal bag that data form is .apk or .jar.Renewal file includes: class updates file, local update storehouse and resource updates file.Class updates in file the program's code file (.Class file or .dex file) comprised and is used for realizing concrete program function.Resource updates file contains except code such as resource files such as picture, word, animation and videos.Local update storehouse comprises the local library file that file format is .so generated after being compiled by c/c++.If updating bag is the upgrading to the existing plug-in unit of software, then renewal file is replaced it the content in the file of front already present same file name.If updating bag is the plug-in unit newly increased, then renewal file is stored under application data catalogue in new folder.
Step 105, adds the store path pointing to local update storehouse in running software attribute.
Step 106, software start after store path according to described interpolation, call the local file in local update storehouse.
Former local library (nativelibrary) for providing public method and interface for running software before software upgrading.Can not be loaded by Classloader owing to updating the local update file in the local update storehouse wrapped, it is necessary to local update file is put in former local library and it could be carried out normal call.But access former local library to need to obtain root authority (the highest weight limit of Android system), in order to the local update file that root authority could be used that in local update storehouse need not be obtained, the operation attribute (java.library.path) of running software adds the store path pointing to local update storehouse.And the operation attribute revising java is to obtain root authority, thus calling local update storehouse during without influence on running software.When needing to use local update storehouse, call the local library file in local update storehouse by the newly added store path pointing to local update storehouse.
Step 107, class described in dynamic load updates file and resource updates file.
In the present embodiment, after receiving running software instruction, dynamically content in renewal file it is loaded into internal memory according to the operation logic of software and performs, change the display of former software or perform logic.Realize the upgrading of mourning in silence to software.
The above-mentioned method for upgrading software based on Android system, it may not be necessary to install and update bag, be modified running software attribute dynamic load can update file after software starts.Owing to amendment running software attribute need not obtain the highest weight limit of Android system, thus this method realizes the upgrading of mourning in silence to software.
Traditional method for upgrading software, downloads complete software upgrading bag, the i.e. software installation files of Android system, legacy version software is replaced with new version software, so that reinstall redaction after uninstalling legacy version on backstage.Installation process needs the operation interrupting user to legacy version.
Method provided by the invention only need to download the renewal bag that the plug-in unit needing upgrading is corresponding.Not by installing renewal bag, only dynamically the content updated in bag is loaded into internal memory when software starts, update bag not install, simply change the plug-in unit of software start-up loading, user is transparent by whole process, not affecting user's operation to software, user is not felt by achieving when upgrading the upgrading of mourning in silence of software.
In one embodiment, step 107, class described in dynamic load updates the step of file and resource updates file and includes: updates the class file in file by Classloader loading classes, and performs class file;Resource file in resource updates file is loaded in resource object, accesses resource file by resource object.
Classloader is responsible for the syllabified code of loading procedure file to java virtual machine so that program file is dynamically loaded in java virtual machine and performs.Such as, it is the class file of .Class/.dex by DexClassLoader (one of Classloader) load document form.The class file updated in bag can be performed.Resource updates file is loaded in Resource object, it is achieved the access to the resource file in resource updates file.
As in figure 2 it is shown, in one embodiment, before step 101, the method also includes the step obtaining more new data, specifically includes as follows:
Step 201, to sending software upgrading request.
Step 202, receives the software update information returned according to software upgrading request, and more fresh information includes updating chained address corresponding to bag and updating bag check value.
Step 203, preserves renewal bag check value to local.
Step 204, is downloaded to updating bag in the temporary folder of this locality according to chained address.
In the present embodiment, software can send software upgrading request from trend server upon actuation, can detect whether there is the renewal bag that plug-in unit is corresponding after the software upgrading request that server receives.Concrete, this locality plug-in version number and renewal are wrapped version number and are compared by server, if finding there is new version number, then return new version number correspondence and update the link address wrapped and renewal bag check value.
Each bag that updates has the renewal bag check value of correspondence, updates bag check value and refers to for determining the unique mark updating bag.Before down loading updating bag, preserving renewal bag check value to terminal local, check value can be used to judge whether software has successfully been downloaded renewal bag and identified renewal bag when software starts.
In one embodiment, in step 204, before renewal bag being downloaded to local temporary files folder according to chained address, the method also includes: detection current network conditions;Judge whether current network conditions meets pre-conditioned, if so, then enter and be downloaded to updating bag in the temporary folder of this locality according to chained address.
In the present embodiment, pre-conditioned refer to wifi network environment.Mobile terminal is typically via mobile communications network online such as 2G, 3G or 4G, and mobile communications network network speed is slow, and data traffic charge is expensive.If the data traffic expense contracting for fixed output quotas raw by mobile communications network down loading updating in the client of mobile terminal is costly.And mobile terminal is under wifi network environment, not only downloads free and speed of download is fast.In order to prevent down loading updating bag from can bring too high expense to user, by detecting current network conditions, if current network conditions is not under wifi network environment, then carry out software upgrading.
As it is shown on figure 3, in one embodiment, it is provided that a kind of software updating apparatus based on Android system, this device includes such as lower module:
Check value acquisition module 31, is used for obtaining renewal bag check value.
Authentication module 32, is used for verifying renewal bag check value.
In one embodiment, updating bag check value is update the informative abstract value that bag is corresponding, authentication module 32 be additionally operable to obtain under application data catalogue add-on file clip pack containing informative abstract value corresponding to plug-in unit;The informative abstract value that informative abstract value corresponding for plug-in unit is corresponding with updating bag is contrasted one by one;If being absent from the informative abstract value that the identical plug-in unit of the informative abstract value corresponding with updating bag is corresponding, being then verified, otherwise, checking can't pass.
Update bag transferring module 33, for when authentication module the result be by time, then the bag that updates in temporary folder is migrated to during add-on file in the application data catalogue that software is corresponding presss from both sides.
Update bag decompression module 34, be used for decompressing renewal bag and obtain updating file, update file and include: class updates file, local update storehouse and resource updates file.
Module 35 is added in path, for adding the store path pointing to local update storehouse in running software attribute.
Library file calling module 36, store path according to described interpolation after starting for software, calls the local file in local update storehouse.
File load module 37, described in dynamic load, class updates file and resource updates file.
As shown in Figure 4, in one embodiment, file dlm (dynamic loading module) 37 includes:
Class file performs module 371, for being updated the class file in file by Classloader loading classes, and performs described class file.
Resource file access modules 372, for being loaded in resource object by the resource file in resource updates file, accesses described resource file by described resource object.
As it is shown in figure 5, in one embodiment, the software updating apparatus based on Android system also includes updating data acquisition module 30, is used for obtaining more new data.
Update data acquisition module 30 to include:
Upgrade request module 301, for sending software upgrading request.Information receiving module 303, for receiving the software update information returned according to software upgrading request.In the present embodiment, more fresh information includes updating chained address corresponding to bag and updating bag check value.
Check value preserves module 305, for preserving renewal bag check value to local.
Update bag download module 307, for being downloaded to updating bag in the temporary folder of this locality according to chained address.
As shown in Figure 6, in one embodiment, update data acquisition module 30 also to include:
Network detection module 306, is used for detecting current network conditions.
Network judge module 308, is used for judging whether current network conditions meets pre-conditioned.
When the judged result of network judge module 308 is for being, then enters and update bag download module 307.
Above example only have expressed the several embodiments of the present invention, and it describes comparatively concrete and detailed, but therefore can not be interpreted as the restriction to the scope of the claims of the present invention.It should be pointed out that, for the person of ordinary skill of the art, without departing from the inventive concept of the premise, it is also possible to making some deformation and improvement, these broadly fall into protection scope of the present invention.Therefore, the protection domain of patent of the present invention should be as the criterion with claims.