A kind of method and system of dynamic replacement driver codes of modules of Android device
Technical field
Driven the present invention relates to Android device debugging technique field, more particularly to a kind of dynamic replacement Android device upper module
The method and system of code.
Background technology
Factory and scheme business, according to version type circuit design requirements, select each peripheral hardware mould when Android device is produced
Block produces machine.The code of Android system must be configured according to these peripheral modules, then compile out system image, programming
Into machine.If a certain batch order, it is thus only necessary to substituted for some peripheral hardware, such as Android device on the basis of upper once version type
It is upper to replace most frequent WIFI module, then to be accomplished by being reconfigured on code and programming, the time of consuming is long, efficiency
Lowly.
The content of the invention
The technical problem to be solved in the present invention, is to provide a kind of side of dynamic replacement driver codes of modules of Android device
Method and system, solve it is existing when Android device upper module is replaced consuming the time length, inefficiency the problem of.
What the present invention was realized in:
A kind of method of dynamic replacement driver codes of modules of Android device, comprises the following steps:
Step 10, the driving code loading catalogue by the driving KO files deposit Android device of the module;
Step 20, carry out ADB using host computer and Android device and be connected;
Step 30, performed using ADB the title of the module is written to the orders of sysfs file system nodes;
Step 40, restart Android device.
Further, the step 10 is specially:The driving KO files of the module are stored in Android device using ADB
Drive code loading catalogue.
Further, the restarting equipment in the step 40 is specially:The order for restarting Android device is sent using ADB.
Further, described module is WIFI module.
And the present invention also provides a kind of method of dynamic replacement driver codes of modules of Android device, applied to host computer
On, described host computer carries out ADB with Android device and is connected, and comprises the following steps:
Step 15, the driving code loading catalogue that the driving KO files of the module are sent to Android device;
The title of the module is written to the order of sysfs file system nodes by step 25, execution;
Step 35, restart Android device.
Further, described module is WIFI module.
And correspondingly, based on the above method, also provide a kind of dynamic replacement Android device upper module driving generation
The system of code, including Android device and host computer, described Android device carry out ADB with host computer and are connected, it is characterised in that:Institute
The host computer stated includes following module:
Drive sending module:Driving code for the driving KO files of Android device upper module to be sent to Android device
Load catalogue;
Title writing module:The title of Android device upper module is written to sysfs file system nodes for performing
Order;
Equipment restarts module:For restarting Android device.
Further, described Android device upper module is WIFI module.
The invention has the advantages that:It need not change and configuration code, save Android device and adjusted when module is replaced
The time of examination, efficiency is improved, accelerate the manufacturing schedule of project.
Brief description of the drawings
The present invention is further illustrated in conjunction with the embodiments with reference to the accompanying drawings.
Fig. 1 is the inventive method execution flow chart.
Embodiment
Refer to shown in Fig. 1, the present invention is described in detail below.
A kind of method of dynamic replacement driver codes of modules of Android device, this method is application method, is set for Android
Module image of haveing been friends in the past has been burnt for upper, but the module in Android device has replaced with the situation of new module, initially enters step
Rapid S101 adds the driving code of driving file (also referred to as driving KO files) deposit Android device of the module (i.e. new module)
Catalogue is carried, step S101 can then clip to driving code loading catalogue manually by the way that driving file first is put into storage card,
Method for optimizing is that file will be driven to send and driving code loading catalogue is stored to using ADB.ADB full name are Android Debug
Bridge, is the Debug instruments of Android, after being connected by host computer (such as computer) with the ADB of Android device, and host computer can be achieved
Order to Android device, which is performed or uploaded, downloads file.
If using ADB modes in S101, ADB connections will be first carried out before step S101, then now may be used
To save step S102.Otherwise to carry out step S102 to be connected using host computer and Android device progress ADB, subsequently into step
S103 performs the order that the title of module is written to sysfs file system nodes using ADB, i.e., replace the title of new module
Fall the title of old module.Finally restart Android device in step S104.Restarting that Android device can restart manually can also
The order for restarting Android device is sent using ADB.
This method can be used for WIFI module, it can also be used to other peripheral modules, such as camera module, sensor assembly.
Principle detailed description is carried out with WIFI module below.
Carry out after above-mentioned steps, Android device can be restarted, after restarting, when user clicks on opening for the WIFI of application program
When closing opening WIFI module, application program meeting Scheduling Framework layer (Framework Layer), ccf layer calls Android system
JNI mechanism, is sent to hardware abstraction layer (Hardware Layer), hardware abstraction layer is from WIFI module name by operational order
The title of WIFI module is read in the sysfs file system nodes of title, and is gone according to module title to driving code loading catalogue
Corresponding driving file is found, the driving file is then loaded, registration and initialization of the new module driving in kernel is completed.
To sum up, the present invention need not can be changed and configuration code, as long as using original Android mirror image come programming, utilizing
ADB instruments dynamically adjust peripheral hardware model, you can to complete the production of new engine.
Although the foregoing describing the embodiment of the present invention, those familiar with the art should manage
Solution, the specific embodiment described by us is merely exemplary, rather than for the restriction to the scope of the present invention, is familiar with this
The equivalent modification and change that the technical staff in field is made in the spirit according to the present invention, should all cover the present invention's
In scope of the claimed protection.