TECHNICAL FIELD

The present invention relates to the field of mobile communications technologies, and in particular, to a broadcast control method and apparatus, and a terminal.

BACKGROUND

As one of four components of an Android system, a broadcast is an inter-process communication mechanism, and is widely used in many operating systems. The broadcast may be used to transmit data, send a notification, and the like. However, because the broadcast is widely used, some unavoidable problems arise. For example, when an application runs on a background, although the application is temporarily not used by a user, the application can frequently receive a broadcast, and implement self-running by using the broadcast. This causes power consumption of a terminal device.

SUMMARY

Embodiments of the present invention provide an intelligent broadcast control method and apparatus, and a terminal.

According to a first aspect, the present invention provides a broadcast control method. The method is applied to a terminal. A first application runs in an operating system of the terminal. The method includes:

when the first application runs on a background of the operating system of the terminal, obtaining a first broadcast to be sent to the first application; and

buffering the first broadcast and stopping sending the first broadcast to the first application.

With reference to the first aspect, in a first possible implementation of the first aspect, before the buffering the first broadcast and stopping sending the first broadcast to the first application, the method further includes:

determining that a running characteristic of the first application meets a first preset freezing condition, where the running characteristic of the first application includes a background continuous runtime of the first application in the operating system of the terminal, and the first preset freezing condition includes that a background continuous runtime of an application is greater than a preset runtime.

With reference to the first aspect or the first possible implementation of the first aspect, in a second possible implementation of the first aspect, before the buffering the first broadcast and stopping sending the first broadcast to the first application, the method further includes:

determining that the first broadcast belongs to a preset frozen broadcast, where the preset frozen broadcast includes at least one of a preset system broadcast or a preset second-application broadcast.

With reference to the first aspect or the first possible implementation of the first aspect, in a third possible implementation of the first aspect, before the buffering the first broadcast and stopping sending the first broadcast to the first application, the method further includes:

determining that a running characteristic of the first broadcast meets a second preset freezing condition, where the running characteristic of the first broadcast includes a receiver quantity of the first broadcast, and the second preset freezing condition includes that a receiver quantity of a broadcast is greater than a preset receiver quantity; or

determining that a running characteristic of the first broadcast meets a second preset freezing condition, where the running characteristic of the first broadcast includes transmission frequency of the first broadcast, and the second preset freezing condition includes that transmission frequency of a broadcast is higher than preset transmission frequency.

With reference to any one of the first aspect to the third possible implementation of the first aspect, in a fourth possible implementation of the first aspect, after the buffering the first broadcast and stopping sending the first broadcast to the first application, the method further includes: unfreezing the first broadcast and sending the first broadcast to the first application.

With reference to the fourth possible implementation of the first aspect, in a fifth possible implementation of the first aspect, before the unfreezing the first broadcast, the method further includes: detecting that the first application is switched from the background of the operating system of the terminal to a foreground to run.

With reference to the fourth possible implementation of the first aspect, in a sixth possible implementation of the first aspect, before the unfreezing the first broadcast, the method further includes: obtaining a second broadcast to be sent to the first application, where the second broadcast belongs to a preset important broadcast.

With reference to any one of the first aspect to the third possible implementation of the first aspect, in a seventh possible implementation of the first aspect, after the buffering the first broadcast, the method further includes:

obtaining a third broadcast to be sent to the first application;

determining whether the third broadcast and the first broadcast belong to a same type of broadcast; and

if the third broadcast and the first broadcast belong to a same type of broadcast, buffering the third broadcast and deleting the buffered first broadcast.

According to a second aspect, the present invention provides a broadcast control apparatus. A first application runs in an operating system of a terminal. The apparatus includes:

a broadcast obtaining module, configured to: when the first application runs on a background of the operating system of the terminal, obtain a first broadcast to be sent to the first application; and a broadcast distribution module, configured to buffer the first broadcast and stop sending the first broadcast to the first application.

With reference to the second aspect, in a first possible implementation of the second aspect, the broadcast distribution module is further configured to determine that a running characteristic of the first application meets a first preset freezing condition, where the running characteristic of the first application includes a background continuous runtime of the first application in the operating system of the terminal, and the first preset freezing condition includes that a background continuous runtime of an application is greater than a preset runtime.

With reference to the second aspect or the first possible implementation of the second aspect, in a second possible implementation of the second aspect, the broadcast distribution module is further configured to determine that the first broadcast belongs to a preset frozen broadcast, where the preset frozen broadcast includes at least one of a preset system broadcast or a preset second-application broadcast.

With reference to the second aspect or the first possible implementation of the second aspect, in a third possible implementation of the second aspect, the broadcast distribution module is further configured to determine that a running characteristic of the first broadcast meets a second preset freezing condition, where the running characteristic of the first broadcast includes a receiver quantity of the first broadcast, and the second preset freezing condition includes that a receiver quantity of a broadcast is greater than a preset receiver quantity; or

determine that a running characteristic of the first broadcast meets a second preset freezing condition, where the running characteristic of the first broadcast includes transmission frequency of the first broadcast, and the second preset freezing condition includes that transmission frequency of a broadcast is higher than preset transmission frequency.

With reference to any one of the second aspect to the third possible implementation of the second aspect, in a fourth possible implementation of the second aspect, the broadcast distribution module is further configured to: unfreeze the first broadcast and send the first broadcast to the first application.

With reference to the fourth possible implementation of the second aspect, in a fifth possible implementation of the second aspect, the broadcast distribution module is further configured to detect that the first application is switched from the background of the operating system of the terminal to a foreground to run.

With reference to the fourth possible implementation of the second aspect, in a sixth possible implementation of the second aspect, the broadcast distribution module is further configured to obtain a second broadcast to be sent to the first application, where the second broadcast belongs to a preset important broadcast.

With reference to any one of the second aspect to the third possible implementation of the second aspect, in a seventh possible implementation of the second aspect, the broadcast distribution module is further configured to: obtain a third broadcast to be sent to the first application;

determine whether the third broadcast and the first broadcast belong to a same type of broadcast; and

if the third broadcast and the first broadcast belong to a same type of broadcast, buffer the third broadcast and delete the buffered first broadcast.

According to a third aspect, an embodiment of the present invention provides a terminal. The terminal includes a processor, a memory, a system bus, and a communications interface. The processor, the memory, and the communications interface are connected by using the system bus, one or more programs are stored in the memory and executed by the processor, and the one or more programs include all instructions used to perform the broadcast control method in the first aspect.

Based on the foregoing technical solutions, according to the broadcast control method and apparatus, and the terminal provided in the embodiments of the present invention, when it is identified that one or more application programs are running on a background, and meet a specific condition, a broadcast that is to be received by the one or more application programs is frozen. In this way, the following problems are resolved: The one or more application programs frequently receive a broadcast on the background, and this causes a system to get stuck; excessive power consumption of a terminal device causes the terminal device heated; and the like. In addition, system performance is further improved. When the one or more application programs are switched from the background to a foreground to run, and/or meet an unfreezing condition, the broadcast for the one or more application programs may be unfrozen. Therefore, the one or more application programs can conveniently process the broadcast to be received by the one or more application programs.

