(19)
(11)EP 3 270 566 B1

(12)EUROPEAN PATENT SPECIFICATION

(45)Mention of the grant of the patent:
27.07.2022 Bulletin 2022/30

(21)Application number: 15896778.6

(22)Date of filing:  30.06.2015
(51)International Patent Classification (IPC): 
H04L 67/14(2022.01)
H04W 52/02(2009.01)
(52)Cooperative Patent Classification (CPC):
H04W 52/0216; H04W 52/0267; H04L 67/14; H04W 52/0264; Y02D 30/70; H04L 65/40
(86)International application number:
PCT/CN2015/082884
(87)International publication number:
WO 2017/000247 (05.01.2017 Gazette  2017/01)

(54)

METHOD FOR TERMINAL AND NETWORK DEVICE INTERACTION AND TERMINAL

VERFAHREN ZUR INTERAKTION ZWISCHEN ENDGERÄT UND NETZWERKVORRICHTUNG SOWIE ENDGERÄT

PROCÉDÉ D'INTERACTION ENTRE UN TERMINAL ET UN DISPOSITIF DE RÉSEAU, ET TERMINAL


(84)Designated Contracting States:
AL AT BE BG CH CY CZ DE DK EE ES FI FR GB GR HR HU IE IS IT LI LT LU LV MC MK MT NL NO PL PT RO RS SE SI SK SM TR

(43)Date of publication of application:
17.01.2018 Bulletin 2018/03

(73)Proprietor: Huawei Technologies Co., Ltd.
Longgang District Shenzhen, Guangdong 518129 (CN)

(72)Inventors:
  • ZHAO, Jing
    Shenzhen Guangdong 518129 (CN)
  • ZHONG, Guanghua
    Shenzhen Guangdong 518129 (CN)

(74)Representative: Goddar, Heinz J. 
Boehmert & Boehmert Anwaltspartnerschaft mbB Pettenkoferstrasse 22
80336 München
80336 München (DE)


(56)References cited: : 
EP-A1- 2 799 953
CN-A- 102 662 474
US-A1- 2012 188 928
US-A1- 2015 055 594
EP-A1- 2 882 233
CN-A- 104 052 861
US-A1- 2014 321 448
  
      
    Note: Within nine months from the publication of the mention of the grant of the European patent, any person may give notice to the European Patent Office of opposition to the European patent granted. Notice of opposition shall be filed in a written reasoned statement. It shall not be deemed to have been filed until the opposition fee has been paid. (Art. 99(1) European Patent Convention).


    Description

    TECHNICAL FIELD



    [0001] The present invention relates to the communications field, and in particular, to a method for interaction between a terminal and a network device, and a terminal.

    BACKGROUND



    [0002] With development of science and technology, a large quantity of terminals appear on the market and become popularized, a quantity of terminal users also increases dramatically, and a large quantity of application programs mushroom. This brings huge entertainment and high practicability to users. However, a terminal system platform such as an Android platform is an electric energy-consuming platform, charging is performed almost every day, and electric energy is insufficient for consumption of the Android platform. In addition, currently, some malicious applications also emerge increasingly, and some malicious application programs consume electric energy in the background when a user is ignorant. Even if there is no malicious application program in a terminal, when a user enables multiple application programs in the terminal, these application programs alternately interact with a network frequently, thereby consuming high electric energy. This not only causes inconvenience to user experience, but also may cause the user to miss some important issues. For example, a contract is missed because a power-consuming mobile phone is out of power when a user is away from home. Although various power banks are available currently, a power bank cannot be used on some occasions and is inconvenient to carry. Therefore, a terminal power consumption problem is not fundamentally resolved. Therefore, how to better reduce power consumption of a terminal and prolong a standby time is currently an urgent requirement of a user.

    [0003] Currently, there is no effective solution to the foregoing case.

    [0004] Android is a Linux-based operating system that freely uses open source code, is mainly used for mobile devices such as a smartphone and a tablet computer, and is currently developed by Google. For details, refer to https://en.wikipedia.org/wiki/Android_(operating_system). Android versions include Android 1.5, Android 2.2, Android 4.3, Android 4.4, Android 5.0, and the like.

    [0005] US 2014/321448 A1 discloses detection of network transactions or keepalives for maintaining long lived connections. A keepalive detector can detect keepalive traffic based on keepalive parameters determined from an analysis of socket level network communication log data that record data transfer events including data sent from mobile applications or clients on a mobile device and data received by the mobile applications or clients on the mobile device, timing characteristics, protocol types, etc.

    [0006] US 2015/055594 A1 discloses methods for optimizing the sending of keepalive messages by extending keepalive periods and for delaying background requests for a certain period of time.

    [0007] EP 2 799 953 A1 discloses a terminal control method that includes: obtaining position distribution of a terminal held position on the terminal; and performing, according to a mapping relationship between position distribution and a terminal control operation, an operation corresponding to the position distribution, so as to control the terminal.

    [0008] EP 2 882 233 A1 discloses a service agent method. A modem acts as an application processor. The methods includes: receiving, by the modem, heartbeat configuration information corresponding to an application and sent by the application processor, where the application processor is in a sleep state after sending the heartbeat configuration information corresponding to the application, and establishing, by the modem according to the heartbeat configuration information corresponding to the application, a heartbeat connection with an application server corresponding to the application. US 2012/188928 A1 discloses a method for maintaining the connection between a terminal and a network server. The terminal has a first processing unit with a first state and a second state, wherein the power consumption of the second state is less than the power consumption of the first state. When the first processing unit is in the second state, the terminal or the network server sends heartbeat data packets periodically in order to maintain the connection between said terminal and said network server.

    SUMMARY



    [0009] The present invention disclose a method of claim 1 for interaction between a terminal and a network device, and a terminal of claim 5, to resolve an existing problem, and reduce power consumption of the terminal. Possible implementation manners are disclosed in the dependent claims.

    [0010] According to a first aspect, an embodiment of the present invention provides a method for interaction between a terminal and a network device, and the method includes:

    sending, by a terminal, a first heartbeat to a network device;

    receiving, by the terminal, a first heartbeat response returned by the network device, where the first heartbeat response is a response corresponding to the first heartbeat;

    after receiving the first heartbeat response, upon obtaining that a screen of the terminal is in an off state, while the terminal is not powered off, prohibiting a background application that is running on the terminal from accessing the network device;

    after prohibiting the background application from accessing the network device and before the terminal sends a second heartbeat which is a heartbeat next to the first heartbeat to the network device, allowing, by the terminal, the background application of the terminal to access the network device;

    then sending, by the terminal, the second heartbeat to the network device; and

    receiving, by the terminal, a second heartbeat response returned by the network device, where the second heartbeat response is a response corresponding to the second heartbeat.



    [0011] With reference to the first aspect, in a first implementation manner of the first aspect, N application programs run on the terminal, N is an integer, N is greater than 1, and the first heartbeat includes a heartbeat sent by each of the N application programs to an application server corresponding to each of the N application programs.

    [0012] With reference to the first implementation manner of the first aspect, in a second implementation manner of the first aspect, the N application programs send heartbeats to the network device by using a network agent in the terminal.

    [0013] With reference to the first or second implementation manner of the first aspect, in a third implementation manner of the first aspect, the network device includes a network server of a terminal equipment vendor corresponding to the terminal, the first heartbeat is sent to the network server, and the network server is configured to forward the first heartbeat to application servers corresponding to the N application programs.

    [0014] According to a second aspect, an embodiment of the present invention provides a terminal, and the terminal includes:

    a transceiver, configured to send and receive data exchanged between the terminal and a network device;

    one or more processors;

    a memory;

    multiple application programs; and

    one or more programs, where the one or more programs are stored in the memory and are configured to be executed by the one or more processors, the one or more programs include an instruction, and the instruction is used for:

    sending, by the terminal, a first heartbeat to the network device;

    receiving, by the terminal, a first heartbeat response returned by the network device, where the first heartbeat response is a response corresponding to the first heartbeat;

    after receiving the first heartbeat response, upon obtaining that a screen of the terminal is in an off state, while the terminal is not powered off, prohibiting a background application that is running on the terminal from accessing the network device;

    after prohibiting the background application from accessing the network device and before the terminal sends a second heartbeat which is a heartbeat next to the first heartbeat to the network device, allowing, by the terminal, the background application of the terminal to access the network device;

    then sending, by the terminal, the second heartbeat to the network device; and

    receiving, by the terminal, a second heartbeat response returned by the network device, where the second heartbeat response is a response corresponding to the second heartbeat.



    [0015] With reference to the second aspect, in a first implementation manner of the second aspect, N application programs run on the processor, N is an integer, N is greater than 1, and the first heartbeat includes a heartbeat sent by each of the N application programs to an application server corresponding to each of the N application programs.

    [0016] With reference to the first implementation manner of the second aspect, in a second implementation manner of the second aspect, the N application programs send heartbeats to the network device by using a network agent in the terminal.

    [0017] With reference to the first or second implementation manner of the second aspect, in a third implementation manner of the second aspect, the network device includes a network server of a terminal equipment vendor corresponding to the terminal, the first heartbeat is sent to the network server, and the network server is configured to forward the first heartbeat to application servers corresponding to the N application programs.

    [0018] In the solutions provided in the embodiments of the present invention, when the screen is off between two heartbeats, and optionally, the off state lasts for a preset period of time, data exchange between a background application program and the network device is interrupted, so that power consumption of the terminal can be effectively reduced when both the terminal and an application server to which the application program belongs are online and a user is unaware.

    BRIEF DESCRIPTION OF DRAWINGS



    [0019] To describe the technical solutions in the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings required for describing the prior art or the embodiments. Apparently, the accompanying drawings in the following description show merely some embodiments of the present invention, and a person skilled in the art may still derive other drawings from these accompanying drawings.

    FIG. 1 is a structural block diagram of a mobile phone according to an embodiment of the present invention;

    FIG. 2 is a schematic diagram of a heartbeat mechanism applied to Android 4.3 and Android 4.4 systems according to an embodiment of the present invention;

    FIG. 3 is an architectural networking diagram according to an embodiment of the present invention;

    FIG. 4 is a schematic flowchart of a method for interaction between a terminal and a network device according to Embodiment 1 of the present invention;

    FIG. 5 is a schematic flowchart of a method according to an example;

    FIG. 6 is a schematic diagram of an apparatus structure of a terminal according to Embodiment 3 of the present invention; and

    FIG. 7 is a schematic diagram of a hardware structure of a terminal according to Embodiment 4 of the present invention.


    DESCRIPTION OF EMBODIMENTS



    [0020] To make the objectives, technical solutions, and advantages of the present invention clearer, the following further describes the embodiments of the present invention in detail with reference to the accompanying drawings. To understand the present invention, the following description mentions many specific details. However, a person skilled in the art should understand that the present invention may be implemented without these specific details. In other embodiments, well-known methods, processes, components, and circuits are not described in detail, so as to prevent the embodiments from being blurred. Apparently, the described embodiments are some rather than all of the embodiments of the present invention. The scope of the present invention is defined by the appended claims.

    [0021] The terms used in the embodiments of the present invention are merely for the purpose of illustrating specific embodiments, and are not intended to limit the present invention. The terms "a", "said", and "the" of singular forms used in the embodiments and the appended claims of the present invention are also intended to include plural forms, unless otherwise specified in the context clearly. It should also be understood that, the term "and/or" used herein indicates and includes any or all possible combinations of one or more associated listed items. It should be further understood that the term "include" used in the specification specifies presence of features, integers, steps, operations, elements, and/or components, with presence or attachment of other features, integers, steps, operations, components, elements, and their combinations not excluded.

    [0022] A terminal involved in the embodiments of the present invention may be a terminal device such as a mobile phone, a tablet computer, a personal digital assistant (Personal Digital Assistant, PDA for short), a point of sales terminal (Point of Sales, POS for short), or a vehicle-mounted computer. This is not specifically limited in the embodiments of the present invention. In an example, the terminal is a mobile phone. FIG. 1 shows a block diagram of a partial structure of a mobile phone 100 related to a terminal according to an embodiment of the present invention.

    [0023] Referring to FIG. 1, the mobile phone 100 includes components such as a radio frequency (Radio Frequency, RF for short) circuit 110, a memory 120, an input unit 130, a display unit 140, a sensor 150, an audio circuit 170, a wireless fidelity (wireless fidelity, WiFi for short) module 180, a processor 160, and a power supply 190. A person skilled in the art may understand that a structure of the mobile phone shown in FIG. 1 is used only as an example of implementation manners and does not constitute a limitation on the mobile phone, and the mobile phone may include more or fewer components than those shown in the figure, or some components may be combined, or components may be deployed differently.

    [0024] The components of the mobile phone 100 are specifically described below with reference to FIG. 1.

    [0025] The RF circuit 110 may be configured to receive and send signals in an information receiving and sending process or a call process. Particularly, the RF circuit 110 receives downlink information from a base station, then sends the downlink information to the processor 160 for processing, and sends related uplink data to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA for short), a duplexer, and the like. In addition, the RF circuit 110 may further communicate with a network and another device by means of wireless communication. Any communications standard or protocol may be used for the wireless communication and includes but is not limited to Global System for Mobile Communications (Global System of Mobile communication, GSM for short), General Packet Radio Service (General Packet Radio Service, GPRS for short), Code Division Multiple Access (Code Division Multiple Access, CDMA for short), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA for short), and the like.

    [0026] The memory 120 may be configured to store a software program and a module. The processor 160 runs the software program and the module stored in the memory 120, to implement various functional applications and data processing of the mobile phone 100. The memory 120 may mainly include a program storage area and a data storage area. The program storage area may store an operating system, an application program required by at least one function (such as a sound playback function or an image display function), and the like, and the data storage area may store data (such as audio data and a phone book) created according to use of the mobile phone 100, and the like. In addition, the memory 120 may include a high-speed random access memory, and may also include a non-volatile memory such as at least one disk storage component, a flash memory component, or another volatile solid-state storage component. The memory 120 in FIG. 1 may refer to all memories of the mobile phone 100, or the memory 120 may refer to a first memory of the mobile phone 100. The mobile phone 100 further includes a second memory 121, or the mobile phone 100 further includes another memory that is not shown.

    [0027] The input unit 130 may be configured to: receive entered digital or character information, and generate key signal input related to a user setting and function control of the mobile phone 100. Specifically, the input unit 130 may include a touch panel 131 and another input device 132. The touch panel 131, also referred to as a touchscreen, may collect a touch operation of a user on or near the touch panel 131 (such as an operation of the user on or near the touch panel 131 by using any suitable object or attachment, such as a finger or a touch pen), and drive a corresponding connection apparatus according to a preset program. Optionally, the touch panel 131 may include two parts: a touch detection apparatus and a touch controller. The touch detection apparatus detects a touch orientation of the user, detects a signal generated by the touch operation, and transfers the signal to the touch controller. The touch controller receives touch information from the touch detection apparatus, converts the touch information into contact coordinates, then sends the contact coordinates to the processor 160, and can receive and execute a command sent by the processor 160. In addition, the touch panel 131 may be implemented in multiple types such as a resistive type, a capacitive type, an infrared type, and a surface acoustic wave type. In addition to the touch panel 131, the input unit 130 may include the another input device 132. Specifically, the another input device 132 may include but be not limited to one or more of a physical keyboard, a functional key (such as a volume control key or an on/off key), a trackball, a mouse, or a joystick.

    [0028] The display unit 140 may be configured to display information entered by the user or information provided for the user, and various menus of the mobile phone 100. The display unit 140 may include a display panel 141, and optionally, the display panel 141 may be configured by using a liquid crystal display (Liquid Crystal Display, LCD for short), an organic light-emitting diode (Organic Light-Emitting Diode, OLED for short), and the like. Further, the touch panel 131 may cover the display panel 141. After detecting a touch operation on or near the touch panel 131, the touch panel 131 transfers the touch operation to the processor 160, so as to determine a type of a touch event. Then, the processor 160 provides corresponding visual output on the display panel 141 according to the type of the touch event. Although in FIG. 1, the touch panel 131 and the display panel 141 are used as two separate components to implement input and output functions of the mobile phone 100, in some embodiments, the touch panel 131 and the display panel 141 may be integrated to implement the input and output functions of the mobile phone 100.

    [0029] The mobile phone 100 may further include at least one sensor 150 such as an optical sensor, a motion sensor, or another sensor. Specifically, the optical sensor may include an ambient light sensor and a proximity sensor. The ambient light sensor may adjust luminance of the display panel 141 according to brightness of ambient light. The proximity sensor may switch off the display panel 141 and/or backlight when the mobile phone 100 is moved to an ear. As a type of motion sensor, an accelerometer sensor can detect magnitudes of accelerations in various directions (generally on three axes), can detect a magnitude and a direction of gravity at rest, and may be applied to an application that recognizes a mobile phone gesture (for example, screen switching between a landscape mode and a portrait mode, a related game, and magnetometer gesture calibration), a function related to vibration recognition (such as a pedometer or a knock), and the like. For other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor that may be further configured for the mobile phone 100, details are not described herein.

    [0030] The audio circuit 170 may include a loudspeaker and a microphone, and the microphone can provide an audio interface between the user and the mobile phone 100. The audio circuit 170 may convert received audio data into an electric signal and transmit the electric signal to the loudspeaker. The loudspeaker converts the electric signal into a sound signal for output. In another aspect, the microphone converts a collected sound signal into an electric signal. The audio circuit 170 receives the electric signal, converts the electric signal into audio data, and then outputs the audio data to the processor 160 for processing. Then, the processor 160 sends the audio data to, for example, another mobile phone by using the RF circuit 110, or outputs the audio data to the memory 120 for further processing.

    [0031] WiFi is a short-range wireless transmission technology. The mobile phone 100 may help, by using the WiFi module 180, the user receive and send e-mails, browse a webpage, access streaming media, and the like. WiFi provides wireless broadband Internet access for the user. Although FIG. 14 shows the WiFi module 180, it may be understood that the WiFi module 180 is not a necessary component of the mobile phone 100, and the WiFi module 180 may be omitted according to a requirement provided that the essence of the present invention is not changed.

    [0032] The processor 160 is a control center of the mobile phone 100, is connected to various parts of the entire mobile phone by using various interfaces and lines, and performs various functions and data processing of the mobile phone 100 by running or executing the software program and/or the module stored in the memory 120 and invoking the data stored in the memory 120, so as to perform overall monitoring on the mobile phone. Optionally, the processor 160 may include one or more processing units. Optionally, an application processor (Application Processor, AP) and a communication processor (Communication Processor, CP) may be integrated into the processor 160. The application processor mainly processes an operating system, a user interface, an application program, and the like. The communication processor may also be referred to as a baseband processor (Baseband Processor, BP), and mainly processes wireless communication, for example, is responsible for managing all radio frequency services that need an antenna. It may be understood that, the communication processor may not be integrated into the processor 160. The communication processor may include a modem module, an encoding and decoding module, a scrambling module, an interleaving module, and the like. According to different actual requirements of a terminal, the communication processor may include different functional modules. For example, different communication processor chips are used for different terminals.

    [0033] The mobile phone 100 further includes the power supply 190 (such as a battery) for supplying power to the components. Preferably, the power supply may be logically connected to the processor 160 by using a power management system, thereby implementing functions such as charging, discharging, and power consumption management by using the power management system.

    [0034] The mobile phone 100 may further include a camera, a Bluetooth module, and the like although they are not shown in the figure, and details are not described herein.

    Heartbeat Mechanism



    [0035] To keep a terminal and a corresponding server to which an application program belongs online, the application program needs to send a heartbeat to the application server at a specific interval, and after receiving the heartbeat, the application server returns a heartbeat response to the application program. The heartbeat may also be referred to as a heartbeat frame or a heartbeat packet.

    [0036] If the application program does not receive, within a specified period of time, the heartbeat response returned by the application server, the application program considers that a network link is disconnected or an error occurs in the application server, and performs connection and login again. If the application server does not receive, within a specified period of time, the heartbeat sent by the application program, the application server releases a server resource, and cancels an online state of the application program.

    [0037] In the Android 4.3 system, as shown in FIG. 2, application programs running on a terminal include application programs a1, a2, and a3. The application programs a1, a2, and a3 separately send heartbeats to application servers at different intervals. Each application program running on the terminal sends a heartbeat to an application server at an interval in the foregoing heartbeat sending manner, to keep the application program online. Each time each running application program sends a heartbeat, the terminal needs to request a data transmission connection from a network device of a mobile network, and exchange a heartbeat and a heartbeat response with the application server by means of the data transmission connection.

    [0038] However, each time the terminal establishes a data transmission connection to the network device of the mobile network, the terminal needs to occupy a signaling resource of a control layer of the mobile network. For example, in a packet domain network architecture, the terminal needs to activate the Packet Data Protocol (Packet Data Protocol, PDP) on one side by means of signaling interaction with the network device of the mobile network, the network device assigns an IP address to the terminal, and then, the terminal uses the IP address to perform data transmission with a network communications peer device in a data network. Therefore, frequent transmission of heartbeat messages occupies a large quantity of signaling resources of the control layer of the mobile network, and when multiple application programs in the terminal are online, this case is severer, thereby affecting normal running of another service, and reducing network service quality of the mobile network.

    [0039] The Android 4.4 system is obtained by optimizing the Android 4.3 system, and performs combination and batch processing on some heartbeats of applications running on a terminal, as shown in FIG. 2. The terminal includes running application programs a1, a2, and a3. The application programs a1, a2, and a3 separately send heartbeats to application servers at different intervals. The Android 4.4 system performs batch processing on heartbeats whose sending times are adjacent and close to each other. For example, in the first part, times at which the terminal sends heartbeats of a1 and a2 are adjacent and close to each other, and combination processing may be performed on the sending of the two heartbeats. For example, one time point is selected from the sending times of the heartbeats of a1 and a2 to send a heartbeat b1. The heartbeat b1 includes the heartbeats of the applications a1 and a2. It may be understood that, performing combination processing on the sending of the two heartbeats herein may be combining the heartbeats of a1 and a2 for sending, or may be sending the heartbeats of a1 and a2 successively at the sending time points. In other words, the heartbeat b1 may be two heartbeats, and is a collective term for the heartbeats of a1 and a2; or the heartbeat b1 may be one heartbeat into which the heartbeats of a1 and a2 are combined. If the heartbeats of a1 and a2 are combined into the heartbeat b1, a network device needs to separately forward the heartbeats of a1 and a2 to corresponding application servers. In the second part, times at which the terminal sends heartbeats of a2 and a1 are adjacent and close to each other, and combination processing may be performed on the sending of the two heartbeats. One time point is selected from the sending times of the heartbeats of a2 and a1 to send a heartbeat b2. The heartbeat b2 includes the heartbeats of the applications a2 and a1. In the third part, times at which the terminal sends heartbeats of a2 and a3 are adjacent and close to each other, and combination processing is performed on the sending of the two heartbeats. One time point may be selected from the sending times of the heartbeats of a2 and a3 to send a heartbeat b3. The heartbeat b3 includes the heartbeats of the applications a2 and a3. The rest can be deduced by analogy.

    [0040] Although the Android 4.4 system performs batch processing on running heartbeats, it may be seen that, after the batch processing, an interval at which heartbeats are sent is still short, and activities are frequent. Consequently, overall power consumption of the terminal is still large

    [0041] Unifying heartbeats refers to unifying multiple application programs running on a terminal, to send heartbeats simultaneously or successively at one determined interval. When a unified heartbeat interval arrives, the terminal establishes a data transmission connection to a network device, and sends heartbeats corresponding to the multiple application programs to corresponding application servers by means of the established data transmission connection. The unified heartbeat interval of the terminal is a heartbeat sending interval that makes application programs currently running on the terminal and corresponding application servers online. When the network connection is unblocked, if the terminal sends the heartbeats of the multiple running application programs and receives heartbeat responses of the application servers at the unified heartbeat interval, the application programs and the corresponding application servers always remain online, and no new connection needs to be established for interaction between the application programs and the corresponding application servers. It may be understood that, the unified heartbeat interval is related to an application program currently running on the terminal. When an application program is enabled or an application program is disabled, the unified heartbeat interval may change.

    [0042] An Android platform allows a process to run in the background, such as a message push or network data synchronization. Consequently, when a screen is off and a terminal enters a standby state, network resources are frequently occupied, and standby power consumption is relatively large. A main reason is that after the screen is off, applications still access a network by using data services. To resolve a problem that the power consumption is excessively large when the screen is off, some vendors directly disable a data service when the screen is off for over 30 minutes or over one hour, to reduce the power consumption. However, within a time shorter than one hour or 30 minutes, the standby power consumption is still large. According to current analyses of actually measured data of a large quantity of users, during normal use, each user performs a screen-on operation once every more than 10 minutes on average. Therefore, an effective scope of a network disconnection function for over 30 minutes or over one hour is limited, and the function is effective only when a mobile phone is not used for a long time, for example, during sleep at night. If a data service is disabled as soon as the screen of the terminal is off, to reduce the power consumption, a service running on the terminal is affected. For example, a user is chatting with a friend by using WeChat. When the screen is off after a message is sent, if the terminal directly disables a data service in this case, the user cannot receive a reply message of the friend in a timely manner. Apparently, user experience is affected. Therefore, for the foregoing case, the terminal needs to be further optimized to reduce the standby power consumption.

    [0043] An embodiment of the present invention provides some solutions to resolve the foregoing problem. A mobile phone is used as an example. A networking architecture in this embodiment of the present invention is shown in FIG. 3.

    [0044] The networking architecture includes a terminal and a network device. A part A is the terminal, and a part B and a part C is the network device. The part B is optional.

    [0045] Part A: A network agent related to network access may be established in the terminal, and all data exchanged between the terminal and the network device is received and sent by the network agent.

    [0046] Part B: This is an optional part. The network device may include a network server of a terminal equipment vendor. A communications link is established between the network agent in the terminal and the network server of the terminal equipment vendor. Interaction between the terminal and the network server is processed according to a unified heartbeat interval. All network requests of application programs in the terminal are forwarded by the network server to corresponding application servers. The network server of the terminal equipment vendor performs unified management on interaction between the terminal and a network. Provided that it is ensured that the link is unblocked during heartbeat running, the application programs in the terminal and the corresponding servers corresponding to the application programs are all online.

    [0047] Part C: The network device includes a third-party application server. The third-party application server is an application server corresponding to an application program running on the terminal. The network server of the terminal equipment vendor may interact with the third-party application server, and serve as an agent of all terminal devices. It should be understood that, the application program in this embodiment of the present invention does not include a local application program, that is, does not include an application program that does not interact with the third-party application server.

    [0048] If the network device does not include the network server of the terminal equipment vendor, the network agent in the terminal may separately send heartbeats of currently running application programs to the third-party application server when a unified heartbeat arrives. It may be understood that, when the terminal sends a heartbeat or another interaction message to the network server of the terminal equipment vendor or the third-party application server, some other devices such as a base station and a WiFi device in the network may be used. All of the content can be understood by a person skilled in the art, and details are not described in this embodiment of the present invention.

    [0049] Optionally, the network agent in the terminal may be a timing management service unit, and the timing management service unit may set a timer according to an indication. A unified heartbeat interval may be set for the terminal by using the timing management service unit, and when it is notified that the unified heartbeat interval arrives, the terminal is woken up at a time indicated by the timer, to send a heartbeat to an application server corresponding to an online application program in the terminal.

    [0050] Embodiment 1 of the present invention discloses a method for interaction between a terminal and a network device, so that standby power consumption can be reduced when a user is unaware, a running application program remains not suspended and disabled, and a heartbeat does not stop. The following describes a specific implementation process of the solution by using an example in which a terminal is a mobile phone, as shown in FIG. 4.

    [0051] S102. The mobile phone is in a screen-on state.

    [0052] For example, a screen of the mobile phone is in an on state, a user is chatting with a friend by using WeChat, and the mobile phone normally communicates with a network device. In addition, application programs running on the mobile phone further include Facebook and Sina Weibo.

    [0053] Optionally, a network agent may be included in the mobile phone. The network agent in the mobile phone manages all network sessions on a mobile phone side that are exchanged between the mobile phone and the network device. For example, data sent by an application program running on the mobile phone to the network device is all sent by using the network agent, and data received by the mobile phone is all sent to a corresponding application program by using the network device.

    [0054] Optionally, the network device may include a network server of a terminal equipment vendor. The mobile phone interacts with a third-party server by using the network server of the terminal equipment vendor. Herein, the terminal equipment vendor is a manufacturer of the mobile phone. For example, if the mobile phone used by the user is Huawei mate 7, the server of the terminal equipment vendor is a Huawei server; if the mobile phone used by the user is iPhone 6, the server of the terminal equipment vendor is an Apple server, and so on. The third-party server refers to a server corresponding to an application program, such as a WeChat server, a Facebook server, or a Sina server.

    [0055] S104. At a moment 0, the mobile phone sends a first heartbeat to a network device.

    [0056] For example, the first heartbeat includes a heartbeat sent by each of three application programs running on the mobile phone to an application server corresponding to each of the three application programs, for example, a heartbeat sent by WeChat to the WeChat server, a heartbeat sent by Facebook to the Facebook server, and a heartbeat sent by Sina Weibo to the Sina server. If the network device does not include the network server of the terminal equipment vendor, the mobile phone separately sends, at the moment 0, a heartbeat to the application server corresponding to each application program. If the network device includes the network server of the terminal equipment vendor, the mobile phone sends heartbeats to the network server of the terminal equipment vendor. The network server of the terminal equipment vendor separately forwards the received heartbeats to corresponding third-party servers, that is, the WeChat server, the Facebook server, and the Sina server. The mobile phone sends a heartbeat to a third-party server at a unified heartbeat interval t. That the mobile phone sends a heartbeat to the network server of the terminal equipment vendor may be that the mobile phone combines heartbeats of all running application programs for sending, or may be that the mobile phone separately sends heartbeats of all running application programs to the network server of the terminal equipment vendor. The first heartbeat is a collective term for heartbeats sent by currently running application programs to corresponding application servers, so that the application servers know that the application servers are "online".

    [0057] Application programs running on the terminal may include an application program running in the foreground and an application program running in the background. The application program running in the foreground refers to an application program that is running in a window and whose running interface can directly interact with the user. The application program running in the background refers to an application program that is running on a resource manager and that does not have an interface or whose interface cannot directly interact with the user but that occupies a system resource. After the screen of the terminal is off, all running application programs may be considered as background application programs or background applications.

    [0058] S106. After receiving the first heartbeat, the network device returns a first heartbeat response to the mobile phone.

    [0059] For example, after receiving first heartbeats, the WeChat server, the Facebook server, and the Sina server return first heartbeat responses to the mobile phone. If the network device does not include the network server of the terminal equipment vendor, the application server corresponding to each application program in the mobile phone separately sends a first heartbeat response to the mobile phone. If the network device includes the network server of the terminal equipment vendor, the application servers corresponding to all the application programs, that is, the WeChat server, the Facebook server, and the Sina server, separately send the first heartbeat responses to the network server of the terminal equipment vendor, and then, the network server of the terminal equipment vendor forwards the received first heartbeat responses to the mobile phone. First heartbeat responses received by the mobile phone include the first heartbeat responses of the three application programs running on the mobile phone, that is, WeChat, Facebook, and Sina Weibo. The network server of the terminal equipment vendor may combine the first heartbeat responses of the three application programs, and send a heartbeat response obtained by means of combination to the mobile phone, and then, the network agent of the mobile phone separately forwards the heartbeat responses to the corresponding application programs. Alternatively, the network server of the terminal equipment vendor may separately send the received first heartbeat responses of the three application programs to the mobile phone.

    [0060] S108. Obtain a status of a screen of the mobile phone, and perform a corresponding operation.

    [0061] For example, after receiving the first heartbeat response, the mobile phone immediately obtains the status of the screen of the mobile phone. Alternatively, after receiving the first heartbeat response, the mobile phone may obtain the status of the screen of the mobile phone after a predetermined time. When the screen of the mobile phone is in an on state, the mobile phone normally interacts with the network device, and does not perform other processing.

    [0062] S110. Turn off the screen of the mobile phone.

    [0063] For example, after sending a message to a friend by using WeChat, the user presses a button to turn off the screen. In this case, only the screen of the mobile phone is in an off state, but the mobile phone is not powered off. All application programs running on the mobile phone may be considered as background applications.

    [0064] S112. At a moment t, the mobile phone sends a second heartbeat to the network device.

    [0065] For example, the heartbeat is a unified heartbeat of all application programs running on the mobile phone, for example, WeChat, Facebook, and Sina Weibo. It may be understood that, if the application programs that are running on the mobile phone when the first heartbeat is sent in S104 are the same as the application programs that are running when the second heartbeat is sent in S112, the unified heartbeat interval at which the mobile phone sends a heartbeat may not change. If after S104, the user enables another application program or disables some application programs, the unified heartbeat interval at which the mobile phone sends a heartbeat may vary according to different running application programs. A manner in which the mobile phone sends the second heartbeat to the network device is the same as a manner of sending the first heartbeat. Details are not described herein again.

    [0066] S114. After receiving the second heartbeat, the network device returns a second heartbeat response to the mobile phone.

    [0067] For example, after receiving second heartbeats, the WeChat server, the Facebook server, and the Sina server return second heartbeat responses to the mobile phone. A manner in which the WeChat server, the Facebook server, and the Sina server send the second heartbeat responses to the mobile phone is the same as a manner of sending the first heartbeat responses. Details are not described herein again.

    [0068] S116. Obtain the status of the screen of the mobile phone, and perform a corresponding operation.

    [0069] For example, after the mobile phone receives the second heartbeat response, if the screen of the mobile phone is in an off state, and duration of the off state is not greater than T1, the mobile phone releases network link resources of a connection between the mobile phone and the network device. After the mobile phone releases the network link resources, a modem is in an idle state (Idle State), and does not interact with an air interface any longer. Therefore, the mobile phone cannot exchange data with the network device. Optionally, the mobile phone may release the network link resources by using a radio resource control (Radio Resource Control, RRC) release interface such as an RRC release interface.

    [0070] If the screen of the mobile phone is in an off state, and duration of the off state is greater than T1 and not greater than T2, where T2>T1>0, a background application of the mobile phone is prohibited from accessing the network device. When the background application of the mobile phone is prohibited from accessing the network device, the mobile phone and the network device may remain connected. However, alternatively, if a time during which the mobile phone does not interact with the network device exceeds a threshold, the mobile phone may release network link resources.

    [0071] Optionally, the mobile phone may prohibit some application programs from accessing the network device. For example, the mobile phone may allow a specific proportion of application programs to access a network, and prohibit other application programs from accessing the network. Alternatively, the mobile phone may prohibit some preset application programs from accessing a network, or the mobile phone may prohibit some application programs that frequently interact with a network or that exchange a large amount of data with a network from accessing the network. By determining, through statistics, whether a quantity of interaction times or a size of interaction traffic exceeds a corresponding threshold, the mobile phone may determine whether the application program frequently interacts with the network or exchanges a relatively large amount of data with the network.

    [0072] If the screen of the mobile phone is in an off state, and duration of the off state is greater than T2, a data service of the terminal is disabled.

    [0073] Optionally, if the screen of the mobile phone is in an off state and the duration of the off state is not greater than T1 when the mobile phone receives the second heartbeat response, the network link resources of the connection between the mobile phone and the network device are released. If the duration of the off state of the screen of the mobile phone reaches T1 before a next unified heartbeat interval arrives, the background application of the mobile phone is prohibited from accessing the network device; or if the duration of the off state of the screen of the mobile phone reaches T2 before a next unified heartbeat interval arrives, the data service of the mobile phone is disabled.

    [0074] S118. Before a unified heartbeat interval arrives, the mobile phone restores a normal connection to the network device.

    [0075] For example, if the network link resources of the mobile phone and the network device are released, the mobile phone restores the network link resources of the connection to the network device. The mobile phone establishes a connection to the network device again, and the modem is switched from the idle state to a running state.

    [0076] It may be understood that, the network link resources may be completely the same as or may be not completely the same as network link resources existing when the first heartbeat is sent. For example, time frequency resources allocated on a network side may be different. However, in another aspect such as a network protocol, there is no substantial difference between the network link resources established in this step and the network link resources existing when the first heartbeat is sent. It may be considered that, the network link resources established in this step are the same as the network link resources existing when the first heartbeat is sent.

    [0077] If the background application of the mobile phone is prohibited from accessing the network device, the mobile phone allows the background application to access the network device.

    [0078] If the data service of the mobile phone is disabled, the data service of the mobile phone is enabled.

    [0079] For example, if the screen of the mobile phone is in an off state and the duration of the off state is less than T1 after the mobile phone receives the first heartbeat response, and the duration of the off state is greater than T1 and less than T2 before the current unified heartbeat interval of the mobile phone arrives, the mobile phone restores the network link resources of the connection to the network device, and allows the background application of the mobile phone to access the network device.

    [0080] S120. At a moment 2t, the mobile phone sends a third heartbeat to the network device.

    [0081] For example, the heartbeat is a unified heartbeat of all application programs running on the mobile phone, for example, WeChat, Facebook, and Sina Weibo. A manner in which the mobile phone sends the third heartbeat to the network device is the same as manners of sending the first and second heartbeats. Details are not described herein again.

    [0082] S122. After receiving the third heartbeat, the network device returns a third heartbeat response to the mobile phone.

    [0083] For example, after receiving third heartbeats, the WeChat server, the Facebook server, and the Sina server return third heartbeat responses to the mobile phone. A manner in which the WeChat server, the Facebook server, and the Sina server send the third heartbeat responses to the mobile phone is the same as manners of sending the first and second heartbeat responses. Details are not described herein again.

    [0084] S124. The mobile phone periodically sends and receives a heartbeat at a unified heartbeat interval t, and obtains the status of the screen of the mobile phone to perform a corresponding operation.

    [0085] For example, before the screen of the mobile phone is lighted up, at the unified heartbeat interval t, the mobile phone sends a heartbeat to the network device and receives a heartbeat response returned by the network device, and the mobile phone determines duration of an off state of the screen of the mobile phone each time the mobile phone receives the heartbeat response, to perform a corresponding operation. Refer to S116. Details are not described herein again.

    [0086] S126. A user lights up the screen of the mobile phone, and the mobile phone normally communicates with the network device.

    [0087] For example, after the user operates the mobile phone, and lights up the screen of the mobile phone, the mobile phone normally interacts with the network device. That is, after the mobile phone receives a heartbeat response, when learning that the screen of the mobile phone is in an on state, the mobile phone does not perform other processing, and keeps a normal connection to the network device. It should be understood that, in this embodiment, that the mobile phone does not perform other processing is that the mobile phone does not perform processing other than normal interaction with the network device, for example, processing related to releasing the network link resources of the connection between the terminal and the network device, and/or prohibiting the background application of the terminal from accessing the network device, and/or disabling the data service of the terminal in S116.

    [0088] Optionally, the mobile phone may start one timekeeper/timer or multiple timekeepers/timers to perform timekeeping. For the heartbeat interval t, and the duration T1 and T2 of the off state of the screen of the mobile phone, one timekeeper may be started to perform timekeeping, or two or three timekeepers may be started to perform timekeeping, or more timekeepers may be started to perform timekeeping. This is not limited in the present invention.

    [0089] Optionally, after the mobile phone receives a heartbeat response, if the screen of the mobile phone is in an off state, and duration of the off state is not greater than T1, the mobile phone releases network link resources of a connection between the mobile phone and the network device. Before a next heartbeat interval arrives, the mobile phone may continue to determine whether the duration of the off state of the screen is greater than T1. If the duration of the off state of the mobile phone reaches T1, a background application of the mobile phone is prohibited from accessing the network device. If the duration of the off state of the mobile phone reaches T2, a data service of the mobile phone is disabled. The mobile phone may set a timekeeper, so that when the duration of the off state of the mobile phone reaches T1, the mobile phone may be triggered to prohibit the background application from accessing the network device. The mobile phone may set a timekeeper, so that when the duration of the off state of the screen of the mobile phone reaches T2, the mobile phone may be triggered to disable the data service of the mobile phone. Alternatively, before a next heartbeat interval arrives, the mobile phone may not continue to determine the duration of the off state of the screen. For example, after the mobile phone receives the heartbeat response, if the duration of the off state of the screen of the mobile phone is not greater than T1, the mobile phone releases the network link resources of the connection between the mobile phone and the network device, and then, does not determine, before the next heartbeat interval arrives, whether the duration of the off state of the screen is greater than T1 or T2.

    [0090] Optionally, in another optional implementation manner of S116, after the mobile phone receives a heartbeat response, if the screen of the mobile phone is in an off state, and if duration of the off state is not greater than T1, the mobile phone releases network link resources of a connection between the mobile phone and the network device; or if duration of the off state is not greater than T2, the mobile phone disables a data service of the mobile phone; or if duration of the off state is greater than T2, the mobile phone prohibits a background application of the mobile phone from accessing the network device.

    [0091] Optionally, in another optional implementation manner of S116, after the mobile phone receives a heartbeat response, if the screen of the mobile phone is in an off state, and if duration of the off state is not greater than T1, the mobile phone prohibits a background application of the mobile phone from accessing the network device; or if duration of the off state is greater than T1 and not greater than T2, the mobile phone releases network link resources of a connection between the mobile phone and the network device; or if duration of the off state is greater than T2, the mobile phone disables a data service of the mobile phone.

    [0092] Optionally, in another optional implementation manner of S116, after the mobile phone receives a heartbeat response, if the screen of the mobile phone is in an off state, and if duration of the off state is not greater than T1, the mobile phone prohibits a background application of the mobile phone from accessing the network device; or if duration of the off state is greater than T1 and not greater than T2, the mobile phone disables a data service of the mobile phone; or if duration of the off state is greater than T2, the mobile phone releases network link resources of a connection between the mobile phone and the network device.

    [0093] Optionally, in another optional implementation manner of S116, after the mobile phone receives a heartbeat response, if the screen of the mobile phone is in an off state, and if duration of the off state is not greater than T1, the mobile phone disables a data service of the mobile phone; or if duration of the off state is greater than T1 and not greater than T2, the mobile phone prohibits a background application of the mobile phone from accessing the network device; or if duration of the off state is greater than T2, the mobile phone releases network link resources of a connection between the mobile phone and the network device.

    [0094] Optionally, in another optional implementation manner of S116, after the mobile phone receives a heartbeat response, if the screen of the mobile phone is in an off state, and if duration of the off state is not greater than T1, the mobile phone disables a data service of the mobile phone; or if duration of the off state is greater than T1 and not greater than T2, the mobile phone releases network link resources of a connection between the mobile phone and the network device; or if duration of the off state is greater than T2, the mobile phone prohibits a background application of the mobile phone from accessing the network device.

    [0095] Optionally, after the mobile phone receives a heartbeat response, if the screen of the mobile phone is in an off state, the mobile phone may use only a single policy, and does not need to determine duration of the off state of the screen of the mobile phone. For example, if the screen of the mobile phone is in an off state, the mobile phone releases network link resources; or if the screen of the mobile phone is in an off state, the mobile phone prohibits a background application from accessing the network device; or if the screen of the mobile phone is in an off state, the mobile phone disables a data service.

    [0096] In this embodiment of the present invention, after a terminal receives a heartbeat response, if a screen is in an off state, and optionally, the off state lasts for a preset period of time, the terminal may release network link resources of a connection between the terminal and the network device, and/or prohibit a background application of the terminal from accessing the network device, and/or disable a data service of the terminal, and restore a status of network connection to a normal connection state before sending a heartbeat again. In this way, when the screen is off between two heartbeats, and optionally, the off state lasts for a preset period of time, data exchange between an application program and the network device is interrupted, so that power consumption of the terminal can be effectively reduced when both the terminal and an application server to which the application program belongs are online and a user is unaware.

    Example



    [0097] This example is an experiment performed on the basis of Embodiment 1, and a mobile phone in the 3G standard is used as an example of a terminal in this embodiment. The terminal releases network link resources by using t as an interval, and enables a modem to enter a sleep state, and t is a unified heartbeat interval of the terminal. In this example, the mobile phone releases the network link resources by using a radio resource control (Radio Resource Control, RRC) release interface.

    [0098] Some daily applications, for example, WeChat, QQ, Netease News, Zarek, and Dianping, are installed and run on the mobile phone in the 3G standard in this example. The mobile phone may first obtain, by means of calculation, a unified heartbeat of a currently running application program. There are multiple implementation manners of calculating the unified heartbeat. The unified heartbeat of the mobile phone may be preset empirically or by using another condition.

    [0099] As shown in FIG. 5, this example may include the following steps.

    [0100] S202. At a moment 0, the mobile phone sends a heartbeat.

    [0101] The mobile phone communicates with a network device by using a 3G network. Application programs that are running on the mobile phone separately send heartbeats to application servers corresponding to the application programs. It may be understood that, another network device in the 3G network, for example, a base station, that may be used when the mobile phone sends a heartbeat to an application server is content well-known by a person skilled in the art, and details are not described herein.

    [0102] S204. The mobile phone receives a heartbeat response.

    [0103] The mobile phone receives heartbeat responses returned by the application servers. After receiving the heartbeats, the application servers separately return the heartbeat responses to the mobile phone.

    [0104] S206. The mobile phone releases network link resources if a screen of the mobile phone is in an off state.

    [0105] After receiving the heartbeat responses, the mobile phone obtains a status of the screen of the mobile phone. If the screen of the mobile phone is in an off state, the RRC release interface is used to release network link resources of a connection between the mobile phone and the network, so that the modem is in an idle state.

    [0106] S208. The mobile phone restores the network link resources.

    [0107] When a unified heartbeat interval is about to arrive, the mobile phone restores the network link resources, so that the mobile phone is normally connected to the network. The modem is switched from the idle state to a running state, and establishes a connection to the network device again.

    [0108] S210. At a moment t, the mobile phone sends a heartbeat.

    [0109] When the unified heartbeat interval arrives, the mobile phone sends heartbeats to application servers corresponding to currently running application programs.

    [0110] S212. The mobile phone receives a heartbeat response.

    [0111] The mobile phone receives heartbeat responses returned by the application servers. After receiving the heartbeats, the application servers separately return the heartbeat responses to the mobile phone.

    [0112] S214. Periodically perform S202 to S212 until the screen of the mobile phone is in an on state.

    [0113] In other words, the mobile phone periodically sends, at a unified heartbeat interval t, a heartbeat to an application server corresponding to an application program running on the mobile phone, and receives a heartbeat response. Each time the mobile phone receives the heartbeat response, the mobile phone releases the network link resources and is disconnected from the network, and before a next heartbeat interval arrives, the mobile phone restores the network link resources and establishes a connection to the network again, until a user lights up the screen of the mobile phone.

    [0114] In the actual measurement experiment in this example, an average current of the mobile phone for three hours is 15.351 mA with use of the foregoing method, and is 7 mA less than an average current 22.268 mA for three hours without use of the foregoing method, and gains reach 31.1%. In the method in this example, power consumption can be reduced and a standby time of a mobile phone can be prolonged when a user is unaware and an application program heartbeat is kept.

    [0115] In this example, after a terminal receives a first heartbeat response, if it is determined that a screen is in an off state, the terminal interrupts, by releasing network link resources, data exchange between an application program in the terminal and a network device, and restores the network link resources before sending a second heartbeat, so that power consumption of the terminal can be effectively reduced when both the terminal and an application server to which the application program belongs are online and a user is unaware.

    Embodiment 3



    [0116] Embodiment 3 of the present invention provides a terminal 300. A structural diagram of the terminal 300 is shown in FIG. 6, and the terminal 300 is configured to execute the methods in Embodiment 1 and the example. All solutions and features that can be implemented in Embodiment 1 and the are applicable to this embodiment, and details are not described herein again.

    [0117] The terminal 300 includes a sending module 310, a receiving module 320, and a processing module 330. It may be understood that, the sending module 310 and the receiving module 320 may also be integrated into a transceiver module.

    [0118] In an implementation manner,

    the sending module is configured to send a first heartbeat to a network device;

    the receiving module is configured to receive a first heartbeat response returned by the network device, where the first heartbeat response is a response corresponding to the first heartbeat;

    the processing module is configured to: after the receiving module receives the first heartbeat response, if a screen of the terminal is in an off state, and if duration of the off state is not greater than T1, release network link resources of a connection between the terminal and the network device; or if duration of the off state is greater than T1 and not greater than T2, where T2>T1>0, prohibit a background application of the terminal from accessing the network device; or if duration of the off state is greater than T2, disable a data service of the terminal;

    before the sending module sends a second heartbeat to the network device, the processing module is further configured to execute the following:

    if the network link resources of the connection between the terminal and the network device are released, restoring the network link resources; or

    if the background application of the terminal is prohibited from accessing the network device, allowing the background application of the terminal to access the network device; or

    if the data service of the terminal is disabled, enabling the data service of the terminal;

    the sending module is further configured to send the second heartbeat to the network device; and

    the receiving module is further configured to receive a second heartbeat response returned by the network device, where the second heartbeat response is a response corresponding to the second heartbeat.



    [0119] Optionally, N application programs run on the processing module, N is an integer, N is greater than 1, and the first heartbeat includes a heartbeat sent by each of the N application programs to an application server corresponding to each of the N application programs.

    [0120] Optionally, the terminal may further include a network agent module. The network agent module may also be integrated into the processing module 330. The N application programs send heartbeats to the network device by using the network agent in the terminal.

    [0121] Optionally, the network device includes a network server of a terminal equipment vendor corresponding to the terminal. That the sending module sends the first heartbeat to the network device may be that the sending module sends the first heartbeat to the network server, and then, the network server forwards the first heartbeat to application servers corresponding to the N application programs.

    [0122] In another implementation manner,

    the processing module 330 is configured to: after the receiving module 320 receives the first heartbeat response, if a screen of the terminal is in an off state, release network link resources of a connection between the terminal and the network device; and

    before the sending module 310 sends a second heartbeat to the network device, the processing module 330 is further configured to restore the network link resources.



    [0123] In another implementation manner,

    the processing module 330 is configured to: after the receiving module 320 receives the first heartbeat response, if a screen of the terminal is in an off state, prohibit a background application of the terminal from accessing the network device; and

    before the sending module 310 sends a second heartbeat to the network device, the processing module 330 is further configured to allow the background application of the terminal to access the network device.



    [0124] In another implementation manner,

    the processing module 330 is configured to: after the receiving module 310 receives the first heartbeat response, if a screen of the terminal is in an off state, disable a data service of the terminal; and

    before the sending module 320 sends a second heartbeat to the network device, the processing module 330 is further configured to enable the data service of the terminal.



    [0125] The terminal 300 in this embodiment may be further configured to implement another implementation manner in Embodiment 1 or the example. For concise description, details are not described herein again.

    [0126] In this embodiment of the present invention, after a terminal receives a heartbeat response, if a screen is in an off state, the terminal releases network link resources of a connection between the terminal and the network device/prohibits a background application of the terminal from accessing the network device/disables a data service of the terminal, and restores a status of the network connection to a normal connection state before sending a heartbeat again. In this way, when the screen is off between two heartbeats, data exchange between an application program and the network device is interrupted, so that power consumption of the terminal can be effectively reduced when both the terminal and an application server to which the application program belongs are online and a user is unaware.

    [0127] Embodiment 4 of the present invention further provides a terminal 400. A schematic diagram of a hardware structure of the terminal 400 is shown in FIG. 7. The terminal 400 is configured to execute the methods in Embodiment 1 and example. All solutions and features that can be implemented in Embodiment 1 and example are applicable to this embodiment, and details are not described herein again.

    [0128] The terminal 400 includes a processor 160, a memory 120, a transceiver 406, and a bus 408. The processor 160, the memory 120, and the transceiver 406 communicate with each other by using the bus 408. It may be understood that, although the processor 160 and the memory 120 in the terminal that are shown in FIG. 5 are the same as the processor 160 and the memory 120 in FIG. 1, the terminal 400 in this embodiment is not limited to a mobile phone, and structures of the processor, the memory, and the like in the terminal 400 may be related to the structure of the mobile phone 100 but be not limited by the structure of the mobile phone. It may be understood that, the terminal may further include a screen, configured to display information, for example, the display unit 140 in FIG. 1, or may include only the display panel 141.

    [0129] The processor 160 includes an application processor (Application Processor, AP) and a communication processor (Communication Processor, CP). The application processor mainly processes an operating system, a user interface, an application program, and the like. The communication processor may also be referred to as a baseband processor (Baseband Processor, BP), and mainly processes wireless communication. The transceiver 406 may include the RF circuit 110 and/or the WiFi module 180 in FIG. 1. The terminal 400 may communicate with a network device by using the transceiver 406. The transceiver 406 may send data to the network device, and receive data from the network device. For a structure of the terminal 400, refer to FIG. 1 and specific descriptions of components of the mobile phone 100, and details are not described herein again.

    [0130] The processor 160 may include a network agent. All data exchanged between the terminal and the network device is received and sent by the network agent. Specifically, the network agent may be a software module of the processor 160. Optionally, the network agent may be a software module in the AP.

    [0131] Specifically, in an implementation manner,
    the processor 160 may be configured to send a first heartbeat to the network device. It may be understood that, the processor 160 sends, to the transceiver 406, the first heartbeat that is to be sent to the network device, and then, the transceiver sends the first heartbeat to the network device. When N application programs run on the processor 160, the first heartbeat includes a heartbeat sent by each of the N application programs to an application server corresponding to each of the N application programs. N is a positive integer. If the network device does not include a network server of a terminal equipment vendor, the processor 160 separately sends a heartbeat to the application server corresponding to each application program. If the network device includes a network server of a terminal equipment vendor, the processor 160 sends a heartbeat to the network server of the terminal equipment vendor. The network server of the terminal equipment vendor separately forwards received heartbeats to corresponding application servers.

    [0132] The processor 160 is further configured to receive a first heartbeat response returned by the network device. Likewise, the first heartbeat response received by the processor is received by the transceiver 406 from the network device. The first heartbeat response is a heartbeat response returned by the application server corresponding to each of the N application programs. If the network device does not include the network server of the terminal equipment vendor, the application server corresponding to each application program separately sends a first heartbeat response to the terminal. If the network device includes the network server of the terminal equipment vendor, the application servers corresponding to all the application programs separately send first heartbeat responses to the network server of the terminal equipment vendor, and then, the network server of the terminal equipment vendor forwards the received first heartbeat responses to the terminal.

    [0133] The processor 160 is further configured to: after receiving the first heartbeat response, obtain a status of the screen, and if the screen of the terminal is in an off state, and if duration of the off state is not greater than T1, release network link resources of a connection between the terminal and the network device; or if duration of the off state is greater than T1 and not greater than T2, where T2>T1>0, prohibit a background application of the terminal from accessing the network device; or if duration of the off state is greater than T2, disable a data service of the terminal.

    [0134] Before sending a second heartbeat to the network device, the processor 160 is further configured to execute the following:

    if the network link resources of the network agent and the network device are released, restoring the network link resources; or

    if the background application of the terminal is prohibited from accessing the network device, allowing the background application of the terminal to access the network device; or

    if the data service of the terminal is disabled, enabling the data service of the terminal.



    [0135] The processor 160 may be further configured to send the second heartbeat to the network device. A manner of sending the second heartbeat is the same as a manner of sending the first heartbeat, and details are not described herein again.

    [0136] The processor 160 is further configured to receive a second heartbeat response. A manner of receiving the second heartbeat is the same as a manner of receiving the first heartbeat, and details are not described herein again.

    [0137] Optionally,

    in another optional implementation manner,

    the processor 160 obtains a status of the screen after receiving the first heartbeat response, and if the screen of the terminal is in an off state, the processor 160 may release network link resources of a connection between the terminal and the network device; or the processor 160 may prohibit a background application of the terminal from accessing the network device; or the processor 160 may disable a data service of the terminal. In this implementation manner, the processor may not need to obtain duration of the off state of the screen.



    [0138] Before sending a second heartbeat to the network device, the processor 160 is further configured to execute the following:

    if the network link resources of the network agent and the network device are released, restoring the network link resources; or

    if the background application of the terminal is prohibited from accessing the network device, allowing the background application of the terminal to access the network device; or

    if the data service of the terminal is disabled, enabling the data service of the terminal.



    [0139] The terminal 400 may be further configured as a terminal for implementing another implementation manner. For details, refer to the optional implementation manners in Embodiment 1, and details are not described herein again.

    [0140] In the solution provided in this embodiment, after a terminal receives a heartbeat response, if a screen is in an off state, the terminal releases network link resources of a connection between the terminal and the network device/prohibits a background application of the terminal from accessing the network device/disables a data service of the terminal, and restores a status of network connection to a normal connection state before sending a heartbeat again. In this way, when the screen is off between two heartbeats, data exchange between an application program and the network device is interrupted, so that power consumption of the terminal can be effectively reduced when both the terminal and an application server to which the application program belongs are online and a user is unaware.

    [0141] It should be understood that, in all the embodiments in the specification, as shown in FIG. 7, the terminal generally includes at least one processor (such as a CPU), at least one transceiver, and at least one bus. The processor is a control center of an electronic device, is connected to parts of the entire electronic device by using various interfaces and lines, and performs various functions and/or data processing of the electronic device by running or executing a software program and/or a module stored in a storage unit and invoking data stored in the storage unit. The processor may include an integrated circuit (Integrated Circuit, IC for short), for example, may include a single packaged IC, or may include multiple connected packaged ICs that have same functions or different functions. For example, the processor may include only a central processing unit (Central Processing Unit, CPU for short), or may be a combination of a GPU, a digital signal processor (Digital Signal Processor, DSP for short), and a control chip (such as a baseband chip) in a communications unit. In an implementation manner of the present invention, the CPU may be a single computing core or may include multiple computing cores.

    [0142] It should be noted that, although only the processor 160, the memory 120, the transceiver 406, and the bus 408 are shown for the terminal 400 shown in FIG. 7, in a specific implementation process, a person skilled in the art should understand that, the terminal 400 further includes another component that is necessary for normal running. In addition, according to a specific requirement, a person skilled in the art should understand that, the terminal 400 may further include a hardware component for implementing another additional function. In addition, a person skilled in the art should understand that, the terminal 400 may include only a component necessary for implementing the embodiments of the present invention, and does not need to include all components shown in FIG. 7.

    [0143] The hardware structure shown in FIG. 7 and the foregoing description are applicable to various terminals provided in the embodiments of the present invention. A person of ordinary skill in the art may understand that all or some of the steps of the foregoing methods may be implemented by a program instructing relevant hardware. The program may be stored in a computer readable storage medium. The storage medium includes a ROM, a RAM, an optical disc, and the like.

    [0144] A person of ordinary skill in the art may be aware that, in combination with the examples described in the embodiments disclosed in the specification, units and algorithm steps can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed by hardware or software depends on particular applications and design constraint conditions of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of the present invention.

    [0145] The foregoing descriptions are merely specific implementation manners of the present invention, but are not intended to limit the protection scope of the present invention. Any variation or replacement readily figured out by a person skilled in the art within the technical scope disclosed in the present invention shall fall within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.


    Claims

    1. A method for interaction between a terminal and a network device, wherein the method comprises:

    sending (S112), by a terminal, a first heartbeat to a network device;

    receiving (S114), by the terminal, a first heartbeat response returned by the network device, wherein the first heartbeat response is a response corresponding to the first heartbeat;

    after receiving the first heartbeat response, upon obtaining that a screen of the terminal is in an off state, while the terminal is not powered off, prohibiting (S116) a background application that is running on the terminal from accessing the network device;

    after prohibiting the background application from accessing the network device and before the terminal sends a second heartbeat which is a heartbeat next to the first heartbeat to the network device, allowing (S118), by the terminal, the background application of the terminal to access the network device;

    then sending (S120), by the terminal, the second heartbeat to the network device; and

    receiving (S122), by the terminal, a second heartbeat response returned by the network device, wherein the second heartbeat response is a response corresponding to the second heartbeat.


     
    2. The method according to claim 1, wherein N application programs run on the terminal, N is an integer, N is greater than 1, and the first heartbeat comprises a heartbeat sent by each of the N application programs to an application server corresponding to each of the N application programs.
     
    3. The method according to claim 2, wherein the N application programs send heartbeats to the network device by using a network agent in the terminal.
     
    4. The method according to either of claim 2 or 3, wherein the network device comprises a network server of a terminal equipment vendor corresponding to the terminal, the first heartbeat is sent to the network server, and the network server is configured to forward the first heartbeat to application servers corresponding to the N application programs.
     
    5. A terminal (400), wherein the terminal (400) comprises:

    a transceiver (406), configured to send and receive data exchanged between the terminal (400) and a network device;

    one or more processors (160);

    a memory (120);

    multiple application programs; and

    one or more programs, wherein the one or more programs are stored in the memory (120) and are configured to be executed by the one or more processors (160), the one or more programs comprise an instruction, and the instruction is used for:

    sending, by the terminal (400), a first heartbeat to the network device;

    receiving, by the terminal (400), a first heartbeat response returned by the network device, wherein the first heartbeat response is a response corresponding to the first heartbeat;

    after receiving the first heartbeat response, upon obtaining that a screen of the terminal is in an off state, while the terminal is not powered off, prohibiting a background application that is running on the terminal from accessing the network device;

    after prohibiting the background application from accessing the network device and before the terminal (400) sends a second heartbeat which is a heartbeat next to the first heartbeat to the network device, allowing, by the terminal (400), the background application of the terminal (400) to access the network device;

    then sending, by the terminal (400), the second heartbeat to the network device; and

    receiving, by the terminal (400), a second heartbeat response returned by the network device, wherein the second heartbeat response is a response corresponding to the second heartbeat.


     
    6. The terminal (400) according to claim 5, wherein N application programs run on the processor, N is an integer, N is greater than 1, and the first heartbeat comprises a heartbeat sent by each of the N application programs to an application server corresponding to each of the N application programs.
     
    7. The terminal (400) according to claim 6, wherein the N application programs send heartbeats to the network device by using a network agent in the terminal (400).
     
    8. The terminal (400) according to either of claim 6 or 7, wherein the network device comprises a network server of a terminal equipment vendor corresponding to the terminal (400), the first heartbeat is sent to the network server, and the network server is configured to forward the first heartbeat to application servers corresponding to the N application programs.
     


    Ansprüche

    1. Verfahren zur Interaktion zwischen einem Endgerät und einer Netzwerkvorrichtung, wobei das Verfahren umfasst:

    Senden (S112), durch ein Endgerät, eines ersten "Heartbeat" an eine Netzwerkvorrichtung;

    Empfangen (S114), durch das Endgerät, einer ersten "Heartbeat"-Antwort, die durch die Netzwerkvorrichtung zurückgegeben wird, wobei die erste "Heartbeat"-Antwort eine Antwort entsprechend dem ersten "Heartbeat" ist;

    nach dem Empfangen der ersten "Heartbeat"-Antwort, nach dem Feststellen, dass ein Bildschirm des Endgeräts in einem Aus-Zustand ist, während das Endgerät nicht ausgeschaltet ist, Verhindern (S116), dass eine Hintergrundanwendung, die auf dem Endgerät ausgeführt wird, auf die Netzwerkvorrichtung zugreift;

    nach dem Verhindern, dass die Hintergrundanwendung auf die Netzwerkvorrichtung zugreift, und bevor das Endgerät einen zweiten "Heartbeat", der ein "Heartbeat" neben dem ersten "Heartbeat" ist, an die Netzwerkvorrichtung sendet, Zulassen (S118), durch das Endgerät, dass die Hintergrundanwendung des Endgeräts auf die Netzwerkvorrichtung zugreift;

    dann Senden (S120), durch das Endgerät, des zweiten "Heartbeat" an die Netzwerkvorrichtung und

    Empfangen (S122), durch das Endgerät, einer zweiten "Heartbeat"-Antwort, die durch die Netzwerkvorrichtung zurückgegeben wird, wobei die zweite "Heartbeat"-Antwort eine Antwort entsprechend dem zweiten "Heartbeat" ist.


     
    2. Verfahren nach Anspruch 1, wobei N Anwendungsprogramme auf dem Endgerät ausgeführt werden, N eine Ganzzahl ist, N größer als 1 ist und der erste "Heartbeat" einen "Heartbeat" umfasst, der durch jedes der N Anwendungsprogramme an einen Anwendungsserver entsprechend jedem der N Anwendungsprogramme gesendet wird.
     
    3. Verfahren nach Anspruch 2, wobei die N Anwendungsprogramme "Heartbeats" durch Verwenden eines Netzwerkagenten im Endgerät an die Netzwerkvorrichtung senden.
     
    4. Verfahren nach einem der Ansprüche 2 oder 3, wobei die Netzwerkvorrichtung einen Netzwerkserver eines Endgerätausrüstungsanbieters entsprechend dem Endgerät umfasst, der erste "Heartbeat" an den Netzwerkserver gesendet wird und der Netzwerkserver zum Weiterleiten des ersten "Heartbeat" an Anwendungsserver entsprechend den N Anwendungsprogrammen ausgelegt ist.
     
    5. Endgerät (400), wobei das Endgerät (400) umfasst:

    einen Transceiver (406), der zum Senden und Empfangen von Daten, die zwischen dem Endgerät (400) und einer Netzwerkvorrichtung ausgetauscht werden, ausgelegt ist;

    einen oder mehrere Prozessoren (160);

    einen Speicher (120);

    mehrere Anwendungsprogramme und

    ein oder mehrere Programme, wobei das eine oder die mehreren Programme in dem Speicher (120) gespeichert und dazu ausgelegt sind, durch den einen oder die mehreren Prozessoren (160) ausgeführt zu werden, das eine oder die mehreren Programme eine Anweisung umfassen und die Anweisung verwendet wird zum:

    Senden, durch das Endgerät (400), eines ersten "Heartbeat" an die Netzwerkvorrichtung;

    Empfangen, durch das Endgerät (400), einer ersten "Heartbeat"-Antwort, die durch die Netzwerkvorrichtung zurückgegeben wird, wobei die erste "Heartbeat"-Antwort eine Antwort entsprechend dem ersten "Heartbeat" ist;

    nach dem Empfangen der ersten "Heartbeat"-Antwort, nach dem Feststellen, dass ein Bildschirm des Endgeräts in einem Aus-Zustand ist, während das Endgerät nicht ausgeschaltet ist, Verhindern, dass eine Hintergrundanwendung, die auf dem Endgerät ausgeführt wird, auf die Netzwerkvorrichtung zugreift;

    nach dem Verhindern, dass die Hintergrundanwendung auf die Netzwerkvorrichtung zugreift, und bevor das Endgerät (400) einen zweiten "Heartbeat", der ein "Heartbeat" neben dem ersten "Heartbeat" ist, an die Netzwerkvorrichtung sendet, Zulassen, durch das Endgerät (400), dass die Hintergrundanwendung des Endgeräts (400) auf die Netzwerkvorrichtung zugreift;

    dann Senden, durch das Endgerät (400), des zweiten "Heartbeat" an die Netzwerkvorrichtung und

    Empfangen, durch das Endgerät (400), einer zweiten "Heartbeat"-Antwort, die durch die Netzwerkvorrichtung zurückgegeben wird, wobei die zweite "Heartbeat"-Antwort eine Antwort entsprechend dem zweiten "Heartbeat" ist.


     
    6. Endgerät (400) nach Anspruch 5, wobei N Anwendungsprogramme auf dem Prozessor ausgeführt werden, N eine Ganzzahl ist, N größer als 1 ist und der erste "Heartbeat" einen "Heartbeat" umfasst, der durch jedes der N Anwendungsprogramme an einen Anwendungsserver entsprechend jedem der N Anwendungsprogramme gesendet wird.
     
    7. Endgerät (400) nach Anspruch 6, wobei die N Anwendungsprogramme "Heartbeats" durch Verwenden eines Netzwerkagenten im Endgerät (400) an die Netzwerkvorrichtung senden.
     
    8. Endgerät (400) nach einem der Ansprüche 6 oder 7, wobei die Netzwerkvorrichtung einen Netzwerkserver eines Endgerätausrüstungsanbieters entsprechend dem Endgerät (400) umfasst, der erste "Heartbeat" an den Netzwerkserver gesendet wird und der Netzwerkserver zum Weiterleiten des ersten "Heartbeat" an Anwendungsserver entsprechend den N Anwendungsprogrammen ausgelegt ist.
     


    Revendications

    1. Procédé pour une interaction entre un terminal et un dispositif de réseau, le procédé comprenant :

    l'envoi (SI 12), par un terminal, d'un premier battement de cœur à un dispositif de réseau ;

    la réception (S114), par le terminal, d'une première réponse à battement de cœur renvoyée par le dispositif de réseau, la première réponse à battement de cœur étant une réponse correspondant au premier battement de cœur ;

    après la réception de la première réponse à battement de cœur, lors de l'obtention qu'un écran du terminal est dans un état éteint, tandis que le terminal n'est pas hors tension, l'interdiction (S116) à une application d'arrière-plan qui tourne sur le terminal d'accéder au dispositif de réseau ;

    après l'interdiction à l'application d'arrière-plan d'accéder au dispositif de réseau et avant que le terminal n'envoie au dispositif de réseau un deuxième battement de cœur qui est un battement de cœur consécutif au premier battement de cœur, l'autorisation (S118), par le terminal, à l'application d'arrière-plan du terminal d'accéder au dispositif de réseau ;

    puis l'envoi (S120), par le terminal, du deuxième battement de cœur au dispositif de réseau ; et

    la réception (S122), par le terminal, d'une deuxième réponse à battement de cœur renvoyée par le dispositif de réseau, la deuxième réponse à battement de cœur étant une réponse correspondant au deuxième battement de cœur.


     
    2. Procédé selon la revendication 1, dans lequel N programmes d'application tournent sur le terminal, N est un nombre entier, N est plus grand que 1, et le premier battement de cœur comprend un battement de cœur envoyé par chacun des N programmes d'application à un serveur d'applications correspondant à chacun des N programmes d'application.
     
    3. Procédé selon la revendication 2, dans lequel les N programmes d'application envoient des battements de cœur au dispositif de réseau en utilisant un agent de réseau dans le terminal.
     
    4. Procédé selon soit la revendication 2, soit la revendication 3, dans lequel le dispositif de réseau comprend un serveur de réseau d'un vendeur d'équipements terminaux correspondant au terminal, le premier battement de cœur est envoyé au serveur de réseau, et le serveur de réseau est configuré de façon à réacheminer le premier battement de cœur aux serveurs d'applications correspondant aux N programmes d'application.
     
    5. Terminal (400), le terminal (400) comprenant :

    un émetteur-récepteur (406), configuré de façon à envoyer et à recevoir des données échangées entre le terminal (400) et un dispositif de réseau ;

    un ou plusieurs processeurs (160) ;

    une mémoire (120) ;

    des programmes d'application multiples ; et

    un ou plusieurs programmes, le ou les programmes étant stockés dans la mémoire (120) et étant configurés de façon à être exécutés par le ou les processeurs (160), le ou les programmes comprenant une instruction, et l'instruction étant utilisée pour :

    envoyer, par le terminal (400), un premier battement de cœur au dispositif de réseau ; recevoir, par le terminal (400), une première réponse à battement de cœur renvoyée par le dispositif de réseau, la première réponse à battement de cœur étant une réponse correspondant au premier battement de cœur ;

    après la réception de la première réponse à battement de cœur, lors de l'obtention qu'un écran du terminal est dans un état éteint, tandis que le terminal n'est pas hors tension, l'interdiction à une application d'arrière-plan qui tourne sur le terminal d'accéder au dispositif de réseau ;

    après l'interdiction à l'application d'arrière-plan d'accéder au dispositif de réseau et avant que le terminal (400) n'envoie au dispositif de réseau un deuxième battement de cœur qui est un battement de cœur consécutif au premier battement de cœur, l'autorisation, par le terminal (400), à l'application d'arrière-plan du terminal (400) d'accéder au dispositif de réseau ;

    puis l'envoi, par le terminal (400), du deuxième battement de cœur au dispositif de réseau ; et

    la réception, par le terminal (400), d'une deuxième réponse à battement de cœur renvoyée par le dispositif de réseau, la deuxième réponse à battement de cœur étant une réponse correspondant au deuxième battement de cœur.


     
    6. Terminal (400) selon la revendication 5, dans lequel N programmes d'application tournent sur le processeur, N est un nombre entier, N est plus grand que 1, et le premier battement de cœur comprend un battement de cœur envoyé par chacun des N programmes d'application à un serveur d'applications correspondant à chacun des N programmes d'application.
     
    7. Terminal (400) selon la revendication 6, dans lequel les N programmes d'application envoient des battements de cœur au dispositif de réseau en utilisant un agent de réseau dans le terminal (400).
     
    8. Terminal (400) selon soit la revendication 6, soit la revendication 7, dans lequel le dispositif de réseau comprend un serveur de réseau d'un vendeur d'équipements terminaux correspondant au terminal (400), le premier battement de cœur est envoyé au serveur de réseau, et le serveur de réseau est configuré de façon à réacheminer le premier battement de cœur aux serveurs d'applications correspondant aux N programmes d'application.
     




    Drawing




















    Cited references

    REFERENCES CITED IN THE DESCRIPTION



    This list of references cited by the applicant is for the reader's convenience only. It does not form part of the European patent document. Even though great care has been taken in compiling the references, errors or omissions cannot be excluded and the EPO disclaims all liability in this regard.

    Patent documents cited in the description