CN105335200B - Method for upgrading system and device - Google Patents

Method for upgrading system and device Download PDF

Info

Publication number
CN105335200B
CN105335200B CN201510827502.6A CN201510827502A CN105335200B CN 105335200 B CN105335200 B CN 105335200B CN 201510827502 A CN201510827502 A CN 201510827502A CN 105335200 B CN105335200 B CN 105335200B
Authority
CN
China
Prior art keywords
original
function
parameter
original method
calling
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.)
Active
Application number
CN201510827502.6A
Other languages
Chinese (zh)
Other versions
CN105335200A (en
Inventor
董俊杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiaomi Inc
Original Assignee
Xiaomi Inc
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 Xiaomi Inc filed Critical Xiaomi Inc
Priority to CN201510827502.6A priority Critical patent/CN105335200B/en
Publication of CN105335200A publication Critical patent/CN105335200A/en
Application granted granted Critical
Publication of CN105335200B publication Critical patent/CN105335200B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The disclosure is directed to a kind of method for upgrading system and devices, wherein method for upgrading system includes: that original method is replaced with first method, and original method is backuped in second method;The calling to first method will be converted to the calling of original method, and calls the original method of backup by second method.The embodiment of the present disclosure, by the way that original method is replaced with first method, original method is backuped in second method, then the calling to first method will be converted to the calling of original method, and the original method of backup is called by second method, to realize the upgrading of compatible system, cost saved the time, reduce error rate and improve upgrading efficiency in the case where not modifying source code.

Description

Method for upgrading system and device
Technical field
This disclosure relates to operation system technology field more particularly to a kind of method for upgrading system and device.
Background technique
Android (Android) system is the mobile device operation system of an open source.Many mobile device operation systems at present System is based on Android system exploitation, is Android compatible system.But all Android compatible systems must be compatible with promising Android system, institute The software of system exploitation.Therefore, these Android compatible systems not only need to guarantee the normal use of own software, and need to guarantee The normal use of third party software based on Android system exploitation.
In order to transform Android system as a new Android compatible system, existing technical solution is by modification source Code is realized.By being inserted into position or modifying original code, then further in the source code of Android system Compiling is realized.
Since source code must be modified, it is just able to achieve the transformation of Android system, this is resulted in when Android system upgrades, must Extra work must be paid to carry out the merging of source code and modify the upgrading that can just complete compatible system, it is more not only to expend the time And it is easy error.
Summary of the invention
To overcome the problems in correlation technique, the disclosure provides a kind of method for upgrading system and device.
According to the first aspect of the embodiments of the present disclosure, a kind of method for upgrading system is provided, comprising:
Original method is replaced with into first method, the original method is backuped in second method;
The calling to the first method will be converted to the calling of the original method, and is called by the second method The original method of backup.
In one embodiment, described that original method is replaced with into first method, the original method is backuped in second method, Include:
By the original method inlet by backup code to be covered a to region of memory;
The first jump instruction is written in the inlet of the original method, first jump instruction is for jumping to the first letter Number, the first function are used for the parameter by the Parameter Switch of the original method for the first method;
The second jump instruction is written in the inlet of the second method, second jump instruction is for jumping to second Function, the second function are used for the parameter by the Parameter Switch of the second method for the original method;
Jump back instruction is written in the region of memory.
In one embodiment, described by the original method inlet by backup code to be covered a to region of memory Before, the method also includes:
A data area is created, the data area is used to save the ground of the address of the original method, the first method Location, the address of the second method and the region of memory address;
When the first jump instruction is written in the inlet of the original method, the method also includes:
The address of the data area is written;
When the second jump instruction is written in the inlet of the second method, the method also includes:
The address of the data area is written.
It is in one embodiment, described to be converted to the calling to the first method to the calling of the original method, comprising:
First function is jumped to by first jump instruction, and by the first function by the ginseng of the original method Number is converted to the parameter of the first method, to execute the first method.
In one embodiment, the original method that backup is called by the second method, comprising:
Second function is jumped to by second jump instruction, by the second function by the ginseng of the second method Number is converted to the parameter of the original method, to execute the code of the region of memory backup.
It in one embodiment, is the original side by the Parameter Switch of the second method by the second function described After the parameter of method, the method also includes:
The code for executing the uncovered part of original method is jumped back to according to the jump back instruction.
According to the second aspect of an embodiment of the present disclosure, a kind of system upgrade device is provided, comprising:
Backup module is replaced, is configured as original method replacing with first method, the original method is backuped into second party In method;
Calling module is converted, is configured as that the calling of the original method will be converted to and the replacement backup module is replaced The first method calling, and by the second method call it is described replacement backup module back up the original method.
In one embodiment, the replacement backup module includes:
Backup submodule is configured as backup code to be covered a to memory field the original method inlet Domain;
First write-in submodule, be configured as the original method inlet be written the first jump instruction, described first Jump instruction is used to the Parameter Switch of the original method be the first party for jumping to first function, the first function The parameter of method;
Second write-in submodule is configured as being written the second jump instruction in the inlet of the second method, described the Two jump instructions are used to the Parameter Switch of the second method be the original for jumping to second function, the second function The parameter of method;
Submodule is written in third, is configured as that jump back instruction is written in the region of memory.
In one embodiment, the replacement backup module further include:
Submodule is created, is configured as code to be covered the original method inlet in the backup submodule It backups to before a region of memory, creates a data area, the data area is used to save the address, described of the original method The address of first method, the address of the second method and the region of memory address;
Wherein, the first write-in submodule is additionally configured to jump finger in the inlet of original method write-in first When enabling, the address of the data area is written;
Wherein, the second write-in submodule is additionally configured to jump in the inlet of second method write-in second When instruction, the address of the data area is written.
In one embodiment, the conversion calling module includes:
First jumps transform subblock, is configured as jumping finger by described the first of the first write-in submodule write-in Order jumps to first function, and is the ginseng of the first method by the Parameter Switch of the original method by the first function Number, to execute the first method.
In one embodiment, the conversion calling module includes:
Second jumps transform subblock, is configured as jumping finger by described the second of the second write-in submodule write-in Order jumps to second function, by the second function by the Parameter Switch of the second method be the original method parameter, To execute the code of the region of memory backup.
In one embodiment, the conversion calling module further include:
Jump back to implementation sub-module, be configured as described second jump transform subblock by the second function will described in After the Parameter Switch of second method is the parameter of the original method, is jumped back to according to the jump back instruction and execute the original method not The code of covered portionss.
According to the third aspect of an embodiment of the present disclosure, a kind of system upgrade device is provided, comprising:
Processor;
Memory for storage processor executable instruction;
Wherein, processor is configured as:
Original method is replaced with into first method, the original method is backuped in second method;
The calling to the first method will be converted to the calling of the original method, and is called by the second method The original method of backup.
The technical scheme provided by this disclosed embodiment can include the following benefits: by the way that original method is replaced with One method, original method is backuped in second method, then will be converted to the calling to first method to the calling of original method, and The original method that backup is called by second method, to realize the upgrading of compatible system, greatly in the case where not modifying source code The earth saves the time, reduces error rate and improves upgrading efficiency.
It is realized by write-in jump instruction and original method is replaced with into first method, original method is backuped in second method, To call conversion to provide condition for subsequent implementation method.
By creating data area, information needed for replacement process is saved, provides condition for implementation method replacement.
The calling by original method to first method can be realized by Parameter Switch, due to containing upgrading in first method Fresh code afterwards, therefore, the embodiment can realize system upgrade in the case where not modifying source code.
The calling by second method to backup code is realized by Parameter Switch, thereby may be ensured that third party software It is compatible.
The calling for executing original method unmasked portion code is jumped back to by jump back instruction, thereby may be ensured that soft to third party The compatibility of part.
It should be understood that above general description and following detailed description be only it is exemplary and explanatory, not The disclosure can be limited.
Detailed description of the invention
The drawings herein are incorporated into the specification and forms part of this specification, and shows and meets implementation of the invention Example, and be used to explain the principle of the present invention together with specification.
Fig. 1 is a kind of flow chart of method for upgrading system shown according to an exemplary embodiment.
Fig. 2 is a kind of flow chart of method replacement process shown according to an exemplary embodiment.
Fig. 3 A is the implementation procedure schematic diagram of ART shown according to an exemplary embodiment.
Fig. 3 B is the institutional framework schematic diagram of Class shown according to an exemplary embodiment a kind of.
Fig. 3 C-3D is a kind of scene figure of method for upgrading system shown according to an exemplary embodiment.
Fig. 4 is the flow chart of another method replacement process shown according to an exemplary embodiment.
Fig. 5 is that the calling of a kind of pair of original method shown according to an exemplary embodiment is converted to calling to first method Flow chart.
Fig. 6 is a kind of flow chart that original method is called by second method shown according to an exemplary embodiment.
Fig. 7 is a kind of block diagram of system upgrade device shown according to an exemplary embodiment.
Fig. 8 is the block diagram of another system upgrade device shown according to an exemplary embodiment.
Fig. 9 is the block diagram of another system upgrade device shown according to an exemplary embodiment.
Figure 10 is the block diagram of another system upgrade device shown according to an exemplary embodiment.
Figure 11 is the block diagram of another system upgrade device shown according to an exemplary embodiment.
Figure 12 is the block diagram of another system upgrade device shown according to an exemplary embodiment.
Figure 13 is a kind of block diagram suitable for system upgrade device shown according to an exemplary embodiment.
Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment Described in embodiment do not represent all embodiments consistented with the present invention.On the contrary, they be only with it is such as appended The example of device and method being described in detail in claims, some aspects of the invention are consistent.
Fig. 1 is a kind of flow chart of method for upgrading system shown according to an exemplary embodiment, as shown in Figure 1, this is System upgrade method can be applied on mobile terminal, which may include mobile phone, tablet computer, PDA (Personal Digital Assistant, personal digital assistant) etc., this approach includes the following steps S101-S102:
In step s101, original method is replaced with into first method, original method is backuped in second method.
In this embodiment, in order to reach in the case where not modifying source code, follow Android compatible system Android system upgrading, while third party software is kept being compatible with, original method is replaced with first method by the present embodiment, will be former Method backups in second method.
Since android system largely uses java language to write, and the smallest executable unit of Java language is method (Method).Therefore, the present embodiment is replaced as unit of method.Wherein, method is the set of batch processing code, the group Program code can receive one group of input data as parameter, and return to calculated result.
In this embodiment, the process of implementation method replacement may include:
In step S1011, by original method inlet by backup code to be covered a to region of memory.
Java is a kind of interpreted languages, operation java system, it is necessary to install a software virtual machine.Software virtual machine Bytecode is read, and according to the meaning of bytecode, executes different operations.In 5.0 pervious versions, Android is used Dalvik virtual machine.Since 5.0, Android introduces the virtual machine of an entitled ART.As shown in Figure 3A, the execution of ART A step more than process ratio Dalvik: Dalvik bytecode is converted into the instruction code that CPU can be read directly, and is stored Hereof, the format of this file is known as OAT file by ART, is then stored in OAT file by CPU directly to execute Instruction code.
Wherein, the storage of OAT file is class (Class) information of java and the instruction code of method.One use The software that java language is write, program are made of one group of class, and each Class is by several domains (Field) and Method group At.Field is used to define data.One Field defines a data.All Field inside Class, define the Class The data acquisition system possessed.And Method all inside Class co-operates the conjunction of this group data set.Each of each Class The data of Method all contain the position of the director data of the Method.Since the embodiment of the present disclosure is not related to Field, because This, will hereafter ignore the Field inside Class automatically and gather.
When the system is operated, ART constructs the institutional framework of a Class in memory, similar with the structure of OAT file, such as Shown in Fig. 3 B.The director data of Method is the instruction code set that CPU can be allowed directly to run.For different CPU architectures, Director data is different.Wherein, the most commonly used is the CPU of X86-based on desktop computer, notebook computer, in intelligence Energy field of mobile phones mainly uses the CPU, etc. of ARM framework.
The CPU of all frameworks has the assembly instruction collection of oneself, and assembly instruction is the mnemonic that can be read with the mankind It writes, then generates the binary instruction code that CPU can be executed by assemble software.In turn, these binary instruction codes The memonic symbol that can be read for the mankind can also be disassembled.In smart phone field, the CPU of ARM framework is mainstream, because This, the present embodiment is using the CPU of ARM framework come the realization process of description scheme.
In order to replace the Method inside a Class, which introduces two methods, i.e. first method and second party Method, first method are for replacing the method in original method i.e. Android system, and second method is used to back up original method.
For convenience, original method can be known as methodA, first method is known as handleMethodA, by Two methods are known as originalMethodA.
In this embodiment, the code address of methodA is found, copy inlet is new to one piece by code to be covered It is spare in the region of memory opened up.
In step S1012, the first jump instruction is written in the inlet of original method.
The first jump instruction is written in the inlet of methodA, i.e., first jump instruction is for covering methodA entrance The code at place, in this way, it is subsequent when system calls methodA, it can be realized and be joined by the first function in the first jump instruction Number conversion, i.e., be the parameter of first method for the Parameter Switch of original method, and then realizes the calling by original method to first method.
In step S1013, the second jump instruction is written in the inlet of second method.
In this embodiment, the code address for finding originalMethodA, in the inlet of originalMethodA The second jump instruction is written, in this way, it is subsequent when system calls originalMethodA, it can be by the second jump instruction Second function realize Parameter Switch, i.e., by the Parameter Switch of second method be original method parameter, and then realize by second party The calling for the code that method is capped to the inlet methodA.
In step S1014, jump back instruction is written in region of memory.
In order to which subsequent can jump back to executes the uncovered code of methodA, which can add in region of memory Add jump back instruction.
It can be seen that S1011-S1014 through the above steps, may be implemented the replacement between method, to be subsequent realization The conversion of method call provides condition.
In step s 102, the calling to first method will be converted to the calling of original method, and passes through second method tune With the original method of backup.
In this embodiment, since the first jump instruction is written in the inlet of original method, it can be jumped by first Turn instruction and jump to first function, and be the parameter of first method by the Parameter Switch of original method by first function, to hold Row first method.
Similarly, since the second jump instruction is written in the inlet of second method, finger can be jumped by second Order jumps to second function, and is the parameter of original method by the Parameter Switch of second method by second function, thereby executing interior Deposit the code of region backup.
It is assumed that Android compatible system is rice shaddock (MIUI) system, as shown in Figure 3 C, the original method in Android system is original side Method 1-3, the corresponding MIUI method for replacing original method 1-3 are that (dotted line in Fig. 3 C indicates original method 1- to MIUI method 1-3 The corresponding relationship of 3 and MIUI method 1-3), it can in the operation of MIUI software using upgrade method provided in an embodiment of the present invention Original method 1-3 is replaced with MIUI method 1-3, after the completion of replacement, the calling of Android method will can be converted to MIUI The calling of method, meanwhile, as shown in Figure 3D, MIUI method still is able to call the Android method being replaced, to realize when peace When tall and erect system version upgrades, MIUI system can also upgrade therewith, and modification Android source code is not needed in escalation process, thus The time can be saved, error rate is reduced and improves upgrading efficiency.
In addition, due in android system, each software is operated in different processes, and between process mutually Isolation, therefore, does not interfere with other processes to the modification of a process.For the process where MIUI software, by Android The method that the method for system replaces with MIUI system may be implemented MIUI system and upgrade with the upgrading of android system;And For third party software, the method for android system is not replaced, to ensure that the compatibility to third party software, i.e., The upgrading of MIUI system on third party software without influence, so as to avoid because system caused by compatibility issue is unstable.
It should be noted that the embodiment is by taking android system and MIUI system as an example, description MIUI system with The upgrading of android system and the process upgraded.It should be appreciated by those skilled in the art upgradings between other compatible systems It can be realized using the method, be not listed one by one herein.
Original method is backuped to second by the way that original method is replaced with first method by above system upgrade method embodiment In method, then the calling to first method will be converted to the calling of original method, and the original of backup is called by second method Method cost saved the time, reduce out to realize the upgrading of compatible system in the case where not modifying source code Error rate and improve upgrading efficiency.
Fig. 4 is the flow chart of another method replacement process shown according to an exemplary embodiment, as shown in figure 4, packet Include following steps S401-S410:
In step S401, a data area is created, and initialize.
Wherein, which is used to save the address of the address of original method, the address of first method and second method.
In step S402, the entry address of original method is obtained.
In step S403, calculate original method inlet will coated region size, and distribute a region of memory, will The address of the region of memory is saved in data area.
In step s 404, by original method inlet by code copies to be covered into region of memory.
In step S405, in the address of original method inlet write-in the first jump instruction and data area.
In this embodiment, the purpose in the address of original method inlet write-in data area is to make subsequent joined When number conversion, the available address to first method.
In step S406, the register after addition jumps back to restores instruction.
In step S 407, it calculates the register after jumping back to and restores IA.
In step S408, register recovery IA is added to region of memory, and be written and jump back in region of memory Instruction.
In step S409, the entry address of second method is obtained.
In step S410, in the address of the inlet of second method write-in the second jump instruction and data area.
In this embodiment, the purpose in the address of second method inlet write-in data area is to make subsequent progress When Parameter Switch, the available address to second method.
Above-described embodiment may be implemented original method replacing with first method, original method backuped in second method, from And conversion is called to provide condition for subsequent implementation method.
Fig. 5 is that the calling of a kind of pair of original method shown according to an exemplary embodiment is converted to calling to first method Flow chart, as shown in figure 5, this approach includes the following steps S501-S506:
In step S501, the register used is saved.
Since register may preserve other information, before register is written into new data, needing to save is made Register.
In step S502, jump target addresses are obtained, and be written into register.
In this embodiment, processor cannot jump directly to any one specified address, and can only first by target A register is written in location, and processor reads destination address and executed from register.For example, currently a popular processor architecture In (such as ARM CPU), just in this way.
Wherein, jump target addresses can be the first function address in the first jump instruction.
In step S503, first function is jumped to.
In step S504, restore the register being saved.
At this point, the register for saving first function address has been completed to jump task, do not use, at this moment needs to restore Previously stored register.
It should be noted that all embodiments of the disclosure are both needed to save the register used before using register, After having used register, it is both needed to restore previously stored register.
In addition, the embodiment by R0 register (R0 register be ARM CPU 16 registers in one) for into Row description can jump to first function using other modes in practical applications.For example, the processor of other frameworks is (such as X86) allow to directly write to destination address in jump instruction.In this case, additional register is not needed to save and jump Turn address.But it there is still a need for " preservation-use-recovery " principles for following register, to guarantee that data will not lose, thus Guarantee the integrality and consistency of data.
It is the parameter of first method by the Parameter Switch of original method in step S505.
It in this embodiment, is the parameter of first method by the Parameter Switch of original method by first function.
In step S506, the entrance of first method is obtained, and jumps to first method.
After the completion of Parameter Switch, the available entrance to first method, so as to jump execution first method.
Above-described embodiment can realize the calling by original method to first method, due to first method by Parameter Switch In contain upgrading after fresh code, therefore, which can realize system upgrade in the case where not modifying source code.
Fig. 6 is a kind of flow chart that original method is called by second method shown according to an exemplary embodiment, such as Fig. 6 It is shown, this approach includes the following steps S601-S612:
In step s 601, the register used is saved.
In step S602, jump target addresses are obtained, and be written into register.
Wherein, jump target addresses can be the second function address in the second jump instruction.
In step S603, second function is jumped to.
In step s 604, restore the register being saved.
It in step s 605, is the parameter of original method by the Parameter Switch of second method.
It in this embodiment, is the parameter of original method by the Parameter Switch of second method by second function.
In step S606, the address for having backed up the region of memory of original method is obtained.
In step S607, the inlet of the region of memory is jumped to, and executes code.
In this embodiment, the code of region of memory is the capped code in inlet of original method.
Above-mentioned steps S601-607 realizes the process that the code of backup is called by second function.
In step S608, the register used is saved.
In step S609, obtains to jump back to and restore instruction, and be written into register.
In step S610, the rebound for jumping to original method restores instruction.
In step s 611, restore the value of register.
In step S612, the code of uncovered part in original method is continued to execute.
Above-mentioned steps S601-612 realizes second method to the calling of original method.
Above-described embodiment is realized the calling by second method to original method by Parameter Switch, be thereby may be ensured that the The compatibility of software of the third party.
Corresponding with aforementioned system upgrade method embodiment, the disclosure additionally provides system upgrade Installation practice.
Fig. 7 is a kind of block diagram of system upgrade device shown according to an exemplary embodiment, as shown in fig. 7, the system Update device includes: replacement backup module 71 and conversion calling module 72.
Replacement backup module 71 is configured as original method replacing with first method, and original method is backuped to second method In.
In this embodiment, in order to reach in the case where not modifying source code, follow Android compatible system Android system upgrading, while third party software is kept being compatible with, original method is replaced with first method by the present embodiment, will be former Method backups in second method.
Since android system largely uses java language to write, and the smallest executable unit of Java language is method (Method).Therefore, the present embodiment is replaced as unit of method.Wherein, method is the set of batch processing code, the group Program code can receive one group of input data as parameter, and return to calculated result.
Conversion calling module 72 is configured as that the calling of original method will be converted to first to replacement backup module replacement The calling of method, and the original method for calling replacement backup module to back up by second method.
In this embodiment, since the first jump instruction is written in the inlet of original method, it can be jumped by first Turn instruction and jump to first function, and be the parameter of first method by the Parameter Switch of original method by first function, to hold Row first method.
Similarly, since the second jump instruction is written in the inlet of second method, finger can be jumped by second Order jumps to second function, and is the parameter of original method by the Parameter Switch of second method by second function, thereby executing interior Deposit the code of region backup.
It is assumed that Android compatible system is rice shaddock (MIUI) system, as shown in Figure 3 C, the original method in Android system is original side Method 1-3, the corresponding MIUI method for replacing original method 1-3 are that (dotted line in Fig. 3 C indicates original method 1- to MIUI method 1-3 The corresponding relationship of 3 and MIUI method 1-3), it can in the operation of MIUI software using upgrade method provided in an embodiment of the present invention Original method 1-3 is replaced with MIUI method 1-3, after the completion of replacement, the calling of Android method will can be converted to MIUI The calling of method, meanwhile, as shown in Figure 3D, MIUI method still is able to call the Android method being replaced, to realize when peace When tall and erect system version upgrades, MIUI system can also upgrade therewith, and modification Android source code is not needed in escalation process, thus The time can be saved, error rate is reduced and improves upgrading efficiency.
In addition, due in android system, each software is operated in different processes, and between process mutually Isolation, therefore, does not interfere with other processes to the modification of a process.For the process where MIUI software, by Android The method that the method for system replaces with MIUI system may be implemented MIUI system and upgrade with the upgrading of android system;And For third party software, the method for android system is not replaced, to ensure that the compatibility to third party software, i.e., The upgrading of MIUI system on third party software without influence, so as to avoid because system caused by compatibility issue is unstable.
For device as shown in Figure 7 for realizing above-mentioned method flow as shown in Figure 1, the related content being related to describes phase Together, it does not repeat herein.
Original method is replaced with first method by replacement backup module, by original side by above system update device embodiment Method backups in second method, then will be converted to the tune to first method to the calling of original method by converting calling module With, and the original method backed up is called by second method, to realize the liter of compatible system in the case where not modifying source code Grade, cost saved the time, reduces error rate and improves upgrading efficiency.
Fig. 8 is the block diagram of another system upgrade device shown according to an exemplary embodiment, as shown in figure 8, upper On the basis of stating embodiment illustrated in fig. 7, backup module 71 is replaced can include: the write-in of backup submodule 711, first submodule 712, Submodule 714 is written in second write-in submodule 713 and third.
Backup submodule 711 is configured as backup code to be covered a to region of memory original method inlet.
Java is a kind of interpreted languages, operation java system, it is necessary to install a software virtual machine.Software virtual machine Bytecode is read, and according to the meaning of bytecode, executes different operations.In 5.0 pervious versions, Android is used Dalvik virtual machine.Since 5.0, Android introduces the virtual machine of an entitled ART.As shown in Figure 3A, the execution of ART A step more than process ratio Dalvik: Dalvik bytecode is converted into the instruction code that CPU can be read directly, and is stored Hereof, the format of this file is known as OAT file by ART, is then stored in OAT file by CPU directly to execute Instruction code.
Wherein, the storage of OAT file is class (Class) information of java and the instruction code of method.One use The software that java language is write, program are made of one group of class, and each Class is by several domains (Field) and Method group At.Field is used to define data.One Field defines a data.All Field inside Class, define the Class The data acquisition system possessed.And Method all inside Class co-operates the conjunction of this group data set.Each of each Class The data of Method all contain the position of the director data of the Method.Since the embodiment of the present disclosure is not related to Field, because This, will hereafter ignore the Field inside Class automatically and gather.
When the system is operated, ART constructs the institutional framework of a Class in memory, similar with the structure of OAT file, such as Shown in Fig. 3 B.The director data of Method is the instruction code set that CPU can be allowed directly to run.For different CPU architectures, Director data is different.Wherein, the most commonly used is the CPU of X86-based on desktop computer, notebook computer, in intelligence Energy field of mobile phones mainly uses the CPU, etc. of ARM framework.
The CPU of all frameworks has the assembly instruction collection of oneself, and assembly instruction is the mnemonic that can be read with the mankind It writes, then generates the binary instruction code that CPU can be executed by assemble software.In turn, these binary instruction codes The memonic symbol that can be read for the mankind can also be disassembled.In smart phone field, the CPU of ARM framework is mainstream, because This, the present embodiment is using the CPU of ARM framework come the realization process of description scheme.
In order to replace the Method inside a Class, which introduces two methods, i.e. first method and second party Method, first method are for replacing the method in original method i.e. Android system, and second method indicates original method.
For convenience, original method can be known as methodA, first method is known as handleMethodA, by Two methods are known as originalMethodA.
In this embodiment, the code address of methodA is found, copy inlet is new to one piece by code to be covered It is spare in the region of memory opened up.
First write-in submodule 712 is configured as that the first jump instruction is written in the inlet of original method, and first jumps finger It enables for jumping to first function, first function is used for the parameter by the Parameter Switch of original method for first method.
The first jump instruction is written in the inlet of methodA, i.e., first jump instruction is for covering methodA entrance The code at place, in this way, it is subsequent when system calls methodA, it can be realized and be joined by the first function in the first jump instruction Number conversion, i.e., be the parameter of first method for the Parameter Switch of original method, and then realizes the calling by original method to first method.
Second write-in submodule 713 is configured as that the second jump instruction is written in the inlet of second method, and second jumps Instruction is used for the parameter by the Parameter Switch of second method for original method for jumping to second function, second function.
In this embodiment, the code address for finding originalMethodA, in the inlet of originalMethodA The second jump instruction is written, in this way, it is subsequent when system calls originalMethodA, it can be by the second jump instruction Second function realize Parameter Switch, i.e., by the Parameter Switch of second method be original method parameter, and then realize by second party The calling for the code that method is capped to the inlet methodA.
Third write-in submodule 714 is configured as that jump back instruction is written in region of memory.
In order to which subsequent can jump back to executes the uncovered code of methodA, which can add in region of memory Add jump back instruction.
Device as shown in Figure 8 is for realizing above-mentioned method flow as shown in figures 2 or 4, the related content being related to It describes identical, does not repeat herein.
Original method is replaced with first method by write-in jump instruction realization by above system update device embodiment, will Original method backups in second method, to call conversion to provide condition for subsequent implementation method.
Fig. 9 is the block diagram of another system upgrade device shown according to an exemplary embodiment, as shown in figure 9, upper On the basis of stating embodiment illustrated in fig. 8, replacement backup module 71 may also include that creation submodule 710.
Creation submodule 710 is configured as in backup submodule 711 that original method inlet is standby by code to be covered Before part a to region of memory, a data area is created, data area is used to save the ground of the address of original method, first method Location, the address of second method and region of memory address.
Wherein, which is used to save the address of the address of original method, the address of first method and second method.
Wherein, the first write-in submodule 712 is also configured to when the first jump instruction is written in the inlet of original method, The address of data area is written.
Wherein, the second write-in submodule 713 is also configured to that the second jump instruction is written in the inlet of second method When, the address of data area is written.
For device as shown in Figure 9 for realizing above-mentioned method flow as shown in Figure 4, the related content being related to describes phase Together, it does not repeat herein.
Above system update device embodiment saves information needed for replacement process, is real by creating data area Existing method replacement provides condition.
Figure 10 is the block diagram of another system upgrade device shown according to an exemplary embodiment, as shown in Figure 10, On the basis of above-mentioned Fig. 8 or embodiment illustrated in fig. 9, calling module 72 is converted can include:
First jumps transform subblock 721, is configured as the first jump instruction being written by the first write-in submodule 712 First function is jumped to, and is the parameter of first method by the Parameter Switch of original method by first function, to execute first party Method.
For realizing above-mentioned method flow as shown in Figure 5, the related content being related to is described device as shown in Figure 10 It is identical, it does not repeat herein.
Above system update device embodiment can realize the calling by original method to first method by Parameter Switch, Due to containing the fresh code after upgrading in first method, which can be real in the case where not modifying source code Existing system upgrade.
Figure 11 is the block diagram of another system upgrade device shown according to an exemplary embodiment, as shown in figure 11, On the basis of above-mentioned Fig. 8 or embodiment illustrated in fig. 9, calling module 72 is converted can include:
Second jumps transform subblock 722, is configured as the second jump instruction being written by the second write-in submodule 713 Jump to second function, by second function by the Parameter Switch of second method be original method parameter, to execute region of memory The code of backup.
For realizing above-mentioned method flow as shown in FIG. 6, the related content being related to is described device as shown in figure 11 It is identical, it does not repeat herein.
Above system update device embodiment realizes the calling by second method to backup code by Parameter Switch, from And it can guarantee the compatibility to third party software.
Figure 12 is the block diagram of another system upgrade device shown according to an exemplary embodiment, as shown in figure 12, On the basis of above-mentioned embodiment illustrated in fig. 11, conversion calling module 72, which may also include that, jumps back to implementation sub-module 723.
Implementation sub-module 723 is jumped back to be configured as jumping transform subblock 722 by second function for second party second After the Parameter Switch of method is the parameter of original method, the code for executing the uncovered part of original method is jumped back to according to jump back instruction.
For realizing above-mentioned method flow as shown in FIG. 6, the related content being related to is described device as shown in figure 12 It is identical, it does not repeat herein.
Above system update device embodiment jumps back to the tune for executing original method unmasked portion code by jump back instruction With thereby may be ensured that the compatibility to third party software.
About the device in above-described embodiment, the concrete mode that wherein modules, submodule execute operation is having It closes and is described in detail in the embodiment of this method, no detailed explanation will be given here.
Figure 13 is a kind of block diagram suitable for system upgrade device shown according to an exemplary embodiment.For example, device 1300 can be mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical treatment Equipment, body-building equipment, personal digital assistant, aircraft etc..
Referring to Fig.1 3, device 1300 may include following one or more components: processing component 1302, memory 1304, Power supply module 1306, multimedia component 1308, audio component 1310, the interface 1312 of input/output (I/O), sensor module 1314 and communication component 1316.
The integrated operation of the usual control device 1300 of processing component 1302, such as with display, telephone call, data communication, Camera operation and record operate associated operation.Processing element 1302 may include one or more processors 1320 to execute Instruction, to perform all or part of the steps of the methods described above.In addition, processing component 1302 may include one or more moulds Block, convenient for the interaction between processing component 1302 and other assemblies.For example, processing component 1302 may include multi-media module, To facilitate the interaction between multimedia component 1308 and processing component 1302.
Memory 1304 is configured as storing various types of data to support the operation in equipment 1300.These data Example includes the instruction of any application or method for operating on device 1300, contact data, telephone book data, Message, picture, video etc..Memory 1304 can by any kind of volatibility or non-volatile memory device or they Combination is realized, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), it is erasable can Program read-only memory (EPROM), programmable read only memory (PROM), read-only memory (ROM), magnetic memory, flash memory Reservoir, disk or CD.
Electric power assembly 1306 provides electric power for the various assemblies of device 1300.Electric power assembly 1306 may include power management System, one or more power supplys and other with for device 1300 generate, manage, and distribute the associated component of electric power.
Multimedia component 1308 includes the screen of one output interface of offer between described device 1300 and user.? In some embodiments, screen may include liquid crystal display (LCD) and touch panel (TP).If screen includes touch panel, Screen may be implemented as touch screen, to receive input signal from the user.Touch panel includes that one or more touch passes Sensor is to sense the gesture on touch, slide, and touch panel.The touch sensor can not only sense touch or sliding is dynamic The boundary of work, but also detect duration and pressure associated with the touch or slide operation.In some embodiments, more Media component 1308 includes a front camera and/or rear camera.When equipment 1300 is in operation mode, as shot mould When formula or video mode, front camera and/or rear camera can receive external multi-medium data.Each preposition camera shooting Head and rear camera can be a fixed optical lens system or have focusing and optical zoom capabilities.
Audio component 1310 is configured as output and/or input audio signal.For example, audio component 1310 includes a wheat Gram wind (MIC), when device 1300 is in operation mode, when such as call mode, recording mode, and voice recognition mode, microphone quilt It is configured to receive external audio signal.The received audio signal can be further stored in memory 1304 or via communication Component 1316 is sent.In some embodiments, audio component 1310 further includes a loudspeaker, is used for output audio signal.
I/O interface 1312 provides interface, above-mentioned peripheral interface module between processing component 1302 and peripheral interface module It can be keyboard, click wheel, button etc..These buttons may include, but are not limited to: home button, volume button, start button and Locking press button.
Sensor module 1314 includes one or more sensors, and the state for providing various aspects for device 1300 is commented Estimate.For example, sensor module 1314 can detecte the state that opens/closes of equipment 1300, the relative positioning of component, such as institute The display and keypad that component is device 1300 are stated, sensor module 1314 can be with detection device 1300 or device 1,300 1 The position change of a component, the existence or non-existence that user contacts with device 1300,1300 orientation of device or acceleration/deceleration and dress Set 1300 temperature change.Sensor module 1314 may include proximity sensor, be configured in not any physics It is detected the presence of nearby objects when contact.Sensor module 1314 can also include optical sensor, as CMOS or ccd image are sensed Device, for being used in imaging applications.In some embodiments, which can also include acceleration sensing Device, gyro sensor, Magnetic Sensor, pressure sensor or temperature sensor.
Communication component 1316 is configured to facilitate the communication of wired or wireless way between device 1300 and other equipment.Dress The wireless network based on communication standard, such as WiFi can be accessed by setting 1300,2G or 3G or their combination.It is exemplary at one In embodiment, communication component 1316 receives broadcast singal or broadcast correlation from external broadcasting management system via broadcast channel Information.In one exemplary embodiment, the communication component 1316 further includes near-field communication (NFC) module, to promote short distance Communication.For example, radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra wide band can be based in NFC module (UWB) technology, bluetooth (BT) technology and other technologies are realized.
In the exemplary embodiment, device 1300 can be by one or more application specific integrated circuit (ASIC), number Signal processor (DSP), digital signal processing appts (DSPD), programmable logic device (PLD), field programmable gate array (FPGA), controller, microcontroller, microprocessor or other electronic components are realized, for executing the above method.
In the exemplary embodiment, a kind of non-transitorycomputer readable storage medium including instruction, example are additionally provided It such as include the memory 1304 of instruction, above-metioned instruction can be executed by the processor 1320 of device 1300 to complete the above method.Example Such as, the non-transitorycomputer readable storage medium can be ROM, random access memory (RAM), CD-ROM, tape, soft Disk and optical data storage devices etc..
Those skilled in the art will readily occur to its of the disclosure after considering specification and practicing disclosure disclosed herein Its embodiment.This application is intended to cover any variations, uses, or adaptations of the disclosure, these modifications, purposes or Person's adaptive change follows the general principles of this disclosure and including the undocumented common knowledge in the art of the disclosure Or conventional techniques.The description and examples are only to be considered as illustrative, and the true scope and spirit of the disclosure are by following Claim is pointed out.
It should be understood that the present disclosure is not limited to the precise structures that have been described above and shown in the drawings, and And various modifications and changes may be made without departing from the scope thereof.The scope of the present disclosure is only limited by the accompanying claims.

Claims (8)

1. a kind of method for upgrading system, which is characterized in that the described method includes:
Original method is replaced with into first method, the original method is backuped in second method;
The calling to the first method will be converted to the calling of the original method, and is called and backed up by the second method The original method;
It is described that original method is replaced with into first method, the original method is backuped in second method, comprising:
A data area is created, the data area is for saving the address of the original method, the address of the first method, institute State the address of second method and the address of region of memory;By the original method inlet by backup code to be covered described in Region of memory;
In the address of the inlet of original method write-in the first jump instruction and the data area, first jump instruction For jumping to first function, the first function is used for the ginseng by the Parameter Switch of the original method for the first method Number;
In the address of the inlet of second method write-in the second jump instruction and the data area, described second jumps finger It enables for jumping to second function, the second function is used for the ginseng by the Parameter Switch of the second method for the original method Number;
Jump back instruction is written in the region of memory.
2. system according to claim 1 upgrade method, which is characterized in that described to be converted to the calling of the original method For the calling to the first method, comprising:
First function is jumped to by first jump instruction, and is turned the parameter of the original method by the first function It is changed to the parameter of the first method, to execute the first method.
3. system according to claim 1 upgrade method, which is characterized in that described called by the second method is backed up The original method, comprising:
Second function is jumped to by second jump instruction, is turned the parameter of the second method by the second function It is changed to the parameter of the original method, to execute the code of the region of memory backup.
4. method for upgrading system according to claim 3, which is characterized in that it is described will be described by the second function The Parameter Switch of second method is the method for upgrading system after the parameter of the original method further include:
The code for executing the uncovered part of original method is jumped back to according to the jump back instruction.
5. a kind of system upgrade device, which is characterized in that described device includes:
Backup module is replaced, is configured as original method replacing with first method, the original method is backuped in second method;
Calling module is converted, is configured as that the calling of the original method will be converted to the institute to the replacement backup module replacement State the calling of first method, and the original method for calling the replacement backup module to back up by the second method;It is described Replacing backup module includes:
Submodule is created, one data area of creation is configured as, the data area is used to save address, the institute of the original method State the address, the address of the second method and the address of region of memory of first method;
Backup submodule is configured as backup code to be covered to the region of memory the original method inlet;
First write-in submodule, is configured as that the first jump instruction and the data area is written in the inlet of the original method Address, for jumping to first function, the first function is used for the parameter of the original method for first jump instruction Be converted to the parameter of the first method;
Second write-in submodule, is configured as that the second jump instruction and the data field is written in the inlet of the second method The address in domain, second jump instruction are used for for jumping to second function, the second function by the second method Parameter Switch is the parameter of the original method;
Submodule is written in third, is configured as that jump back instruction is written in the region of memory.
6. system upgrade device according to claim 5, which is characterized in that the conversion calling module includes:
First jumps transform subblock, is configured as jumping by first jump instruction of the first write-in submodule write-in First function is gone to, and is the parameter of the first method by the Parameter Switch of the original method by the first function, with Execute the first method.
7. system upgrade device according to claim 5, which is characterized in that the conversion calling module includes:
Second jumps transform subblock, is configured as jumping by second jump instruction of the second write-in submodule write-in Go to second function, by the second function by the Parameter Switch of the second method be the original method parameter, to hold The code of the row region of memory backup.
8. system upgrade device according to claim 7, which is characterized in that the conversion calling module further include:
Implementation sub-module is jumped back to, is configured as jumping transform subblock by the second function for described second described second After the Parameter Switch of method is the parameter of the original method, the execution original method is jumped back to according to the jump back instruction and is not coated The code of cover.
CN201510827502.6A 2015-11-24 2015-11-24 Method for upgrading system and device Active CN105335200B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510827502.6A CN105335200B (en) 2015-11-24 2015-11-24 Method for upgrading system and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510827502.6A CN105335200B (en) 2015-11-24 2015-11-24 Method for upgrading system and device

Publications (2)

Publication Number Publication Date
CN105335200A CN105335200A (en) 2016-02-17
CN105335200B true CN105335200B (en) 2019-05-07

Family

ID=55285761

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510827502.6A Active CN105335200B (en) 2015-11-24 2015-11-24 Method for upgrading system and device

Country Status (1)

Country Link
CN (1) CN105335200B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106445662B (en) * 2016-09-13 2019-09-10 广东欧珀移动通信有限公司 A kind of method and terminal device of graft application program
CN106502703B (en) * 2016-10-27 2020-07-03 腾讯科技(深圳)有限公司 Function calling method and device
CN107832096A (en) * 2017-09-29 2018-03-23 五八有限公司 URL collocation method and terminal
CN107885982B (en) * 2017-09-29 2021-08-24 五八有限公司 Login control processing method and terminal

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101937347A (en) * 2010-08-06 2011-01-05 深圳市共进电子有限公司 Method for managing automatic updating in special networked terminal equipment
CN102693145A (en) * 2012-05-31 2012-09-26 红石阳光(北京)科技有限公司 Differential upgrading method for embedded system
CN103135979A (en) * 2011-12-05 2013-06-05 ***通信集团广东有限公司 Method, device and system for generating terminal applications
CN104239082A (en) * 2013-06-20 2014-12-24 上海博达数据通信有限公司 Hot patching implementation method of embedded system
CN104981778A (en) * 2013-02-22 2015-10-14 马维尔国际贸易有限公司 Patching boot code of read-only memory

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7310800B2 (en) * 2001-02-28 2007-12-18 Safenet, Inc. Method and system for patching ROM code
US7523299B2 (en) * 2005-07-29 2009-04-21 Broadcom Corporation Method and system for modifying operation of ROM based boot code of a network adapter chip
US8099724B2 (en) * 2006-02-28 2012-01-17 Oracle America, Inc. Fast patch-based method calls
CN102622241B (en) * 2011-01-26 2016-06-15 腾讯科技(深圳)有限公司 A kind of method for upgrading software and device
CN104765634B (en) * 2015-05-06 2017-12-08 中孚信息股份有限公司 A kind of linux system kernel New function increases method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101937347A (en) * 2010-08-06 2011-01-05 深圳市共进电子有限公司 Method for managing automatic updating in special networked terminal equipment
CN103135979A (en) * 2011-12-05 2013-06-05 ***通信集团广东有限公司 Method, device and system for generating terminal applications
CN102693145A (en) * 2012-05-31 2012-09-26 红石阳光(北京)科技有限公司 Differential upgrading method for embedded system
CN104981778A (en) * 2013-02-22 2015-10-14 马维尔国际贸易有限公司 Patching boot code of read-only memory
CN104239082A (en) * 2013-06-20 2014-12-24 上海博达数据通信有限公司 Hot patching implementation method of embedded system

Also Published As

Publication number Publication date
CN105335200A (en) 2016-02-17

Similar Documents

Publication Publication Date Title
KR102470275B1 (en) Voice control method and electronic device
CN105468410B (en) Method for upgrading system and device
CN110312985B (en) Electronic device and method for displaying screen thereof
CN107924216B (en) Foldable electronic device including hidden display and information display method thereof
CN107566693B (en) Electronic device and image capturing method thereof
WO2021115194A1 (en) Application icon display method and electronic device
CN104484200B (en) The method and device upgraded to firmware
CN105094931B (en) Method for upgrading software and device
US20210223927A1 (en) Electronic device and method for displaying application used therein
CN104281478B (en) The method and device of more new application
CN108028891B (en) Electronic apparatus and photographing method
KR20180109439A (en) Electronic apparatus and controlling method thereof
CN104951335B (en) The processing method and processing device of application program installation kit
CN107967141A (en) Operating system update method, apparatus and terminal
US10627926B2 (en) User interfacing method and electronic device for performing the same
CN105335200B (en) Method for upgrading system and device
WO2021110133A1 (en) Control operation method and electronic device
CN108605261B (en) Electronic device and operation method thereof
CN111752666A (en) Window display method and device and terminal
CN106528255B (en) Kind loading method and device
CN113867848A (en) Method, device and equipment for calling graphic interface and readable storage medium
CN113190362A (en) Service calling method and device, computer equipment and storage medium
CN109117144A (en) page processing method, device, terminal and storage medium
KR20160016405A (en) Method for processing data and electronic device thereof
CN109725943A (en) A kind of programming jump method, apparatus, electronic equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant