Method, device and computer storage medium for extending Android system functions
By defining extended target system function interfaces and classes, and using the Android reflection mechanism to construct and replace native server classes, the problem of modifying the Android system's extended functions is solved, functional expansion is achieved and code modifications are avoided, and development efficiency and system stability are improved.
Patent Information
- Application Number
- CN202011106553.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-15
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2040-10-15
AI Technical Summary
It is difficult to modify the native framework code by extending the functions of the Android system, making subsequent platform version upgrades time-consuming, laborious, and risky.
By defining extended target system functional interfaces, client classes, and server classes, the reflection mechanism of the Android system is used to build and replace native server classes to achieve functional expansion without modifying the native code.
It realizes the expansion of Android system functions, avoids modification of the native framework code, reduces the workload of code transplantation, and improves development efficiency and system stability.
Smart Images

Figure CN112256249B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of system development, and in particular to a method for expanding the functions of an Android system. Background Art
[0002] Android is an open source smart terminal operating system launched by Google. AIDL (Android Interface Definition Language) is the Android interface definition language, which is a description language used to define the communication interface between the server and the client. It can be used to generate code for IPC (Inter-Process Communication). The system functions provided by Android basically adopt the Manager / ADIL / Service model. For example, AMS, WMS, PMS, Surface, etc. The Manager client provides the SDK interface, the Service server implements the interface function, and the communication part is generated by AIDL.
[0003] During the development process, Android terminal manufacturers often expand the original system functions of the Android framework due to their own functional requirements. The typical approach is to directly modify the framework source code: modify the original ADIL file to add interfaces, modify the Manager client to add interfaces and implementations, and modify the service to add interface implementations. However, this expansion method of directly modifying the native file will change the source code of the Android framework beyond recognition, which is time-consuming, labor-intensive and risky for subsequent platform version upgrades. Summary of the invention
[0004] In view of this, the present application provides a method for extending the functions of the Android system to solve the problem of modifying the native framework code when extending the functions of the Android system.
[0005] The embodiment of the present application provides a method for extending the functions of an Android system, characterized in that the method includes:
[0006] Defining an extended target system function interface; the extended target system function interface is used to extend the function of the Android system module;
[0007] Defining an extended target client class; the extended target client class implements the extended target system functional interface;
[0008] Define an extended target server class; the extended target server class inherits from the server class of the Android system and implements the extended target system function interface.
[0009] In one embodiment, it further includes:
[0010] Using the reflection mechanism of the Android system to construct the extended target server class;
[0011] The extended target server class replaces the native server class in the Android system to modify the service startup code of the Android system.
[0012] In one embodiment, it further includes:
[0013] The extended target system function interface is called to implement the extension of Android system functions.
[0014] In one embodiment, the definition of the extended target system functional interface includes:
[0015] Static variables are defined, and according to the code generated by the Android interface definition language, the static variables are determined to be based on temporary credentials in the communication mechanism.
[0016] In one embodiment, the definition of the extended target system functional interface includes:
[0017] Define the extended target interface function and list.
[0018] In one embodiment, the definition of the extended target system functional interface includes:
[0019] Define the communication interface ID of the target interface function; wherein each of the target interface functions corresponds to a communication interface ID and does not conflict with the communication interface ID generated by the Android interface definition language.
[0020] In one embodiment, the static variables are obtained as follows:
[0021] Search the JAVA file generated by compiling the Android interface definition language file;
[0022] and / or,
[0023] Defined according to preset rules.
[0024] In one embodiment, the definition of the extended target client class includes:
[0025] The communication mechanism of the extended target system function interface is obtained and saved in the member variable defined in the extended target client class.
[0026] In one embodiment, it further includes:
[0027] According to the protocol format of the communication mechanism, the communication interface ID, the static variables and the input parameters of the target interface function are sent to the extended target server class.
[0028] In one embodiment, the extended target server class includes:
[0029] Overload the onTransact function.
[0030] In one embodiment, the extended target server class further includes:
[0031] A function that implements the extended target system functional interface.
[0032] In one embodiment, the overloaded onTransact function includes:
[0033] When the communication interface ID received from the extended target client class is equal to the communication interface ID of the corresponding target interface function in the extended target system function interface, the temporary credential of the static variable is verified and the corresponding target interface function is called;
[0034] Otherwise, call the parent class onTransact function for processing.
[0035] To achieve the above-mentioned purpose, a computer-readable storage medium is also provided, on which a method program for extending the functions of the Android system is stored, characterized in that when the method program for extending the functions of the Android system is executed by a processor, the steps of any of the above-mentioned methods are implemented.
[0036] To achieve the above-mentioned purpose, a device is also provided, including a memory, a processor, and a method program for extending the functions of the Android system stored in the memory and executable on the processor, wherein when the processor executes the method program for extending the functions of the Android system, the steps of any of the above-mentioned methods are implemented.
[0037] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: defining an extended target system function interface; the extended target system function interface is used to extend the function of the Android system module; a new target system function interface is added to extend the function of the native system, which is the basis of the extended target client class and the extended target server class, and is also the object interface to be implemented. Define an extended target client class; the extended target client class implements the extended target system function interface; the extended target client class implements the extended target system function interface to implement new functions to achieve function extension. Define an extended target server class; the extended target server class inherits from the server class of the Android system and implements the extended target system function interface; inheritance can make the extended target server class have the attributes and methods of the native server class or redefine and add attributes and methods, etc. Inheritance technology makes it very easy to reuse previous codes, which can greatly shorten the development cycle and reduce development costs. Solve the problem of modifying the native framework code of the Android system extension function. While achieving the purpose of extending the Android system function, avoid modifying the Android native framework code. The present invention reduces the workload of code transplantation and extension functions and improves efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic diagram of the hardware architecture of the method for extending the functions of the Android system in this application;
[0039] Figure 2 A flowchart of a first embodiment of a method for extending Android system functions in this application;
[0040] Figure 3 A flowchart of a second embodiment of the method for extending the functions of the Android system of the present application;
[0041] Figure 4 This is a schematic diagram of the technical solution for this application taking the expansion of Android AMS system functions as an example. DETAILED DESCRIPTION
[0042] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0043] The main solution of the embodiment of the present invention is: define an extended target system function interface; the extended target system function interface is used to extend the function of the Android system module; define an extended target client class; the extended target client class implements the extended target system function interface; define an extended target server class; the extended target server class inherits from the server class of the Android system and implements the extended target system function interface. The present invention solves the problem of modifying the native framework code when extending the function of the Android system, and achieves the purpose of extending the function of the Android system while avoiding modifying the Android native framework code. At the same time, the present invention reduces the workload of code transplantation and extended functions, and improves efficiency.
[0044] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0045] The present application relates to a device 010 including: Figure 1 Shown: at least one processor 012 and a memory 011.
[0046] Processor 012 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in processor 012 or instructions in software form. The above processor 012 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present invention can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The software module may be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 011, and the processor 012 reads the information in the memory 011 and completes the steps of the above method in combination with its hardware.
[0047] It can be understood that the memory 011 in the embodiment of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct RAM bus random access memory (DRRAM). The memory 011 of the system and method described in the embodiments of the present invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0048] Reference Figure 2 , Figure 2 This is the first embodiment of the method for extending the functions of the Android system of the present application. The method for extending the functions of the Android system comprises the following steps:
[0049] Step S110: defining an extended target system function interface; the extended target system function interface is used to perform function extension on the Android system module.
[0050] Android is a free and open source operating system based on the Linux kernel (excluding GNU components). It is mainly used in mobile devices such as smartphones and tablets, and is led and developed by Google and the Open Handset Alliance. The Android system architecture is divided into four layers, from high to low, namely the application layer (Applications), the application framework layer (Application Framework), the system runtime layer (Libraries and Android Runtime) and the Linux kernel layer (Linux Kernel).
[0051] Interface is a keyword for interface operation in object-oriented programming languages. Its function is to combine required members to encapsulate a set of certain functions. An interface is a template that defines the members that an object must implement, and implements it through classes or structures. An interface cannot contain any code for members, only the members themselves are defined. The specific code of interface members is provided by the class that implements the interface.
[0052] The extended target system functional interface is to define a special class (template) in which member variables and functions that the object must implement are defined, and is implemented through the extended target client class and the extended target server class.
[0053] The native system module is a module in the Android system source code. In this embodiment, the Android system is functionally expanded by adding a new system function interface, wherein the functional expansion is the developer developing new functions for the Android system functions.
[0054] Step S120: defining an extended target client class; the extended target client class implements the extended target system functional interface.
[0055] The extended target client class is to define an extended class of a client, wherein the extended target client class may include a variety of preset member attributes and preset member methods, which are not limited to certain attributes and methods, and are adjusted and changed according to the functions to be extended by the developer.
[0056] The extended target client class realizes the extended target system functional interface through specific code, which includes the definition of variables, the specific implementation of functions, and the implementation of the calling process.
[0057] Class is the basis for information encapsulation in object-oriented programming (OOP). A class is a user-defined reference data type, also known as a class type. Each class contains a data description and a set of functions that operate on data or pass messages. An instance of a class is called an object.
[0058] The essence of a class is a reference data type, similar to basic data types such as byte, short, int (char), long, float, double, etc. The difference is that it is a complex data type. Because its essence is a data type rather than data, it does not exist in the memory and cannot be directly operated. It can only become operable when it is instantiated as an object.
[0059] A class is an abstraction of a class of things in real life that have common characteristics. If the data types provided in a program have a direct correspondence with the concepts in the application, the program will be easier to understand and easier to modify. A well-chosen set of user-defined classes will make the program more concise. In addition, it will make various forms of code analysis easier to perform. In particular, it will make it possible for the compiler to check for illegal uses of objects.
[0060] The class encapsulates properties and methods to operate its own members. A class is a definition of an object with behavior. It describes what an object can do and how it does it. These are programs and processes that can operate on the object. It contains information about how the object behaves, including its name, properties, methods, and events.
[0061] The composition of a class includes member attributes and member methods (data members and member functions). Data members correspond to the attributes of a class. The data members of a class are also a data type and do not require memory allocation. Member functions are used to operate the attributes of a class. They are unique operations of a class, such as "students" can "attend classes", but "fruits" cannot. The operation of interaction between a class and the outside world is called an interface.
[0062] Step S130: define an extended target server class; the extended target server class inherits from the server class of the Android system and implements the extended target system functional interface.
[0063] The extended target server class is to define an extended class of the server, wherein the extended target server class may include a variety of preset member attributes and preset member methods, which are not limited to certain attributes and methods, and are adjusted and changed according to the functions to be extended by the developer.
[0064] Inheritance is a concept in object-oriented software technology. It is one of the three basic characteristics of object-oriented technology, along with polymorphism and encapsulation. Inheritance allows a subclass to have the properties and methods of the parent class or to redefine and add properties and methods. This technology makes it very easy to reuse previous code, which can greatly shorten the development cycle and reduce development costs.
[0065] The creation of a subclass can add new data and new functions, and can inherit all the functions of the parent class, but cannot selectively inherit some of the functions of the parent class. Inheritance is the relationship between classes, not the relationship between objects.
[0066] For example: first define a class called car, which has the following attributes: body size, color, tires, steering wheel, brand, speed, and displacement. From the car class, two classes, sedan and truck, are derived. A small trunk is added to the sedan, and a large cargo box is added to the truck.
[0067] Inheritance allows a subclass to have various properties and methods of the parent class without having to write the same code again. When a subclass inherits the parent class, it can redefine some properties and override some methods, that is, overwrite the original properties and methods of the parent class, so that it has different functions from the parent class.
[0068] The native classes in the Android native system include Activity, Service, ContentProvider, BroadcastReceiver, etc.
[0069] The beneficial effects in the above embodiments are as follows: defining an extended target system function interface; the extended target system function interface is used to extend the function of the Android system module; a new target system function interface is added to extend the function of the native system, which is the basis of the extended target client class and the extended target server class, and is also the object interface to be implemented. defining an extended target client class; the extended target client class implements the extended target system function interface; the extended target client class implements the extended target system function interface, which is used to implement new functions to achieve function extension. defining an extended target server class; the extended target server class inherits from the server class of the Android system and implements the extended target system function interface; inheritance can make the extended target server class have the properties and methods of the native server class or redefine and add properties and methods, etc. inheritance technology makes it very easy to reuse previous codes, which can greatly shorten the development cycle and reduce development costs. solving the problem of modifying the native framework code of the Android system extension function. while achieving the purpose of extending the Android system function, avoiding modification of the Android native framework code. reducing the workload of transplanting extended functions and improving efficiency; efficient product inheritance, high software stability; strong feasibility of system upgrades, and short upgrade cycles.
[0070] Reference Figure 3 , Figure 3 This is the second embodiment of the method for extending the functions of the Android system of the present application, and the method for extending the functions of the Android system comprises the following steps:
[0071] Step S210: defining an extended target system function interface; the extended target system function interface is used to perform function extension on the Android system module.
[0072] Step S220: defining an extended target client class; the extended target client class implements the extended target system functional interface.
[0073] Step S230: define an extended target server class; the extended target server class inherits from the server class of the Android system and implements the extended target system functional interface.
[0074] Step S240: construct the extended target server class using the reflection mechanism of the Android system.
[0075] The JAVA reflection mechanism means that in the running state of the program, objects of any class can be constructed, the class to which any object belongs can be understood, the member variables and methods of any class can be understood, and the properties and methods of any object can be called. This function of dynamically obtaining program information and dynamically calling objects is called the reflection mechanism of the JAVA language. Reflection is regarded as the key to dynamic languages.
[0076] Step S250: Replace the native server class in the Android system with the extended target server class to modify the service startup code of the Android system.
[0077] An extended target server class is constructed through the JAVA reflection mechanism to replace the native server class, and the extended target server class replaces the native server class in the system service startup code to start the system service.
[0078] Calling the extended target system function interface can achieve the expansion of functions, so in the service startup code of the Android system, the extended target system function interface is used as the default startup interface, and the extended target system function replaces the Android native system function interface to achieve the function expansion of the Android system.
[0079] Step S260: calling the extended target system function interface to implement the expansion of Android system functions.
[0080] When the system service is started, the extended target system function interface will be called without any impact on the native system module, thus avoiding unnecessary risks caused by modifying the native system module.
[0081] Compared with the first embodiment, the second embodiment includes step S240, step S250, and step S260. The other steps are the same as those of the first embodiment and will not be described in detail.
[0082] The beneficial effects of the above embodiment are that the extended target server class is constructed through the JAVA reflection mechanism to replace the original server class, and the system startup code is modified to call the extended target system function interface to achieve new function extension, further reducing the workload of transplanting extended functions and improving efficiency.
[0083] In one embodiment, the definition of the extended target system functional interface includes:
[0084] Static variables are defined, and according to the code generated by the Android interface definition language, the static variables are determined to be based on temporary credentials in the communication mechanism.
[0085] In the field of computer programming, static variables refer to a type of variable for which the system statically allocates storage space before the program is executed (i.e., the allocation does not change during runtime). Corresponding to them are automatic variables (i.e., local variables) that only exist temporarily during runtime and some objects that obtain storage space in a dynamic allocation manner, where the storage space of automatic variables is allocated and released on the call stack.
[0086] AIDL (Android Interface Definition Language) is a description language used to define the communication interface between the server and the client. It can be used to generate code for IPC (Inter-Process Communication). In a sense, AIDL is actually a template, because in the process of use, it is not the AIDL file that actually works, but the instance code of an Interface generated based on it. AIDL is actually a template that appears to avoid us from rewriting code.
[0087] The purpose of designing the AIDL language is to achieve inter-process communication. In the Android system, each process runs in an independent memory, where it completes its own activities and is separated from other processes. But sometimes we have the need for interaction between applications, such as transferring data or delegating tasks, and AIDL was born to meet this need. Through AIDL, you can get the data of another process in one process and call its exposed methods, thereby meeting the needs of inter-process communication.
[0088] Usually, an application that exposes methods to other applications for calling is called a server, and an application that calls methods of other applications is called a client. The client interacts by binding to the service of the server.
[0089] The communication mechanism can be a Binder communication mechanism. The Binder mechanism uses the kernel space as a shared area, and the Binder driver establishes a mapping between the memory address of each process and the storage address in the kernel space. Therefore, the data only needs to be copied once. At the same time, the UID / PID identity is added to the sender, supporting both real-name Binder and anonymous Binder to improve security.
[0090] Temporary credentials can be a Token mechanism, which is an identifier for communication between processes.
[0091] In one embodiment, the definition of the extended target system functional interface includes:
[0092] Define the extended target interface function and list.
[0093] Define the extended target interface function, including the name of the interface function, the type of the interface function, etc. Also define the list formed by the interface function. The definition of the extended target interface function and the list are not limited to certain extended target interface functions, and are adjusted and changed according to the functions that the developer wants to extend.
[0094] In one embodiment, the definition of the extended target system functional interface includes:
[0095] Define the communication interface ID of the target interface function; wherein each of the target interface functions corresponds to a communication interface ID and does not conflict with the communication interface ID generated by the Android interface definition language.
[0096] The value of the communication interface ID must not conflict with the communication interface ID generated by the Android interface definition language. It is recommended to start from android.os.IBiner.FIRST_CALL_TRANCTION+10000, or if the number of original AIDL interface functions is greater than 10000, you can adjust the starting value of the communication interface number to ensure that the communication interface ID does not conflict.
[0097] The beneficial effects existing in the above embodiments are that the data security in the system function expansion is ensured through the Binder communication mechanism and the Token authentication mechanism.
[0098] In one embodiment, the static variable is obtained as follows:
[0099] Search the JAVA file generated by compiling the Android interface definition language file;
[0100] and / or,
[0101] Defined according to preset rules.
[0102] The defined static variables can be found in the JAVA file generated by compiling the AIDL file.
[0103] The preset rule can be AIDI package name + interface name.
[0104] For example: IStorageManage.aidl:android.os.storage.IStorageManager.
[0105] In one embodiment, the definition of the extended target client class includes:
[0106] The communication mechanism of the extended target system function interface is obtained and saved in the member variable defined by the extended target client.
[0107] Member variables can be used without initial values, and have a default initial value when called. For example, the initial value of int type is 0, and the initial value of string type is null.
[0108] The beneficial effects of the above embodiments are as follows: realizing the extended target client class is a step to ensure the realization of the extended target system interface, and is the basis for realizing the extension of Android system functions.
[0109] In one of the embodiments, the method further includes: sending the communication interface ID, the static variables and the input parameters of the target interface function to the extended target server class according to the protocol format of the communication mechanism.
[0110] Implement the target interface function with specific code and realize the functions of each interface function.
[0111] The communication mechanism may be a binder communication mechanism, which is a client-server communication structure. The client directly calls the server by obtaining the proxy interface of the server, wherein the methods defined in the proxy interface correspond one to one with the methods defined in the server; when the client calls the method in the proxy interface, the method in the proxy interface packages the parameters passed by the client into a Parcel object. In this embodiment, the parameters to be packaged may be the communication interface number of the extended target interface function, the static variables and input parameters, etc., and these parameters are packaged into a Parcel object.
[0112] The beneficial effects in the above embodiment are as follows: sending the parameters to the extended target server class is to further determine whether the conditions for calling the extended target interface function are met, which is a necessary step for system function expansion and provides parameter data for judgment processing.
[0113] In one embodiment, the extended target server class includes:
[0114] Overload the onTransact function.
[0115] Overloading means that the method name is the same but the parameters are different. The return type can be the same or different. Overloading rules: the overloaded method must change the parameter list (the number or type of parameters is different); the overloaded method can change the return type; the overloaded method can change the access modifier; the overloaded method can declare new or wider checked exceptions; methods can be overloaded in the same class or in a subclass. The return value type cannot be used as a criterion for distinguishing overloaded functions. Each overloaded method (or constructor) must have a unique parameter type list.
[0116] The main content of overloading the onTransact function is to convert the parameters of the onTransact function into the parameters of the extended target interface function. The parameter source of the onTransact function is passed in when the client calls the transact function. Therefore, if the transact function has a fixed-format input, the onTransact function will also have a fixed-format output.
[0117] In one embodiment, the extended target server class further includes:
[0118] A function that implements the extended target system functional interface.
[0119] Implement specific code for the functions of the extended target system functional interface.
[0120] The beneficial effects existing in the above embodiments are that realizing the extended target server class is a step to ensure the realization of the extended target system interface, and is the basis for further realizing the expansion of Android system functions.
[0121] In one embodiment, the overloaded onTransact function includes:
[0122] When the communication interface ID received from the extended target client class is equal to the communication interface ID of the corresponding target interface function in the extended target system function interface, the temporary credential of the static variable is verified and the corresponding target interface function is called;
[0123] Otherwise, call the parent class onTransact function for processing.
[0124] Verification is a method of correcting data errors during data transmission. Verifying the temporary credentials of static variables is an authentication process, which refers to verifying whether the client has the right to access the server. The current mainstream authentication method is to use authentication authorization to verify the correctness of the digital signature. In this embodiment, the correctness of the temporary credentials of the static variables is verified. This is not limited to the above-mentioned authentication method, and other verification modes can also be used.
[0125] The beneficial effects in the above embodiments are that to implement a Binder service, it is necessary to overload the onTransact function, so overloading the onTransact function is a necessary step to implement the communication mechanism and also a necessary step to implement the Android system function expansion.
[0126] In this embodiment, the technical solution diagram of the present application takes the extension of the Android AMS system function as an example, wherein the left half is the native class of the Android system, and the right half is the related class of the present application for the extended function of the Android system, as shown in the following figure. Figure 4 As shown, the extended target system function interface may be IActivityManagerEx, which defines a static variable DESCRIPTOR of type String, and also defines a target interface function mediaPlayerSetVideoFullScreen(); the extended target client class may be ActivityManagerEx, which implements the ActivityManagerEx() function, and implements the target interface function mediaPlayerSetVideoFullScreen() according to specific codes; in addition, the extended target server class may be ActivityManagerServiceEx, which inherits the native server class ActivityManagerService, overloads the onTransact() function, and implements the target interface function mediaPlayerSetVideoFullScreen() according to specific codes.
[0127] It can be seen that the above method does not modify the native framework code of the Android system. And it can achieve the purpose of expanding the functions of the Android system. This method reduces the workload of transplanting extended functions and improves efficiency.
[0128] The present invention also provides a computer-readable storage medium, on which a method program for extending the functions of an Android system is stored, characterized in that when the method program for extending the functions of an Android system is executed by a processor, the steps of any of the above-mentioned methods are implemented.
[0129] The present invention also provides a device, including a memory, a processor, and a method program for extending the functions of an Android system stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above-described methods when executing the method program for extending the functions of an Android system.
[0130] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0131] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0132] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0133] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0134] It should be noted that in the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claim. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.
[0135] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0136] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for extending the functions of an Android system, characterized in that: The method comprises: Defining an extended target system function interface; the extended target system function interface is used to extend the function of the Android system module, and the extended target system function interface defines member variables and functions that the object must implement; Defining an extended target client class; the extended target client class implements the extended target system functional interface, and the extended target client class includes a plurality of preset member attributes and preset member methods; Define an extended target server class; the extended target server class inherits from the Android system server class and implements the extended target system function interface; The definition of the extended target system function interface includes: defining static variables, and determining the static variables based on temporary credentials in the communication mechanism according to the code generated by the Android interface definition language; wherein the communication mechanism is a Binder communication mechanism, and the Binder communication mechanism uses the kernel space as a shared area, and the Binder driver establishes a mapping between the memory address of each process and the storage address in the kernel space; wherein the temporary credential is a Token mechanism, which is an identifier for communication between processes; Define an extended target interface function and list, wherein the extended target interface function includes the name of the interface function and the type of the interface function; Define the communication interface ID of the target interface function starting from when the number of original AIDL interface functions is greater than 10,000; wherein each target interface function corresponds to a communication interface ID and does not conflict with the communication interface ID generated by the Android interface definition language; The static variables are obtained by searching the JAVA file generated by compiling the Android interface definition language file; and / or defining the static variables according to a preset rule; wherein the preset rule is the AIDI package name + interface name; The method further comprises: constructing the extended target server class by using the reflection mechanism of the Android system; replacing the native server class in the Android system with the extended target server class to modify the service startup code of the Android system; calling the extended target system function interface to implement the extension of the Android system function; Wherein, the extended target server class includes: when the communication interface ID received from the extended target client class is equal to the communication interface ID of the corresponding target interface function in the extended target system function interface, then verify the temporary credential of the static variable and call the corresponding target interface function; otherwise, call the parent class onTransact function for processing; Among them, the extended target system function interface is IActivityManagerEx, which defines a static variable DESCRIPTOR of String type; the target interface function is defined as mediaPlayerSetVideoFullScreen; the extended target client class is ActivityManagerEx, which implements ActivityManagerEx function, and implements the target interface function mediaPlayerSetVideoFullScreen according to the code; the extended target server class is ActivityManagerServiceEx, which inherits the native server class ActivityManagerService; overload the onTransact function, and implement the target interface function mediaPlayerSetVideoFullScreen according to the code.
2. The method for extending the function of the Android system as claimed in claim 1, characterized in that: The target client class of the definition extension includes: The communication mechanism of the extended target system function interface is obtained and saved in the member variable defined in the extended target client class.
3. The method for extending the function of the Android system as claimed in claim 2, characterized in that: Also includes: According to the protocol format of the communication mechanism, the communication interface ID, the static variables and the input parameters of the target interface function are sent to the extended target server class.
4. The method for extending the function of the Android system as claimed in claim 1, characterized in that: The extended target server class includes: A function that implements the extended target system functional interface.
5. A computer-readable storage medium, characterized in that: A method program for extending the functions of the Android system is stored thereon, and when the method program for extending the functions of the Android system is executed by a processor, the steps of any one of the methods described in claims 1-4 are implemented.
6. A device, characterized in that: The invention comprises a memory, a processor and a method program for extending the functions of an Android system which is stored in the memory and can be run on the processor, wherein when the processor executes the method program for extending the functions of the Android system, the steps of any one of the methods described in claims 1 to 4 are implemented.
