A broadcast distribution processing method and related equipment

By allowing applications to use child threads to process broadcasts, the problem of low broadcast distribution efficiency is solved, and more efficient broadcast processing and distribution is achieved.

CN119759603APending Publication Date: 2025-04-04HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410199537.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-28
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

In the prior art, in the static registration scenario of broadcast, broadcast distribution efficiency is low, especially when there are many recipients, the recipients at the end of the queue need to wait for a long time, resulting in low processing efficiency.

Method used

By allowing the application to use child threads to process received broadcasts, the duration of broadcast messages queues waiting for processing is reduced. Specifically, if the child thread option information applied by the target broadcast receiver allows the child thread to process the broadcast, the process where the target broadcast receiver is located can process the broadcast through the child thread.

Benefits of technology

The broadcast processing efficiency is improved, and the waiting time for broadcast messages in the message queue is reduced, thereby improving the efficiency of the entire broadcast distribution process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759603A_ABST
    Figure CN119759603A_ABST
Patent Text Reader

Abstract

The present application discloses a broadcast distribution processing method and related equipment. According to the method, an electronic device provides an application with the ability to process broadcasts through a sub-thread. Specifically, when the AMS in the electronic device sends a broadcast to the target broadcast receiver, it can also send the sub-thread option information corresponding to the target broadcast receiver's application to the process where the target broadcast receiver is located, to indicate whether the target broadcast receiver's application allows the sub-thread to process the broadcast. In this way, if the sub-thread option information corresponding to the target broadcast receiver's application indicates that the sub-thread is allowed to process the broadcast, the process where the target broadcast receiver is located can process the broadcast through the sub-thread. In this way, broadcast messages can be processed in relatively idle sub-threads, thereby reducing the length of time that broadcast messages wait in line in the corresponding message queue for processing, improving the broadcast processing efficiency, and thereby improving the efficiency of the entire broadcast distribution process.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the invention patent application with application number 202311274208.8 submitted to the China Patent Office, application date September 28, 2023, and invention name “A broadcast distribution processing method and related equipment”. Technical Field

[0002] The present application relates to the field of terminal technology, and in particular to a broadcast distribution processing method and related equipment. Background Art

[0003] As one of the four major components of the Android operating system, broadcast is a mechanism for message transmission between components (for example, transmitting data, sending notifications, etc.). These components can be in the same process or in different processes. In other words, the broadcast mechanism can be understood as an inter-process communication mechanism. The broadcast mechanism utilizes the observer pattern and is based on a message publish / subscribe event model. The model includes message publishers, message subscribers, and message centers. The message publisher, message subscriber, and message center correspond to the sender (i.e., broadcast sender), receiver (i.e., broadcast receiver), and Activity Manager Service (AMS) in the broadcast mechanism, respectively.

[0004] For the static registration scenario of broadcast, after the sender sends the broadcast to AMS, AMS can determine the receiver corresponding to the broadcast, and then distribute the broadcast serially to the receiver corresponding to the broadcast. On the one hand, since the broadcast is distributed serially, AMS can continue to send the broadcast to the next receiver only after receiving the message sent by the receiver that the broadcast processing is completed. This means that if there are many receivers corresponding to the broadcast, the receiver at the end of the receiver queue needs to wait for a long time before receiving the broadcast sent by AMS, resulting in low efficiency in broadcast distribution processing. On the other hand, after the receiver receives the broadcast sent by AMS, it needs to wait for the message in the message list corresponding to the process where the receiver is located to be processed before it can process the broadcast sent by AMS. This means that if there are many messages in the message list, the broadcast received by the receiver needs to wait in line for a long time before it can be processed, which also leads to low efficiency in broadcast distribution processing.

[0005] Therefore, how to improve the efficiency of broadcast distribution and processing is an urgent problem to be solved. Summary of the invention

[0006] The present application provides a broadcast distribution processing method and related equipment. According to the broadcast distribution processing method, the electronic device provides the application with the ability to process broadcasts through child threads. Specifically, if the child thread option information corresponding to the application where the target broadcast receiver is located indicates that the child thread is allowed to process the broadcast, the process where the target broadcast receiver is located can process the broadcast through the child thread. This method can reduce the length of time that broadcast messages queue in the corresponding message queue waiting for processing, avoid broadcast messages queuing for a long time to wait for their processing when the main thread of the process where the target broadcast receiver is located is heavily tasked, improve the broadcast processing efficiency, and thus improve the efficiency of the entire broadcast distribution process.

[0007] In the first aspect, the present application provides a broadcast distribution processing method. According to the method, an electronic device can receive a first broadcast sent by a broadcast sender through an AMS, confirm a target broadcast receiver based on the first broadcast, and determine the sub-thread option information corresponding to the application where the target broadcast receiver is located. Among them, the sub-thread option information is used to indicate whether the application allows the sub-thread to process the broadcast. In the process of the electronic device sending a first broadcast to the target broadcast receiver, the first broadcast and the first information can be sent to the first process through the AMS, and when the first information indicates that the sub-thread is allowed to process the broadcast, the electronic device can process the first broadcast through the sub-thread of the first process. Among them, the first process is the process where the first broadcast receiver is located, the first broadcast receiver is one of the target broadcast receivers, the first information is the sub-thread option information corresponding to the first application, and the first application is the application where the first broadcast receiver is located.

[0008] In the solution provided in the present application, after receiving the first broadcast, the AMS in the electronic device can determine the target broadcast receiver and the sub-thread option information corresponding to the application where the target broadcast receiver is located. If the sub-thread option information corresponding to the application where the target broadcast receiver is located indicates that the sub-thread is allowed to process the broadcast, then after the process where the target broadcast receiver is located receives the first broadcast sent by the AMS, the first broadcast can be processed by the sub-thread. In this way, the broadcast message can be processed by a relatively idle sub-thread of the process where the target broadcast receiver is located, which can avoid the situation where the main thread of the process where the target broadcast receiver is located has a heavy task, and the broadcast message needs to wait for a long time in the message queue corresponding to the main thread before being processed. This method can reduce the length of time that the broadcast message is queued in the corresponding message queue waiting for processing, improve the broadcast processing efficiency, and thus improve the efficiency of the entire broadcast distribution process.

[0009] In combination with the first aspect, in a possible implementation, before the electronic device sends the first broadcast and the first information to the first process through AMS, the first process has not been created. Before the electronic device sends the first broadcast and the first information to the first process through AMS, the method may also include: the electronic device may create the first process. After the electronic device sends the first broadcast and the first information to the first process through AMS, the method may also include: the electronic device may receive the first broadcast and the first information through the main thread of the first process, encapsulate the first broadcast based on the first information through the main thread of the first process, obtain the first broadcast message, and put the first broadcast message into the first message queue. The electronic device processes the first broadcast through the child thread of the first process, which may specifically include: the electronic device may start the child thread of the first process, re-encapsulate the first broadcast message through the main thread of the first process, obtain the second broadcast message, and put the second broadcast message into the second message queue through the main thread of the first process, and delete the first broadcast message in the first message queue. Among them, the first message queue is the message queue corresponding to the main thread of the first process, and the second message queue is the message queue corresponding to the child thread of the first process.

[0010] In the scheme provided by the present application, after the first process is created, it is necessary to load and parse resources through the main thread. There are many pending messages in the message queue corresponding to the main thread of the first process, and it is impossible to immediately determine whether it is necessary to open the sub-thread (i.e., start the sub-thread). Therefore, the first process first puts the encapsulated broadcast message in the message queue corresponding to its main thread to wait for the completion of a part of the application environment initialization preparation. After completing a part of the application environment initialization preparation, the first process can determine whether it is necessary to open the sub-thread to process the broadcast. In this way, there is no need to wait for the first process to determine whether it is necessary to open the sub-thread to process the broadcast before encapsulating the broadcast message and putting it into the message queue corresponding to the corresponding thread. In this way, when the first process determines that it is necessary to open the sub-thread to process the broadcast, the broadcast can be processed by a relatively idle sub-thread to reduce the broadcast processing time. When the first process determines that it is not necessary to open the sub-thread to process the broadcast, the encapsulated broadcast message can also be placed in the message queue corresponding to the main thread in time, without waiting for subsequent judgment, avoiding the late time of the broadcast message entering the queue due to the execution of the step of determining whether the sub-thread needs to be opened, and controlling the queue time of the broadcast message in the message queue corresponding to the main thread, so as to avoid the increase of the queue time.

[0011] In some embodiments of the present application, the first broadcast message may be a broadcast message with a decision result added thereto (as shown in step S308). The second broadcast message may be a repackaged broadcast message (as shown in step S303).

[0012] It can be understood that before the electronic device sends the first broadcast and the first message to the first process through AMS, the first process has not been created. Specifically, it can mean that when the electronic device is ready to send the first broadcast and the first message to the first process through AMS, the first process has not been created. That is, after determining the target broadcast receiver and the child thread option information corresponding to the application in which it is located, and before AMS sends the first broadcast and the first message to the first process, the first process has not been created.

[0013] In combination with the first aspect, in a possible implementation, the electronic device encapsulates the first broadcast based on the first information through the main thread of the first process to obtain the first broadcast message, which may specifically include: the electronic device may encapsulate the first broadcast through the main thread of the first process to obtain the third broadcast message, and determine through the main thread of the first process whether the first information indicates that the sub-thread is allowed to process the broadcast; when the first information indicates that the sub-thread is allowed to process the broadcast, the electronic device may obtain the first decision result through the main thread of the first process, and add the first decision result to the third broadcast message to obtain the first broadcast message, and when the first information does not indicate that the sub-thread is allowed to process the broadcast, the electronic device may obtain the second decision result through the main thread of the first process, and add the second decision result to the third broadcast message to obtain the first broadcast message. After the electronic device obtains the first broadcast message, the method may further include: when the first broadcast message includes the second decision result, the electronic device may process the first broadcast message through the main thread of the first process. When the first information indicates that the sub-thread is allowed to process the broadcast, the electronic device processes the first broadcast through the sub-thread of the first process, which may specifically include: when the first broadcast message includes the first decision result, the electronic device may process the second broadcast message through the sub-thread of the first process.

[0014] In the solution provided by the present application, after the electronic device sends the first broadcast and the first information to the first process through the AMS, the first process can first encapsulate the first broadcast to obtain the encapsulated broadcast message, then obtain the decision result based on the first information, and add the decision result to the encapsulated broadcast message, and then put the broadcast message with the added decision result into the message queue corresponding to the main thread of the first process. In this way, the process of encapsulating the first broadcast and obtaining the decision result based on the first information can be carried out simultaneously, without having to obtain the decision result first and then encapsulate, which reduces the duration to a certain extent.

[0015] In some embodiments of the present application, the third broadcast message may be a broadcast message obtained by encapsulating the first broadcast message (as shown in step S306).

[0016] In combination with the first aspect, in a possible implementation, the electronic device encapsulates the first broadcast based on the first information through the main thread of the first process to obtain the first broadcast message, which may specifically include: the electronic device may determine through the main thread of the first process whether the first information indicates that the sub-thread is allowed to process the broadcast; when the first information indicates that the sub-thread is allowed to process the broadcast, the electronic device obtains the first decision result through the main thread of the first process, and encapsulates the first broadcast and the first decision result to obtain the first broadcast message, and when the first information does not indicate that the sub-thread is allowed to process the broadcast, the electronic device obtains the second decision result through the main thread of the first process, and encapsulates the first broadcast and the second decision result to obtain the first broadcast message. After the electronic device obtains the first broadcast message, the method may further include: when the first broadcast message includes the second decision result, the electronic device may process the first broadcast message through the main thread of the first process. When the first information indicates that the sub-thread is allowed to process the broadcast, the electronic device processes the first broadcast through the sub-thread of the first process, which may specifically include: when the first broadcast message includes the first decision result, the electronic device may process the second broadcast message through the sub-thread of the first process.

[0017] In the solution provided by the present application, after the electronic device sends the first broadcast and the first information to the first process through the AMS, the first process can first obtain the decision result based on the first information, and then encapsulate the first broadcast and the decision result to obtain the encapsulated broadcast message, and then put the broadcast message with the decision result added into the message queue corresponding to the main thread of the first process. In this way, there is no need to encapsulate the first broadcast first and then add the decision result to the encapsulated broadcast message, but directly encapsulate the first broadcast and the decision result, which simplifies the process to a certain extent.

[0018] In combination with the first aspect, in a possible implementation, before the electronic device sends the first broadcast to the first process through AMS, the first process has been created. After the electronic device sends the first broadcast and the first information to the first process through AMS, the method may also include: the electronic device may receive the first broadcast and the first information through the main thread of the first process, and determine whether the first information indicates that the sub-thread is allowed to process the broadcast; when the first information does not indicate that the sub-thread is allowed to process the broadcast, the electronic device encapsulates the first broadcast through the main thread of the first process, obtains the first broadcast message, and puts the first broadcast message into the first message queue. When the first information indicates that the sub-thread is allowed to process the broadcast, the electronic device processes the first broadcast through the sub-thread of the first process, which may specifically include: when the first information indicates that the sub-thread is allowed to process the broadcast, the electronic device may start the sub-thread of the first process, and may also encapsulate the first broadcast through the main thread of the first process, obtain the first broadcast message, and put the first broadcast message into the second message queue. Among them, the first message queue is the message queue corresponding to the main thread of the first process, and the second message queue is the message queue corresponding to the sub-thread of the first process.

[0019] In the solution provided in the present application, if the electronic device is ready to send the first broadcast to the first process to the AMS, and the first process has been created, the first process does not need to load and parse resources through the main thread, and does not need to wait for the completion of a part of the application environment initialization preparation before determining whether to start the child thread. In this case, the electronic device can first determine whether to process the broadcast through the child thread or the main thread based on the first information, and then encapsulate the first broadcast after determining, and put the encapsulated broadcast message into the message queue corresponding to the corresponding thread. In this way, the first process does not need to determine whether to start the child thread after encapsulating the first broadcast and putting the encapsulated broadcast message into the message queue corresponding to the main thread. Instead, it first determines which thread to process the broadcast, and then encapsulates the broadcast and puts it into the corresponding message queue, which can simplify the process and reduce the processing time required before putting the broadcast message into the message queue.

[0020] In some embodiments of the present application, the first broadcast message may be a broadcast message obtained by encapsulating the first broadcast message. In this case, the first broadcast message does not necessarily have a decision result added thereto.

[0021] It can be understood that before the electronic device sends the first broadcast and the first message to the first process through the AMS, the first process has been created, which can specifically mean that when the electronic device is ready to send the first broadcast and the first message to the first process through the AMS, the first process has been created. In other words, after determining the target broadcast receiver and the child thread option information corresponding to the application in which it is located, and before the AMS sends the first broadcast and the first message to the first process, the first process has been created.

[0022] In combination with the first aspect, in a possible implementation, the electronic device confirms the target broadcast receiver based on the first broadcast through AMS, which may specifically include: the electronic device determines one or more broadcast receivers corresponding to the first broadcast as the target broadcast receivers from the first correspondence. Before the electronic device receives the first broadcast sent by the broadcast sender through AMS, the method may also include: the electronic device may receive an instruction to start the electronic device, and in response to the instruction to start the electronic device, the electronic device may start and parse the package file of the application in the electronic device to obtain the second correspondence and the sub-thread option information corresponding to the application in the electronic device; the electronic device may save the second correspondence and the sub-thread option information corresponding to the application in the electronic device.

[0023] In the solution provided in the present application, when the electronic device is started, it can parse the package file of the application (i.e., the APK file) to obtain the correspondence between the broadcast receiver and the broadcast in the application (i.e., the second correspondence), as well as the sub-thread option information corresponding to the application, and save the correspondence and the sub-thread option information corresponding to the application so that the AMS can subsequently search for the target broadcast receiver.

[0024] In some embodiments of the present application, the first application has not been installed when the electronic device is started. In this case, when the electronic device subsequently installs the first application, it can obtain the correspondence between the broadcast receiver and the broadcast in the first application, as well as the sub-thread option information corresponding to the first application, and put the correspondence between the broadcast receiver and the broadcast in the first application into the second correspondence to obtain an updated second correspondence. The updated second correspondence may be the first correspondence, or may be different from the first correspondence. Specifically, if the electronic device updates the first application after installing the first application, and the correspondence between the broadcast receiver and the broadcast in the first application obtained when the first application is updated does not change, or the electronic device does not update the first application after installing the first application, then the updated second correspondence may be the first correspondence. If the electronic device updates the first application after installing the first application, and the correspondence between the broadcast receiver and the broadcast in the first application obtained when the first application is updated changes, then the updated second correspondence is different from the first correspondence. Similarly, if the electronic device updates the first application after installing it, and the sub-thread option information corresponding to the first application obtained when the first application is updated does not change, or if the electronic device does not update the first application after installing it, then the sub-thread option information corresponding to the first application obtained when the first application is installed is the first information. If the electronic device updates the first application after installing it, and the sub-thread option information corresponding to the first application obtained when the first application is updated changes, then the sub-thread option information corresponding to the first application obtained when the first application is updated is the first information, and the sub-thread option information corresponding to the first application obtained when the first application is installed is different from the first information.

[0025] In some embodiments of the present application, the first application is already installed when the electronic device is started. In this case, the correspondence between the broadcast receiver and the broadcast in the first application, and the sub-thread option information corresponding to the first application can be obtained when the electronic device is started. That is, the second correspondence may include the correspondence between the broadcast receiver and the broadcast in the first application. The second correspondence may be the first correspondence, or may be different from the first correspondence. Specifically, if the correspondence between the broadcast receiver and the broadcast in the first application does not change when the electronic device subsequently updates the first application, or the electronic device does not update the first application subsequently, the second correspondence may be the first correspondence. If the correspondence between the broadcast receiver and the broadcast in the first application changes when the electronic device subsequently updates the first application, the second correspondence is different from the first correspondence. Similarly, if the electronic device does not update the first application subsequently, or the sub-thread option information corresponding to the first application obtained when the first application is updated does not change, the sub-thread option information corresponding to the first application obtained when the electronic device is started is the first information. If the sub-thread option information corresponding to the first application obtained when the electronic device updates the first application subsequently changes, the sub-thread option information corresponding to the first application obtained when the first application is updated is the first information, and the sub-thread option information corresponding to the first application obtained when the electronic device is started is different from the first information.

[0026] In combination with the first aspect, in a possible implementation, the application in the electronic device does not include the first application. Before the electronic device receives the first broadcast sent by the broadcast sender through the activity manager service AMS, the method may also include: the electronic device receives an instruction to install the first application; in response to the instruction to install the first application, the electronic device parses the package file of the first application, obtains the correspondence between the broadcast receiver and the broadcast in the first application, and the first information; the electronic device updates the second correspondence based on the correspondence between the broadcast receiver and the broadcast in the first application, obtains the first correspondence, and saves the first correspondence and the first information.

[0027] In the solution provided in the present application, the first application is not installed when the electronic device is started. This means that the second correspondence does not include the correspondence between the broadcast receiver and the broadcast in the first application. In this case, the electronic device can subsequently install the first application, and when installing the first application, the correspondence between the broadcast receiver and the broadcast in the first application, as well as the sub-thread option information corresponding to the first application can be obtained. The electronic device can put the obtained correspondence between the broadcast receiver and the broadcast in the first application into the second correspondence to obtain the first correspondence. The electronic device can save the first correspondence and the first information. That is, in some embodiments of the present application, the correspondence between the broadcast receiver and the broadcast in the first application obtained when the electronic device installs the first application can be the correspondence between the broadcast receiver and the broadcast in the first application included in the first correspondence, and the sub-thread option information corresponding to the first application obtained when the electronic device installs the first application can be the first information.

[0028] In combination with the first aspect, in a possible implementation, the method also includes: the electronic device receives an instruction to update the first application, and in response to the instruction to update the first application, the electronic device can parse the package file of the first application to obtain the correspondence between the broadcast receiver and the broadcast in the first application, and the second information; the electronic device can save the correspondence between the broadcast receiver and the broadcast in the first application, and the second information.

[0029] In the solution provided in the present application, the electronic device can update the first application, and the present application does not limit the time of updating the first application. In some embodiments of the present application, the electronic device can update the first application before the AMS sends the first broadcast and the first information to the first process in the first application. In this case, the second information can be the first information. In some embodiments of the present application, the electronic device can update the first application after the AMS sends the first broadcast and the first information to the first process in the first application. In this case, since the sub-thread option information corresponding to the first application may not change or may change when the first application is updated, the second information can be the first information or may be different from the first information.

[0030] In some embodiments of the present application, before the AMS sends the first broadcast and the first information to the first process in the first application, the electronic device may update the first application. In this case, the electronic device can again obtain the correspondence between the broadcast receiver and the broadcast in the first application, as well as the sub-thread option information corresponding to the first application. It can be understood that the correspondence between the broadcast receiver and the broadcast in the first application obtained when the electronic device updates the first application may be different from the correspondence between the broadcast receiver and the broadcast in the first application obtained when the electronic device installs the first application. Similarly, the sub-thread option information corresponding to the first application obtained when the electronic device updates the first application may be different from the sub-thread option information corresponding to the first application obtained when the electronic device installs the first application.

[0031] In combination with the first aspect, in a possible implementation manner, the electronic device sending the first broadcast to the target broadcast receiver may specifically include: the electronic device serially sending the first broadcast to the target broadcast receiver.

[0032] In the solution provided by the present application, when there are multiple target broadcast receivers, the electronic device can send the first broadcast to the multiple target broadcast receivers in sequence. It is understood that the specific implementation of serial transmission can be referred to below and will not be described in detail here.

[0033] In a second aspect, the present application provides an electronic device, comprising: one or more memories, and one or more processors; the one or more memories are coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to perform the method described in the first aspect or any one of the implementations of the first aspect.

[0034] In a third aspect, the present application provides a computer storage medium, which includes computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method described in the first aspect or any one of the implementations of the first aspect.

[0035] In a fourth aspect, an embodiment of the present application provides a chip. The chip can be applied to an electronic device, and the chip includes one or more processors, and the processor is used to call computer instructions to enable the electronic device to execute the method described in the first aspect or any implementation of the first aspect.

[0036] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions. When the computer program product is run on an electronic device, the electronic device executes the method described in the first aspect or any one of the implementations of the first aspect.

[0037] It is understandable that the electronic device provided in the second aspect, the computer storage medium provided in the third aspect, the chip provided in the fourth aspect, and the computer program product provided in the fifth aspect are all used to execute the method described in the first aspect or any one of the implementations of the first aspect. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects of any possible implementation of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 A schematic diagram of a broadcast registration and distribution process provided in an embodiment of the present application;

[0039] Figure 2 A schematic diagram of another broadcast distribution process provided in an embodiment of the present application;

[0040] Figure 3A and Figure 3B A schematic diagram of specific stages in a broadcast distribution process provided by an embodiment of the present application;

[0041] Figure 4 A flowchart of a broadcast distribution processing method provided in an embodiment of the present application;

[0042] Figure 5 A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;

[0043] Figure 6 A software module interaction diagram provided for an embodiment of the present application;

[0044] Figure 7 A flowchart of a PMS parsing inventory file provided in an embodiment of the present application;

[0045] Fig. 8A and Figure 8B A flowchart of another broadcast distribution processing method provided in an embodiment of the present application;

[0046] Fig. 9 A schematic diagram of the duration of specific stages in a broadcast distribution process provided in an embodiment of the present application;

[0047] Fig.10 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0049] It should be understood that the terms "first", "second", etc. in the specification, claims and drawings of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.

[0050] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments.

[0051] First, some of the terms and related technologies involved in this application are explained to facilitate understanding by those skilled in the art.

[0052] 1. Broadcast

[0053] According to the above, the broadcast mechanism involves a broadcast sender, a broadcast receiver (also called a broadcast receiver), and an AMS.

[0054] The following is based on Figure 1 This section describes the broadcast registration and distribution process.

[0055] like Figure 1As shown, the broadcast receiver can register in AMS (i.e., broadcast registration). The broadcast sender can send a broadcast to AMS. AMS can find the broadcast receiver corresponding to the broadcast based on the relevant information of the registered broadcast receiver (BroadcastReceiver), and transmit the broadcast to the corresponding broadcast queue (i.e., broadcast enqueue) for AMS processing. It can be understood that the broadcast can correspond to multiple broadcast receivers. When AMS processes, it can send the broadcast to its corresponding broadcast receiver in turn, that is, to achieve broadcast distribution. Generally speaking, the registration of broadcast receivers in AMS, the sending of broadcasts by broadcast senders to AMS, and the sending of broadcasts by AMS to broadcast receivers are all implemented based on the Binder mechanism. The Binder mechanism is an interprocess communication (IPC) mechanism. Its specific meaning can be referred to the relevant technical documents, which will not be explained in detail here.

[0056] 2. Broadcast registration method

[0057] Broadcast registration methods include static registration and dynamic registration.

[0058] Static registration refers to registering the relevant information of the broadcast receiver in the manifest file of the application (which can be referred to as the application for short), and then parsing the relevant file when the application is installed to complete the registration.

[0059] Dynamic registration refers to registering the relevant information of the broadcast receiver with the AMS by calling a function method (for example, the context registration receiver Context.registerReceiver method).

[0060] It can be understood that for statically registered receivers, the AMS will distribute broadcasts to them serially.

[0061] For example, Figure 2 As shown in FIG. 1 , statically registered receivers 1, 2, 3, and 4 can register broadcast receivers with AMS in a static registration manner. The broadcast corresponding to the registered broadcast receivers can include broadcast A. The corresponding broadcast event can trigger the broadcast sender to send broadcast A to AMS. After receiving broadcast A, AMS can search for the broadcast receiver corresponding to broadcast A based on the relevant information of the registered broadcast receivers, and obtain the following information: Figure 2 The receiver list shown in the figure is displayed, and the broadcast A is placed in the broadcast queue, waiting for the AMS to distribute the broadcast A. Figure 2The receiver list shown may include statically registered receiver 1, statically registered receiver 2, statically registered receiver 3, and statically registered receiver 4. Since the broadcast receivers corresponding to broadcast A are all receivers that register the broadcast using static registration, after the AMS completes the distribution of the broadcast that is ahead of broadcast A in the broadcast queue, it can start to send broadcast A serially according to the order of the receivers in the receiver list. Figure 2 As shown, the first broadcast receiver in the receiver list is statically registered receiver 1, and the application process where statically registered receiver 1 is located is receiver process a. Since receiver process a has not yet run, AMS can first pull up (i.e., start) receiver process a and send broadcast A to receiver process a. After receiver process a has processed broadcast A, it can notify AMS. In this way, AMS can continue to send broadcast A to the second broadcast receiver in the receiver list. Figure 2 As shown, the second broadcast receiver in the receiver list is statically registered receiver 2, and the application process where statically registered receiver 2 is located is receiver process b. Although receiver process b and receiver process a belong to the process corresponding to application 1, receiver process a has started running at this time, while receiver process b has not yet run. Therefore, AMS can first pull up receiver process b, and then send broadcast A to receiver process b. After receiver process b has processed broadcast A, it can notify AMS. In this way, AMS can continue to send broadcast A to the third broadcast receiver in the receiver list (i.e., statically registered receiver 3). Similar to the above-mentioned broadcast sending process for statically registered receiver 1 and statically registered receiver 2, since the process where statically registered receiver 3 is located (i.e., receiver process c) has not yet run, AMS can first pull up receiver process c, and then send broadcast A to receiver process c. Similarly, after receiver process c has processed broadcast A, it can notify AMS. In this way, AMS can continue to send broadcast A to the fourth broadcast receiver in the receiver list (i.e., statically registered receiver 4). Similar to the broadcast sending process for statically registered receivers 1, 2, and 3, since the process where statically registered receiver 4 is located (i.e., receiver process d) has not yet run, AMS can first start receiver process d and then send broadcast A to receiver process d. After receiver process b has finished processing broadcast A, it can notify AMS. At this point, AMS has completed the distribution of broadcast A.

[0062] It can be understood that the application is stored as a static file in the storage space such as the hard disk of the computer system. A process refers to an instance of a running application. A process is a system resource management entity maintained by the operating system under dynamic conditions. In other words, an application is an inanimate entity that can only become an active entity when the processor executes it, called a process. Each process has its own independent address space, memory, and data stack, and communication between different processes can be achieved through the IPC mechanism.

[0063] Understandable, such as Figure 3A As shown, the entire broadcast process can be divided into two stages. The first stage is the broadcast enqueue stage, and the second stage is the broadcast distribution stage. The broadcast enqueue stage refers to the process in which the broadcast sender sends the broadcast to the AMS, and the AMS assigns the broadcast to the corresponding broadcast queue according to the broadcast information (e.g., broadcast attributes) and the relevant information of the broadcast sender (e.g., the relevant information of the process where the broadcast sender is located), and queues up in turn for distribution. The broadcast distribution stage refers to the process in which the AMS distributes the broadcast to each broadcast receiver corresponding to the broadcast until the AMS receives the notification message sent to the AMS after the last broadcast receiver corresponding to the broadcast processes the broadcast. It can be understood that the broadcast distribution stage includes the distribution stage of each broadcast receiver corresponding to the broadcast. For each broadcast receiver corresponding to the broadcast, its distribution stage may include a waiting stage and a processing stage. Among them, the waiting stage refers to the stage in which the AMS waits for the broadcast receiver to process after sending the broadcast to the broadcast receiver. The waiting stage may include a queuing stage. The queuing stage refers to the stage in which the broadcast is encapsulated into a broadcast message and queued in the message queue of the broadcast receiver. The processing stage refers to the stage in which the broadcast receiver processes the broadcast message in the message queue. It is understandable that the distribution duration of the broadcast receiver (i.e., the duration of the distribution phase) may include the waiting duration (i.e., the duration of the waiting phase) and the processing duration (i.e., the duration of the processing phase). Among them, the waiting duration may include the queuing duration (i.e., the duration of the queuing phase).

[0064] like Figure 3BAs shown, if the process where the broadcast receiver is located has not yet run, its waiting stage may include not only a queuing stage, but also a process start-up stage and a state value adjustment (e.g., ADJ) stage. Among them, the process start-up stage is the first stage in the waiting stage, the state value adjustment stage is located after the process start-up stage, and the queuing stage is located after the state value adjustment stage. The process start-up stage refers to the stage in which the AMS triggers the electronic device to start the process where the broadcast receiver is located. The state value adjustment stage refers to the stage in which the electronic device adjusts the state value corresponding to the process where the broadcast receiver is located. It can be understood that for broadcast receivers whose processes have not yet run, the waiting time may include the process start-up time (i.e., the time of the process start-up stage), the state value adjustment time (i.e., the time of the state value adjustment stage) and the queuing time.

[0065] It can be understood that compared with the broadcast receiver whose process is already running, the waiting time of the broadcast receiver whose process is not yet running also includes the process startup time and the status value adjustment time, so the waiting time of the broadcast receiver whose process is not yet running is likely to be longer.

[0066] According to the above, for the static registration scenario of broadcasts, AMS completes the distribution of broadcasts through serial distribution. On the one hand, once there are many broadcast receivers corresponding to the broadcast, the broadcast distribution phase will take a long time, and the entire broadcast process will take a long time, resulting in inefficient broadcast distribution processing. On the other hand, after the broadcast receiver receives the broadcast sent by AMS, it needs to wait for the message at the front of the message list corresponding to the process where the broadcast receiver is located to be processed before it can process the broadcast sent by AMS. This means that if there are many messages at the front of the message list, the broadcast received by the broadcast receiver needs to wait in line for a long time before it can be processed, that is, the waiting time in the distribution phase is long, which will lead to inefficient broadcast distribution processing.

[0067] In particular, when there are broadcast receivers whose processes are not yet running, if the AMS sends a broadcast to the broadcast receiver whose processes are not yet running, the electronic device will first start the application process of the receiver, and then encapsulate the broadcast into a broadcast message and put it into the message queue corresponding to the main thread of the application process of the receiver, waiting for the main thread of the application process of the receiver to process it. It is understandable that after the application process is started, it is often necessary to perform tasks such as resource loading and information updating. The main thread of some application processes has a large amount of tasks, and there are many messages to be processed in the message queue corresponding to the main thread, which causes the encapsulated broadcast message to be queued in the message queue corresponding to the main thread for a long time before it can be processed, resulting in low efficiency in broadcast distribution processing.

[0068] It is understandable that a process only provides space for resource loading, and specific resource scheduling still needs threads to complete. A thread is included in a process and is the smallest unit that the operating system can perform computation scheduling. Multiple threads can run concurrently in a process, and the same thread will share all system resources in the process. When a process is created, the operating system will create a thread to schedule resources, and this thread is the main thread. The main thread can create one or more child threads.

[0069] An embodiment of the present application provides a broadcast distribution processing method. According to the broadcast distribution processing method, an electronic device can allow an application to use a sub-thread of the process where the broadcast receiver is located to process the received broadcast, without using the main thread of the process where the broadcast receiver is located to process the received broadcast. In this way, the broadcast message can be queued in a relatively idle sub-thread waiting for processing, without having to queue in a relatively busy main thread waiting for processing. This method can reduce the length of time that the broadcast message queues in the corresponding message queue waiting for processing, improve the broadcast processing efficiency, and thereby improve the efficiency of the entire broadcast distribution process.

[0070] A broadcast distribution processing method provided by an embodiment of the present application is introduced below.

[0071] See also Figure 4 , Figure 4 This is a flowchart of a broadcast distribution processing method provided in an embodiment of the present application. The broadcast distribution processing method may include but is not limited to the following steps:

[0072] S101: A broadcast sender sends a first broadcast to an AMS.

[0073] The broadcast sender in the electronic device may send a first broadcast to the AMS in the electronic device. Correspondingly, the AMS may receive the first broadcast sent by the broadcast sender to the AMS.

[0074] It is understandable that the broadcast sender can be an operating system in an electronic device, or an application, component, etc. in the electronic device, and this application does not impose any restrictions on this.

[0075] S102: The AMS determines a target broadcast receiver based on the first broadcast and the first corresponding relationship. The target broadcast receiver includes the first broadcast receiver. The process where the first broadcast receiver is located is the first process. The target broadcast receiver is a broadcast receiver for receiving the first broadcast. The first corresponding relationship is a corresponding relationship between a broadcast receiver and a broadcast.

[0076] After receiving the first broadcast sent by the broadcast sender, the AMS may determine a broadcast receiver corresponding to the first broadcast based on the first corresponding relationship. The broadcast receiver is the target broadcast receiver and may be used to receive the first broadcast.

[0077] It is understandable that the first corresponding relationship may be a corresponding relationship between a broadcast receiver and a broadcast. One broadcast receiver may correspond to one or more broadcasts. The broadcasts corresponding to different broadcast receivers may be the same or different.

[0078] Exemplarily, as shown in Table 1, the broadcast corresponding to broadcast receiver receiver1 is broadcast 1, the broadcast corresponding to broadcast receiver receiver2 is broadcast 2, the broadcast corresponding to broadcast receiver receiver3 is broadcast 1, the broadcast corresponding to broadcast receiver receiver4 is broadcast 3 and broadcast 4, and the broadcast corresponding to broadcast receiver receiver5 is broadcast 2 and broadcast 3. If the first broadcast is broadcast 1, that is, the broadcast sender sends broadcast 1 to the AMS, then after the AMS receives broadcast 1, it can determine that the broadcast receivers corresponding to broadcast 1 include receiver 1 and receiver 3 according to the corresponding relationship shown in Table 1, and the AMS can determine that the target broadcast receivers include receiver 1 and receiver 3.

[0079] Table 1

[0080] Broadcast Receiver broadcast receiver1 Broadcast 1 receiver2 Broadcast 2 receiver3 Broadcast 1 receiver4 Broadcast 3, Broadcast 4 receiver5 Broadcast 2, Broadcast 3 …… ……

[0081] In some embodiments of the present application, when a broadcast receiver performs a broadcast registration, the corresponding relationship between it and the registered broadcast can be recorded in a manifest file (e.g., AndroidManifest.xml file). After the electronic device is started, the electronic device can scan the manifest files of several applications to obtain the corresponding relationship between the broadcast receiver and the broadcast in the several applications. In some embodiments of the present application, the electronic device can save the corresponding relationship in the package manager service (PackageManagerService, PMS). In this case, after the AMS receives the broadcast sent by the broadcast sender, it can perform scheduling management, obtain the broadcast receiver corresponding to the broadcast from the PMS according to the corresponding relationship, and send the broadcast to the broadcast receiver. In some embodiments of the present application, the electronic device can save the corresponding relationship in the AMS. In this case, after the AMS receives the broadcast sent by the broadcast sender, it can directly determine the broadcast receiver corresponding to the broadcast based on the corresponding relationship it saves, and send the broadcast to the broadcast receiver. It can be understood that the corresponding relationship can also be saved in other modules. In this case, the AMS can obtain the corresponding relationship based on the corresponding interface or specific storage address.

[0082] Similarly, when an electronic device installs or updates an application, it can scan the manifest file of the application to obtain the correspondence between the broadcast receivers and the broadcasts in the application. The electronic device can save the correspondence between the broadcast receivers and the broadcasts in the application in the PMS or AMS or other modules. It is understandable that if the PMS or AMS or other modules originally save the correspondence between the broadcast receivers and the broadcasts in the application previously obtained by the electronic device, the electronic device can replace the previously obtained correspondence between the broadcast receivers and the broadcasts in the application with the most recently obtained correspondence between the broadcast receivers and the broadcasts in the application.

[0083] It can be understood that the correspondence between the broadcast receiver and the broadcast is the first correspondence. The first correspondence may include a correspondence between a broadcast receiver (eg, a first broadcast receiver) in the first application and a broadcast that it can receive.

[0084] It should be noted that AMS can also determine the process where the target broadcast receiver is located (i.e., the process to which the target broadcast receiver belongs) based on the correspondence between the broadcast receiver and the process to which it is located. It is understandable that there is a correspondence between processes and applications. After AMS determines the process where the target broadcast receiver is located, it can determine the application corresponding to the process where the target broadcast receiver is located, and the application is the application where the target broadcast receiver is located. In some embodiments of the present application, AMS can also determine the application where the target broadcast receiver is located (i.e., the application to which the target broadcast receiver belongs) directly based on the correspondence between the broadcast receiver and the application to which it is located. Specifically, AMS can determine the process where the first broadcast receiver is located (i.e., the first process) based on the correspondence between the broadcast receiver and the process to which it is located, and can also determine the application where the first broadcast receiver is located (i.e., the first application) based on the correspondence between the broadcast receiver and the application to which it is located, or the correspondence between the process and the application.

[0085] It is understandable that the application where the broadcast receiver is located may correspond to one or more application processes. The process where the broadcast receiver is located is one of the one or more application processes corresponding to the application where the broadcast receiver is located.

[0086] It is understandable that one broadcast receiver may correspond to one process and one application. In some embodiments of the present application, different broadcast receivers may be in different processes, but in the same application. In other embodiments of the present application, different broadcast receivers may be in the same process, and in the same application.

[0087] It is understood that the process where the broadcast receiver is located refers to the process of registering the broadcast receiver, that is, the process that initiates the registration of the broadcast receiver. It is understood that the processes where different broadcast receivers are located can be the same or different.

[0088] For example, as shown in Table 2, the process corresponding to the broadcast receiver receiver1 is process 1, that is, the process where receiver1 is located is process 1, the process corresponding to the broadcast receiver receiver2 is process 1, that is, the process where receiver2 is located is process 1, the process corresponding to the broadcast receiver receiver3 is process 2, that is, the process where receiver3 is located is process 2, the process corresponding to the broadcast receiver receiver4 is process 3, that is, the process where receiver4 is located is process 3, and the process corresponding to the broadcast receiver receiver5 is process 2, that is, the process where receiver5 is located is process 2. In this case, if the target broadcast receivers include receiver1 and receiver3, the AMS can search for the processes and applications corresponding to receiver1 and receiver3 according to the corresponding relationship shown in Table 2. As shown in Table 2, the process corresponding to receiver1 is process 1, the application corresponding to receiver1 is application 1, the process corresponding to receiver3 is process 2, and the application corresponding to receiver3 is application 2.

[0089] Table 2

[0090] Broadcast Receiver process application receiver1 Process 1 Application 1 receiver2 Process 1 Application 1 receiver3 Process 2 Application 2 receiver4 Process 3 Application 1 receiver5 Process 2 Application 2 …… ……

[0091] In some embodiments of the present application, when a broadcast receiver registers for a broadcast, not only can the correspondence between it and the registered broadcast be recorded in the manifest file, but also the process and application in which it is located. Similar to the above, after the electronic device is started, the electronic device can scan the manifest file of each application to obtain the correspondence between each broadcast receiver and its process and its application. In one possible implementation, the electronic device can save the correspondence between the broadcast receiver and its process and its application in the PMS. After the AMS receives the first broadcast sent by the broadcast sender, it can not only obtain the broadcast receiver corresponding to the first broadcast, that is, the target broadcast receiver, from the PMS according to the first correspondence, but also obtain the process and application of the target broadcast receiver from the PMS according to the correspondence between the broadcast receiver and its process and its application, so as to execute subsequent steps.

[0092] In some embodiments of the present application, the AMS may store a correspondence between the broadcast receiver, its process, and its application. After receiving the first broadcast sent by the broadcast sender, the AMS may directly determine the target broadcast receiver's process and the target broadcast receiver's application based on the stored correspondence between the broadcast receiver, its process, and its application.

[0093] It is understandable that the corresponding relationship between the broadcast receiver and the process and application can also be stored in other modules. In this case, the AMS can obtain the corresponding relationship based on the corresponding interface or specific storage address.

[0094] S103: If the first process is not running when the AMS is preparing to send the first broadcast to the first broadcast receiver, the AMS triggers and starts the first process.

[0095] After AMS receives the first broadcast sent by the broadcast sender, it can determine the target broadcast receiver, and assign the first broadcast to the corresponding broadcast queue, queuing and waiting to be distributed to the target broadcast receiver. After AMS has distributed the broadcasts that are ahead of the first broadcast in the broadcast queue where the first broadcast is located, it can prepare to distribute the first broadcast. In some embodiments of the present application, when AMS is ready to send the first broadcast to the first broadcast receiver, the process where the first broadcast receiver is located (i.e., the first process) has not yet run (i.e., has not yet been created). In this case, AMS can trigger the start of the first process, that is, pull up the first process. In some other embodiments of the present application, when AMS is ready to send the first broadcast to the first broadcast receiver, the first process is already running. In this case, the electronic device does not need to execute step S103, but can directly execute step S104, that is, send the first broadcast to the first process.

[0096] It is understandable that when AMS distributes the first broadcast, it sends it serially to each target broadcast receiver. That is to say, after AMS distributes the first broadcast to a target broadcast receiver and receives the notification message of the completion of broadcast processing sent by the target broadcast receiver, it continues to distribute the first broadcast to the next target broadcast receiver. This also means that AMS sends the first broadcast to the target broadcast receiver that is ahead of the first broadcast receiver, and only after receiving the notification message of the completion of broadcast processing sent by the target broadcast receiver, can it prepare to send the first broadcast to the first broadcast receiver. It is understandable that the present application does not limit the order in which AMS distributes the first broadcast to the target broadcast receivers.

[0097] In some embodiments of the present application, the distribution order can be determined according to the priority of the target broadcast receiver. The target broadcast receiver with a higher priority is ranked in the front, and the target broadcast receiver with a lower priority is ranked in the back. It can be understood that the priority of the target broadcast receiver can be set according to actual needs, and the present application does not make specific restrictions on this.

[0098] In some embodiments of the present application, the above distribution order can be determined according to the order in which the AMS finds the target broadcast receivers.

[0099] In some other embodiments of the present application, the distribution order can be determined according to the order of the target broadcast receiver list found by the AMS. Specifically, the AMS can determine the target broadcast receiver list according to the first corresponding relationship, and distribute the first broadcast to each target broadcast receiver in turn according to the order of the target broadcast receivers in the target broadcast receiver list. The target broadcast receiver list may include one or more target broadcast receivers. The target broadcast receiver list may include the first broadcast receiver.

[0100] S104: The AMS sends a first broadcast to the first process.

[0101] As described above, after the first process starts running, the AMS may send a first broadcast to the first process.

[0102] S105: The first process obtains sub-thread option information corresponding to the first application. The sub-thread option information is used to indicate whether the application supports sub-thread processing broadcast. The first application is the application corresponding to the first process.

[0103] After the first process is started, sub-thread option information corresponding to the application corresponding to the first process (ie, the first application) may be obtained, thereby determining whether the first application supports the sub-thread of the first process to process the received first broadcast.

[0104] In some embodiments of the present application, when a broadcast receiver performs broadcast registration, sub-thread option information corresponding to the application where the broadcast receiver is located may be recorded in a manifest file.

[0105] Similar to the above, after the electronic device is started, the manifest file of the application in the electronic device can be scanned to obtain the sub-thread option information corresponding to the application in the electronic device. In some embodiments of the present application, the electronic device can save the sub-thread option information corresponding to the application in the PMS. In this case, after the AMS receives the first broadcast sent by the broadcast sender, it can not only obtain the corresponding relationship between the broadcast receiver and the broadcast (i.e., the first corresponding relationship), as well as the corresponding relationship between the broadcast receiver and its process and its application from the PMS, but also obtain the sub-thread option information corresponding to the application where the target broadcast receiver is located from the PMS. In some embodiments of the present application, the AMS can first obtain the sub-thread option information corresponding to the first application, and then send the sub-thread option information corresponding to the first application obtained to the first process. In a possible implementation, when the AMS sends the first broadcast to each target broadcast receiver, it can send the sub-thread option information corresponding to the application to each target broadcast receiver. That is, when the AMS sends the first broadcast to the first process, the sub-thread option information corresponding to the first application can be sent to the first process together.

[0106] It is understandable that the sub-thread option information corresponding to the application in the electronic device can also be stored in other modules (e.g., AMS). In this case, the process where the target broadcast receiver is located can obtain the sub-thread option information corresponding to the application where the target broadcast receiver is located based on the corresponding interface or specific storage address.

[0107] It is understandable that the child thread option information can be expressed in the form of text, numbers, strings, etc., and this application does not impose any restrictions on this.

[0108] S106: If the child thread option information corresponding to the first application includes first parameter information, the first process processes the first broadcast through its child thread.

[0109] After the first process obtains the sub-thread option information corresponding to the first application, it can determine whether the sub-thread option information corresponding to the first application includes the first parameter information. If the sub-thread option information corresponding to the first application includes the first parameter information, the first process can process the first broadcast through the sub-thread of the first process and notify the AMS after the processing is complete. If the sub-thread option information corresponding to the first application does not include the first parameter information, the first process can process the first broadcast through the main thread of the first process and notify the AMS after the processing is complete.

[0110] In some embodiments of the present application, after the first process obtains the sub-thread option information corresponding to the first application, the first broadcast and the sub-thread option information corresponding to the first application can be encapsulated into a broadcast message, and the broadcast message can be placed in the message queue corresponding to the main thread of the first process. It can be understood that after the first process is started, application binding can be performed. During the application binding process, after the first process completes a part of the application environment initialization preparation, the broadcast message can be taken out from the message queue corresponding to its main thread, and it is determined whether the sub-thread option information corresponding to the first application included in the broadcast message includes the first parameter information. If the sub-thread option information corresponding to the first application includes the first parameter information, the first process can take out the broadcast message from the message queue corresponding to the main thread, re-encapsulate it, and then send it to the sub-thread of the first process for processing, and delete the broadcast message in the message queue corresponding to the main thread.

[0111] It is understood that the application environment initialization preparation may include local material parsing and package file parsing. In this case, the first process completes a part of the application environment initialization preparation, which may specifically include: the first process reaches s% of the parsing progress of the local material and package file. It is understood that s may be greater than 0 and less than 100. For example, s may be 60.

[0112] It can be understood that application binding refers to the process of binding a process to a specified application after the process is created. Application binding can be completed by calling the bindApplication() method of the ActivityThread object. This method sends a BIND_APPLICATION message to the message queue, and finally processes the message through the handleBindApplication() method, and then calls the makeApplication() method to load the application classes into the memory.

[0113] It is understandable that the first parameter information can be represented by text, numbers, strings, etc., and the present application does not limit this. For example, the first parameter information can be true. For another example, the first parameter information can be 1.

[0114] Exemplarily, if the child thread option information corresponding to the first application is true, the first process processes the first broadcast through its child thread; if the child thread option information corresponding to the first application is false, the first process processes the first broadcast through its main thread.

[0115] Exemplarily, if the sub-thread option information corresponding to the first application is 1, the first process processes the first broadcast through its sub-thread; if the sub-thread option information corresponding to the first application is 0, the first process processes the first broadcast through its main thread.

[0116] In some embodiments of the present application, a plurality of sub-threads may be loaded in the first process. In this case, the first process may select one of the plurality of sub-threads loadable by the first process to process the broadcast message.

[0117] It is understandable that the subthread used to process the broadcast message in the first process can be set according to actual needs. In some embodiments of the present application, the first process can select the idlest subthread among the multiple subthreads to process the broadcast message. It is understandable that the idlest subthread can refer to the subthread with the least number of messages queued for processing in the corresponding message queue. In some embodiments of the present application, the first application can pre-set the default subthread of the first process and process the broadcast message through the default subthread. In some embodiments of the present application, in some scenarios (for example, the number of target broadcast receivers is greater than the first number, the memory occupancy is large, etc.), the first process can directly process the broadcast message through its default subthread, and in some other scenarios (for example, the number of target broadcast receivers is not greater than the first number, the memory occupancy is small, etc.), the first process may not directly process the broadcast message through its default subthread, but first determine the idlest subthread among the multiple subthreads of the first process, and finally process the broadcast message through the idlest subthread.

[0118] It is understandable that the first number can be set according to actual needs, and this application does not impose any specific restrictions on this. For example, the first number can be 3.

[0119] It is understood that the memory occupancy may refer to the ratio of the size of the used memory in the memory space of the first application to the total size of the memory space. A larger memory occupancy may refer to the ratio being greater than the first ratio, and a smaller memory occupancy may refer to the ratio being not greater than the first ratio. It is understood that the first ratio may be set according to actual needs, and the present application does not impose any specific restrictions on this. For example, the first ratio may be 0.6.

[0120] The following introduces the software structure of the electronic device involved in the embodiments of the present application.

[0121] See also Figure 5 , Figure 5 A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application.

[0122] like Figure 5 As shown, the software system of the electronic device can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android operating system of the layered architecture as an example to exemplify the software structure of the electronic device.

[0123] The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the software framework of the electronic device may include an application layer, an application framework layer, a system library, a runtime, a hardware abstraction layer (HAL), and a kernel layer.

[0124] The application layer can include a series of application packages. For example, an application package can include applications such as camera, gallery, settings, call, map, navigation, WLAN, Bluetooth, music, video, and short message.

[0125] The application layer may further include a first application. The first application may be a system application or a third-party application. The first application may include an information decision module. The information decision module may be used to determine whether a process in the first application needs to start a child thread to process the broadcast after receiving the broadcast. In some embodiments of the present application, the first application may further include a child thread scheduling module. The child thread scheduling module may be used to send a broadcast message queued in a message queue corresponding to the main thread to a child thread for processing, and delete the broadcast message in the message queue corresponding to the main thread.

[0126] It is understandable that after the first application is started, the Android operating system can create a process corresponding to the first application, such as the first process. It is understandable that after the first process is created, the first application can run in the first process. In some embodiments of the present application, after the first process is created, the information decision module and the sub-thread scheduling module in the first application can run in the main thread of the first process. In some embodiments of the present application, the first application may also include other processes.

[0127] The application framework layer provides an application programming interface (API) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions. The application framework layer can include a series of system services. System services are modular components that focus on specific functions. The functions provided by the application framework API can communicate with system services to access the underlying hardware.

[0128] The application framework layer may include a system service (SystemServer) process and a resource management process.

[0129] The SystemServer process is responsible for starting and managing the entire application framework layer. After the SystemServer process is created, it can mainly handle the following: (1) Initialize some system settings, virtual machine configuration, etc.; (2) Start the Binder thread pool so that Binder cross-process communication can be performed with other processes; (3) Create a system service manager (SystemServiceManager), which is used to create, start and manage the life cycle of system services; (4) Create the main thread Looper and enter a loop to wait for messages; (5) Start various system services, such as AMS, PMS, Window Manager Service (WMS) and Input Manager Service (IMS).

[0130] The SystemServer process can include AMS and PMS. AMS is used to manage all Activities and processes in the application. It can start, pause, stop and destroy Activities, as well as manage the life cycle of the application. AMS can also allocate system resources such as memory, processes and threads to different applications. PMS is mainly responsible for the installation, management and uninstallation of applications. When a new application is installed, PMS will identify all components of the application (for example, services, broadcast receivers, etc.) and assign corresponding permissions to these components. PMS can also check the status of installed applications to ensure the integrity and security of the application. In some embodiments of the present application, PMS may also include a parameter identification module. The parameter identification module can be used to parse several broadcast-related parameters in the manifest file.

[0131] It is understandable that the SystemServer process may also include other services (eg, WMS, IMS, etc.), which are not described in detail in this application.

[0132] The resource management module can be used to initialize the configuration at startup (for example, broadcast-related configuration) and process the maintenance and testing information transmitted by the SystemServer process, that is, to maintain and test the exceptions and problems that occur in the process of the SystemServer process managing the application framework layer (for example, exceptions and problems that occur during broadcast distribution).

[0133] It is worth noting that the information decision module, sub-thread scheduling module, parameter identification module and resource management process involved in this application are new software modules that are different from the existing software framework.

[0134] The application framework layer may also include a window manager, a content provider, a view system, a phone manager, a resource manager, and a notification manager. The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make the data accessible to the application. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text notification icon may include a view for displaying text and a view for displaying pictures. The phone manager is used to provide communication functions for electronic devices. For example, the management of call status (including connected, hung up, etc.). The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a quick stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the top status bar of the system in the form of an icon or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is prompted in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.

[0135] The system library can include multiple functional modules. For example: Surface Manager, Media Libraries, 3D graphics processing library (for example, OpenGL ES), 2D graphics engine (for example, SGL), etc. The specific meanings and functions of these functional modules can be referred to in the relevant technical documents, which will not be described in detail here. The specific meanings and functions of these functional modules can be referred to in the relevant technical documents, which will not be described in detail here.

[0136] The runtime is responsible for the scheduling and management of the system. The runtime includes the core library and the virtual machine. The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0137] The runtime may include an incubator (zygote) process. The zygote process is started by the first process initialization (init) process in the user space. It is the first AndroidRuntime process running in the Android operating system and also a bridge between the Native layer and the Java layer. The Java layer is mainly coded in Java, while the Native layer is coded in languages ​​such as C / C++. The interaction between the two is achieved through Java Native Interface (JNI). The main functions of the zygote process include creating a SystemServer process and incubating (forking) other application processes.

[0138] The Hardware Abstraction Layer (HAL) is an interface layer between the operating system kernel and the upper-level software, and its purpose is to abstract the hardware. The hardware abstraction layer is an abstract interface driven by the device kernel, which is used to implement the application programming interface that provides access to the underlying device to the higher-level Java API framework. HAL can provide a standard interface to display the device hardware functions to the higher-level Java API framework. HAL contains multiple library modules, such as camera HAL, audio HAL, etc. Each library module implements an interface for a specific type of hardware component. When the system framework layer API requires access to the hardware of a portable device, the operating system will load the library module for the hardware component.

[0139] The kernel layer is the layer between hardware and software. The kernel layer is the foundation of the Android operating system. The kernel layer is responsible for hardware drivers, networking, power, system security, and memory management. The kernel layer is an intermediate layer between hardware and software, and its role is to pass application requests to the hardware. The kernel layer can include display drivers, camera drivers, audio drivers, and sensor drivers.

[0140] It should be noted that the application provides Figure 5 The software architecture diagram of the electronic device shown is only an example and does not limit the specific module division in different layers of the Android operating system. For details, please refer to the introduction of the Android operating system software architecture in conventional technology. In addition, the broadcast distribution processing method provided by this application can also be implemented based on other operating systems, and this application will not cite examples one by one.

[0141] The following is based on Figure 5 A specific implementation of the above embodiment is introduced with reference to the software structure of the electronic device shown.

[0142] 1. The electronic device obtains the corresponding relationship between the broadcast and the broadcast receiver, and the sub-thread option information corresponding to the application where the broadcast receiver is located.

[0143] like Figure 6 As shown, a broadcast receiver can register a broadcast in the manifest file of the application in which it is located. For example, a first broadcast receiver can register a broadcast in the manifest file of the first application. In this way, the manifest file of the first application can include the correspondence between the first broadcast receiver and the broadcast that the first broadcast receiver can receive, as well as the sub-thread option information corresponding to the first application. It is understandable that the manifest files of other applications can also include the correspondence between the broadcast receivers in the other applications and the broadcast, as well as the sub-thread option information corresponding to the other applications.

[0144] like Figure 6 As shown, when the electronic device is started (i.e., powered on) or the application is installed or updated, the PMS in the electronic device can parse the Android application package (APK) file corresponding to the application (e.g., the first application). In the process of PMS parsing the APK file corresponding to the application, PMS can parse the manifest file of the application, obtain the correspondence between the broadcast and the broadcast receiver from the manifest file, and can also identify the sub-thread option information corresponding to the application through the parameter identification module in PMS, thereby obtaining the sub-thread option information corresponding to the application where the broadcast receiver is located. PMS can store the obtained correspondence between the broadcast and the broadcast receiver, as well as the sub-thread option information corresponding to the application where the broadcast receiver is located in PMS.

[0145] It is understandable that APK is an application package file format used by the Android operating system to distribute and install mobile applications and middleware. If an Android application code wants to run on an Android device, it needs to be compiled first, and then packaged into a file that can be recognized by the Android operating system before it can be run. This file format that can be recognized and run by the Android operating system is APK.

[0146] Combine the following Figure 7 This section describes a specific implementation method for PMS to parse inventory files.

[0147] First, the software modules involved in the process of PMS parsing inventory files are introduced.

[0148] like Figure 7As shown, PMS may include an initial application helper (InitAPPHelper), an installation package helper (InstallPackageHelper), a parallel package parser (ParallelPackageParser), a package parser (PackageParser), a parsing package tool (ParsingPackageUtils) and a parsing activity tool (ParserActivityUtils). Among them, the parsing activity tool may include a parameter identification module. It can be understood that InitAPPHelper and InstallPackageHelper belong to the Helper class (helper class), which is usually used to implement auxiliary functions, can have a state (i.e., a member variable of the class), and usually requires the creation of an instance of the class before use. ParallelPackageParser and PackageParser belong to the PackageParser class, which is mainly used to parse APK files on electronic devices. ParsingPackageUtils and ParserActivityUtils belong to the Util class (tool class), which is usually used to implement general functions or algorithms, contains only static methods and constants, and generally does not require the creation of a class instance when used.

[0149] Next, the process of PMS parsing the inventory file is specifically described in combination with the software modules in the above PMS. The process may include but is not limited to the following steps:

[0150] S201: The initial application assistant receives a request to start an electronic device or install an application or update an application.

[0151] In some embodiments of the present application, a user can trigger the startup of an electronic device. Specifically, a user can trigger the startup of an electronic device by pressing a power button of the electronic device, etc. Accordingly, the electronic device starts the bootloader, loads and starts the Linux kernel, starts the init process, creates the zygote process and the SystemServer process. The SystemServer process can start the PSM. After the PMS is started, the initial application assistant in the PMS can receive a request to start the electronic device.

[0152] In some embodiments of the present application, a user may trigger the installation of an application in an electronic device. Accordingly, the initial application assistant may receive a request to install the application.

[0153] In some embodiments of the present application, a user may trigger an update of an application in an electronic device, or the electronic device may automatically update an application in the electronic device. Accordingly, the initial application assistant may receive a request to update the application.

[0154] S202: The initial application assistant starts scanning the installation path.

[0155] After the initial application assistant receives a request to start an electronic device or install an application or update an application, it can start scanning the installation path of the application. Specifically, if the initial application assistant receives a request to start an electronic device, the initial application assistant can scan the installation path of each application in the electronic device. However, if the initial application assistant receives a request to install an application, the initial application assistant can scan the installation path of the application to be installed. Similarly, if the initial application assistant receives a request to update an application, the initial application assistant can scan the installation path of the application to be updated.

[0156] In some embodiments of the present application, the initial application assistant scans the installation path of each application in the electronic device, which may specifically include: the initial application assistant can scan the installation path of each system application under the system / app / directory, scan the installation path of each pre-installed application under the system / priv-app / directory, and scan the installation path of each third-party application installed by the user under the data / app / directory.

[0157] In some embodiments of the present application, the initial application assistant may call the scanDirTracedLI() method and the scanDirLI() method in the scanDirTracedLI() method to scan the installation path of the application.

[0158] S203: The initial application assistant instructs the installation package assistant to scan the APK file.

[0159] After the initial application assistant starts scanning the installation path of the application, it can instruct the installation package assistant to scan the APK file. That is, in the process of scanning the installation path of the application, the initial application assistant can instruct the installation package assistant to scan the APK file.

[0160] S204: The installation package assistant instructs the parallel package parser to parse the APK file.

[0161] For the scenario of starting an electronic device, after the installation package assistant traverses all APK files under the file directory (for example, system / app / directory, system / priv-app / directory, data / app / directory, etc.), it can instruct the parallel package parser to parse each APK file.

[0162] For the application installation scenario, after the installation package assistant scans the APK file of the corresponding application to be installed, it can instruct the parallel package parser to parse the APK file corresponding to the application to be installed. Similarly, for the application update scenario, after the installation package assistant scans the installation path of the corresponding application to be updated, it can instruct the parallel package parser to parse the APK file corresponding to the application to be updated.

[0163] In some embodiments of the present application, the installation package assistant instructs the parallel package parser to parse the APK file, which may specifically include: the installation package assistant may create a ParallelPackageParser object, and call the submit() method to submit the request to execute the parsing of the APK file.

[0164] S205: The parallel package parser starts parsing the APK file.

[0165] The installation package assistant can call the parallel package parser to instruct the parallel package parser to parse the APK file. Accordingly, after the parallel package parser is called, it can start parsing the APK file. It can be understood that the parallel package parser can use thread pools and queues to perform APK file parsing.

[0166] S206: The parallel package parser calls the package parser during the process of parsing the APK file.

[0167] The parallel package parser can call the package parser during the parsing of the APK file to further parse the APK file through the package parser. It can be understood that the package parser is a parser for package files (APKs) on disk. It supports parsing applications packaged into a single "monoblock" APK, and also supports parsing "cluster" applications packaged into multiple APKs in a single directory.

[0168] In some embodiments of the present application, the parallel package parser calls the package parser, which may specifically include: the parallel package parser may call the parserPackage() method in the package parser to parse the APK file, and finally convert the static file into a package. Package is a data structure in memory, which contains all the information of a package, such as package name, package path, permissions, four major components, etc.

[0169] S207: The package parser instructs the package parsing tool to parse the manifest file.

[0170] After the parallel package parser calls the package parser in the process of parsing the APK file, the package parser can further call the parsing package tool to instruct the parsing package tool to parse the manifest file.

[0171] S208: The parsing package tool starts parsing the manifest file.

[0172] After the parsing package tool is called, it can start parsing the manifest file. It is understandable that in the process of parsing the manifest file, the parsing package tool can parse the tags of the manifest file.

[0173] For example, the tags of the manifest file may include <manifest>Label. <manifest>The next level of sub-tags of a tag can include <application>Label. <application>The next level of sub-tags of a tag can be <activity>Label, <provider>Label, <service>Tags and <receiver>Tags. Among them, <manifest>Labels can refer to display labels, <application>Tags can refer to application tags, <activity>Tags can refer to active tags, <provider>Tags can refer to provider tags, <service>Tags can refer to service tags, <receiver>The label may refer to a receiver label (which may be referred to as a receiver node).

[0174] In some embodiments of the present application, the package parsing tool may call the PackageParser.parseBaseApk() method to parse the manifest file.

[0175] S209: The parsing package tool instructs the parsing activity tool to parse the receiver node in the manifest file.

[0176] After the Parse Package Tool starts parsing the manifest file, you can instruct the Parse Activity Tool to parse the receiver node in the manifest file to obtain information about the broadcast and the broadcast receiver.

[0177] S210: The parsing activity tool parses the sub-thread parameter information corresponding to the application included in the manifest file, and the correspondence between the broadcast receivers in the application and the broadcast.

[0178] In the process of parsing the receiver node in the manifest file included in the APK file, the parsing activity tool can parse and obtain the sub-thread parameter information corresponding to the application corresponding to the APK file, as well as the correspondence between the broadcast receiver registered in the application and the broadcast (i.e., the first correspondence). In some embodiments of the present application, the parsing activity tool can also parse and obtain the process where the broadcast receiver registered in the application corresponding to the APK file is located.

[0179] It is understandable that the parsing activity tool can store the parsed broadcast and broadcast receiver related information in the PMS. For example, the parsing activity tool can store the parsed sub-thread parameter information corresponding to the application, the correspondence between the broadcast receiver registered in the application and the broadcast, and the identifier of the process where the broadcast receiver registered in the application is located (for example, the process name) in the PMS.

[0180] 2. After receiving the broadcast, the AMS in the electronic device determines the target broadcast receiver based on the correspondence between the broadcast and the broadcast receiver, and sends the broadcast to the target broadcast receiver. The target broadcast receiver determines whether to start the sub-thread to process the broadcast based on the sub-thread option information corresponding to its application.

[0181] like Figure 6 As shown, the broadcast sender can send a first broadcast to the AMS. On the one hand, after receiving the first broadcast sent by the broadcast sender, the AMS can put the first broadcast into the corresponding broadcast queue. On the other hand, after receiving the first broadcast sent by the broadcast sender, the AMS can determine the broadcast receiver corresponding to the first broadcast, that is, the target broadcast receiver, based on the correspondence between the broadcast and the broadcast receiver stored in the PMS, and determine the sub-thread option information corresponding to the application where the target broadcast receiver is located based on the sub-thread option information corresponding to the application stored in the PMS. In some embodiments of the present application, the AMS can also determine the process where the target broadcast receiver is located based on the process where the broadcast receiver is located stored in the PMS. It can be understood that the target broadcast receiver may include the first broadcast receiver, the process where the first broadcast receiver is located is the first process, and the application where the first broadcast receiver is located is the first application.

[0182] It is understandable that the present application does not limit the specific layering of the broadcast sender in the system architecture. In some embodiments of the present application, the broadcast sender can be at the application layer. In some other embodiments of the present application, the broadcast sender can be at the application framework layer.

[0183] In some embodiments of the present application, Figure 6 As shown, the AMS can obtain the target broadcast receiver and corresponding sub-thread option information from the PMS by sending a target broadcast receiver acquisition request to the PMS.

[0184] According to the above, if there are multiple target broadcast receivers, the AMS can distribute the first broadcast to the multiple target broadcast receivers in series. The following takes the AMS distributing the first broadcast to the first broadcast receiver as an example to introduce the specific process of the AMS distributing the broadcast and the specific process of the corresponding target broadcast receiver processing the broadcast.

[0185] like Figure 6 As shown, if the process where the first broadcast receiver is located (i.e., the first process) has been created, the AMS can send the sub-thread option information corresponding to the first broadcast and the application where the first broadcast receiver is located (i.e., the first application) to the main thread of the first process. If the first process has not been created (i.e., not yet running), the AMS can trigger the zygote process to fork the first process, i.e., create the first process. This process can be called the cold start process of the first process in the first application. After the zygote process creates the first process, the AMS can send the sub-thread option information corresponding to the first broadcast and the first application to the main thread of the first process. If the first process has been created, the AMS can directly send the sub-thread option information corresponding to the first broadcast and the first application to the main thread of the first process. This process can be called the hot start process of the first process in the first application.

[0186] After the main thread of the first process receives the first broadcast and the sub-thread option information corresponding to the first application, it can determine whether to process the first broadcast through the main thread of the first process or through the sub-thread of the first process based on the sub-thread option information corresponding to the first application. If the sub-thread option information corresponding to the first application does not indicate that the sub-thread is allowed to process the broadcast, the main thread of the first process can directly process the first broadcast. If the sub-thread option information corresponding to the first application indicates that the sub-thread is allowed to process the broadcast, the main thread of the first process can load the sub-thread, and the sub-thread of the first process can process the first broadcast.

[0187] In some embodiments of the present application, when the child thread option information corresponding to the first application includes the first parameter information, the child thread option information corresponding to the first application indicates that the child thread is allowed to process the broadcast, and when the child thread option information corresponding to the first application does not include the first parameter information, the child thread option information corresponding to the first application does not indicate that the child thread is allowed to process the broadcast.

[0188] In some embodiments of the present application, when a specific field in the child thread option information corresponding to the first application is specific content, the child thread option information corresponding to the first application indicates that the child thread is allowed to process the broadcast; otherwise, the child thread option information corresponding to the first application does not indicate that the child thread is allowed to process the broadcast.

[0189] Of course, there may be other specific implementations for the sub-thread option information corresponding to the first application to indicate that the sub-thread is allowed to process the broadcast, and this application does not impose any limitation on this.

[0190] In some embodiments of the present application, if the child thread option information corresponding to the first application does not indicate that the child thread is allowed to process the broadcast, the main thread of the first process can encapsulate the first broadcast into a broadcast message and put it into the message queue corresponding to the main thread of the first process to wait for processing. If the child thread option information corresponding to the first application indicates that the child thread is allowed to process the broadcast, the main thread of the first process can load the child thread, encapsulate the first broadcast into a broadcast message and put it into the message queue corresponding to the child thread of the first process to wait for processing.

[0191] In some embodiments of the present application, Figure 6 As shown, the main thread of the first process can obtain a decision result based on the sub-thread option information corresponding to the first application through the information decision module running in the main thread of the first process. The main thread of the first process can also determine whether to start the sub-thread of the first process to process the first broadcast based on the decision result through the sub-thread scheduling module running in the main thread of the first process. It can be understood that the information decision module and sub-thread scheduling module running in the main thread of the first process mentioned here refer to the information decision module and sub-thread scheduling module in the first application. It can be understood that after the first process is created, the first application can run in the first process, then the information decision module and sub-thread scheduling module in the first application can run in the first process, specifically, can run in the main thread of the first process.

[0192] In a possible implementation, the main thread of the first process can receive information through an information decision module running in the main thread of the first process, determine whether the sub-thread option information corresponding to the first application indicates that the sub-thread broadcast is allowed, obtain a decision result, and encapsulate the decision result and the first broadcast together to obtain a broadcast message, that is, obtain a broadcast message with the decision result added, and then put the broadcast message with the decision result added into the message queue corresponding to the main thread of the first process (such as Figure 6 The sub-thread scheduling module running in the main thread of the first process can obtain the broadcast message with the decision result added from the message queue 1, and determine whether to start the sub-thread of the first process according to the decision result.

[0193] In a possible implementation, the main thread of the first process may first encapsulate the first broadcast into a broadcast message. During the encapsulation process, the main thread of the first process may receive and determine whether the sub-thread option information corresponding to the first application indicates that the sub-thread broadcast is allowed through the information decision module running in the main thread of the first process, obtain the decision result, and add the decision result to the broadcast message obtained by encapsulating the first broadcast, and then put the broadcast message with the decision result added into the message queue 1. The sub-thread scheduling module running in the main thread of the first process may obtain the broadcast message with the decision result added from the message queue 1, and determine whether the sub-thread of the first process needs to be started according to the decision result.

[0194] It can be understood that if the sub-thread option information corresponding to the first application includes the first parameter information, the decision result is to start the sub-thread (i.e., the first decision result); if the sub-thread option information for starting the first process does not include the first parameter information, the decision result is not to start the sub-thread (i.e., the second decision result).

[0195] If the decision result is to start the child thread, the child thread scheduling module running in the main thread of the first process can start the child thread of the first process. The main thread of the first process can repackage the broadcast message with the decision result added to obtain a repackaged broadcast message, and put the repackaged broadcast message into the message queue corresponding to the child thread of the first process (such as Figure 6 The sub-thread scheduling module running in the main thread of the first process can complete the above steps of repackaging broadcast messages and deleting broadcast messages in message queue 1.

[0196] If the decision result is not to start the child thread, the broadcast message encapsulated by the first broadcast and added with the decision result continues to queue in the message queue 1 waiting for the main thread of the first process to process.

[0197] It is understood that the decision result can be represented by numbers, words, characters, etc., and this application does not impose specific restrictions on this. For example, when the decision result is 1, it means that the sub-thread is started, and when the decision result is 0, it means that the sub-thread is not started. For another example, when the decision result is startthread, it means that the sub-thread is started, and when the decision result is no thread, it means that the sub-thread is not started.

[0198] It should be noted that if the first process has not been created before AMS sends the first broadcast to the first process, after AMS triggers the zygote process to create the first process, the first process can be bound to the first application. After the first process completes part of the application environment initialization preparation, the information decision module running in the main thread of the first process can determine the decision result based on the sub-thread option information corresponding to the first application.

[0199] In some embodiments of the present application, the above-mentioned broadcast message may be a RECEIVER message. Specifically, processing the broadcast may be accomplished by calling the scheduleReceiver() method. The method sends a RECEIVER message to a message queue, calls the handleReceiver() method to process the message, and further calls the onReceive() method in the handleReceiver() method to process the message. The main thread or child thread of the first process processes the broadcast message in its corresponding message queue, which may specifically include: the main thread or child thread of the first process executes the onReceive() method. It is understandable that, generally speaking, the onReceiver() method involves interaction with other components, such as sending notifications, starting services, etc.

[0200] In some embodiments of the present application, message queue 1 and message queue 2 may use a Handle mechanism. The Handle mechanism is an asynchronous callback mechanism Handler, which can be used to make corresponding notifications after completing a long task. It is understandable that the specific meaning and usage of the Handle mechanism can be referred to in relevant technical documents, and this application will not elaborate on it here.

[0201] Combine the following Fig. 8A and Figure 8B A specific implementation method of distributing a first broadcast to a first broadcast receiver by an AMS when a first process has not been created is introduced.

[0202] (1) AMS distributes the first broadcast to the main thread of the first process, encapsulates it and puts the broadcast message into the corresponding message queue (such as Fig. 8A shown).

[0203] S301: If the first process has not been created, the AMS triggers the creation of the first process.

[0204] If the process where the first broadcast receiver is located has not been created when the AMS is preparing to send the first broadcast to the first broadcast receiver, the AMS may first trigger the electronic device to create the first process. It is understandable that the AMS may trigger the zygote process in the electronic device to fork the first process.

[0205] It is understandable that after the electronic device creates and starts the first process, the main() method in ActivityThread begins to be called and the message loop queue is opened. It is understandable that after the main() method begins to be called, the attch() method therein can begin to be called. The attch() method can be used to complete the finishing work after the first process is created. For example, the attach() method can be used to transmit information such as process identification (pid) and user identification (uid) to prepare for binding the application. It is understandable that each process has a unique pid. As soon as the application process starts running, the operating system will automatically assign a pid to the process. UID can be used to identify the application.

[0206] It should be noted that ActivityThread is an object created in the main() method running in the main thread, and can be considered as a part of the main thread. In some embodiments of the present application, ActivityThread can also be understood as the main thread. In this case, the above-mentioned message loop queue can be understood as the message queue corresponding to the main thread mentioned above.

[0207] In some embodiments of the present application, the AMS may call the startProcessLocked() method to create the first process. The startProcessLocked() method may pass parameters to the zygote process through the socket channel, and the zygote process then forks the first process based on the parameters, and calls the ZygoteInit.main() method to instantiate the ActivityThread object, and returns the process ID of the first process. ActivityThread may then call Looper.prepareLoop() and Looper.loop() to start the message loop queue.

[0208] S302: The first process notifies the AMS that the creation of the first process is complete.

[0209] After the first process is created, the AMS may be notified. It is understandable that the first process may notify the AMS that the first process has been created by sending a corresponding notification message to the AMS.

[0210] S303: The AMS triggers the first process to bind the first application.

[0211] After receiving the notification message that the first process is created, the AMS may trigger the first process to start binding with the first application.

[0212] S304: The first process sends a binding application message to message queue 1.

[0213] After the first process starts to bind the first application, it can send a binding application message to the message queue corresponding to the main thread of the first process (ie, message queue 1).

[0214] In some embodiments of the present application, the first process may call the bindApplication() method to implement binding between the first process and the first application. The relevant description of the bindApplication() method can be referred to above, and the present application will not repeat it here.

[0215] S305: The AMS sends the first broadcast and sub-thread option information corresponding to the first application to the main thread of the first process.

[0216] After AMS triggers the first process to bind the first application, it can send the first broadcast and the sub-thread option information corresponding to the first application to the main thread of the first process. Correspondingly, the main thread of the first process can receive the first broadcast and the sub-thread option information corresponding to the first application sent by AMS.

[0217] It is understandable that after the AMS receives the first broadcast sent by the broadcast sender, it can determine whether to add the first broadcast to the foreground broadcast queue or the background broadcast queue, and determine whether to add the first broadcast to the serial list or the parallel list in the broadcast queue based on the distribution order of the first broadcast.

[0218] It is understandable that the AMS can implement the distribution of the first broadcast through a broadcast queue (BroadcastQueue). The broadcast queue is mainly responsible for sending the broadcast received by the AMS to the corresponding broadcast receiver. In some embodiments of the present application, the broadcast queue in the AMS may include a foreground broadcast queue and a background broadcast queue. The foreground broadcast queue is used to distribute the foreground broadcast, and the background broadcast queue is used to distribute the background broadcast. The specific meaning and difference between the foreground broadcast and the background broadcast can be referred to the relevant technical documents, and this application will not be described in detail here.

[0219] It is understandable that the broadcast queue may include a parallel list and a serial list. The broadcast tasks stored in the parallel list include unordered broadcast tasks and dynamic broadcast receiver tasks. The broadcast tasks stored in the serial list include ordered broadcast tasks and static broadcast receiver tasks. Among them, static broadcast receiver tasks refer to broadcast tasks for statically registered broadcast receivers. In the serial list, broadcast tasks corresponding to different broadcasts are queued in chronological order, and broadcast tasks corresponding to the same broadcast with multiple statically registered broadcast receivers are queued according to the priority of the broadcast receivers. It is understandable that the next broadcast task can only be processed after one broadcast task in the serial list is processed.

[0220] Taking the first broadcast as an example, if the first broadcast corresponds to multiple statically registered target broadcast receivers, the first broadcast can be placed in a serial list in the corresponding broadcast queue (e.g., the foreground broadcast queue or the background broadcast queue). In the serial list, each statically registered target broadcast receiver corresponding to the first broadcast corresponds to a broadcast task. This means that the first broadcast corresponds to multiple broadcast tasks, and the multiple broadcast tasks can be queued according to the priority of the multiple statically registered target broadcast receivers corresponding to the first broadcast.

[0221] In some embodiments of the present application, the order of the multiple broadcast tasks corresponding to the first broadcast in the serial list is consistent with the order of the corresponding target broadcast receivers in the target broadcast receiver list mentioned above. It is understandable that the multiple broadcast tasks corresponding to the first broadcast may include the broadcast task corresponding to the first broadcast receiver. The order of the broadcast tasks corresponding to the first broadcast receiver in the serial list is consistent with the order of the first broadcast receiver in the target broadcast receiver list. For example, among the multiple broadcast tasks corresponding to the first broadcast, the broadcast task corresponding to the first broadcast receiver ranks first, and the order of the first broadcast receiver in the target broadcast receiver list is also first.

[0222] S306: The main thread of the first process encapsulates the first broadcast into a broadcast message.

[0223] After the main thread of the first process receives the first broadcast sent by the AMS and the sub-thread option information corresponding to the first application, the first broadcast may be encapsulated to obtain a broadcast message.

[0224] In some embodiments of the present application, the main thread of the first process may encapsulate the sub-thread option information corresponding to the first broadcast and the first application to obtain a broadcast message.

[0225] S307: The information decision module running in the main thread of the first process obtains a decision result based on the sub-thread option information corresponding to the first application.

[0226] In some embodiments of the present application, as shown in step S305, after the main thread of the first process receives the sub-thread option information corresponding to the first application sent by AMS, the information decision module running in the main thread of the first process can obtain a decision result based on the sub-thread option information corresponding to the first application.

[0227] In some other embodiments of the present application, the electronic device may first execute step S307 and then execute step S306. In this case, the information decision module running in the main thread of the first process may obtain a decision result based on the sub-thread option information corresponding to the first application, and then encapsulate the first broadcast and the decision result into a broadcast message to obtain a broadcast message with the decision result added (as shown in step S308).

[0228] In some other embodiments of the present application, when the electronic device executes step S306, the main thread of the first process can encapsulate the first broadcast and the sub-thread option information corresponding to the first application to obtain a broadcast message. In this case, the information decision module running in the main thread of the first process can extract the sub-thread option information corresponding to the first application from the broadcast message, and obtain a decision result based on the sub-thread option information corresponding to the first application.

[0229] In some embodiments of the present application, the information decision module may obtain a decision result based on whether the sub-thread option information corresponding to the first application includes the first parameter information. Specifically, as described above, if the sub-thread option information corresponding to the first application includes the first parameter information, the decision result is to start the sub-thread of the first process, and if the sub-thread option information for starting the first process does not include the first parameter information, the decision result is not to start the sub-thread of the first process.

[0230] S308: The main thread of the first process adds the decision result to the broadcast message obtained by the first broadcast encapsulation, and puts the broadcast message with the decision result added into the message queue 1.

[0231] After the information decision module running in the main thread of the first process obtains the decision result, the main thread of the first process can add the decision result to the broadcast message obtained by the first broadcast encapsulation (as shown in step S307), obtain the broadcast message with the decision result added, and put the broadcast message with the decision result added into message queue 1.

[0232] In some embodiments of the present application, the electronic device may first execute step S307 and then execute step S306. In this case, the broadcast message encapsulated by the main thread of the first process is a broadcast message with a decision result added, and the broadcast message with the decision result added may be directly put into message queue 1.

[0233] It is understandable that the present application does not restrict the order of step S304 and step S305, and does not restrict the order of step S306 and step S307.

[0234] (2) The sub-thread scheduling module running in the main thread of the first process determines whether to start the sub-thread of the first process to process the encapsulated broadcast message (such as Figure 8B shown).

[0235] S309: If the first process completes a portion of the application environment initialization preparation during processing of the bound application message, the main thread of the first process obtains the broadcast message corresponding to the first broadcast in the message queue 1 through the sub-thread scheduling module running in the main thread of the first process.

[0236] As shown in step S304, after the bound application message is sent to the message queue 1, the bound application message is queued in the message queue 1 and waits for processing by the main thread of the first process. After all the messages in the message queue 1 that are queued before the bound application message are processed, the main thread of the first process can start processing the bound application message. If, in the process of processing the bound application message, the first process completes a part of the application environment initialization preparation, the sub-thread scheduling module running in the main thread of the first process can obtain the broadcast message corresponding to the first broadcast from the message queue 1. It can be understood that the broadcast message corresponding to the first broadcast can refer to the broadcast message obtained by the first broadcast encapsulation and added with the decision result mentioned in step S308.

[0237] According to the above, in some embodiments of the present application, the main thread of the first process can process the bound application message through the handleBindApplication() method.

[0238] S310: The sub-thread scheduling module running in the main thread of the first process determines whether to start the sub-thread of the first process based on the decision result in the broadcast message corresponding to the first broadcast.

[0239] After the sub-thread scheduling module running in the main thread of the first process obtains the broadcast message corresponding to the first broadcast from the message queue 1, the decision result determined by the information decision module running in the main thread of the first process can be obtained from the broadcast message corresponding to the first broadcast (as shown in step S307). If the decision result is to start the sub-thread, the sub-thread scheduling module running in the main thread of the first process determines to start the sub-thread of the first process. However, if the decision result is not to start the sub-thread, the sub-thread scheduling module running in the main thread of the first process determines not to start the sub-thread of the first process. It is worth noting that if the sub-thread scheduling module running in the main thread of the first process determines not to start the sub-thread of the first process, the broadcast message corresponding to the first broadcast is queued in the message queue 1 waiting for the main thread of the first process to be processed.

[0240] Exemplarily, if the decision result obtained by the sub-thread scheduling module running in the main thread of the first process is 1, the sub-thread scheduling module running in the main thread of the first process can determine that the decision result indicates that the sub-thread is started, and the sub-thread scheduling module running in the main thread of the first process can determine to start the sub-thread of the first process. If the decision result obtained by the sub-thread scheduling module running in the main thread of the first process is 0, the sub-thread scheduling module running in the main thread of the first process can determine that the decision result indicates that the sub-thread is not started, and the sub-thread scheduling module running in the main thread of the first process can determine to start the sub-thread of the first process.

[0241] S311: If the sub-thread scheduling module running in the main thread of the first process determines to start the sub-thread of the first process, the main thread of the first process starts the sub-thread of the first process.

[0242] If the sub-thread scheduling module running in the main thread of the first process determines that the sub-thread of the first process needs to be started, the main thread of the first process can load the sub-thread of the first process.

[0243] S312: If the sub-thread scheduling module running in the main thread of the first process determines to start the sub-thread of the first process, the main thread of the first process repackages the broadcast message corresponding to the first broadcast to obtain the repackaged broadcast message.

[0244] If the sub-thread scheduling module running in the main thread of the first process determines that the sub-thread of the first process needs to be started, the main thread of the first process can re-encapsulate the broadcast message corresponding to the first broadcast to obtain the re-encapsulated broadcast message. It can be understood that the main thread of the first process re-encapsulates the broadcast message corresponding to the first broadcast, which can specifically include: the main thread of the first process changes the timestamp of the broadcast message corresponding to the first broadcast. The main thread of the first process re-encapsulates the broadcast message corresponding to the first broadcast, which can specifically also include: the main thread of the first process changes the relevant attribute value of the broadcast message corresponding to the first broadcast.

[0245] In some embodiments of the present application, the above-mentioned process of repackaging the broadcast message can be completed by a sub-thread scheduling module running in the main thread of the first process.

[0246] S313: The main thread of the first process sends the repackaged broadcast message to message queue 2.

[0247] After the main thread of the first process obtains the repackaged broadcast message, it can send the repackaged broadcast message to the child thread of the first process and put it into the message queue (ie, message queue 2) corresponding to the child thread of the first process.

[0248] In some embodiments of the present application, the broadcast message is repackaged by a sub-thread scheduling module running in the main thread of the first process. In this case, the sub-thread scheduling module running in the main thread of the first process can put the repackaged broadcast message into the message queue 2.

[0249] S314: If the sub-thread scheduling module running in the main thread of the first process determines to start the sub-thread of the first process, the main thread of the first process deletes the broadcast message corresponding to the first broadcast in the message queue 1.

[0250] If the child thread scheduling module running in the main thread of the first process determines to start the child thread of the first process, the main thread of the first process can delete the broadcast message corresponding to the first broadcast in the message queue 1.

[0251] In some embodiments of the present application, the above-mentioned process of deleting the broadcast message can be completed by a sub-thread scheduling module running in the main thread of the first process.

[0252] S315: The child thread of the first process processes the repackaged broadcast message in the message queue 2.

[0253] After the main thread of the first process puts the repackaged broadcast message into the message queue 2, the repackaged broadcast message can be queued in the message queue 2 and wait for the child thread of the first process to process it. After all the messages in the message queue 2 that are queued before the repackaged broadcast message are processed, the child thread of the first process can process the repackaged broadcast message in the message queue 2.

[0254] According to the above, in some embodiments of the present application, the child thread of the first process processes the repackaged broadcast message in the message queue 2, which may specifically include: the child thread of the first process executes the onReceive() method.

[0255] It can be understood that the present application does not restrict the order of step S311 and step S312, does not restrict the order of step S312 and step S314, and does not restrict the order of step S313 and step S314.

[0256] It can be understood that, through the above method, one or more applications in the electronic device do not need to process the broadcast message through the relatively idle sub-thread of the process where the broadcast receiver is located, but can process the broadcast message through the relatively idle sub-thread of the process where the broadcast receiver is located. In this case, the broadcast message can be processed by the sub-thread without queuing in the message queue corresponding to the sub-thread, or the broadcast message can be processed by the sub-thread after queuing in the message queue corresponding to the sub-thread for a short time, which reduces the waiting time before processing the broadcast message and improves the efficiency of broadcast distribution processing.

[0257] Exemplarily, the AMS prepares to send a first broadcast to a first broadcast receiver in a first process. Fig. 9 As shown, at time t1, AMS can trigger the creation of the first process, that is, time t1 is the starting time of the process startup phase. If the application where the first broadcast receiver is located (i.e., the first application) starts the child thread of the first process to process the broadcast message corresponding to the first broadcast, the broadcast message corresponding to the first broadcast can be processed at time t2. If the first application does not start the child thread of the first process, but the main thread of the first process processes the broadcast message corresponding to the first broadcast, the broadcast message corresponding to the first broadcast can be processed at time t3. Among them, time t2 is earlier than time t3. It can be understood that if the first application starts a child thread to process the broadcast message, the duration of the queuing stage (i.e., the queuing duration) will be reduced, the broadcast message will be processed faster, and then the first broadcast will be sent to the next broadcast receiver faster.

[0258] The hardware structure of the electronic device involved in the embodiments of the present application is introduced below.

[0259] See also Fig.10 , Fig.10 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.

[0260] like Fig.10 As shown, the electronic device may include a processor, an external memory interface, an internal memory, an audio module, a speaker, a receiver, a microphone, an earphone interface, and a display screen.

[0261] The structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device. In some embodiments of the present application, the electronic device may include more components than shown. For example, the electronic device may include sensors such as a touch sensor, an acceleration sensor, and a gyroscope sensor. In some embodiments of the present application, the electronic device may include fewer components than shown, or combine certain components, or split certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware. The interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device.

[0262] The processor may include one or more processing units. For example, the processor may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). A memory may also be provided in the processor for storing instructions and data.

[0263] The electronic device can realize the display function through a GPU, a display screen, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor may include one or more GPUs, which execute program instructions to generate or change display information. The display screen is used to display images, videos, etc. In some embodiments of the present application, the electronic device may include one or more display screens.

[0264] In the present application, the ability of an electronic device to display a user interface depends on the display function provided by the above-mentioned GPU, display screen and application processor.

[0265] The internal memory can be used to store computer executable program codes, and the executable program codes include instructions. The processor executes various functional applications and data processing of the electronic device by running the instructions stored in the internal memory. The internal memory may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (for example, a sound playback function, an image playback function, etc.), etc. The data storage area can store data created during the use of the electronic device (for example, audio data, a phone book, etc.), etc.

[0266] It is understood that the internal memory may include one or more random access memories (RAM) and one or more non-volatile memories (NVM). For example, at least one disk storage device, flash memory device, universal flash storage (UFS), etc. The random access memory can be directly read and written by the processor, and can be used to store executable programs (e.g., machine instructions) of the operating system or other running programs, and can also be used to store user and application data, etc. The non-volatile memory can also store executable programs and store user and application data, etc., and can be loaded into the random access memory in advance for direct reading and writing by the processor.

[0267] In the present application, the code for implementing the broadcast distribution processing method described in the embodiment of the present application may be stored in a non-volatile memory. When implementing the method, the electronic device may load the executable code stored in the non-volatile memory into a random access memory.

[0268] The external memory interface can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device. The external memory card can communicate with the processor through the external memory interface to implement data storage functions. For example, music, video and other files can be saved in the external memory card.

[0269] Electronic devices can implement audio functions through audio modules, speakers, receivers, microphones, headphone jacks, and application processors.

[0270] The audio module is used to convert digital audio information into analog audio signal output, and also used to convert analog audio input into digital audio signal. The speaker, also known as the "horn", is used to convert audio electrical signals into sound signals. The receiver, also known as the "earpiece", is used to convert audio electrical signals into sound signals. The microphone, also known as the "microphone" or "microphone", is used to convert sound signals into electrical signals. The headphone jack is used to connect wired headphones.

[0271] The display screen is used to display images, videos, etc. In some embodiments of the present application, the electronic device may include one or more display screens. The electronic device may implement the display function through a graphics processor, a display screen, and an application processor.

[0272] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.< / receiver> < / service> < / provider> < / activity> < / application> < / manifest> < / receiver> < / service> < / provider> < / activity> < / application> < / application> < / manifest> < / manifest>

Claims

1. A broadcast distribution processing method, characterized in that: The method is applied to an electronic device, the electronic device includes an AMS (Activity Management Service), a broadcast sender and a broadcast receiver, and the method includes: The broadcast sender sends a first broadcast; The AMS receives the first broadcast; The AMS determines a target broadcast receiver corresponding to the first broadcast; The AMS determines sub-thread option information corresponding to the application where the target broadcast receiver is located, wherein the sub-thread option information is used to indicate whether the application allows the sub-thread to process the broadcast.

2. The method according to claim 1, characterized in that The method further comprises: The AMS sends the first broadcast and the first information to a first process, wherein the first process is the process where the first broadcast receiver is located, the first broadcast receiver is one of the target broadcast receivers, the first information is sub-thread option information corresponding to a first application, and the first application is the application where the first broadcast receiver is located.

3. The method according to claim 2, characterized in that The method further comprises: In response to the first information indicating that the child thread is allowed to process the broadcast, the child thread of the first process processes the first broadcast.

4. The method according to claim 3, before the AMS sends the first broadcast and the first information to the first process, the method further comprises: Creating the first process; After the AMS sends the first broadcast and the first information to the first process, the method further includes: The main thread of the first process receives the first broadcast and the first information; The main thread of the first process encapsulates the first broadcast based on the first information to obtain a first broadcast message; The first broadcast message is placed into a first message queue, where the first message queue is a message queue corresponding to a main thread of the first process.

5. The method according to claim 4, wherein the child thread of the first process processes the first broadcast, comprising: Starting a child thread of the first process; The main thread of the first process re-encapsulates the first broadcast message to obtain a second broadcast message; The main thread of the first process puts the second broadcast message into a second message queue and deletes the first broadcast message in the first message queue, wherein the second message queue is a message queue corresponding to the child thread of the first process.

6. The method according to claim 4, characterized in that The main thread of the first process encapsulates the first broadcast based on the first information to obtain a first broadcast message, including: The main thread of the first process encapsulates the first broadcast to obtain a third broadcast message; The main thread of the first process determines whether the first information indicates that the child thread is allowed to process the broadcast; In response to the first information indicating that the child thread is allowed to process the broadcast, the main thread of the first process obtains a first decision result, adds the first decision result to the third broadcast message, and obtains the first broadcast message; Alternatively, in response to the first information not indicating that the child thread is allowed to process the broadcast, the main thread of the first process obtains a second decision result, adds the second decision result to the third broadcast message, and obtains the first broadcast message.

7. The method according to claim 6, characterized in that After obtaining the first broadcast message, the method further includes: In response to the first broadcast message including the first decision result, a child thread of the first process processes the first broadcast message; Alternatively, in response to the first broadcast message including the second decision result, the main thread of the first process processes the first broadcast message.

8. The method according to claim 4, characterized in that The main thread of the first process encapsulates the first broadcast based on the first information to obtain a first broadcast message, including: The main thread of the first process determines whether the first information indicates that the child thread is allowed to process the broadcast; In response to the first information indicating that the child thread is allowed to process the broadcast, the main thread of the first process obtains a first decision result, and encapsulates the first broadcast and the first decision result to obtain the first broadcast message; Alternatively, in response to the first information not indicating that the child thread is allowed to process the broadcast, the main thread of the first process obtains a second decision result, and encapsulates the first broadcast and the second decision result to obtain the first broadcast message.

9. The method according to claim 8, characterized in that After obtaining the first broadcast message, the method further includes: In response to the first broadcast message including the first decision result, a child thread of the first process processes the first broadcast message; Alternatively, in response to the first broadcast message including the second decision result, the main thread of the first process processes the first broadcast message.

10. The method according to claim 2, characterized in that After the AMS sends the first broadcast and the first information to the first process, the method further includes: The main thread of the first process receives the first broadcast and the first information; The main thread of the first process determines whether the first information indicates that the child thread is allowed to process the broadcast; In response to the first information not indicating that the child thread is allowed to process the broadcast, the main thread of the first process encapsulates the first broadcast to obtain a first broadcast message, and puts the first broadcast message into a first message queue, wherein the first message queue is a message queue corresponding to the main thread of the first process; Alternatively, in response to the first information indicating that the child thread is allowed to process the broadcast, the child thread of the first process is started, the main thread of the first process encapsulates the first broadcast, obtains the first broadcast message, and puts the first broadcast message into a second message queue, wherein the second message queue is the message queue corresponding to the child thread of the first process.

11. The method according to any one of claims 1 to 10, characterized in that The AMS determines a target broadcast receiver corresponding to the first broadcast, including: One or more broadcast receivers corresponding to the first broadcast are determined as the target broadcast receivers from the first corresponding relationship.

12. The method according to claim 11, characterized in that Before the AMS receives the first broadcast, the method further includes: Receive a start command; In response to the start instruction, start and parse the package file of the application to obtain the second corresponding relationship and the sub-thread option information corresponding to the application; The second corresponding relationship and the sub-thread option information corresponding to the application are saved.

13. The method according to claim 12, characterized in that Before the AMS receives the first broadcast, the method further includes: receiving an instruction to install the first application; In response to the instruction to install the first application, parsing the package file of the first application, obtaining the correspondence between the broadcast receiver and the broadcast in the first application, and the first information; The second corresponding relationship is updated based on the corresponding relationship between the broadcast receiver and the broadcast in the first application, the first corresponding relationship is obtained, and the first corresponding relationship and the first information are saved.

14. The method according to any one of claims 1 to 10, characterized in that The method further comprises: receiving an instruction to update the first application; In response to the instruction to update the first application, parsing the package file of the first application, obtaining the correspondence between the broadcast receiver and the broadcast in the first application, and the second information; The correspondence between the broadcast receiver and the broadcast in the first application and the second information are saved.

15. The method according to any one of claims 1 to 10, characterized in that The broadcast sender sends the first broadcast to the target broadcast receiver, including: The broadcast sender serially sends the first broadcast to the target broadcast receiver.

16. An electronic device, comprising one or more memories and one or more processors, characterized in that: The memory is used to store a computer program; the processor is used to call the computer program so that the electronic device executes the method described in any one of claims 1-15.

17. A computer storage medium, characterized in that: include: Computer instructions; when the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 15.