Android system event processing method, device, equipment and readable storage medium
By parsing configuration files and listening for events during Android system startup, and handling event actions according to configuration items, the stability and maintenance issues of the system framework code are resolved, enabling flexible implementation of functional requirements and reducing the frequency of system modifications.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-12
- Publication Date
- 2026-03-31
AI Technical Summary
Making extensive, frequent, and tightly coupled modifications to the Android system framework code can affect the stability of the system framework, lead to fragmentation of the system code, and increase the workload of subsequent system code maintenance and feature porting.
When the Android system starts, the configuration file is parsed, system events are listened for, and event actions are handled according to the configuration items in the configuration information, avoiding direct modification of the system framework code.
By handling events through configuration files, functional requirements can be met without modifying the code, reducing the frequency of system framework modifications and improving system stability and ease of function portability.
Smart Images

Figure CN115700467B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Android system development technology, and in particular to an Android system event handling method, apparatus, device and readable storage medium. Background Technology
[0002] With the development of "three-network convergence" (three networks, namely telecommunications network, computer network and cable TV network), the Android system has become the most widely used system on smart set-top boxes. The services carried on set-top boxes are becoming increasingly rich, and operators have more and more functional requirements for set-top box systems. In the process of developing and adapting the system framework, set-top box equipment manufacturers need to modify the code to meet the needs of different customers.
[0003] Currently, when there are new system requirements, the system framework code is usually modified directly to meet the functional requirements. However, making a lot of frequent and coupled modifications to the Android system framework code will affect the stability of the system framework and lead to the fragmentation of the system code, which in turn leads to a large workload for subsequent system code maintenance and function porting. Summary of the Invention
[0004] The main objective of this invention is to provide an Android system event handling method, apparatus, device, and readable storage medium, aiming to solve the technical problem that large-scale, frequent, and coupled modifications to the Android system framework code will affect the stability of the system framework, and will also lead to fragmentation of the system code, resulting in a large workload for subsequent system code maintenance and function porting.
[0005] In a first aspect, the present invention provides an Android system event handling method, the Android system event handling method comprising:
[0006] When the Android system starts, it parses the configuration file to obtain configuration information, which includes one or more configuration items, including event type, event parameters and event action;
[0007] Listen for Android system events, treat the listened Android system events as pending events, and obtain the event type and event parameters of the pending events;
[0008] Based on the event type and event parameters of the event to be processed, search for the corresponding configuration item in the configuration information. If found, execute the event action in the found configuration item.
[0009] Optionally, the configuration item further includes a trigger condition, wherein if found, executing the event action in the found configuration item includes:
[0010] If found, and the current environment of the Android system meets the triggering conditions in the found configuration item, then the event action in the found configuration item will be executed.
[0011] Optionally, the configuration items also include functions, function parameters, classes, and packages, and the execution of the event actions in the found configuration items includes:
[0012] Load the classes and packages found in the configuration items, execute the event actions in the configuration items, and execute the functions in the configuration items with the function parameters in the configuration items as parameters.
[0013] Optionally, the configuration item further includes a processing flag, which, after the step of executing the event action in the found configuration item if found, includes:
[0014] If the value of the processing flag in the found configuration item is the first preset value, the event will be handed over to the Android system for further processing.
[0015] If the value of the processing flag in the found configuration item is the second preset value, then the event processing ends.
[0016] Optionally, the event types include key events, Intent events, broadcast events, and data read / write events, and before parsing the configuration file to obtain configuration information when the Android system starts, including:
[0017] Configure the configuration file according to the event type.
[0018] Secondly, the present invention also provides an Android system event handling device, the Android system event handling device comprising:
[0019] The parsing module is used to parse the configuration file to obtain configuration information when the Android system starts. The configuration information includes one or more configuration items, and the configuration items include event type, event parameters and event actions.
[0020] The listening module is used to listen for Android system events, treat the listened Android system events as pending events, and obtain the event type and event parameters of the pending events;
[0021] The execution module is used to search for the corresponding configuration item in the configuration information based on the event type and event parameters of the event to be processed. If found, the event action in the found configuration item is executed.
[0022] Optionally, the configuration item further includes a trigger condition, and the execution module is used to:
[0023] If found, and the current environment of the Android system meets the triggering conditions in the found configuration item, then the event action in the found configuration item will be executed.
[0024] Optionally, the configuration items also include functions, function parameters, classes, and packages; the execution module is further used for:
[0025] Load the classes and packages found in the configuration items, execute the event actions in the configuration items, and execute the functions in the configuration items with the function parameters in the configuration items as parameters.
[0026] Thirdly, the present invention also provides an Android system event handling device, the Android system event handling device including a processor, a memory, and an Android system event handling program stored in the memory and executable by the processor, wherein when the Android system event handling program is executed by the processor, it implements the steps of the Android system event handling method as described above.
[0027] Fourthly, the present invention also provides a readable storage medium storing an Android system event handler, wherein when the Android system event handler is executed by a processor, it implements the steps of the Android system event handling method as described above.
[0028] In this invention, when the Android system starts, the configuration file is parsed to obtain configuration information. This configuration information includes one or more configuration items, each containing an event type, event parameters, and event actions. Android system events are monitored, and the monitored events are treated as pending events. The event type and event parameters of each pending event are obtained. Based on the event type and event parameters of the pending event, the corresponding configuration item is searched in the configuration information. If found, the event action in the found configuration item is executed. This invention, by parsing the configuration file and monitoring Android system events during Android system startup, and then processing the events according to the corresponding configuration items in the parsed configuration information, enables most Android system functionalities to be implemented through the configuration file. This avoids the need for extensive, frequent, and tightly coupled code modifications during Android system development. Attached Figure Description
[0029] Figure 1 This is a flowchart illustrating an embodiment of the Android system event handling method of the present invention;
[0030] Figure 2 This is a schematic diagram of a configuration file for an embodiment of the Android system event handling method of the present invention;
[0031] Figure 3 This is a schematic diagram of event types in an embodiment of the Android system event handling method of the present invention;
[0032] Figure 4 This is a schematic diagram of the event handling framework of an embodiment of the Android system event handling method of the present invention;
[0033] Figure 5 This is a schematic diagram of the functional modules of an embodiment of the Android system event handling device of the present invention.
[0034] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0035] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0036] In a first aspect, embodiments of the present invention provide an Android system event handling device, the Android system event handling device including a processor, a memory, and an Android system event handling program stored in the memory and executable by the processor, wherein when the Android system event handling program is executed by the processor, it implements the steps of the Android system event handling method as described above.
[0037] Secondly, embodiments of the present invention provide an Android system event handling method.
[0038] To more clearly demonstrate the Android system event handling method provided in the embodiments of this application, we will first introduce the application scenarios of the Android system event handling method provided in the embodiments of this application.
[0039] The Android system event handling method provided in this application is applicable as the use of the Android system becomes more and more widespread. When developing the Android system according to the functional requirements of customers, a large number of frequent and coupled modifications to the Android system framework code are required, which will affect the stability of the system framework and lead to the fragmentation of the system code. This will result in a large workload for subsequent system code maintenance and function porting.
[0040] In one embodiment, reference is made to Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the Android system event handling method of the present invention, as shown below. Figure 1 As shown, the Android system event handling method includes:
[0041] Step S10: When the Android system starts, the configuration file is parsed to obtain configuration information. The configuration information includes one or more configuration items, and the configuration items include event type, event parameters and event actions.
[0042] In this embodiment, when the Android system starts, configuration information is obtained by parsing the configuration file. The configuration file can be edited and saved in XML (Extensible Markup Language) format, as shown in the reference. Figure 2 , Figure 2This is a schematic diagram of a configuration file for an embodiment of the Android system event handling method of the present invention, as shown below. Figure 2 As shown, configuration information typically consists of multiple configuration items, including but not limited to event type, event parameters, and event actions. (Refer to...) Figure 3 , Figure 3 This is a schematic diagram of event types in an embodiment of the Android system event handling method of the present invention, as shown below. Figure 3 As shown, event types include, but are not limited to, key events, Intent events, broadcast events, and data read / write events. Event types can be expanded as needed, as can event actions. Event parameters are the relevant event parameters when the aforementioned events occur. For example, in a key event, the current key value is the event parameter. Event actions are the actions to be performed when a corresponding type of event occurs and the corresponding event parameters are generated. For example, if the event type is a key event and the current key value is 3, a certain function is executed. Specific event actions correspond to specific event types. For example, if the specific event type is "send key," the specific event action is to call a predefined interface to send a virtual key; if the specific event type is "initiate an Intent request," the action is configured according to the function. The parameters in the configuration file are used to launch an Activity or Service. If the specific event type is to call a system framework function, the class name, function name, parameter types, and parameter values of the function to be called are specified in the configuration file. The corresponding function is then called via reflection to trigger the corresponding function execution action. If the specific event type is to send a broadcast, a predefined interface is called to send a system broadcast. If the specific event type is to perform data read / write, the corresponding data read / write interface is called based on the configuration file type being read / written. For example, if it is a database, the database read / write interface is called; if it is a system property, the property read / write interface is called; if it is a regular file, the file read / write interface is called; and if it is a SharedPreferences file, the SharedPreferences read / write interface is called.
[0043] Step S20: Listen for Android system events, treat the listened Android system events as pending events, and obtain the event type and event parameters of the pending events.
[0044] In this embodiment, Android system events are monitored. When an Android system event is detected, the monitored Android system event is treated as a pending event, and the event type and event parameters of the pending event are obtained.
[0045] Step S30: Based on the event type and event parameters of the event to be processed, search for the corresponding configuration item in the configuration information. If found, execute the event action in the found configuration item.
[0046] In this embodiment, after obtaining the event type and event parameters of the event to be processed in step S20, since the configuration items in the configuration information store the event type, event parameters, and event actions, a search is performed in the configuration information according to the event type and event parameters of the event to be processed. If a configuration item corresponding to the event type and event parameters of the event to be processed is found, the event action in the found configuration item is executed, thereby realizing the processing of the monitored Android system events according to the configuration items in the configuration file. Another foreseeable situation is that if a configuration item corresponding to the event type and event parameters of the event to be processed is not found in the configuration information, the current event to be processed is thrown to the Android system for processing.
[0047] In this embodiment, refer to Figure 4 , Figure 4 This is a schematic diagram of the event handling framework of an embodiment of the Android system event handling method of the present invention, as shown below. Figure 4 As shown, since most user behaviors in the Android system are triggered by events, the embodiments of this invention enable most Android system functionalities to be achieved through configuration files without modifying the code. This avoids the need for extensive, frequent, and coupled modifications to the code during Android system development, reduces the frequency of modifications to the Android system framework code, thereby reducing the workload of subsequent system code maintenance, improving the ease of function porting, and ensuring the functional stability of the system framework code.
[0048] Furthermore, in one embodiment, the configuration item further includes a triggering condition, and step S30 includes:
[0049] If found, and the current environment of the Android system meets the triggering conditions in the found configuration item, then the event action in the found configuration item will be executed.
[0050] In this embodiment, the configuration item may also include a trigger condition. The trigger condition is mainly used to make logical judgments on the event to be processed. The event action in the configuration item will be executed only when the current environment of the Android system meets the trigger condition in the found configuration item. The trigger condition can support the combination of multiple sub-conditions. The relationship between different sub-conditions can be identified by logical operators such as &&, || and !.
[0051] Furthermore, in one embodiment, the configuration item further includes functions, function parameters, classes, and packages, and step S30 includes:
[0052] Load the classes and packages found in the configuration items, execute the event actions in the configuration items, and execute the functions in the configuration items with the function parameters in the configuration items as parameters.
[0053] In this embodiment, the configuration item may also include functions, function parameters, classes and packages. Since the Android system often needs to reference the corresponding classes and packages to execute the related functions, the classes and packages found in the configuration item are loaded first, the event actions in the configuration item are executed, and the functions in the configuration item are executed with the function parameters in the configuration item as parameters.
[0054] Furthermore, in one embodiment, the configuration item further includes a processing flag bit, which, after step S30, includes:
[0055] If the value of the processing flag in the found configuration item is the first preset value, the event will be handed over to the Android system for further processing.
[0056] If the value of the processing flag in the found configuration item is the second preset value, then the event processing ends.
[0057] In this embodiment, since some events need to be processed by the Android system, the configuration item may also include a processing flag bit, which is used to indicate whether the event processing is ended or transferred to the Android system for further processing after the event to be processed is completed in this embodiment of the invention. For example, if the value of the processing flag bit in the found configuration item is 1, the event is transferred to the Android system for further processing; if the value of the processing flag bit in the found configuration item is 0, the event processing is ended.
[0058] Further, in one embodiment, the event types include key events, Intent events, broadcast events, and data read / write events, and before step S10, the following is included:
[0059] Configure the configuration file according to the event type.
[0060] In this embodiment, the event types include, but are not limited to, key events, Intent events, broadcast events, and data read / write events. The event types of Android system events can also be extended, and the configuration file can be configured accordingly based on the event type. Different configurations can be made for different event types, thereby realizing flexible handling of different types of events occurring in the Android system.
[0061] Thirdly, embodiments of the present invention also provide an Android system event handling device.
[0062] Reference Figure 5 , Figure 5 This is a schematic diagram of the functional modules of an embodiment of the Android system event handling device of the present invention.
[0063] In this embodiment, the Android system event handling device includes:
[0064] The parsing module 10 is used to parse the configuration file to obtain configuration information when the Android system starts. The configuration information includes one or more configuration items, and the configuration items include event type, event parameters and event actions.
[0065] The listening module 20 is used to listen for Android system events, treat the listened Android system events as pending events, and obtain the event type and event parameters of the pending events.
[0066] The execution module 30 is used to search for the corresponding configuration item in the configuration information based on the event type and event parameters of the event to be processed. If the item is found, the event action in the found configuration item is executed.
[0067] Furthermore, in one embodiment, the configuration item further includes a triggering condition, and the execution module 30 is used to:
[0068] If found, and the current environment of the Android system meets the triggering conditions in the found configuration item, then the event action in the found configuration item will be executed.
[0069] Furthermore, in one embodiment, the configuration items further include functions, function parameters, classes, and packages, and the execution module 30 is further configured to:
[0070] Load the classes and packages found in the configuration items, execute the event actions in the configuration items, and execute the functions in the configuration items with the function parameters in the configuration items as parameters.
[0071] Furthermore, in one embodiment, the configuration item further includes a processing flag, and the Android system event handling device further includes a processing module for:
[0072] If the value of the processing flag in the found configuration item is the first preset value, the event will be handed over to the Android system for further processing.
[0073] If the value of the processing flag in the found configuration item is the second preset value, then the event processing ends.
[0074] Furthermore, in one embodiment, the event types include key events, Intent events, broadcast events, and data read / write events. The Android system event handling device further includes a configuration module for:
[0075] Configure the configuration file according to the event type.
[0076] The functions of each module in the Android system event handling device correspond to the steps in the Android system event handling method embodiment, and their functions and implementation processes will not be described in detail here.
[0077] Fourthly, embodiments of the present invention also provide a readable storage medium.
[0078] The present invention provides a readable storage medium storing an Android system event handler, wherein when the Android system event handler is executed by a processor, it implements the steps of the Android system event handling method described above.
[0079] The methods implemented when the Android system event handler is executed can be referred to in various embodiments of the Android system event handling method of this invention, and will not be repeated here.
[0080] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0081] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0082] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of the present invention.
[0083] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. An Android system event processing method, characterized in that, The Android system event processing method comprises the steps of: When the Android system is started, configuration information is obtained by analyzing a configuration file, the configuration information comprises one or more configuration items, and the configuration item comprises an event type, an event parameter and an event action; An Android system event is listened to, the Android system event listened to is taken as a to-be-processed event, and the event type and the event parameter of the to-be-processed event are obtained; According to the event type and the event parameter of the to-be-processed event, a corresponding configuration item is searched for in the configuration information, if the configuration item is searched for, an event action in the searched-for configuration item is executed; The event type comprises a key event, an Intent event, a broadcast event and a data read-write event, and before the step of when the Android system is started, configuration information is obtained by analyzing a configuration file, the configuration file is configured according to the event type; The configuration item further comprises a processing flag bit, and after the step of if the configuration item is searched for, an event action in the searched-for configuration item is executed, the following step is further included: If the value of the processing flag bit in the searched-for configuration item is a first preset value, the event is transferred to the Android system for continuous processing; If the value of the processing flag bit in the searched-for configuration item is a second preset value, the event processing is ended; The configuration item further comprises a trigger condition, and the step of if the configuration item is searched for, an event action in the searched-for configuration item is executed further comprises the following step: If the configuration item is searched for and the current environment of the Android system satisfies the trigger condition in the searched-for configuration item, the event action in the searched-for configuration item is executed. The configuration item further comprises a function, a function parameter, a class and a package, and the step of if the configuration item is searched for, an event action in the searched-for configuration item is executed further comprises the following step:
2. The Android system event processing method of claim 1, wherein, The class and the package in the searched-for configuration item are loaded, the event action in the configuration item is executed, the function parameter in the configuration item is taken as a parameter, and the function in the configuration item is executed. The Android system event processing device comprises:
3. An Android system event processing apparatus, characterized by comprising: An analysis module, configured to, when the Android system is started, obtain configuration information by analyzing a configuration file, the configuration information comprises one or more configuration items, and the configuration item comprises an event type, an event parameter and an event action; A listening module, configured to listen to an Android system event, take the Android system event listened to as a to-be-processed event, and obtain the event type and the event parameter of the to-be-processed event; An execution module, configured to, according to the event type and the event parameter of the to-be-processed event, search for a corresponding configuration item in the configuration information, if the configuration item is searched for, execute an event action in the searched-for configuration item; The event type comprises a key event, an Intent event, a broadcast event and a data read-write event, and the Android system event processing device further comprises a configuration module, configured to: The configuration file is configured according to the event type; The configuration item further comprises a processing flag bit, and the Android system event processing device further comprises a processing module, configured to: If the value of the processing flag bit in the searched-for configuration item is a first preset value, the event is transferred to the Android system for continuous processing; If the value of the processing flag bit in the searched-for configuration item is a second preset value, the event processing is ended; The configuration item further comprises a trigger condition, and the execution module is configured to: If the configuration item is searched for and the current environment of the Android system satisfies the trigger condition in the searched-for configuration item, the event action in the searched-for configuration item is executed. 4. The Android system event handling apparatus of claim 3, wherein, The configuration item further includes functions, function parameters, classes and packages, and the execution module is further configured to: load the classes and packages in the found configuration item, execute the event actions in the configuration item, and execute the functions in the configuration item with the function parameters in the configuration item as parameters.
5. An Android system event handling device, characterized by The Android system event processing device includes a processor, a memory, and an Android system event processing program stored in the memory and executable by the processor, and when the Android system event processing program is executed by the processor, the steps of the Android system event processing method according to any one of claims 1 to 2 are implemented.
6. A readable storage medium characterized by, The readable storage medium has an Android system event processing program stored thereon, and when the Android system event processing program is executed by a processor, the steps of the Android system event processing method according to any one of claims 1 to 2 are implemented.
Citation Information
Patent Citations
Method used for achieving GMRP
CN104092616A