CN-122027993-A - Broadcast message transmission method, electronic device, storage medium, and program product
Abstract
The application provides a broadcast message sending method, electronic equipment, a storage medium and a program product, which can reduce the consumption of CPU resources of the electronic equipment. The method comprises the steps of receiving a first broadcast message, wherein a broadcast event aimed by the first broadcast message is a first broadcast event, sending a second broadcast message to a first application if the first application comprises a plurality of broadcast receivers aimed at the first broadcast event, wherein the second broadcast message comprises the first broadcast message and list information of the plurality of broadcast receivers, and sending the first broadcast message in the second broadcast message to the plurality of broadcast receivers through the first application.
Inventors
- Qi changle
Assignees
- 荣耀终端股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20241112
Claims (13)
- 1. A method for transmitting a broadcast message, comprising: Receiving a first broadcast message, wherein a broadcast event aimed by the first broadcast message is a first broadcast event; If a first application comprises a plurality of broadcast receivers for the first broadcast event, sending a second broadcast message to the first application, wherein the second broadcast message comprises the first broadcast message and list information of the plurality of broadcast receivers; The first broadcast message of the second broadcast messages is transmitted to the plurality of broadcast receivers by the first application.
- 2. The method of claim 1, wherein the second broadcast message further includes first indication information, and the first indication information is used to indicate a transmission mode of the first broadcast message, where the transmission mode includes blocking transmission and non-blocking transmission.
- 3. The method according to claim 2, wherein said transmitting the first broadcast message of the second broadcast messages to the plurality of broadcast receivers if the transmission manner of the first broadcast message is a blocking transmission, comprises: selecting a first broadcast receiver from the plurality of broadcast receivers; transmitting the first broadcast message to the first broadcast receiver; Selecting a second broadcast receiver from the plurality of broadcast receivers in the case where the first broadcast receiver processing completes the first broadcast message; And transmitting the first broadcast message to the second broadcast receiver.
- 4. A method according to claim 3, characterized in that the method further comprises: And receiving second indication information sent by the first application, wherein the second indication information is used for indicating a broadcasting system to resume the dispatch of the broadcast message, and the second indication information is sent when the first application sends the first broadcast message to the plurality of broadcasting receivers and the plurality of broadcasting receivers process the first broadcast message.
- 5. The method according to claim 2, wherein if the transmission manner of the first broadcast message is non-blocking transmission, the transmitting the first broadcast message of the second broadcast message to the plurality of broadcast receivers includes: The first broadcast message is asynchronously transmitted to each of the plurality of broadcast receivers.
- 6. The method of any of claims 1-5, wherein the priorities of the plurality of broadcast receivers are the same.
- 7. The method of any of claims 1-6, wherein prior to the sending the second broadcast message to the first application, the method further comprises: Acquiring a first broadcast receiver from a process broadcast queue management object, wherein a broadcast event aimed by the first broadcast receiver is the first broadcast event; the sending a second broadcast message to the first application includes: And if the process broadcast queue management object has the same priority as the first broadcast receiver and targets the broadcast receivers of the first broadcast event, sending the second broadcast message to the first application.
- 8. The method of claim 7, wherein the method further comprises: and if the process broadcast queue management object does not have the broadcast receiver with the same priority as the first broadcast receiver and aims at the broadcast receiver of the first broadcast event, sending the first broadcast message to the first broadcast receiver.
- 9. The method of claim 8, wherein the transmitting the first broadcast message to the first broadcast receiver comprises: Transmitting the first broadcast message to the first broadcast receiver through a first interface, wherein the first interface is a special interface for dispatching the broadcast message to one broadcast receiver; the sending the second broadcast message to the first application includes: and sending the second broadcast message to the first application through a second interface, wherein the second interface is an interface special for dispatching broadcast messages to a plurality of broadcast receivers.
- 10. The method according to any one of claims 1-9, wherein after sending a second broadcast message to the first application, the method further comprises: recording a transmission condition of the second broadcast message, wherein the transmission condition comprises whether to trigger application of unresponsive ANR.
- 11. An electronic device comprising a memory and a processor, the memory having stored thereon a computer program executable on the processor, the processor implementing the method according to any of claims 1 to 10 when the computer program is executed.
- 12. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program which, when executed by a processor, causes the processor to perform the method of any of claims 1 to 10.
- 13. A computer program product comprising a program for causing a computer to perform the method of any one of claims 1-10.
Description
Broadcast message transmission method, electronic device, storage medium, and program product Technical Field The present application relates to the field of terminal technologies, and in particular, to a broadcast message sending method, an electronic device, a storage medium, and a program product. Background A broadcast mechanism is a very important communication mechanism for transferring information between applications or between different components of an application. When the broadcasting system receives the broadcasting message, the broadcasting system may transmit the broadcasting message to a broadcasting receiver in the application program, which listens for the broadcasting message, and the broadcasting receiver may perform a corresponding process based on the broadcasting message. Currently, the sending mechanism of the broadcast message occupies more resources of the central processing unit (central processing unit, CPU), which is not beneficial to reducing the power consumption of the electronic device. Disclosure of Invention The application provides a broadcast message sending method, electronic equipment, a storage medium and a program product, which can reduce the consumption of CPU resources of the electronic equipment. In a first aspect, a method for sending broadcast messages is provided, and the method comprises the steps of receiving a first broadcast message, wherein a broadcast event aimed by the first broadcast message is a first broadcast event, sending a second broadcast message to a first application if the first application comprises a plurality of broadcast receivers aimed at the first broadcast event, wherein the second broadcast message comprises the first broadcast message and list information of the plurality of broadcast receivers, and sending the first broadcast message in the second broadcast message to the plurality of broadcast receivers through the first application. When the broadcast system in the embodiment of the application sends the broadcast message to the first application, the broadcast messages of the broadcast receivers aiming at the same event can be packaged, the packaged broadcast messages (namely, the second broadcast messages) are sent to the first application at one time, and then the first application sends the broadcast messages to the corresponding broadcast receivers one by one. Compared with the scheme that the broadcasting system sends the broadcasting messages aiming at a plurality of broadcasting receivers to the first application for a plurality of times, the scheme of the embodiment of the application can reduce the interaction times between the broadcasting system and the application process, reduce the consumption of CPU resources and is beneficial to improving the user experience. Especially for the scene of orderly broadcasting, the interaction times between the broadcasting system and the application process can be greatly reduced, and the consumption of CPU resources is reduced. In some implementations, the second broadcast message further includes first indication information, where the first indication information is used to indicate a transmission mode of the first broadcast message, where the transmission mode includes blocking transmission and non-blocking transmission. By carrying the first indication information in the second broadcast message, the first application can definitely send the first broadcast message to the plurality of broadcast receivers, which is beneficial to ensuring the correct sending of the first broadcast message. In some implementations, if the transmission mode of the first broadcast message is blocking transmission, the transmitting the first broadcast message in the second broadcast message to the plurality of broadcast receivers includes selecting a first broadcast receiver from the plurality of broadcast receivers, transmitting the first broadcast message to the first broadcast receiver, selecting a second broadcast receiver from the plurality of broadcast receivers if the first broadcast receiver processes the first broadcast message, and transmitting the first broadcast message to the second broadcast receiver. If the sending mode of the first broadcast message is blocking sending, the first application can sequentially send the first broadcast message to a plurality of broadcast receivers by traversing a plurality of broadcast receiver lists, and then send the first broadcast message to the next broadcast receiver under the condition that one broadcast receiver finishes processing the first broadcast message, so that the orderly sending of the first broadcast message can be ensured. In some implementations, the method further includes receiving second indication information sent by the first application, where the second indication information is used to instruct a broadcast system to resume dispatch of the broadcast message, the second indication information is sent when the first application s