Broadcast distribution method and electronic device

CN117992251BActive Publication Date: 2026-08-07HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-01-10
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

具体的,通过AMS确定可替换广播先后分发队列的接收者属性一致性,在具有一致性的情况下替换广播,从而优化了广播消息的分发过程,可以避免存储大量冗余信息,减小存储空间占用,提高AMS性能,减少系统资源的消耗,并解决了安卓系统中由于相同动作的广播可替换而导致的广播堵塞问题

Benefits of technology

[0004] To address the aforementioned technical problems, this application provides a broadcast distribution method and an electronic device. In this method, the electronic device can replace replaceable broadcasts via AMS without causing broadcast congestion. Specifically, AMS determines the consistency of receiver attributes in the sequential distribution queues of replaceable broadcasts, and replaces the broadcast when consistency is achieved. This optimizes the broadcast message distribution process, avoids storing large amounts of redundant information, reduces storage space usage, improves AMS performance, reduces system resource consumption, and solves the broadcast congestion problem caused by replaceable broadcasts of the same action in the Android system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117992251B_ABST
    Figure CN117992251B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a broadcast distribution method and an electronic device. The electronic device can replace the replaceable broadcast through the AMS, and does not cause broadcast jam. Specifically, the receiver attribute consistency of the replaceable broadcast sequence distribution queue is determined through the AMS, the broadcast is replaced in the case of consistency, thereby optimizing the distribution process of the broadcast message, avoiding storage of a large amount of redundant information, reducing the storage space occupation, improving the AMS performance, reducing the consumption of system resources, and solving the broadcast jam problem caused by the replaceable broadcast of the same action in the Android system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of terminal devices, and more particularly to a broadcast distribution method and electronic device. Background Technology

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

[0003] When the state of an electronic device changes, such as when the device is powered on or when its network connection changes, the system or an application can broadcast the change to notify recipients. A single broadcast can correspond to multiple recipients registered with that broadcast. In Android, broadcasts are used in various services and applications, serving as a crucial conduit for maintaining the normal flow of events. However, broadcast congestion can trigger a series of chain reactions. For example, in a power-on scenario, broadcast congestion can lead to system applications and processes not receiving broadcasts, potentially causing serious problems such as Wi-Fi lists not updating, time not updating, and battery level not updating. Summary of the Invention

[0004] To address the aforementioned technical problems, this application provides a broadcast distribution method and an electronic device. In this method, the electronic device can replace replaceable broadcasts via AMS without causing broadcast congestion. Specifically, AMS determines the consistency of receiver attributes in the sequential distribution queues of replaceable broadcasts, and replaces the broadcast when consistency is achieved. This optimizes the broadcast message distribution process, avoids storing large amounts of redundant information, reduces storage space usage, improves AMS performance, reduces system resource consumption, and solves the broadcast congestion problem caused by replaceable broadcasts of the same action in the Android system.

[0005] In a first aspect, embodiments of this application provide a broadcast distribution method applied to an electronic device, comprising: receiving a target broadcast message currently sent by a broadcast publisher via an Activity Manager Service (AMS); determining a first receiver queue matching the target broadcast message via the AMS; determining a second receiver queue matching a candidate broadcast message via the AMS, wherein the candidate broadcast message is a broadcast message to be distributed previously sent by the broadcast publisher, and the candidate broadcast message has the same broadcast action as the target broadcast message; determining, via the AMS, whether there is consistency between the first receiver queue and the second receiver queue based on receiver attributes; and, if there is consistency, replacing the candidate broadcast message with the target broadcast message via the AMS, so as to distribute the target broadcast message to the corresponding broadcast receiver.

[0006] By ensuring the consistency of receiver attributes in the order of replacement broadcast distribution queues through AMS, and replacing broadcasts when consistency is achieved, the broadcast message distribution process is optimized. This avoids storing a large amount of redundant information, reduces storage space usage, improves AMS performance, reduces system resource consumption, and solves the broadcast blocking problem caused by the replacement of broadcasts with the same action in the Android system.

[0007] According to the first aspect, in the case of said consistency: the first receiver queue and the second receiver queue have at least one identical receiver attribute.

[0008] According to the first aspect, or any implementation of the first aspect above, the receiver attributes include the number of receivers, the receiver priority, and the receiver identifier. Determining whether there is consistency based on the receiver attributes through the AMS includes: determining through the AMS whether at least one of the number of receivers, the receiver priority, and the receiver identifier is the same.

[0009] Requiring at least one receiver to have the same attributes (number of receivers, receiver priority, and receiver identifier) ​​ensures that the differences between the two receiver queues are small or non-existent when determining consistency. This allows for replacement operations to avoid broadcast congestion when consistency is achieved.

[0010] According to the first aspect, or any implementation of the first aspect above, the step of determining whether at least one of the receiver quantity, receiver priority, and receiver identifier is the same through the AMS includes: performing the following loop operation: determining whether the i-th attribute among the receiver quantity, receiver priority, and receiver identifier is the same, where i is an integer greater than or equal to 1; if they are not the same, it is determined that there is no consistency, and the loop operation ends; if they are the same, any attribute that has not been judged is taken as the i-th attribute, until the judgment of all receiver attributes is completed.

[0011] By using a loop, the attributes of each receiver queue can be compared one by one to determine whether they are consistent. This loop operation ensures that each attribute is compared and evaluated, thereby determining whether there is consistency between two receiver queues based on the receiver attributes.

[0012] According to the first aspect, or any implementation of the first aspect above, before determining whether the consistency exists through the AMS, the method further includes: determining through the AMS that there are at least two receivers in the first receiver queue; and when there are at least two receivers, determining through the AMS that the at least two receivers have different priorities.

[0013] AMS can pre-emptively determine whether broadcast congestion has occurred, improving the efficiency of consistency checks and avoiding invalid checks. Specifically, with only one receiver, there will be no situation where it waits for other higher-priority receivers to receive the same broadcast from AMS, or waits for a receiver at the front of the queue to receive the broadcast from AMS. Furthermore, when priorities are the same, there will be no situation where a lower-priority receiver waits for a higher-priority receiver; the higher-priority receiver will receive the broadcast from AMS first.

[0014] According to the first aspect, or any implementation of the first aspect above, the first receiver queue indicates a first number of receivers, and the second receiver queue indicates a second number of receivers. Executing the loop operation includes: first determining whether the first number and the second number are the same. Executing the logic for determining the number is relatively fast, which helps improve the efficiency of the determination.

[0015] According to the first aspect, or any implementation of the first aspect above, if the first quantity is the same as the second quantity, the execution of the loop operation further includes: taking the receiver priority as the i-th attribute; wherein, the first priority array indicates the priority of each receiver in the first receiver queue, the second priority array indicates the priority of each receiver in the second receiver queue, and determining whether the i-th attribute is the same further includes: determining whether the first priority array and the second priority array are the same.

[0016] If they are different, it is determined that there is no consistency, which can avoid unnecessary judgments when the priority arrays are inconsistent and improve the judgment efficiency.

[0017] According to the first aspect, or any implementation of the first aspect above, the first priority array is a first water level array, and the second priority array is a second water level array, wherein the water level element value in each water level array represents the priority of the corresponding receiver.

[0018] According to the first aspect, or any implementation of the first aspect above, if the first priority array and the second priority array are the same, the execution of the loop operation further includes: taking the receiver identifier as the i-th attribute; determining whether the i-th attribute is the same further includes: for the identifier of each receiver in the first receiver queue, determining whether there is a matching identifier in the second receiver queue.

[0019] Consistency can be determined by comparing the first quantity, the second quantity, the receiver priority array, and the receiver identifier. Performing consistency checks on multiple receiver attributes between two receiver queues helps improve efficiency, saves time and resources, and enhances the accuracy and reliability of the consistency results.

[0020] Secondly, embodiments of this application provide an electronic device. The electronic device includes a memory and a processor, the memory and processor being coupled together. The memory stores program instructions, which, when executed by the processor, cause the electronic device to perform the methods of the first aspect or any possible implementation thereof.

[0021] Thirdly, embodiments of this application provide a computer-readable medium for storing a computer program, the computer program including instructions for performing the method in the first aspect or any possible implementation of the first aspect.

[0022] Fourthly, embodiments of this application provide a computer program including instructions for performing the method in the first aspect or any possible implementation thereof.

[0023] Fifthly, embodiments of this application provide a chip including a processing circuit and transceiver pins. The transceiver pins and the processing circuit communicate with each other via an internal connection path. The processing circuit executes the method in the first aspect or any possible implementation of the first aspect to control the receiving pin to receive signals and to control the transmitting pin to transmit signals. Attached Figure Description

[0024] Figure 1A schematic diagram illustrating a broadcast registration and distribution process provided in an embodiment of this application;

[0025] Figure 2 A schematic diagram illustrating yet another broadcast distribution process provided in an embodiment of this application;

[0026] Figure 3 A schematic diagram illustrating a specific stage in a broadcast distribution process provided in an embodiment of this application;

[0027] Figures 4a-4c These are illustrations of the display interface of an electronic device when broadcast congestion occurs, provided in the embodiments of this application.

[0028] Figures 5a-5c This is a schematic diagram illustrating a broadcast jam as provided in an embodiment of this application;

[0029] Figure 6 A flowchart illustrating a broadcast distribution processing method provided in this application embodiment;

[0030] Figure 7 A flowchart of the loop judgment provided in the embodiments of this application;

[0031] Figure 8 A flowchart of the preliminary judgment provided for embodiments of this application;

[0032] Figure 9 A flowchart for consistency determination provided in the embodiments of this application;

[0033] Figure 10 This is a schematic diagram of the structure of an electronic device as an example.

[0034] Figure 11 This is a schematic diagram of the software structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0035] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0036] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.

[0037] The terms "first" and "second," etc., used in the specification and claims of this application are used to distinguish different objects, not to describe a specific order of objects. For example, "first target object" and "second target object," etc., are used to distinguish different target objects, not to describe a specific order of target objects.

[0038] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0039] In the description of the embodiments in this application, unless otherwise stated, "multiple" means two or more. For example, multiple processing units means two or more processing units. Multiple systems means two or more systems.

[0040] First, some of the terms and related technologies used in this application will be explained to facilitate understanding by those skilled in the art.

[0041] Broadcast: The broadcast mechanism involves broadcast publishers, broadcast receivers (also known as broadcast recipients), and AMS.

[0042] Registration: In the Android system, broadcast publishers send broadcast messages, and broadcast receivers register as broadcast receivers and define the broadcast messages they are interested in, thereby enabling them to receive the corresponding broadcast messages.

[0043] Priority: For example, ordered broadcast corresponds to the serial sending method. When broadcast receivers receive broadcasts, there is a priority issue. Broadcasts are sent according to priority. Broadcast receivers with higher priority will receive the broadcast first, and subsequent applications or modules with lower priority will receive the broadcast later.

[0044] Receiver queue: The same broadcast has multiple broadcast receivers, which are stored in the receiver queue. AMS can distribute the same broadcast to each broadcast receiver in the receiver queue according to priority. Each distribution is an inter-process communication (e.g., binder communication).

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

[0046] Figure 1 This is a schematic diagram of a broadcast registration and distribution process provided in an embodiment of this application.

[0047] like Figure 1 As shown, broadcast receivers can register in AMS (i.e., broadcast registration). Broadcast publishers can send broadcasts to AMS. AMS can find the corresponding broadcast receiver for a broadcast based on the relevant information of the registered broadcast receivers and transmit the broadcast to the corresponding broadcast queue (i.e., broadcast enqueueing) for AMS processing. It can be understood that a broadcast can correspond to multiple broadcast receivers. During processing, AMS can send the broadcast to its corresponding broadcast receivers sequentially, thus achieving broadcast distribution. Generally, the registration of broadcast receivers in AMS, the sending of broadcasts by broadcast publishers 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 inter-process communication (IPC) mechanism; its specific meaning can be found in relevant technical documents and will not be elaborated upon here.

[0048] Figure 2 This is a schematic diagram of another broadcast distribution process provided in an embodiment of this application.

[0049] like Figure 2 As shown, broadcast receivers A, B, and C can register with AMS. For example, AMS can retrieve the registration instructions for broadcast receivers, which are issued by the broadcast receivers themselves. Typically, broadcast receivers register (subscribe) to the broadcast messages they want to receive with AMS via inter-process communication mechanisms. Specifically, for example, the service process of a broadcast receiver registers with AMS as a broadcast receiver by calling the `registerReceiver` function, and simultaneously defines the broadcast messages it is interested in. When AMS sends broadcast messages in the broadcast sending queue, it sends the broadcast message to the corresponding broadcast receiver based on the broadcast receiver's registration status. After receiving the broadcast message, the broadcast receiver calls back the receiving method (such as the `onReceive` method) in the registered broadcast receiver to execute the corresponding functions to process the received broadcast message.

[0050] Different receivers of the same broadcast can have different priorities. For example, receiver A (0) indicates a priority of 0 for receiving broadcast A, receiver A (1000) indicates a priority of 1000 for receiving broadcast A, receiver B (0) indicates a priority of 0 for receiving broadcast B, receiver B (1000) indicates a priority of 1000 for receiving broadcast B, and receiver C (0) indicates a priority of 0 for receiving broadcast C. Corresponding broadcast events can trigger the broadcast publisher to send a broadcast to AMS. For example, broadcast event A triggers the broadcast publisher to send broadcast A to AMS, broadcast event B triggers the broadcast publisher to send broadcast B to AMS, and broadcast event C triggers the broadcast publisher to send broadcast C to AMS.

[0051] In the Android system, broadcast messages sent by the publisher can be pre-stored in AMS (Advanced Management System). AMS then notifies the listeners (receivers) to handle the broadcast message. Within AMS, broadcast messages can be stored in a broadcast queue. After receiving a broadcast, AMS can locate the corresponding broadcast receiver based on the registered receiver's information, and obtain the desired result. Figure 2 The receiver queue is shown, and the broadcast is placed into the broadcast queue, waiting for AMS to distribute it to the corresponding receivers according to priority. For example... Figure 2 The receiver queue shown may include A broadcast receiver (0), A broadcast receiver (1000), B broadcast receiver (0), B broadcast receiver (1000) and C broadcast receiver (0).

[0052] like Figure 2 The receiver queues are shown. When AMS sends a broadcast A, it first distributes it to the broadcast A receiver (1000) in process Process2, and then to the broadcast A receiver (1000) in process Process1. When AMS sends a broadcast B, it first distributes it to the broadcast B receiver (1000) in process Process1, and then to the broadcast B receiver (0) in process Process2. When AMS sends a broadcast A, it directly distributes it to the broadcast C receiver (0) in process Process2. For each process, the process registers one or more receivers with AMS. The broadcasts received by each receiver can be different and have different priorities. For example, in process Process1, broadcast A is distributed to broadcast A receiver (0) first, and then broadcast B is distributed to broadcast B receiver (1000). For example, in process Process2, broadcast A is distributed to broadcast A receiver (1000) first, then broadcast B is distributed to broadcast B receiver (0), and finally broadcast C is distributed to broadcast C receiver (0).

[0053] It's understandable that Process1 and Process2 can belong to the same or different applications. An application is stored as a static file in the computer system's hard drive or other storage space. A process refers to a running instance of an application. A process is a system resource management entity maintained by the operating system under dynamic conditions. In other words, an application is a lifeless entity; it only becomes an active entity, called a process, when the processor executes it. Each process has its own independent address space, memory, and data stack, and communication between different processes can be achieved through IPC mechanisms.

[0054] Figure 3 This is a schematic diagram illustrating a specific stage in a broadcast distribution process provided in an embodiment of this application.

[0055] like Figure 3 As shown, the entire broadcast process can be divided into two phases. The first phase is the broadcast enqueue phase, and the second phase is the broadcast distribution phase. The broadcast enqueue phase refers to the process where the broadcast publisher sends the broadcast to the AMS, and the AMS allocates the broadcast to the corresponding broadcast queue based on broadcast information (e.g., broadcast attributes) and relevant information about the broadcast publisher (e.g., information about the process the broadcast publisher belongs to), and the broadcast queues wait to be distributed. The broadcast distribution phase refers to the AMS distributing the broadcast to each broadcast receiver corresponding to that broadcast, until the AMS receives the notification message sent to the AMS by the last broadcast receiver that processed the broadcast.

[0056] It is understandable that the broadcast distribution phase includes the dispatch phase for each broadcast receiver corresponding to the broadcast. For each broadcast receiver, the dispatch phase can include a waiting phase and a processing phase. The waiting phase refers to the phase after AMS sends the broadcast to the broadcast receiver and waits for the receiver to process it. The waiting phase can include a queuing phase. The queuing phase refers to the phase where the broadcast, after being encapsulated into a broadcast message, is queued in the broadcast receiver's message queue. The processing phase refers to the phase where the broadcast receiver processes the broadcast messages in the message queue. It is understandable that the broadcast receiver's dispatch duration (i.e., the duration of the dispatch phase) can include the waiting duration (i.e., the duration of the waiting phase) and the processing duration (i.e., the duration of the processing phase). The waiting duration can include the queuing duration (i.e., the duration of the queuing phase).

[0057] Reference Figures 1-3This document provides a detailed introduction to the modern broadcast mechanism of the Android system (e.g., version U). In Android, various applications generate a wide variety of broadcast messages during operation. For example, an application monitoring battery status within an electronic device will broadcast messages during battery usage, and the SMS module will also generate a broadcast message upon receiving a message. Application developers can also listen for broadcast messages emitted during application operation and perform program logic operations based on these messages. In this broadcast information transmission mechanism, broadcast messages may be received by one or more applications, or they may not be received by any application.

[0058] Broadcasting can be understood as a publish-subscribe pattern, where the sender (broadcast publisher) sends a broadcast (Intent), and the receiver (broadcast receiver) registers to be interested in a specific broadcast and receives the corresponding broadcast. The broadcast action is an attribute used to identify a broadcast. The broadcast action is a string describing the purpose or operation of the broadcast. It is usually prefixed with the application's package name to ensure uniqueness.

[0059] When a broadcaster sends a broadcast, it may send multiple broadcasts with the same broadcast action, such as sending multiple broadcasts of type A with the same broadcast action. Specifically, for example, an application monitoring battery usage might send multiple broadcasts with the same broadcast action during battery usage. Similarly, an application monitoring network status might send multiple broadcasts with the same broadcast action when the network signal is unstable or network switching is frequent. Sending multiple broadcasts with the same broadcast action can lead to a large amount of redundant information being stored in the broadcast queue of AMS, consuming significant storage space and resources, reducing AMS performance, and potentially causing receivers to process too many broadcasts, thus impacting performance and resource consumption.

[0060] Based on the above situation, in such Figure 3As shown in the broadcast enqueue phase, multiple broadcasts with the same broadcast action can be merged (hereinafter referred to as replaceable broadcasts) and then assigned to the corresponding broadcast queues. During the broadcast merging and distribution process, broadcast congestion may occur, such as congestion caused by a deadlock between two or more broadcasts waiting for each other. These broadcasts are ordered broadcasts, or ordinary broadcasts with multiple receivers set with different priorities, where at least one broadcast is a replaceable broadcast. Specifically, the native modern broadcast mechanism in Google U versions may cause broadcast congestion problems. For example, in Google U6, a broadcast may have multiple receivers registered in the same application, with multiple receivers involving two or more priorities. Lower-priority receivers need to wait for higher-priority receivers to receive the broadcast first. When merging broadcast messages with the same broadcast action, the priority order in the broadcast message queue may be reversed. Combined with the modern broadcast mechanism where later enqueued broadcast messages in the broadcast message queue need to wait for earlier enqueued broadcast messages to be distributed, this may lead to broadcast congestion problems. Broadcast congestion affects the normal transmission of broadcast messages, causing subscribers to be unable to receive them. This can lead to a series of serious problems such as WiFi lists not updating, time not updating, and battery levels not updating, impacting the user experience.

[0061] Figures 4a-4c These are diagrams showing the display interface of an electronic device when broadcast congestion occurs, as provided in the embodiments of this application.

[0062] For example, in a boot-up scenario, broadcast congestion can prevent system applications and processes from receiving broadcasts, potentially leading to serious issues such as Wi-Fi lists not updating, time not updating, and battery level not updating. For instance, a component in the system might monitor network connection status and send broadcasts to other components when the network connection status changes, allowing them to update the network connection status. If broadcast congestion affects the network status of applications, such as… Figure 4a The electronic device's display showed a network status error message (101). For example, a clock application displays the current system time, and one component listens for broadcasts of time changes and updates the clock display upon receiving such broadcasts. If broadcast congestion occurs, the clock application may fail to update the system time in a timely manner. Figure 4b The time displayed on the electronic device's screen is always 00:00. For example, in a battery monitoring application that displays the current battery level, one component listens for broadcasts of battery level changes and updates the battery level display upon receiving such broadcasts. If broadcast congestion occurs, the battery level display may not be updated in a timely manner. Figure 4c The battery level displayed on the electronic device's screen is 103, indicating an abnormal state.

[0063] The following is through Figures 5a-5c To further explain the reasons for the aforementioned broadcast congestion.

[0064] Figures 5a-5c This is a schematic diagram illustrating a broadcast jam as provided in an embodiment of this application.

[0065] According to the modern broadcast mechanism of Android U version, each process will have its own process broadcast queue in AMS. For example Figure 5a As shown, BroadcastProcessQueue1, BroadcastProcessQueue2, and BroadcastProcessQueue3 represent the process broadcast queues of processes Process1, Process2, and Process3, respectively, forming a... Figure 2 The broadcast queue in AMS is shown. For example, when AMS receives broadcast A, it can match broadcast receiver (0) and broadcast receiver (1000). Among them, the process to which broadcast receiver (0) belongs is process1, and the process to which broadcast receiver (1000) belongs is process2.

[0066] The arrows in the diagram represent waiting relationships. The sequence B (1000) -> A (0) means that broadcast receiver B is waiting for broadcast receiver A to receive a broadcast. (0) indicates that the corresponding receiver's priority is 0, and (1000) indicates that the corresponding receiver's priority is 1000. This can be understood as... Figure 5a The number of receivers, threads, and priorities shown are for illustrative purposes only.

[0067] Because during broadcast distribution, lower-priority receivers wait for higher-priority receivers to distribute their broadcasts first, and other broadcasts in the same queue wait for the broadcast at the head of the queue to distribute their broadcasts first. Combined with... Figure 5a The various broadcast receivers and arrows in the diagram have the following relationship:

[0068] In queue BroadcastProcessQueue1, B(1000) is waiting for A(0) at the head of the queue.

[0069] A(0) at the head of queue BroadcastProcessQueue1 is waiting for A(1000) in BroadcastProcessQueue2 due to broadcast priority.

[0070] A(1000) in queue BroadcastProcessQueue2 is waiting for B(0) at the head of the queue due to the queue rules.

[0071] B(0) at the head of queue BroadcastProcessQueue2 is waiting for B(1000) in BroadcastProcessQueue1 due to broadcast priority.

[0072] This creates a circular wait, leading to the blocking of BroadcastProcessQueue1 and BroadcastProcessQueue2 queues, which is the "deadlock" mentioned above.

[0073] Furthermore, in BroadcastProcessQueue1, C(1000) is waiting for B(1000) ahead of it. In BroadcastProcessQueue3, C(0) is waiting for the higher-priority C(1000), causing C's broadcast to be blocked. In BroadcastProcessQueue3, D(1000), E(1000), F(1000), and C(1000) ahead of it are also waiting. Similarly, this could cause the entire system's broadcast queue to be blocked, preventing broadcasts from being distributed.

[0074] by Figure 5a Taking queues A(0) and B(1000) in BroadcastProcessQueue1 and queues A(1000) and B(0) in BroadcastProcessQueue2 as examples, further... Figure 5b and Figure 5c Explain the cause of the deadlock.

[0075] like Figure 5b As shown, initially, process Process1 has registered receivers for broadcasts A and B. The priority of broadcast A receiver in process Process1 is 0, and the priority of broadcast B receiver is 1000. A is a replaceable broadcast. Process Process2 has no receiver for broadcast A, but one receiver for broadcast B with a priority of 0. Sending broadcast A first, followed by broadcast B, will result in the following... Figure 5b The status of each process's broadcast queue. A1 broadcast represents the A broadcast sent first, and A2 broadcast represents the A broadcast sent later. A1 and A2 have the same broadcast action.

[0076] like Figure 5b and Figure 5c As shown, process2 then registers another broadcast receiver A with a priority of 1000. The broadcast receiver A in process2 is added to the tail of the queue normally. If another broadcast A2 is sent, according to the original logic, the new broadcast A2 in process1 will replace the old broadcast A1. Finally, Figure 5c The state is thus formed Figure 5aThe state shown is as follows. Broadcast A and broadcast B form a deadlock, causing the broadcast queues of processes Process1 and Process2 to become blocked, which in turn causes the broadcast queues of more processes to become blocked.

[0077] To address the above issues, this application provides a broadcast distribution method. According to this method, electronic devices can replace replaceable broadcasts via AMS without causing broadcast congestion. Specifically, AMS determines the consistency of receiver attributes in the sequential distribution queues of replaceable broadcasts, and replaces broadcasts when consistency is achieved. This optimizes the broadcast message distribution process, avoids storing large amounts of redundant information, reduces storage space usage, improves AMS performance, reduces system resource consumption, and solves the broadcast congestion problem caused by replaceable broadcasts of the same action in the Android system.

[0078] The following describes a broadcast distribution processing method provided by an embodiment of this application.

[0079] Figure 6 This is a flowchart of a broadcast distribution processing method provided in an embodiment of this application.

[0080] In operation S601, the broadcast publisher sends a target broadcast message to the Activity Manager service (AMS).

[0081] It is understood that the broadcaster can be the operating system in an electronic device, or it can be an application, component, etc., and this application does not impose any restrictions on this. For example, a broadcast can be a screen on / off signal, a network status switch, a telephone broadcast, etc. The broadcaster is the system or application that sends the broadcast, and the broadcast receiver is a system or application that has registered for broadcasting, used to receive the broadcast and process related business. Applications can include software, programs, components, etc.

[0082] In operation S602, the target broadcast message currently sent by the broadcast publisher is received through the Activity Manager Service (AMS).

[0083] For example, when a broadcast publisher sends a broadcast, it can call a broadcast sending function, such as the `sendBroadcast` function, to send the broadcast to the ActivityManagerService. Upon receiving the broadcast, AMS can add it to the broadcast queue as a pending broadcast. In other words, broadcasts in the broadcast queue are broadcasts awaiting transmission by AMS to eligible receivers via inter-process communication mechanisms. The target broadcast message can be any broadcast to be sent to a receiver.

[0084] In operation S603, the first receiver queue that matches the target broadcast message is determined through AMS.

[0085] For example, in broadcast message transmission, applications (which can also be processes) that need to listen for or process broadcast messages need to register a broadcast receiver with AMS in advance. Specifically, a process can statically register a broadcast receiver with AMS in the manifest file included in the Android application. AMS stores all broadcast receivers in a member variable. AMS first queries the member variable to find all receivers corresponding to the broadcast message, and then generates a broadcast record. Further, AMS puts the broadcast message into the corresponding broadcast queue based on the contact attribute information of the receiver of the broadcast message in the broadcast record.

[0086] When a broadcast receiver registers for a broadcast, the mapping between its receiver and the registered broadcasts is recorded in the manifest file (e.g., the AndroidManifest.xml file). When an electronic device boots up, or when an application is installed or updated, the manifest files of several applications can be scanned to obtain the mapping between broadcast receivers and broadcasts within those applications.

[0087] In some embodiments of this application, the electronic device can store the mapping relationship in the AMS. In this case, after receiving a broadcast from a broadcast publisher, the AMS can directly determine the broadcast receiver corresponding to the broadcast based on the stored mapping relationship and send the broadcast to that receiver. It is understood that the mapping relationship can also be stored in other modules. In this case, the AMS can obtain the mapping relationship based on a corresponding interface or a specific storage address.

[0088] Based on the aforementioned correspondence, for example, after receiving a target broadcast message, AMS can scan the manifest files of several applications based on the target broadcast message's attribute information (such as broadcast identifier, action information, etc.) to obtain the correspondence between broadcast receivers in those applications and the target broadcast message, thereby determining the first receiver queue. Therefore, based on the target broadcast message, AMS is used to determine the first matching receiver queue, thus identifying which receivers should receive the broadcast message.

[0089] In operation S604, the second receiver queue matching the candidate broadcast message is determined by AMS, wherein the candidate broadcast message is a broadcast message to be distributed that was previously sent by the broadcast publisher, and the candidate broadcast message has the same broadcast action as the target broadcast message.

[0090] For example, when a broadcast message sent by a broadcaster is received by AMS, the broadcast message will be distributed to the corresponding broadcast receiver by AMS because the broadcast receiver has registered a corresponding broadcast receiver to receive the broadcast message. Therefore, AMS can match the second receiver queue. For instance, taking a mobile phone in an electronic device as an example, candidate broadcast messages may include screen-on broadcasts, screen-off broadcasts, unlock broadcasts, network status change broadcasts, Bluetooth status change broadcasts, phone status change broadcasts, language switch broadcasts, and theme switch broadcasts, etc. The target broadcast message and the candidate broadcast messages have the same broadcast action, that is, the same attributes used to identify the broadcast. Specifically, they may have the same string describing the purpose or operation of the broadcast.

[0091] In operation S605, AMS determines whether there is consistency between the first receiver queue and the second receiver queue based on receiver attributes.

[0092] After AMS stores a broadcast message in a specific broadcast queue, the scheduling priority of that broadcast message is determined by the priority of the broadcast message receiver corresponding to the broadcast queue where the message is stored. If the broadcast message is an ordered broadcast message, it must be queued and distributed according to its chronological order after being stored in the broadcast queue; that is, the broadcast message must wait for other broadcast messages ahead in the queue to be distributed and processed before it can be scheduled. Furthermore, if the broadcast receivers have different priorities, the broadcast message must be distributed according to the priority of each receiver after being stored in the broadcast queue.

[0093] For example, receiver attributes refer to certain characteristics or properties of broadcast receivers, used to determine whether there are identical receivers when multiple broadcast messages have the same action. These attributes may include receiver type, process, application, corresponding operation after the receiver receives the message (such as update time), number of receivers, receiver priority, or receiver identifier, etc. By comparing receiver attributes, it can be determined whether the first receiver queue and the second receiver queue are consistent.

[0094] For example, in the broadcast distribution of a mobile application, recipient attributes can include the application type (e.g., social media app, game app, news app, etc.), the application version (e.g., free version, paid version), and user settings (e.g., location settings, etc.). When a broadcast publisher sends a broadcast message, AMS matches the recipient attributes of the two recipient queues to determine if they are consistent.

[0095] It's understandable that comparing the receiver attributes of the first and second receiver queues determines whether a replacement operation is needed. This is to ensure that a replacement operation is only performed when the receiver attributes are consistent. The receiver attributes act as a judgment and filter, ensuring that broadcast message replacement only occurs when consistency conditions are met.

[0096] When operating S606, under the condition of consistency, the candidate broadcast message is replaced by the target broadcast message through AMS.

[0097] When operating S607, the target broadcast message is distributed to the corresponding broadcast receiver via AMS.

[0098] For example, in a smartphone application, a broadcast distribution method is used to send notification messages to multiple applications, such as a boot message broadcast notification to the SMS app, battery management app, time updater, and network management app. The broadcast publisher can be a system application, while the target broadcast message is the currently sent boot message broadcast. A first receiver queue stores the receivers registered by the applications or processes matching the target broadcast message, while candidate broadcast messages are the last sent boot message broadcasts that have the same notification action as the target broadcast message. Consistency refers to the fact that the first receiver queue and the second receiver queue have the same or similar receiver attributes.

[0099] The AMS can determine the process of the target broadcast receiver (i.e., the process to which the target broadcast receiver belongs) based on the correspondence between the broadcast receiver and its process. It is understood that a correspondence exists between processes and applications. After determining the process of the target broadcast receiver, the AMS can determine the application corresponding to that process; this application is the application to which the target broadcast receiver belongs. In some embodiments of this application, the AMS can also directly determine the application to which the target broadcast receiver belongs (i.e., the application to which the target broadcast receiver belongs) based on the correspondence between the broadcast receiver and its application. This determines the receiver attribute.

[0100] Understandably, when AMS distributes boot message notifications to applications such as SMS, battery management, time updates, and network management, it can send the message serially to the broadcast receivers within each application. For example, AMS might distribute the boot message broadcast to a receiver in the battery management application, and after receiving a completion message from that receiver, it then distributes the boot message broadcast to the time update application. In other words, AMS sends the boot message broadcast to higher-priority broadcast receivers and only prepares to send it to lower-priority broadcast receivers after receiving a completion message. Similarly, AMS sends the boot message broadcast to the broadcast receivers at the top of the broadcast queue and only prepares to send it to the broadcast receivers at the bottom of the queue after receiving a completion message.

[0101] In some embodiments of this application, the aforementioned priorities can be determined based on the number of times the SMS program, battery management program, time update program, and network management program are run. For example, the ranking results can be obtained from largest to smallest based on the number of times the SMS program, battery management program, time update program, and network management program are run, and then broadcast receivers in applications with different ranking ranges can be determined as different priorities based on the ranking results.

[0102] In other embodiments of this application, the aforementioned priorities can also be determined by the importance levels of the SMS application, battery management application, time update application, and network management application. For example, when memory is insufficient, memory is released sequentially according to importance level, which can reflect the importance of the application to some extent. Therefore, the receiving priority of broadcast receivers in each application can be determined based on this.

[0103] In some other embodiments of this application, the aforementioned priority can also be determined based on the process type of the broadcast receiver. For example, determining the respective broadcast receivers in the SMS program, battery management program, time update program, and network management program, determining the process to which the broadcast receiver belongs, and determining the process type as an interactive process, batch processing process, monitoring process, etc. Priority is determined based on the importance level of the processes.

[0104] According to embodiments of this application, electronic devices can replace replaceable broadcasts via AMS without causing broadcast congestion. Specifically, AMS determines the consistency of receiver attributes in the sequential distribution queues of replaceable broadcasts, and replaces the broadcast when consistency is achieved. This optimizes the broadcast message distribution process, avoids storing large amounts of redundant information, reduces storage space usage, improves AMS performance, reduces system resource consumption, and solves the broadcast congestion problem caused by replaceable broadcasts of the same action in the Android system.

[0105] In some embodiments of this application, where consistency is required: the first receiver queue and the second receiver queue have at least one identical receiver attribute.

[0106] In determining consistency, at least one attribute must be shared between two receiver queues. For example, suppose a notification message is sent to various mobile applications when the network status is updated. When a broadcaster sends a broadcast message indicating a WiFi connection failure, AMS matches the first receiver queue based on the WiFi connection failure attribute and the attributes of the receivers registered for that broadcast. Then, it matches the second receiver queue based on the previous broadcast message with the same action. For instance, if each receiver registered in AMS has a unique hash value, and the hash values ​​in the first and second receiver queues correspond one-to-one (i.e., the same hash value exists in both queues), then they are considered to have the same receiver attribute, meeting the consistency requirement.

[0107] In some embodiments of this application, for example, recipients registered in AMS have unique names, and differences are allowed for the same recipient attributes, without requiring complete consistency. For instance, it can be stipulated that recipients in the first recipient queue and recipients in the second recipient queue have similar names. Similarity can be due to having the same keywords or semantic similarity; for example, the presence of synonyms such as "monitoring," "monitoring," "surveying," or "observation" in the name indicates potential semantic similarity. This better accommodates different variations and differences while maintaining a certain level of consistency.

[0108] In some embodiments of this application, when multiple receiver attributes exist, the importance of each attribute can be used to determine whether it should be included in the consistency judgment logic. That is, the commonality of a certain receiver attribute is more important than other attributes. This allows the consistency judgment logic to be determined based on importance, and the logic can be dynamically adjusted when receiver attributes change, making it more flexible and adaptable to changes. For example, some receiver attributes may change with time, environment, or other factors. Therefore, it allows for the consideration of changes in receiver attributes during consistency judgment.

[0109] In some embodiments of this application, the receiver attributes include the number of receivers, the receiver priority, and the receiver identifier. Determining whether there is consistency based on receiver attributes through AMS includes: determining whether at least one of the number of receivers, the receiver priority, and the receiver identifier is the same through AMS.

[0110] For example, a broadcast message indicating a WiFi connection failure is designated as the target broadcast message and is distributed by AMS to multiple receivers. Receiver attributes include the number of receivers, receiver priority, and receiver identifier. When the broadcaster sends the WiFi connection failure broadcast message, AMS matches the first receiver queue based on the WiFi connection failure attributes and the attributes of the receivers who registered the broadcast. Then, it matches the second receiver queue based on previous broadcast messages with the same action. To determine consistency, AMS compares the number of receivers, receiver priority, and receiver identifier in the first and second receiver queues to determine if at least one attribute is the same.

[0111] For example, suppose the first receiver queue has 3 receivers, identified as A, B, and C. The second receiver queue has 4 receivers, identified as D, E, F, and G. In this case, the number of receivers and their identifiers are not identical, thus failing the consistency judgment logic based on receiver attributes.

[0112] According to embodiments of this application, requiring at least one receiver attribute (number of receivers, receiver priority, and receiver identifier) ​​to be the same can ensure that when judging consistency, the difference between the two receiver queues is small or non-existent, so that the replacement operation can avoid broadcast congestion when there is consistency.

[0113] Figure 7 A flowchart for the loop judgment provided in the embodiments of this application.

[0114] like Figure 7 As shown, AMS can include a judgment module, an update module, and a result module. The judgment module is used to determine the object to be judged, execute conditional statements, and output the judgment result. The judgment module is communicatively connected to the update module and the result module, and can output judgment results or send call instructions to the update module and the result module. The update module is used to update the object to be judged, and can output update results or send call instructions to the judgment module. The result module is used to receive the judgment result from the judgment module and output whether consistency is achieved.

[0115] The following loop operation is executed during the judgment process:

[0116] In operation S701, the judgment module determines the i-th attribute to be judged from the receiver quantity, receiver priority, and receiver identifier, where i is an integer greater than or equal to 1. This determines whether the receiver attribute to be compared is the quantity, priority, or identifier.

[0117] In operation S702, the decision module determines whether the i-th attribute among the number of receivers, receiver priority, and receiver identifier is the same. That is, it compares whether the i-th attribute of the two receiver queues is the same to determine whether they are consistent.

[0118] In operation S703, if not, the judgment module sends the judgment result to the result module. The result module determines that there is no consistency between the two receiver queues and ends the loop operation. That is, when the judgment result is inconsistent, the loop operation ends immediately and no further attribute comparisons are performed.

[0119] If the condition is met during operation S704, the judgment module continues to determine whether all receiver attributes have been completely evaluated. That is, if the judgment result is consistent, subsequent attribute comparisons are performed to determine whether all attributes are consistent.

[0120] In operation S705, the update module takes any unjudged attribute as the i-th attribute and sends it to the judgment module, which then returns to execute operation S701. That is, after determining that an attribute is consistent, the comparison of the next attribute continues until all attributes have been compared.

[0121] In operation S706, if the judgment result of the judgment module indicates that the attributes of each receiver are the same, the result module determines that there is consistency between the two receiver queues and ends the loop operation.

[0122] It's understandable that a loop operation can compare the attributes of each receiver queue to determine if they are consistent. This loop operation ensures that each attribute is compared and evaluated, thereby determining whether there is consistency between two receiver queues based on the receiver attributes.

[0123] For example, suppose there's a music player app. In this app, users can choose to play their own music files, and music can play in the background. The user opens the music player app and selects the music file to play. The music player app creates a background process that reads the music data from the file system and decodes it into an audio signal. The playback process then sends the decoded audio signal to the audio output device so the user can hear the music. The user can perform actions on the app interface, such as pausing, resuming, and adjusting the volume. If the user opens another app, such as an alarm clock app, and sets an alarm time, the alarm clock app will trigger an alarm event when the alarm time arrives. The music player app creates a background receiving process that registers a receiver with AMS (Application Management System) to receive system broadcasts, such as alarm broadcasts.

[0124] When the alarm time arrives, the system sends a broadcast notification to all applications registered for the corresponding event. The music player application, as a recipient, can receive this broadcast notification and trigger corresponding actions on its interface, such as playing a music file as the alarm sound. The receiving process is responsible for relaying the alarm broadcast, for example, to the music player application's playback process. The music player application's playback process will respond to the alarm broadcast, pause the currently playing music according to the instructions, and then play the alarm sound.

[0125] As can be seen, the playback process in the music player application is responsible for playing music, while the receiver within it is responsible for receiving alarm clock broadcasts and notifying the music player application to perform corresponding actions. The process broadcast queue of the receiving process can include multiple receivers; the receiver responsible for receiving alarm clock broadcasts might be, for example,... Figure 5a As shown, it is placed at the back of the process broadcast queue and has a lower priority than other receivers that are also receiving alarm broadcasts. To avoid broadcast congestion when multiple alarm broadcasts with the same action are sent, it is possible to check if the number of matching receivers, receiver priorities, or receiver identifiers are consistent. For example, whether the receiver in the receiving process still exists, whether its priority has changed, or whether its identifier is consistent. The specific judgment process is as follows: Figure 7 The loop operations shown will not be elaborated further here.

[0126] Figure 8 A flowchart for the preliminary judgment provided in the embodiments of this application.

[0127] like Figure 8 As shown, this embodiment includes the following steps before determining whether consistency is achieved via AMS:

[0128] In operation S801, the AMS determines that there are at least two receivers in the first receiver queue. That is, the AMS checks the first receiver queue to confirm that there are at least two receivers in the queue.

[0129] In operation S802, when there are at least two receivers, the AMS determines that at least two receivers have different priorities. That is, when there are multiple receivers, the AMS further checks the receivers in the first receiver queue and determines whether their priorities are different.

[0130] For example, suppose there's a notification management application in an Android system. When a new notification arrives, this application is responsible for sending it to the appropriate recipient application. The first recipient queue can refer to all applications registered to receive notifications. AMS checks the first recipient queue and confirms that at least two recipients (such as two applications or different processes within the same application) have registered for notification reception. Next, AMS further checks these applications and determines whether their notification receiving priorities are different. For example, a recipient in application A might have a high priority, while a recipient in application B might have a low priority. AMS can perform a pre-emptive check to prevent broadcast congestion, improving the efficiency of consistency checks and avoiding invalid checks. Specifically, with only one recipient, there won't be a situation where the recipient waits for other high-priority recipients to receive the same broadcast from AMS, or waits for a recipient at the front of the queue to receive the broadcast from AMS. And when priorities are the same, there won't be a low-priority recipient waiting for a high-priority recipient; the high-priority recipient will receive the broadcast from AMS first.

[0131] Figure 9 A flowchart for consistency judgment provided in the embodiments of this application.

[0132] like Figure 9 As shown, determining the number of recipients, recipient priority, and recipient identifier includes:

[0133] In operation S901, the judgment module first checks the first quantity and the second quantity. The first receiver queue indicates the receivers with the first quantity, and the second receiver queue indicates the receivers with the second quantity. Executing the logic for judging the quantity is relatively fast, which helps improve judgment efficiency.

[0134] The first quantity refers to the number of receivers in the first receiver queue. For example, a first quantity of 3 means there are 3 receivers in the first receiver queue, and a first receiver queue of [A,B,C] means there are receivers A, B, and C in the first receiver queue. The second quantity refers to the number of receivers in the second receiver queue. For example, a second quantity of 4 means there are 4 receivers in the second receiver queue, and a second receiver queue of [X,Y,Z,W] means there are receivers X, Y, Z, and W in the second receiver queue.

[0135] In operation S902, the determination module obtains a result indicating whether the first quantity and the second quantity are the same. If not, it sends the result to the result module, which determines that there is no consistency, thus avoiding unnecessary judgments when the quantities are inconsistent. If yes, the judgment continues.

[0136] In operation S903, if the first quantity and the second quantity are the same, the judgment module calls the update module. The update module sends the receiver priority as the i-th attribute to the judgment module. The judgment module judges the first priority array and the second priority array, where the first priority array indicates the priority of each receiver in the first receiver queue, and the second priority array indicates the priority of each receiver in the second receiver queue.

[0137] Receiver priority refers to the priority order of receivers, that is, the order in which broadcast messages are received. For example, if receiver A has a priority of 1, receiver B has a priority of 2, and receiver C has a priority of 3 in the first receiver queue, then the first priority array is [1, 2, 3]. For example, if receiver X has a priority of 3, receiver Y has a priority of 1, receiver Z has a priority of 2, and receiver W has a priority of 4 in the second receiver queue, then the second priority array is [3, 1, 2, 4].

[0138] In some embodiments of this application, the first priority array is a first water level array, and the second priority array is a second water level array, wherein the water level element value in each water level array represents the priority of the corresponding receiver.

[0139] A water level array is an array used to represent the water level height at different locations through its element values. In this array, each element represents a location, and the element's value represents the water level height at that location. In other words, in the water level array, each element's location corresponds to a receiver, and the element's value indicates the receiver's priority. For example, the water level array [3,4,5,7,8] represents five receivers with priorities of 3, 4, 5, 7, and 8. When a broadcast message is sent, AMS determines the order in which the broadcast is distributed to the various receivers based on the positions and element values ​​in the water level array.

[0140] In operation S904, the judgment module determines whether the two priority arrays are the same. If not, the result is sent to the result module, which determines that they are inconsistent, thus avoiding unnecessary judgments when the priority arrays are inconsistent. If they are the same, the judgment continues.

[0141] In operation S905, if the first priority array and the second priority array are the same, the judgment module calls the update module, which uses the receiver identifier as the i-th attribute. For each receiver identifier in the first receiver queue, the judgment module determines whether there is a matching identifier in the second receiver queue.

[0142] The receiver identifier refers to a unique identifier for the receiver, such as a hash value or other identifier. For example, receiver A's identifier is ID-A, and receiver B's identifier is ID-B.

[0143] In operation S906, the determination module checks whether the receiver identifiers of the two receiver queues are the same. If not, the result is sent to the result module, which then determines that there is no consistency. If yes, then consistency is determined.

[0144] When operating S907, the output of the result module is inconsistent.

[0145] When operating S908, the result module outputs consistent results.

[0146] According to this embodiment, the consistency of two receiver queues can be determined. Consistency can be determined by comparing the first quantity, the second quantity, the receiver priority array, and the receiver identifier. Performing consistency checks on multiple receiver attributes between the two receiver queues helps improve efficiency, saves time and resources, and enhances the accuracy and reliability of the consistency results.

[0147] Combination Figure 9 The following is illustrative code to execute the consistency judgment process provided in the embodiments of this application. Based on Figures 5a-5b The formation process shows that between two adjacent replaceable broadcasts, the receivers who registered for the broadcast changed. This is related to the fact that the broadcast is a replaceable broadcast and that the receivers of the broadcast are ordered.

[0148] First, the code `testRecord.receivers.size() != record.receivers.size()` is executed. This checks if the first and second counts are the same; this logic ensures that the number of receivers in the two broadcasts has not changed. By comparing the sizes of `testRecord.receivers` and `record.receivers`, if they are not equal, it means the number of receivers has changed. This check is placed first to optimize performance; if the counts are inconsistent, subsequent comparisons are unnecessary.

[0149] Next, if the first and second counts are the same, the priority watermark arrays are checked by executing `!Arrays.equals(testRecord.blockedUntilBeyondCount, record.blockedUntilBeyondCount)`. This check ensures that the priority watermark arrays for the two broadcasts are consistent. By comparing the contents of `testRecord.blockedUntilBeyondCount` and `record.blockedUntilBeyondCount`, if they are not equal, it means the priority watermark arrays are inconsistent. Placing this check second is also for performance optimization; if the arrays are inconsistent, subsequent comparisons do not need to be executed.

[0150] Finally, the `!testRecord.receivers.containsAll(record.receivers)` check is executed to ensure that the receivers of the two broadcasts are completely identical. By comparing the contents of `testRecord.receivers` and `record.receivers`, if `testRecord.receivers` does not contain all the elements of `record.receivers`, it means that the receivers are not completely identical. This check is combined with `testRecord.receivers.size() != record.receivers.size()` because the first two checks have already ruled out inconsistencies in the number of receivers and priority watermark groups; a complete receiver comparison is only necessary if these two conditions are met.

[0151] These judgment logics ensure that the number of receivers, priority watermark array, and specific receivers of the two broadcasts are completely consistent, thus satisfying the consistency condition. This allows AMS to replace candidate broadcast messages with target broadcast messages and avoids broadcast congestion, improving the stability and efficiency of broadcast distribution.

[0152] like Figure 10 This is a schematic diagram illustrating the structure of an electronic device 100. Optionally, the electronic device 100 can be referred to as a terminal or a terminal device, and its specific product form can be a smart terminal, such as a mobile phone, tablet, digital video camera, smartwatch, smart wearable device, laptop computer, smart speaker, etc. Specifically, the functional modules involved in this application can be deployed on the DSP chip of the relevant device, specifically as applications or software therein. A task processing function can be provided through software installation or upgrades, as well as through hardware calls and cooperation.

[0153] It should be understood that, Figure 10 The electronic device 100 shown is only one example of an electronic device, and the electronic device 100 may have more or fewer components than shown in the figure, may combine two or more components, or may have different component configurations. Figure 10 The various components shown can be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application-specific integrated circuits.

[0154] Electronic device 100 may include: processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging AMS 140, power supply AMS 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include pressure sensors, gyroscope sensors, accelerometers, temperature sensors, motion sensors, barometric pressure sensors, magnetic sensors, distance sensors, proximity sensors, fingerprint sensors, touch sensors, ambient light sensors, bone conduction sensors, etc.

[0155] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, memory, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.

[0156] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.

[0157] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory.

[0158] The wireless communication function of electronic device 100 can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor, and baseband processor.

[0159] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be reused to improve antenna utilization.

[0160] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.

[0161] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies.

[0162] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with networks and other devices through wireless communication technology.

[0163] Electronic device 100 implements display functions through a GPU, display screen 194, and application processor. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0164] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.

[0165] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0166] The ISP is used to process data fed back from the camera. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's image sensor. The light signal is converted into an electrical signal, and the camera's image sensor transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye.

[0167] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard formats such as RGB and YUV. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.

[0168] The camera 193 can be located at the edge of the electronic device, and can be an under-display camera or a pop-up camera. The camera 193 may include a rear-facing camera, or a rear-facing camera. This application embodiment does not limit the specific location and shape of the camera 193. The electronic device 100 may include one or more cameras with different focal lengths, such as telephoto cameras, wide-angle cameras, ultra-wide-angle cameras, or panoramic cameras.

[0169] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to perform data storage functions.

[0170] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121, such as enabling electronic device 100 to implement the broadcast distribution method in this embodiment. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.). The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.

[0171] Electronic device 100 can implement audio functions through audio module 170 and application processor, such as music playback and recording.

[0172] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.

[0173] A touch sensor, also known as a "touch panel," can be located on the display screen 194. The touch sensor and display screen 194 together form a touchscreen, also called a "touch screen." The touch sensor detects touch operations applied to or near it. The touch sensor can then transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194.

[0174] A pressure sensor is used to sense pressure signals and can convert these signals into electrical signals. In some embodiments, the pressure sensor may be located on the display screen 194. The electronic device 100 may also calculate the position of a touch based on the detection signal from the pressure sensor.

[0175] A gyroscope sensor can be used to determine the motion attitude of an electronic device 100. In some embodiments, the angular velocity of the electronic device 100 about three axes (i.e., the x, y, and z axes) can be determined by the gyroscope sensor.

[0176] An accelerometer can detect the magnitude of acceleration of an electronic device 100 in various directions (typically three axes). When the electronic device 100 is stationary, the accelerometer can detect the magnitude and direction of gravity. Accelerometers can also be used to identify the posture of electronic devices, and are applied in applications such as screen orientation switching and pedometers.

[0177] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.

[0178] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This embodiment of the invention uses the layered architecture Android system as an example to illustrate the software structure of electronic device 100.

[0179] Figure 11 This is a schematic diagram of the software structure of an electronic device provided in an embodiment of this application.

[0180] like Figure 11 As shown, the software system of an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of an electronic device.

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

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

[0183] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications within the application layer. The application framework layer includes predefined functions. It may also include a series of system services. System services are modular components focused on specific functions. The functionality provided by the application framework API allows communication with system services to access the underlying hardware. For example, the application framework layer may include a window manager, content providers, a view system, a phone manager, a resource manager, and a notification manager. The window manager manages window programs. It can obtain the screen size, determine the presence of a status bar, lock the screen, and capture the screen. The content provider stores and retrieves data, making this data accessible to applications. This data may include video, images, audio, made and received phone calls, browsing history and bookmarks, and a phone book. The view system includes visual controls, such as controls for displaying text and controls for displaying images. The view system can be used to build applications. A display interface can consist 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 images. The phone manager provides communication functionality for the electronic device 100. For example, call status management (including connection, hang-up, etc.). The resource manager provides applications with various resources, such as localized strings, icons, images, layout files, video files, etc. The notification manager allows applications to display notifications in the status bar, which can be used to convey informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager is used to notify of download completion, message alerts, etc. The notification manager can also display notifications as icons or scrolling text in the system's top status bar, such as notifications from background applications, or as dialog windows on the screen. Examples include displaying text messages in the status bar, emitting alert sounds, vibrating electronic devices, and flashing indicator lights.

[0184] System libraries can include multiple functional modules. Examples include: Surface Manager, Media Libraries, 3D graphics processing libraries (e.g., OpenGL ES), and 2D graphics engines (e.g., SGL). The specific meanings and functions of these modules can be found in relevant technical documentation and will not be elaborated upon here.

[0185] The runtime is responsible for system scheduling and management. The runtime includes the core libraries and the virtual machine. The core libraries consist of two parts: one part contains the functionalities that Java needs to call, and the other part is the Android core library. The application layer and application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0186] The Hardware Abstraction Layer (HAL) is an interface layer located between the operating system kernel and upper-level software, its purpose being to abstract hardware. The HAL is an abstract interface for device kernel drivers, providing application programming interfaces (APIs) that allow access to the underlying device to higher-level Java API frameworks. The HAL can provide a standard interface to display device hardware functionality to higher-level Java API frameworks. The HAL contains multiple library modules, such as a camera HAL and an audio HAL. Each library module implements an interface for a specific type of hardware component. When the system framework layer API requires access to the portable device's hardware, the operating system loads the library module for that hardware component.

[0187] The kernel layer is the layer between hardware and software. It forms the foundation of the Android operating system. The kernel layer is responsible for hardware drivers, networking, power, system security, and memory management. As an intermediary between hardware and software, the kernel layer relays application requests to the hardware. It can include display drivers, camera drivers, audio drivers, and sensor drivers, among others.

[0188] It should be noted that the application provides Figure 11 The illustrated software architecture diagram of the electronic device is merely an example and does not limit the specific module divisions within different layers of the Android operating system. For details, please refer to the introduction of the Android operating system software architecture in conventional technologies. Furthermore, the broadcast distribution method provided in this application can also be implemented on other operating systems, which will not be listed here.

[0189] It is understood that, in order to achieve the above-mentioned functions, electronic devices include hardware and / or software modules that perform the respective functions. Based on the algorithmic steps of the examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.

[0190] All relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.

[0191] This embodiment also provides a computer storage medium storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the aforementioned method steps to implement the broadcast distribution method in the above embodiment.

[0192] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the broadcast distribution method described in the above embodiment.

[0193] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component or module. The apparatus may include a connected processor and a memory. The memory is used to store computer execution instructions. When the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the broadcast distribution method in the above method embodiments.

[0194] In this embodiment, the electronic device, computer storage medium, computer program product or chip are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding method provided above, and will not be repeated here.

[0195] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0196] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0197] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0198] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0199] Any content in the various embodiments of this application, as well as any content in the same embodiment, can be freely combined. Any combination of the above content is within the scope of this application.

[0200] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0201] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

[0202] The steps of the methods or algorithms described in conjunction with the embodiments of this application can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, portable hard disks, CD-ROMs, or any other form of storage medium well known in the art. An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can reside in an ASIC.

[0203] Those skilled in the art will recognize that the functions described in the embodiments of this application in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.

[0204] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A broadcast distribution method, applied to electronic devices, characterized in that, include: Receive the target broadcast message sent by the broadcast publisher the current time through the Activity Manager service (AMS); The AMS determines the first receiver queue that matches the target broadcast message; The AMS determines a second receiver queue that matches the candidate broadcast message, wherein the candidate broadcast message is a broadcast message to be distributed previously sent by the broadcast publisher, the candidate broadcast message and the target broadcast message have the same broadcast action, the broadcast action is used to indicate the attributes of the candidate broadcast message and the target broadcast message, the target broadcast message and the candidate broadcast message are ordered broadcasts, and the priorities of the receivers in the first receiver queue are different, and the priorities of the receivers in the second receiver queue are different; The AMS determines whether there is consistency between the first receiver queue and the second receiver queue based on receiver attributes; and In the presence of the aforementioned consistency, the AMS uses the target broadcast message to replace the candidate broadcast message, so as to distribute the target broadcast message to the corresponding broadcast receiver; Wherein, under the condition of the aforementioned consistency: The first receiver queue and the second receiver queue have the same receiver attributes; the receiver attributes include the number of receivers, receiver priority, and receiver identifier; The determination of whether the first receiver queue and the second receiver queue have consistency based on receiver attributes through the AMS includes: Perform the following loop operation: The number of receivers is taken as the i-th attribute, the first receiver queue includes a first number of receivers, the second receiver queue includes a second number of receivers, and i is an integer greater than or equal to 1; If the first quantity is determined to be the same as the second quantity, the receiver priority is taken as the i-th attribute. The first priority array indicates the priority of each receiver in the first receiver queue, and the second priority array indicates the priority of each receiver in the second receiver queue. If the first priority array and the second priority array are the same, the receiver identifier is used as the i-th attribute; For each receiver's identifier in the first receiver queue, if it is determined that there is a matching identifier in the second receiver queue, it is determined that the first receiver queue and the second receiver queue have consistency based on receiver attributes. And, when it is determined that the first quantity and the second quantity are not the same, or Determine that the first priority array and the second priority array are not the same, or If, for any identifier of a receiver in the first receiver queue, there is no identical identifier in the second receiver queue, it is determined that the first receiver queue and the second receiver queue do not have the aforementioned consistency. End the loop operation.

2. The method according to claim 1, characterized in that, Before determining whether the consistency exists via the AMS, the method further includes: The AMS determines that there are at least two receivers in the first receiver queue; In the presence of at least two receivers, the AMS determines that the at least two receivers have different priorities.

3. The method according to claim 1, characterized in that, The first priority array is a first water level array, and the second priority array is a second water level array, wherein the water level element value in each water level array represents the priority of the corresponding receiver.

4. 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 invoke the computer program, causing the electronic device to perform the method according to any one of claims 1 to 3.

5. A computer-readable storage medium, characterized in that, Includes a computer program that, when run on an electronic device, causes the electronic device to perform the method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Method and apparatus for adjusting broadcast message queue, and terminal

    CN106851015A

  • Message processing method and apparatus

    CN107231294A