CN105335200A - System upgrading method and device - Google Patents

System upgrading method and device Download PDF

Info

Publication number
CN105335200A
CN105335200A CN201510827502.6A CN201510827502A CN105335200A CN 105335200 A CN105335200 A CN 105335200A CN 201510827502 A CN201510827502 A CN 201510827502A CN 105335200 A CN105335200 A CN 105335200A
Authority
CN
China
Prior art keywords
former method
write
function
parameter
backup
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201510827502.6A
Other languages
Chinese (zh)
Other versions
CN105335200B (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.)
Beijing Xiaomi Technology Co Ltd
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

Abstract

The invention discloses a system upgrading method and a system upgrading device. The system upgrading method comprises the following steps: replacing an original method with a first method, and backuping the original method to a second method; and converting the calling of the original method into the calling of the first method, and calling a backup original method through the second method. According to the embodiments of the invention, by replacing the original method with the first method and backuping the original method to the second method, then converting the calling of the original method into the calling of the first method, and calling the backup original method through the second method, under the condition of not modifying a source code, the upgrading of a compatible system is realized, thereby greatly saving the time, reducing the error rate and improving the efficiency of upgrading.

Description

Method for upgrading system and device
Technical field
The disclosure relates to operation system technology field, particularly relates to a kind of method for upgrading system and device.
Background technology
Android (Android) system is a mobile device operation system of increasing income.A lot of mobile device operation system is all based on Android system exploitation at present, is Android compatible system.But all Android compatible systems must the software developed of the promising Android system of compatible institute.Therefore, these Android compatible systems not only need the normal use ensureing own software, and need the normal use of the third party software ensured based on Android system exploitation.
In order to Android system be transform as a new Android compatible system, existing technical scheme, realized by amendment source code.By in the source code of Android system, insert in position or revise primary code, and then compiling realizes together.
Owing to revising source code, could realize the transformation of Android system, this just causes when Android system is upgraded, and must pay extra work and carries out the merging of source code and revise the upgrading that just can complete compatible system, not only expend time in many and easily make mistakes.
Summary of the invention
For overcoming Problems existing in correlation technique, the disclosure provides a kind of method for upgrading system and device.
According to the first aspect of disclosure embodiment, a kind of method for upgrading system is provided, comprises:
Former method is replaced with the first method, described former method is backuped in the second method;
Be converted to calling described first method by calling of described former method, and by described second method call backup described former method.
In one embodiment, described former method is replaced with the first method, described former method is backuped in the second method, comprising:
The backup code that will be capped described former method porch is to a region of memory;
Write the first jump instruction in the porch of described former method, described first jump instruction is used for jumping to the first function, the parameter of described first function for by the Parameter Switch of described former method being described first method;
Write the second jump instruction in the porch of described second method, described second jump instruction is used for jumping to the second function, the parameter of described second function for by the Parameter Switch of described second method being described former method;
At described region of memory write jump back instruction.
In one embodiment, before the described backup code that will be capped described former method porch a to region of memory, described method also comprises:
Create a data area, described data area is for preserving the address of described former method, the address of described first method, the address of described second method and the address of described region of memory;
When the porch of described former method writes the first jump instruction, described method also comprises:
Write the address of described data area;
When the porch of described second method writes the second jump instruction, described method also comprises:
Write the address of described data area.
In one embodiment, be describedly converted to calling described first method by calling of described former method, comprise:
Jump to the first function by described first jump instruction, and be the parameter of described first method by the Parameter Switch of described former method by described first function, to perform described first method.
In one embodiment, the described described former method by described second method call backup, comprising:
Jumping to the second function by described second jump instruction, is the parameter of described former method by the Parameter Switch of described second method by described second function, to perform the code of described region of memory backup.
In one embodiment, described by described second function by the Parameter Switch of described second method be the parameter of described former method after, described method also comprises:
The code of the not capped part of described former method is performed according to described jump back instruction rebound.
According to the second aspect of disclosure embodiment, a kind of system upgrade device is provided, comprises:
Replace backup module, be configured to former method to replace with the first method, described former method is backuped in the second method;
Conversion calling module, is configured to be converted to calling described first method that described replacement backup module is replaced by calling of described former method, and by replacing the described former method of backup module backup described in described second method call.
In one embodiment, described replacement backup module comprises:
Backup submodule, the backup code being configured to described former method porch to be capped is to a region of memory;
First write submodule, be configured to write the first jump instruction in the porch of described former method, described first jump instruction is used for jumping to the first function, the parameter of described first function for by the Parameter Switch of described former method being described first method;
Second write submodule, be configured to write the second jump instruction in the porch of described second method, described second jump instruction is used for jumping to the second function, the parameter of described second function for by the Parameter Switch of described second method being described former method;
3rd write submodule, is configured at described region of memory write jump back instruction.
In one embodiment, described replacement backup module also comprises:
Create submodule, before being configured to the backup code that will be capped described former method porch at described backup submodule a to region of memory, create a data area, described data area is for preserving the address of described former method, the address of described first method, the address of described second method and the address of described region of memory;
Wherein, described first write submodule, is also configured to, when the porch of described former method writes the first jump instruction, write the address of described data area;
Wherein, described second write submodule, is also configured to, when the porch of described second method writes the second jump instruction, write the address of described data area.
In one embodiment, described conversion calling module comprises:
First redirect transform subblock, be configured to jump to the first function by described first jump instruction of described first write submodule write, and be the parameter of described first method by the Parameter Switch of described former method by described first function, to perform described first method.
In one embodiment, described conversion calling module comprises:
Second redirect transform subblock, be configured to jump to the second function by described second jump instruction of described second write submodule write, be the parameter of described former method by the Parameter Switch of described second method by described second function, to perform the code of described region of memory backup.
In one embodiment, described conversion calling module also comprises:
Rebound implementation sub-module, be configured to, after the Parameter Switch of described second method by described second function is the parameter of described former method by described second redirect transform subblock, perform the code of the capped part of described former method according to described jump back instruction rebound.
According to the third aspect of disclosure embodiment, a kind of system upgrade device is provided, comprises:
Processor;
For the storer of storage of processor executable instruction;
Wherein, processor is configured to:
Former method is replaced with the first method, described former method is backuped in the second method;
Be converted to calling described first method by calling of described former method, and by described second method call backup described former method.
The technical scheme that embodiment of the present disclosure provides can comprise following beneficial effect: by former method is replaced with the first method, former method is backuped in the second method, then calling the first method is converted to by calling of former method, and pass through the former method of the second method call backup, thus when not revising source code, realize the upgrading of compatible system, cost savings the time, decrease error rate and improve upgrading efficiency.
By write jump instruction realization, former method is replaced with the first method, former method is backuped in the second method, thus provides condition for follow-up implementation method calls conversion.
By creating data area, preserving information required in replacement process, replacing for implementation method and providing condition.
Can be realized by former method calling to the first method by Parameter Switch, owing to containing the fresh code after upgrading in the first method, therefore, this embodiment can realize system upgrade when not revising source code.
Realized by the second method calling to backup code by Parameter Switch, thus the compatibility to third party software can be ensured.
Perform calling of former method unmasked portion code by jump back instruction rebound, thus the compatibility to third party software can be ensured.
Should be understood that, it is only exemplary and explanatory that above general description and details hereinafter describe, and can not limit the disclosure.
Accompanying drawing explanation
Accompanying drawing to be herein merged in instructions and to form the part of this instructions, shows embodiment according to the invention, and is used from instructions one and explains principle of the present invention.
Fig. 1 is the process flow diagram of a kind of method for upgrading system according to an exemplary embodiment.
Fig. 2 is the process flow diagram of a kind of method replacement process according to an exemplary embodiment.
Fig. 3 A is the implementation schematic diagram of the ART according to an exemplary embodiment.
Fig. 3 B is the institutional framework schematic diagram of a kind of Class according to an exemplary embodiment.
Fig. 3 C-3D is the scene graph of a kind of method for upgrading system according to an exemplary embodiment.
Fig. 4 is the process flow diagram of the another kind of method replacement process according to an exemplary embodiment.
Fig. 5 is that a kind of according to an exemplary embodiment calls to former method the process flow diagram called be converted to the first method.
Fig. 6 is a kind of process flow diagram by the former method of the second method call according to an exemplary embodiment.
Fig. 7 is the block diagram of a kind of system upgrade device according to an exemplary embodiment.
Fig. 8 is the block diagram of the another kind of system upgrade device according to an exemplary embodiment.
Fig. 9 is the block diagram of the another kind of system upgrade device according to an exemplary embodiment.
Figure 10 is the block diagram of the another kind of system upgrade device according to an exemplary embodiment.
Figure 11 is the block diagram of the another kind of system upgrade device according to an exemplary embodiment.
Figure 12 is the block diagram of the another kind of system upgrade device according to an exemplary embodiment.
Figure 13 is a kind of block diagram being applicable to system upgrade device according to an exemplary embodiment.
Embodiment
Here will be described exemplary embodiment in detail, its sample table shows in the accompanying drawings.When description below relates to accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawing represents same or analogous key element.Embodiment described in following exemplary embodiment does not represent all embodiments consistent with the present invention.On the contrary, they only with as in appended claims describe in detail, the example of apparatus and method that aspects more of the present invention are consistent.
Fig. 1 is the process flow diagram of a kind of method for upgrading system according to an exemplary embodiment, as shown in Figure 1, this method for upgrading system can be applicable on mobile terminal, this mobile terminal can comprise mobile phone, panel computer, PDA (PersonalDigitalAssistant, personal digital assistant) etc., the method comprises the following steps S101-S102:
In step S101, former method is replaced with the first method, former method is backuped in the second method.
In this embodiment, in order to reach when not revising source code, make Android compatible system can follow android system upgrading, third party software being kept compatible simultaneously, former method is replaced with the first method by the present embodiment, former method is backuped in the second method.
Because android system major part adopts java language compilation, and the smallest executable unit of Java language is method (Method).Therefore, the present embodiment is in method for unit replaces.Wherein, method is the set of batch processing code, and this group program code can accept one group of input data as parameter, and returns result of calculation.
In this embodiment, the process that implementation method is replaced can comprise:
In step S1011, the backup code that will be capped former method porch is to a region of memory.
Java is a kind of interpreted languages, operation java system, must install a software virtual machine.Software virtual machine reads bytecode, and according to the implication of bytecode, performs different computings.In version before 5.0, Android uses Dalvik virtual machine.From 5.0, Android introduces the virtual machine of an ART by name.As shown in Figure 3A, a step that the implementation of ART is more than Dalvik: Dalvik bytecode is converted to the instruction code that CPU can directly read, and store hereof, the form of this file, be called OAT file by ART, then directly performed the instruction code be stored in OAT file by CPU.
Wherein, what OAT file stored is class (Class) information of java and the instruction code of method.The software of a use java language compilation, its program is made up of one group of class, and each Class is made up of several territories (Field) and Method.Field is used for defining data.A Field defines data.All Field of Class inside, define the data acquisition that this Class has.And this group data set of Method co-operate conjunction that Class is inner all.The data of each Method of each Class, all contain the position of the director data of this Method.Because disclosure embodiment does not relate to Field, therefore, hereafter the Field set of Class inside will automatically be ignored.
When the system is operated, ART builds the institutional framework of a Class at internal memory, with the similar of OAT file, as shown in Figure 3 B.The director data of Method is the instruction code set that CPU can be allowed directly to run.For different CPU architecture, director data is different.Wherein, conventional on desk-top computer, notebook is the CPU of X86-based, mainly uses the CPU of ARM framework in smart mobile phone field, etc.
The CPU of all frameworks has the assembly instruction collection of oneself, assembly instruction to be write with the mnemonic symbol that the mankind can read, and then generates the CPU binary command code that can perform through assemble software.Conversely, these binary command codes also can be disassembled the memonic symbol for the mankind can read.In smart mobile phone field, the CPU of ARM framework is main flow, and therefore, the present embodiment adopts the CPU of ARM framework to carry out the implementation procedure of description scheme.
In order to replace the Method of a Class inside, this embodiment introduces two methods, i.e. the first method and the second method, and the first method is used to replace the method in former method and Android system, and the second method is used for backing up former method.
For convenience, former method can be called methodA, the first method is called handleMethodA, the second method is called originalMethodA.
In this embodiment, find the code address of methodA, the code that copy porch will be capped is for subsequent use in one piece of region of memory newly opened up.
In step S1012, write the first jump instruction in the porch of former method.
The first jump instruction is write in the porch of methodA, namely this first jump instruction is for covering the code of methodA porch, like this, follow-up as system call methodA, Parameter Switch can be realized by the first function in the first jump instruction, Parameter Switch by former method is the parameter of the first method, and then realizes by former method calling to the first method.
In step S1013, write the second jump instruction in the porch of the second method.
In this embodiment, find the code address of originalMethodA, the second jump instruction is write in the porch of originalMethodA, like this, follow-up as system call originalMethodA, can realize Parameter Switch by the second function in the second jump instruction, the Parameter Switch by the second method is the parameter of former method, and then realizes the calling of code that be capped to methodA porch by the second method.
In step S1014, at region of memory write jump back instruction.
Rebound can perform the code that is not capped of methodA in order to follow-up, this embodiment can add jump back instruction in region of memory.
As can be seen here, by above-mentioned steps S1011-S1014, can to accomplish method between replacement, thus the conversion of calling for follow-up implementation method provides condition.
In step s 102, be converted to calling the first method by calling of former method, and pass through the former method of the second method call backup.
In this embodiment, owing to writing the first jump instruction in the porch of former method, therefore, the first function can be jumped to by the first jump instruction, and be the parameter of the first method by the Parameter Switch of former method by the first function, thus first method of execution.
Similarly, owing to writing the second jump instruction in the porch of the second method, therefore, the second function can be jumped to by the second jump instruction, and be the parameter of former method by the Parameter Switch of the second method by the second function, thus perform the code of region of memory backup.
Suppose, Android compatible system is rice shaddock (MIUI) system, as shown in Figure 3 C, former method in Android system is former method 1-3, corresponding is MIUI method 1-3 (dotted line in Fig. 3 C represents the corresponding relation of former method 1-3 and MIUI method 1-3) for replacing the MIUI method of former method 1-3, adopt the upgrade method that the embodiment of the present invention provides, when MIUI running software, former method 1-3 can be replaced with MIUI method 1-3, after replacement completes, calling MIUI method can be converted to by calling of Android method, simultaneously, as shown in Figure 3 D, MIUI method still can call the Android method be replaced, thus realize when Android system edition upgrading, MIUI system also can be upgraded thereupon, and in escalation process, do not need amendment Android source code, thus can save time, reduce error rate and improve upgrading efficiency.
In addition, due in android system, each software operates in different processes, and mutually isolated between process, therefore, can not have influence on other processes to the amendment of a process.For the process at MIUI software place, the method for android system is replaced with the method for MIUI system, MIUI system can be realized and upgrade along with the upgrading of android system; And for third party software, the method for android system is not replaced, thus ensure that the compatibility to third party software, namely the upgrading of MIUI system is on third party software without impact, thus avoids because the system that causes of compatibility issue is unstable.
It should be noted that, this embodiment, for android system and MIUI system, describes the process that MIUI system is upgraded along with the upgrading of android system.It should be appreciated by those skilled in the art, the upgrading between other compatible systems also can adopt the method to realize, and does not enumerate herein.
Said system upgrade method embodiment, by former method is replaced with the first method, former method is backuped in the second method, then calling the first method is converted to by calling of former method, and pass through the former method of the second method call backup, thus when not revising source code, realize the upgrading of compatible system, cost savings the time, decrease error rate and improve upgrading efficiency.
Fig. 4 is the process flow diagram of the another kind of method replacement process according to an exemplary embodiment, as shown in Figure 4, comprises the steps S401-S410:
In step S401, create a data area, and initialization.
Wherein, this data area is for preserving the address of the address of former method, the address of the first method and the second method.
In step S402, obtain the entry address of former method.
In step S403, calculating former method porch will the size of coated region, and distributes a region of memory, is saved in data area the address of this region of memory.
In step s 404, the code copies that will be capped former method porch is in region of memory.
In step S405, write the address of the first jump instruction and data area in former method porch.
In this embodiment, the object of the address of write data area, former method porch be in order to make follow-up carry out Parameter Switch time, the address of the first method can be got.
In step S406, add the register after rebound and recover instruction.
In step S 407, the register calculated after rebound recovers instruction address.
In step S408, register is recovered instruction address and adds region of memory to, and at region of memory write jump back instruction.
In step S409, obtain the entry address of the second method.
In step S410, write the address of the second jump instruction and data area in the porch of the second method.
In this embodiment, the object of the address of the second write data area, method porch be in order to make follow-up carry out Parameter Switch time, the address of the second method can be got.
Above-described embodiment, can realize former method to replace with the first method, former method be backuped in the second method, thus provides condition for follow-up implementation method calls conversion.
Fig. 5 is that a kind of according to an exemplary embodiment calls to former method the process flow diagram called be converted to the first method, and as shown in Figure 5, the method comprises the following steps S501-S506:
In step S501, preserve by the register used.
Because register may preserve other information, therefore, before register is written into new data, need to preserve by the register used.
In step S502, obtain jump target addresses, and be written in register.
In this embodiment, processor directly can not jump to any one address of specifying, and first destination address can only be write a register, and processor reads destination address and performs from register.Such as, in processor architecture popular at present (as ARMCPU), just adopt in this way.
Wherein, jump target addresses can be the first function address in the first jump instruction.
In step S503, jump to the first function.
In step S504, recover the register be saved.
Now, the register saving the first function address has completed redirect task, does not re-use, the register preserved before at this moment needing to recover.
It should be noted that, all embodiments of the disclosure, before use register, all need to preserve by the register used, after using register, and the register preserved before all needing to recover.
In addition, this embodiment is described for R0 register (R0 register is in 16 registers of ARMCPU), in actual applications, other modes can be adopted to jump to the first function.Such as, the processor (as x86) of other frameworks allows destination address to directly write in jump instruction.In this case, do not need extra register to preserve jump address.But it still needs " preserving-use-recovery " principle following register, to ensure that data can not be lost, thus ensures integrality and the consistance of data.
In step S505, be the parameter of the first method by the Parameter Switch of former method.
In this embodiment, by the first function by the Parameter Switch of former method be the parameter of the first method.
In step S506, obtain the entrance of the first method, and jump to the first method.
After Parameter Switch completes, the entrance of the first method can be got, thus redirect can perform the first method.
Above-described embodiment, can be realized by former method calling to the first method by Parameter Switch, owing to containing the fresh code after upgrading in the first method, therefore, this embodiment can realize system upgrade when not revising source code.
Fig. 6 is a kind of process flow diagram by the former method of the second method call according to an exemplary embodiment, and as shown in Figure 6, the method comprises the following steps S601-S612:
In step s 601, preserve by the register used.
In step S602, obtain jump target addresses, and be written into register.
Wherein, jump target addresses can be the second function address in the second jump instruction.
In step S603, jump to the second function.
In step s 604, the register be saved is recovered.
In step s 605, by the Parameter Switch of the second method be the parameter of former method.
In this embodiment, by the second function by the Parameter Switch of the second method be the parameter of former method.
In step S606, obtain the address of having backed up the region of memory of former method.
In step S607, jump to the porch of this region of memory, and run time version.
In this embodiment, the code that the porch that the code of region of memory is former method is capped.
Above-mentioned steps S601-607 achieves the process of the code by the second function call backup.
In step S608, preserve by the register used.
In step S609, obtain rebound and recover instruction, and be written into register.
In step S610, the rebound jumping to former method recovers instruction.
In step s 611, the value of register is recovered.
In step S612, continue to perform the code of not capped part in former method.
Above-mentioned steps S601-612 achieves the second method calling to former method.
Above-described embodiment, is realized by the second method calling to former method by Parameter Switch, thus can ensure the compatibility to third party software.
Corresponding with aforementioned system upgrade method embodiment, the disclosure additionally provides system upgrade device embodiment.
Fig. 7 is the block diagram of a kind of system upgrade device according to an exemplary embodiment, and as shown in Figure 7, this system upgrade device comprises: replace backup module 71 and conversion calling module 72.
Replace backup module 71 to be configured to former method to replace with the first method, former method is backuped in the second method.
In this embodiment, in order to reach when not revising source code, make Android compatible system can follow android system upgrading, third party software being kept compatible simultaneously, former method is replaced with the first method by the present embodiment, former method is backuped in the second method.
Because android system major part adopts java language compilation, and the smallest executable unit of Java language is method (Method).Therefore, the present embodiment is in method for unit replaces.Wherein, method is the set of batch processing code, and this group program code can accept one group of input data as parameter, and returns result of calculation.
Conversion calling module 72 is configured to be converted to calling first method of replacing backup module replacement by calling of former method, and replaces the former method of backup module backup by the second method call.
In this embodiment, owing to writing the first jump instruction in the porch of former method, therefore, the first function can be jumped to by the first jump instruction, and be the parameter of the first method by the Parameter Switch of former method by the first function, thus first method of execution.
Similarly, owing to writing the second jump instruction in the porch of the second method, therefore, the second function can be jumped to by the second jump instruction, and be the parameter of former method by the Parameter Switch of the second method by the second function, thus perform the code of region of memory backup.
Suppose, Android compatible system is rice shaddock (MIUI) system, as shown in Figure 3 C, former method in Android system is former method 1-3, corresponding is MIUI method 1-3 (dotted line in Fig. 3 C represents the corresponding relation of former method 1-3 and MIUI method 1-3) for replacing the MIUI method of former method 1-3, adopt the upgrade method that the embodiment of the present invention provides, when MIUI running software, former method 1-3 can be replaced with MIUI method 1-3, after replacement completes, calling MIUI method can be converted to by calling of Android method, simultaneously, as shown in Figure 3 D, MIUI method still can call the Android method be replaced, thus realize when Android system edition upgrading, MIUI system also can be upgraded thereupon, and in escalation process, do not need amendment Android source code, thus can save time, reduce error rate and improve upgrading efficiency.
In addition, due in android system, each software operates in different processes, and mutually isolated between process, therefore, can not have influence on other processes to the amendment of a process.For the process at MIUI software place, the method for android system is replaced with the method for MIUI system, MIUI system can be realized and upgrade along with the upgrading of android system; And for third party software, the method for android system is not replaced, thus ensure that the compatibility to third party software, namely the upgrading of MIUI system is on third party software without impact, thus avoids because the system that causes of compatibility issue is unstable.
Device is as shown in Figure 7 for realizing above-mentioned method flow as shown in Figure 1, and the related content related to describes identical, does not repeat herein.
Said system update device embodiment, by replacing backup module, former method is replaced with the first method, former method is backuped in the second method, then calling the first method is converted to by conversion calling module by calling of former method, and pass through the former method of the second method call backup, thus when not revising source code, realize the upgrading of compatible system, cost savings the time, decrease error rate and improve upgrading efficiency.
Fig. 8 is the block diagram of the another kind of system upgrade device according to an exemplary embodiment, as shown in Figure 8, on above-mentioned basis embodiment illustrated in fig. 7, replacing backup module 71 can comprise: backup submodule 711, first writes submodule 712, second and writes submodule 713 and the 3rd write submodule 714.
The backup code that backup submodule 711 is configured to former method porch to be capped is to a region of memory.
Java is a kind of interpreted languages, operation java system, must install a software virtual machine.Software virtual machine reads bytecode, and according to the implication of bytecode, performs different computings.In version before 5.0, Android uses Dalvik virtual machine.From 5.0, Android introduces the virtual machine of an ART by name.As shown in Figure 3A, a step that the implementation of ART is more than Dalvik: Dalvik bytecode is converted to the instruction code that CPU can directly read, and store hereof, the form of this file, be called OAT file by ART, then directly performed the instruction code be stored in OAT file by CPU.
Wherein, what OAT file stored is class (Class) information of java and the instruction code of method.The software of a use java language compilation, its program is made up of one group of class, and each Class is made up of several territories (Field) and Method.Field is used for defining data.A Field defines data.All Field of Class inside, define the data acquisition that this Class has.And this group data set of Method co-operate conjunction that Class is inner all.The data of each Method of each Class, all contain the position of the director data of this Method.Because disclosure embodiment does not relate to Field, therefore, hereafter the Field set of Class inside will automatically be ignored.
When the system is operated, ART builds the institutional framework of a Class at internal memory, with the similar of OAT file, as shown in Figure 3 B.The director data of Method is the instruction code set that CPU can be allowed directly to run.For different CPU architecture, director data is different.Wherein, conventional on desk-top computer, notebook is the CPU of X86-based, mainly uses the CPU of ARM framework in smart mobile phone field, etc.
The CPU of all frameworks has the assembly instruction collection of oneself, assembly instruction to be write with the mnemonic symbol that the mankind can read, and then generates the CPU binary command code that can perform through assemble software.Conversely, these binary command codes also can be disassembled the memonic symbol for the mankind can read.In smart mobile phone field, the CPU of ARM framework is main flow, and therefore, the present embodiment adopts the CPU of ARM framework to carry out the implementation procedure of description scheme.
In order to replace the Method of a Class inside, this embodiment introduces two methods, i.e. the first method and the second method, and the first method is used to replace the method in former method and Android system, the former method of the second method representation.
For convenience, former method can be called methodA, the first method is called handleMethodA, the second method is called originalMethodA.
In this embodiment, find the code address of methodA, the code that copy porch will be capped is for subsequent use in one piece of region of memory newly opened up.
First write submodule 712 is configured to write the first jump instruction in the porch of former method, and the first jump instruction is used for jumping to the first function, the parameter of the first function for by the Parameter Switch of former method being the first method.
The first jump instruction is write in the porch of methodA, namely this first jump instruction is for covering the code of methodA porch, like this, follow-up as system call methodA, Parameter Switch can be realized by the first function in the first jump instruction, Parameter Switch by former method is the parameter of the first method, and then realizes by former method calling to the first method.
Second write submodule 713 is configured to write the second jump instruction in the porch of the second method, and the second jump instruction is used for jumping to the second function, the parameter of the second function for by the Parameter Switch of the second method being former method.
In this embodiment, find the code address of originalMethodA, the second jump instruction is write in the porch of originalMethodA, like this, follow-up as system call originalMethodA, can realize Parameter Switch by the second function in the second jump instruction, the Parameter Switch by the second method is the parameter of former method, and then realizes the calling of code that be capped to methodA porch by the second method.
3rd write submodule 714 is configured at region of memory write jump back instruction.
Rebound can perform the code that is not capped of methodA in order to follow-up, this embodiment can add jump back instruction in region of memory.
Device is as shown in Figure 8 for realizing above-mentioned method flow as shown in figures 2 or 4, and the related content related to describes identical, does not repeat herein.
Said system update device embodiment, replaces with the first method by write jump instruction realization by former method, former method is backuped in the second method, thus provide condition for follow-up implementation method calls conversion.
Fig. 9 is the block diagram of the another kind of system upgrade device according to an exemplary embodiment, as shown in Figure 9, on above-mentioned basis embodiment illustrated in fig. 8, replaces backup module 71 and also can comprise: create submodule 710.
Creating submodule 710 is configured to before backup submodule 711 backup code that will be capped former method porch a to region of memory, create a data area, data area is for preserving the address of former method, the address of the first method, the address of the second method and the address of region of memory.
Wherein, this data area is for preserving the address of the address of former method, the address of the first method and the second method.
Wherein, the first write submodule 712 also can be configured to when the porch of former method writes the first jump instruction, the address of write data area.
Wherein, the second write submodule 713 also can be configured to when the porch of the second method writes the second jump instruction, the address of write data area.
Device is as shown in Figure 9 for realizing above-mentioned method flow as shown in Figure 4, and the related content related to describes identical, does not repeat herein.
Said system update device embodiment, by creating data area, preserves information required in replacement process, replaces provide condition for implementation method.
Figure 10 is the block diagram of the another kind of system upgrade device according to an exemplary embodiment, and as shown in Figure 10, on above-mentioned Fig. 8 or basis embodiment illustrated in fig. 9, conversion calling module 72 can comprise:
First redirect transform subblock 721, the first jump instruction being configured to be write by the first write submodule 712 jumps to the first function, and is the parameter of the first method by the Parameter Switch of former method by the first function, to perform the first method.
Device is as shown in Figure 10 for realizing above-mentioned method flow as shown in Figure 5, and the related content related to describes identical, does not repeat herein.
Said system update device embodiment, can be realized by former method calling to the first method by Parameter Switch, owing to containing the fresh code after upgrading in the first method, therefore, this embodiment can realize system upgrade when not revising source code.
Figure 11 is the block diagram of the another kind of system upgrade device according to an exemplary embodiment, and as shown in figure 11, on above-mentioned Fig. 8 or basis embodiment illustrated in fig. 9, conversion calling module 72 can comprise:
Second redirect transform subblock 722, the second jump instruction being configured to be write by the second write submodule 713 jumps to the second function, is the parameter of former method by the second function by the Parameter Switch of the second method, to perform the code of region of memory backup.
Device is as shown in figure 11 for realizing above-mentioned method flow as shown in Figure 6, and the related content related to describes identical, does not repeat herein.
Said system update device embodiment, is realized by the second method calling to backup code by Parameter Switch, thus can ensure the compatibility to third party software.
Figure 12 is the block diagram of the another kind of system upgrade device according to an exemplary embodiment, and as shown in figure 12, on above-mentioned basis embodiment illustrated in fig. 11, conversion calling module 72 also can comprise: rebound implementation sub-module 723.
Rebound implementation sub-module 723 is configured to, after the Parameter Switch of the second method by the second function is the parameter of former method by the second redirect transform subblock 722, perform the code of the capped part of former method according to jump back instruction rebound.
Device is as shown in figure 12 for realizing above-mentioned method flow as shown in Figure 6, and the related content related to describes identical, does not repeat herein.
Said system update device embodiment, performs calling of former method unmasked portion code by jump back instruction rebound, thus can ensure the compatibility to third party software.
About the device in above-described embodiment, wherein the concrete mode of modules, submodule executable operations has been described in detail in about the embodiment of the method, will not elaborate explanation herein.
Figure 13 is a kind of block diagram being applicable to system upgrade device according to an exemplary embodiment.Such as, device 1300 can be mobile phone, computing machine, digital broadcast terminal, messaging devices, game console, tablet device, Medical Devices, body-building equipment, personal digital assistant, aircraft etc.
With reference to Figure 13, device 1300 can comprise following one or more assembly: processing components 1302, storer 1304, power supply module 1306, multimedia groupware 1308, audio-frequency assembly 1310, the interface 1312 of I/O (I/O), sensor module 1314, and communications component 1316.
The integrated operation of the usual control device 1300 of processing components 1302, such as with display, call, data communication, camera operation and record operate the operation be associated.Treatment element 1302 can comprise one or more processor 1320 to perform instruction, to complete all or part of step of above-mentioned method.In addition, processing components 1302 can comprise one or more module, and what be convenient between processing components 1302 and other assemblies is mutual.Such as, processing element 1302 can comprise multi-media module, mutual with what facilitate between multimedia groupware 1308 and processing components 1302.
Storer 1304 is configured to store various types of data to be supported in the operation of equipment 1300.The example of these data comprises for any application program of operation on device 1300 or the instruction of method, contact data, telephone book data, message, picture, video etc.Storer 1304 can be realized by the volatibility of any type or non-volatile memory device or their combination, as static RAM (SRAM), Electrically Erasable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory EPROM (EPROM), programmable read only memory (PROM), ROM (read-only memory) (ROM), magnetic store, flash memory, disk or CD.
The various assemblies that electric power assembly 1306 is device 1300 provide electric power.Electric power assembly 1306 can comprise power-supply management system, one or more power supply, and other and the assembly generating, manage and distribute electric power for device 1300 and be associated.
Multimedia groupware 1308 is included in the screen providing an output interface between described device 1300 and user.In certain embodiments, screen can comprise liquid crystal display (LCD) and touch panel (TP).If screen comprises touch panel, screen may be implemented as touch-screen, to receive the input signal from user.Touch panel comprises one or more touch sensor with the gesture on sensing touch, slip and touch panel.Described touch sensor can the border of not only sensing touch or sliding action, but also detects the duration relevant to described touch or slide and pressure.In certain embodiments, multimedia groupware 1308 comprises a front-facing camera and/or post-positioned pick-up head.When equipment 1300 is in operator scheme, during as screening-mode or video mode, front-facing camera and/or post-positioned pick-up head can receive outside multi-medium data.Each front-facing camera and post-positioned pick-up head can be fixing optical lens systems or have focal length and optical zoom ability.
Audio-frequency assembly 1310 is configured to export and/or input audio signal.Such as, audio-frequency assembly 1310 comprises a microphone (MIC), and when device 1300 is in operator scheme, during as call model, logging mode and speech recognition mode, microphone is configured to receive external audio signal.The sound signal received can be stored in storer 1304 further or be sent via communications component 1316.In certain embodiments, audio-frequency assembly 1310 also comprises a loudspeaker, for output audio signal.
I/O interface 1312 is for providing interface between processing components 1302 and peripheral interface module, and above-mentioned peripheral interface module can be keyboard, some striking wheel, button etc.These buttons can include but not limited to: home button, volume button, start button and locking press button.
Sensor module 1314 comprises one or more sensor, for providing the state estimation of various aspects for device 1300.Such as, sensor module 1314 can detect the opening/closing state of equipment 1300, the relative positioning of assembly, such as described assembly is display and the keypad of device 1300, the position of all right pick-up unit 1300 of sensor module 1314 or device 1300 assemblies changes, the presence or absence that user contacts with device 1300, the temperature variation of device 1300 orientation or acceleration/deceleration and device 1300.Sensor module 1314 can comprise proximity transducer, be configured to without any physical contact time detect near the existence of object.Sensor module 1314 can also comprise optical sensor, as CMOS or ccd image sensor, for using in imaging applications.In certain embodiments, this sensor module 1314 can also comprise acceleration transducer, gyro sensor, Magnetic Sensor, pressure transducer or temperature sensor.
Communications component 1316 is configured to the communication being convenient to wired or wireless mode between device 1300 and other equipment.Device 1300 can access the wireless network based on communication standard, as WiFi, 2G or 3G, or their combination.In one exemplary embodiment, communication component 1316 receives from the broadcast singal of external broadcasting management system or broadcast related information via broadcast channel.In one exemplary embodiment, described communication component 1316 also comprises near-field communication (NFC) module, to promote junction service.Such as, can based on radio-frequency (RF) identification (RFID) technology in NFC module, Infrared Data Association (IrDA) technology, ultra broadband (UWB) technology, bluetooth (BT) technology and other technologies realize.
In the exemplary embodiment, device 1300 can be realized, for performing said method by one or more application specific integrated circuit (ASIC), digital signal processor (DSP), digital signal processing appts (DSPD), programmable logic device (PLD) (PLD), field programmable gate array (FPGA), controller, microcontroller, microprocessor or other electronic components.
In the exemplary embodiment, additionally provide a kind of non-transitory computer-readable recording medium comprising instruction, such as, comprise the storer 1304 of instruction, above-mentioned instruction can perform said method by the processor 1320 of device 1300.Such as, described non-transitory computer-readable recording medium can be ROM, random access memory (RAM), CD-ROM, tape, floppy disk and optical data storage devices etc.
Those skilled in the art, at consideration instructions and after putting into practice disclosed herein disclosing, will easily expect other embodiment of the present disclosure.The application is intended to contain any modification of the present disclosure, purposes or adaptations, and these modification, purposes or adaptations are followed general principle of the present disclosure and comprised the undocumented common practise in the art of the disclosure or conventional techniques means.Instructions and embodiment are only regarded as exemplary, and true scope of the present disclosure and spirit are pointed out by claim below.
Should be understood that, the disclosure is not limited to precision architecture described above and illustrated in the accompanying drawings, and can carry out various amendment and change not departing from its scope.The scope of the present disclosure is only limited by appended claim.

Claims (13)

1. a method for upgrading system, is characterized in that, described method comprises:
Former method is replaced with the first method, described former method is backuped in the second method;
Be converted to calling described first method by calling of described former method, and by described second method call backup described former method.
2. method for upgrading system according to claim 1, is characterized in that, described former method is replaced with the first method, described former method is backuped in the second method, comprising:
The backup code that will be capped described former method porch is to a region of memory;
Write the first jump instruction in the porch of described former method, described first jump instruction is used for jumping to the first function, the parameter of described first function for by the Parameter Switch of described former method being described first method;
Write the second jump instruction in the porch of described second method, described second jump instruction is used for jumping to the second function, the parameter of described second function for by the Parameter Switch of described second method being described former method;
At described region of memory write jump back instruction.
3. method for upgrading system according to claim 2, is characterized in that, before the described backup code that will be capped described former method porch a to region of memory, described method also comprises:
Create a data area, described data area is for preserving the address of described former method, the address of described first method, the address of described second method and the address of described region of memory;
When the porch of described former method writes the first jump instruction, described method also comprises:
Write the address of described data area;
When the porch of described second method writes the second jump instruction, described method also comprises:
Write the address of described data area.
4. the method for upgrading system according to Claims 2 or 3, is characterized in that, is describedly converted to calling described first method by calling of described former method, comprising:
Jump to the first function by described first jump instruction, and be the parameter of described first method by the Parameter Switch of described former method by described first function, to perform described first method.
5. the method for upgrading system according to Claims 2 or 3, is characterized in that, the described described former method by described second method call backup, comprising:
Jumping to the second function by described second jump instruction, is the parameter of described former method by the Parameter Switch of described second method by described second function, to perform the code of described region of memory backup.
6. method for upgrading system according to claim 5, is characterized in that, described by described second function by the Parameter Switch of described second method be the parameter of described former method after, described method also comprises:
The code of the not capped part of described former method is performed according to described jump back instruction rebound.
7. a system upgrade device, is characterized in that, described method comprises:
Replace backup module, be configured to former method to replace with the first method, described former method is backuped in the second method;
Conversion calling module, is configured to be converted to calling described first method that described replacement backup module is replaced by calling of described former method, and by replacing the described former method of backup module backup described in described second method call.
8. system upgrade device according to claim 7, is characterized in that, described replacement backup module comprises:
Backup submodule, the backup code being configured to described former method porch to be capped is to a region of memory;
First write submodule, be configured to write the first jump instruction in the porch of described former method, described first jump instruction is used for jumping to the first function, the parameter of described first function for by the Parameter Switch of described former method being described first method;
Second write submodule, be configured to write the second jump instruction in the porch of described second method, described second jump instruction is used for jumping to the second function, the parameter of described second function for by the Parameter Switch of described second method being described former method;
3rd write submodule, is configured at described region of memory write jump back instruction.
9. system upgrade device according to claim 8, is characterized in that, described replacement backup module also comprises:
Create submodule, before being configured to the backup code that will be capped described former method porch at described backup submodule a to region of memory, create a data area, described data area is for preserving the address of described former method, the address of described first method, the address of described second method and the address of described region of memory;
Wherein, described first write submodule, is also configured to, when the porch of described former method writes the first jump instruction, write the address of described data area;
Wherein, described second write submodule, is also configured to, when the porch of described second method writes the second jump instruction, write the address of described data area.
10. system upgrade device according to claim 8 or claim 9, it is characterized in that, described conversion calling module comprises:
First redirect transform subblock, be configured to jump to the first function by described first jump instruction of described first write submodule write, and be the parameter of described first method by the Parameter Switch of described former method by described first function, to perform described first method.
11. system upgrade devices according to claim 8 or claim 9, it is characterized in that, described conversion calling module comprises:
Second redirect transform subblock, be configured to jump to the second function by described second jump instruction of described second write submodule write, be the parameter of described former method by the Parameter Switch of described second method by described second function, to perform the code of described region of memory backup.
12. system upgrade devices according to claim 11, is characterized in that, described conversion calling module also comprises:
Rebound implementation sub-module, be configured to, after the Parameter Switch of described second method by described second function is the parameter of described former method by described second redirect transform subblock, perform the code of the capped part of described former method according to described jump back instruction rebound.
13. 1 kinds of system upgrade devices, is characterized in that, comprising:
Processor;
For the storer of storage of processor executable instruction;
Wherein, described processor is configured to:
Former method is replaced with the first method, described former method is backuped in the second method;
Be converted to calling described first method by calling of described former method, and by described second method call backup described former method.
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 true CN105335200A (en) 2016-02-17
CN105335200B 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)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106445662A (en) * 2016-09-13 2017-02-22 广东欧珀移动通信有限公司 Method for transplanting application procedure and terminal equipment
CN106502703A (en) * 2016-10-27 2017-03-15 腾讯科技(深圳)有限公司 A kind of function calling method and device
CN107832096A (en) * 2017-09-29 2018-03-23 五八有限公司 URL collocation method and terminal
CN107885982A (en) * 2017-09-29 2018-04-06 五八有限公司 Log in control process method and terminal

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020120810A1 (en) * 2001-02-28 2002-08-29 Brouwer Roger J. Method and system for patching ROM code
US20070028083A1 (en) * 2005-07-29 2007-02-01 Kelly Yu Method and system for modifying operation of ROM based boot code
CN101030149A (en) * 2006-02-28 2007-09-05 太阳微系统有限公司 Fast patch-based method calls
CN101937347A (en) * 2010-08-06 2011-01-05 深圳市共进电子有限公司 Method for managing automatic updating in special networked terminal equipment
CN102622241A (en) * 2011-01-26 2012-08-01 腾讯科技(深圳)有限公司 Software upgrading method and software upgrading device
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
CN104765634A (en) * 2015-05-06 2015-07-08 山东中孚信息产业股份有限公司 Method for increasing new functions of Linux system kernel
CN104981778A (en) * 2013-02-22 2015-10-14 马维尔国际贸易有限公司 Patching boot code of read-only memory

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020120810A1 (en) * 2001-02-28 2002-08-29 Brouwer Roger J. Method and system for patching ROM code
US20070028083A1 (en) * 2005-07-29 2007-02-01 Kelly Yu Method and system for modifying operation of ROM based boot code
CN101030149A (en) * 2006-02-28 2007-09-05 太阳微系统有限公司 Fast patch-based method calls
CN101937347A (en) * 2010-08-06 2011-01-05 深圳市共进电子有限公司 Method for managing automatic updating in special networked terminal equipment
CN102622241A (en) * 2011-01-26 2012-08-01 腾讯科技(深圳)有限公司 Software upgrading method and software upgrading device
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
CN104765634A (en) * 2015-05-06 2015-07-08 山东中孚信息产业股份有限公司 Method for increasing new functions of Linux system kernel

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106445662A (en) * 2016-09-13 2017-02-22 广东欧珀移动通信有限公司 Method for transplanting application procedure and terminal equipment
CN106502703A (en) * 2016-10-27 2017-03-15 腾讯科技(深圳)有限公司 A kind of function calling method and device
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
CN107885982A (en) * 2017-09-29 2018-04-06 五八有限公司 Log in control process method and terminal
CN107885982B (en) * 2017-09-29 2021-08-24 五八有限公司 Login control processing method and terminal

Also Published As

Publication number Publication date
CN105335200B (en) 2019-05-07

Similar Documents

Publication Publication Date Title
CN104951335B (en) The processing method and processing device of application program installation kit
CN104484200A (en) Method and device for updating firmware
CN105468410A (en) System upgrading method and device
CN104951336A (en) Application program installation method and device
CN104281478B (en) The method and device of more new application
CN104156236A (en) Storage space saving method and device
CN105094577A (en) Method and apparatus for application switching
CN105094931A (en) Software upgrading method and device
CN104679599A (en) Application program duplicating method and device
CN107391218A (en) Compilation Method and device, electronic equipment and computer-readable recording medium
CN107423106A (en) The method and apparatus for supporting more frame grammars
CN105204804A (en) Mode switching method, device and system
CN104536935A (en) Calculation displaying method, calculation editing method and device
CN105335200A (en) System upgrading method and device
CN107241495A (en) The split screen treating method and apparatus of terminal device
CN105376412A (en) Information processing method and device
CN105892805A (en) Instant message processing method and device
CN104407924A (en) Method and device for optimizing internal memory
US10613848B2 (en) Firmware refreshing method and device
CN105094830A (en) Method and device for executing target functions
CN105183571A (en) Function calling method and device
CN106021072A (en) Information display method and device
CN105630546A (en) System updating method and system updating device
CN107450912A (en) Layout method, device and the terminal of the page
CN105487903A (en) System upgrading method and device

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