Control method and device, electronic equipment, storage medium and program product

By identifying and filtering unmonitored data transmission ports of electronic devices during sleep mode, the high power consumption problem caused by receiving a large number of invalid data packets in electronic devices is solved, thus improving battery life.

CN121486937APending Publication Date: 2026-02-06BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411067342.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2026-02-06

AI Technical Summary

Technical Problem

When electronic devices are connected to multiple devices, they receive a large number of data packets, resulting in high power consumption and poor battery life.

Method used

By identifying unmonitored data transmission ports during sleep mode and generating filtering instructions, invalid data packets are filtered using network firmware, reducing the frequency of device wake-up.

Benefits of technology

It reduces the power consumption of electronic devices and improves battery life.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121486937A_ABST
    Figure CN121486937A_ABST
Patent Text Reader

Abstract

The invention relates to a control method and device, electronic equipment, a storage medium and a program product. The method comprises the following steps: determining an unmonitored data transmission port; in response to the situation that the electronic equipment is in a dormant state, generating a filtering instruction of the data transmission port in an application framework layer, and sending the filtering instruction to network firmware; and in the dormant state, filtering a data packet of the data transmission port through the network firmware according to the filtering instruction. Through the method, the power consumption of the electronic equipment can be reduced, and the cruising ability is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of device control, and particularly relates to a control method and device, electronic device, storage medium and program product. BACKGROUND

[0002] Generally, an electronic device can establish a communication connection with other devices (for example, gateway devices, terminal devices, etc.) in a network environment and perform data interaction, and process received data packets to support the operation of the electronic device. However, the electronic device will be connected to multiple other devices and perform data interaction, and needs to receive and process a large amount of data packets, resulting in high power consumption and poor endurance of the electronic device. SUMMARY

[0003] To overcome the problems in the related art, the present disclosure provides a control method and device, electronic device, storage medium and program product, which can reduce the power consumption of the electronic device and improve the endurance of the electronic device.

[0004] According to a first aspect of an embodiment of the present disclosure, a control method is provided, comprising:

[0005] determining a data transmission port that is not monitored;

[0006] in response to the electronic device being in a sleep state, generating a filtering instruction of the data transmission port at an application framework layer, and sending the filtering instruction to a network firmware;

[0007] in the sleep state, filtering data packets of the data transmission port by the network firmware according to the filtering instruction.

[0008] In some embodiments, the method further comprises:

[0009] registering a hook function at a kernel layer, and obtaining network data packets to be sent by the electronic device by using the hook function;

[0010] The determination of the data transmission port that is not monitored comprises:

[0011] detecting, at the kernel layer, network data packets that are not monitored in the network data packets, and determining the data transmission port corresponding to the network data packets that are not monitored.

[0012] In some embodiments, the method further comprises:

[0013] sending the data transmission port determined at the kernel layer to a network stack of the application framework layer;

[0014] The method further includes:

[0015] The method further includes:

[0016] The method further includes:

[0017] In some embodiments, the generating the filtering instruction of the data transmission port based on the network stack includes:

[0018] The method further includes:

[0019] The method further includes:

[0020] In some embodiments, the method further includes:

[0021] The method further includes:

[0022] In some embodiments, the method further includes:

[0023] The method further includes:

[0024] In some embodiments, the method further includes:

[0025] The method further includes:

[0026] In some embodiments, the filtering the data packet of the data transmission port according to the filtering instruction by the network firmware in the sleep state includes:

[0027] The method further includes:

[0028] In some embodiments, the method further includes:

[0029] In response to the electronic device being woken up from the sleep state, a clear instruction is sent to the network firmware through the application framework layer; in the wake-up state, the network firmware clears the filtering instruction according to the clear instruction so as not to filter data packets associated with the data transmission port.

[0030] In some embodiments, the sending of the clear instruction to the network firmware through the application framework layer in response to the electronic device being woken up from the sleep state comprises:

[0031] In response to the electronic device being woken up from the sleep state, the clear instruction of the application framework layer is sent to the network driver of the kernel layer by using a cross-process communication mechanism, and the clear instruction is sent to the network firmware through the network driver.

[0032] According to a second aspect of the embodiments of the present disclosure, a control device is provided, comprising:

[0033] A determination module is configured to determine a data transmission port that is not monitored.

[0034] A generation module is configured to, in response to the electronic device being in a sleep state, generate a filtering instruction of the data transmission port in an application framework layer, and send the filtering instruction to a network firmware.

[0035] A filtering module is configured to, in the sleep state, filter data packets of the data transmission port according to the filtering instruction by the network firmware.

[0036] An acquisition module is configured to register a hook function in a kernel layer, and acquire a network data packet to be sent by the electronic device by using the hook function; the determination module is further configured to detect a network data packet that is not monitored in the network data packet in the kernel layer, and determine the data transmission port corresponding to the network data packet that is not monitored.

[0037] A reporting module is configured to send the data transmission port determined in the kernel layer to a network stack of the application framework layer; the generation module is further configured to, in response to the electronic device being in the sleep state, generate a filtering instruction of the data transmission port based on the network stack; send the filtering instruction in the application framework layer to a network driver of the kernel layer by using a cross-process communication mechanism, and send the filtering instruction to the network firmware through the network driver.

[0038] The generation module is further configured to count the reporting times of the data transmission port through the network stack; in response to the reporting times of the data transmission port being greater than a preset number threshold, generate the filtering instruction of the data transmission port.

[0039] a port occupation module, configured to set the data transmission port as an occupied port through the network stack.

[0040] a port release module, configured to set the data transmission port corresponding to the filtering instruction as an unoccupied port through the network stack in response to the electronic device being woken up from the sleep state.

[0041] a logout module, configured to log out the hook function at the kernel layer in response to the electronic device being woken up from the sleep state.

[0042] The filtering module is further configured to, in the sleep state, in response to receiving a data packet of the data transmission port through the network firmware, prohibit the network firmware from transmitting the data packet to the kernel layer according to the filtering instruction.

[0043] a clearing module, configured to send a clearing instruction to the network firmware through the application framework layer in response to the electronic device being woken up from the sleep state; and clear the filtering instruction to not filter data packets associated with the data transmission port through the network firmware according to the clearing instruction in the wake-up state.

[0044] The clearing module is further configured to, in response to the electronic device being woken up from the sleep state, send the clearing instruction of the application framework layer to a network driver of the kernel layer by using a cross-process communication mechanism, and send the clearing instruction to the network firmware through the network driver.

[0045] According to a third aspect of embodiments of the present disclosure, an electronic device is provided, including:

[0046] a processor;

[0047] a memory for storing computer programs or instructions;

[0048] The processor executes the computer programs or instructions to implement the steps of the method according to the first aspect.

[0049] According to a fourth aspect of embodiments of the present disclosure, a non-transitory computer readable storage medium is provided, which stores computer programs or instructions, and when the computer programs or instructions in the storage medium are executed by a processor, the steps of the method according to the first aspect are implemented.

[0050] According to a fifth aspect of embodiments of the present disclosure, a computer program product is provided, which includes computer programs or instructions, and when the computer programs or instructions are executed by a processor, the steps of the method according to the first aspect are implemented.

[0051] The technical solutions provided by the embodiments of the present disclosure can have the following beneficial effects:

[0052] In the embodiments of the present disclosure, the electronic device determines a data transmission port (a port not associated with an upper layer application) that is not monitored, and in a sleep state, generates a data transmission port filtering instruction for the port not monitored through an application framework layer, and guides the network firmware to filter data packets (i.e., invalid data packets not associated with the upper layer application) of the data transmission port, thereby reducing the case that the electronic device is frequently woken up in the sleep state, reducing the power consumption of the mobile phone, and improving the standby endurance of the mobile phone.

[0053] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS

[0054] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0055] Figure 1 is a flowchart of a control method according to an exemplary embodiment.

[0056] Figure 2 is a device interaction diagram according to an exemplary embodiment.

[0057] Figure 3 is a control method framework diagram according to an exemplary embodiment.

[0058] Figure 4 is a control method flowchart in a screen-off state according to an exemplary embodiment.

[0059] Figure 5 is a control method flowchart in a screen-on state according to an exemplary embodiment.

[0060] Figure 6 is a current diagram of an electronic device not enabling a control method according to an exemplary embodiment.

[0061] Figure 7 is a current diagram of an electronic device enabling a control method according to an exemplary embodiment.

[0062] Figure 8 is a control device block diagram according to an exemplary embodiment.

[0063] Figure 9 is a structural block diagram of a device 900 according to an exemplary embodiment. DETAILED DESCRIPTION

[0064] The exemplary embodiments will be described in detail below with reference to the accompanying drawings. The following description is only examples of apparatus and methods consistent with the present disclosure as recited in the appended claims and is not intended to represent all embodiments consistent with the present disclosure. Rather, they are simply examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0065] To this end, the embodiments of the present disclosure disclose a control method, Figure 1 is a flow chart of a control method according to an exemplary embodiment, as Figure 1 shown, the method mainly includes the following steps:

[0066] S101, determining a data transmission port that is not monitored;

[0067] S102, in response to the electronic device being in a sleep state, generating a filtering instruction of the data transmission port at an application framework layer, and sending the filtering instruction to a network firmware;

[0068] S103, in the sleep state, filtering a data packet of the data transmission port by the network firmware according to the filtering instruction.

[0069] The control method provided by the embodiments of the present disclosure can be executed by an electronic device, which can be a mobile phone, a camera, a tablet computer, a vehicle-mounted device, a wearable device, etc. In some possible implementation manners, the control method can be realized by a processor calling computer readable instructions stored in a memory. In the embodiments of the present disclosure, an operating system adapted to the device is installed on the electronic device, which can be Android, iPhoneOS (iOS), etc. Hereinafter, the Android system installed on the electronic device is taken as an example for description.

[0070] In the embodiments of the present disclosure, the electronic device can establish a wired or wireless network connection with other devices, and perform data interaction with the other devices based on the wired or wireless network connection to respond to the running of the electronic device. The other devices can be terminal devices such as a mobile phone, a camera, a tablet computer, a vehicle-mounted device, a wearable device, etc. or gateway devices such as a router, a switch, etc.

[0071] In the embodiments of the present disclosure, the wired network connection mode established by the electronic device and other devices includes a network cable-based connection, a connection based on a universal serial bus (USB) to Ethernet adapter, and the like; and the wireless network connection mode established by the electronic device and other devices includes a wireless local area network (WLAN), a wireless fidelity (WiFi), a peer-to-peer (P2P) connection, and the like.

[0072] In the embodiments of the present disclosure, the electronic device can establish a network connection with one or more other devices and perform data interaction with the one or more other devices; and in the case where the electronic device establishes a network connection with multiple other devices, the network connection modes can be the same or different. Figure 2 FIG. 1 is a device interaction schematic diagram shown in the embodiments of the present disclosure, as shown in Figure 2 As shown in FIG. 1, a mobile phone 201 (electronic device) establishes a wireless connection with a router 202 (gateway device) and performs data transmission and reception based on a wireless network. The mobile phone 201 receives a data packet sent by the router 202 and processes the data packet to respond to the running of an application program on the mobile phone.

[0073] In the embodiments of the present disclosure, the electronic device can determine the unmonitored data transmission port in a specific state (for example, the mobile phone is in a screen-off state), at a predetermined time interval, or upon receiving a port determination instruction. In the embodiments of the present disclosure, the unmonitored data transmission port can be a port that is not associated with an application or process.

[0074] In step S101, the electronic device can determine the unmonitored data transmission port in multiple ways, for example, by using a monitoring detection command to determine the unmonitored data transmission port; the monitoring detection command includes a port state command (netstat–ano), a network connection obtaining command (Get-NetTCPConnection), and the like; or by determining the unmonitored data transmission port based on the data packet that is not monitored by the upper-layer application in the electronic device. In some embodiments, the electronic device obtains the monitoring state of the port by using the monitoring detection command, counts the monitoring state, and determines the unmonitored data transmission port based on the port with a higher probability of being unmonitored.

[0075] In step S102, in response to the electronic device being in the sleep state, the filtering instruction of the data transmission port is generated in the application framework layer in multiple ways. The filtering instruction can be generated in real time when the data transmission port is reported in the application framework layer. The filtering instruction can be generated when the data transmission port meets the preset filtering instruction generation condition after the data transmission port is reported in the application framework layer.

[0076] In the embodiments of the present disclosure, the filtering instruction is generally used to control the transmission of the data packet, and the electronic device allows or rejects the transmission of the data packet according to different conditions (filtering rules). The filtering rules can be set according to the Internet Protocol (IP), port identifier, protocol type, and the like.

[0077] It should be noted that the application framework layer is closely related to the application program. The application framework layer provides various tools and interfaces for the development of the application program, so as to flexibly extend the application software, and the way of setting the filtering instruction for the data packet of the application software can also be various.

[0078] In the embodiments of the present disclosure, the filtering instruction of the data transmission port generated in the application framework layer can be set according to the specific business requirement of the application program, or can be set based on the protocol used by the application program, or can be obtained by integrating the filtering rule and the security mechanism. For example, the electronic device can generate the filtering instruction for the data transmission port by using the packet filtering mechanism of the application framework layer, or can write the filtering instruction related to the business requirement of the application program of the port according to the unmonitored data transmission port in the application framework layer. The packet filtering mechanism can be an Android packet filter (APF). Therefore, in the embodiments of the present disclosure, the filtering instruction of the data transmission port generated in the application framework layer has good business configuration flexibility, network adaptability, and network security.

[0079] In the embodiments of the present disclosure, the electronic device can send the filtering instruction to the network firmware in multiple ways. The filtering instruction can be sent to the network firmware in real time, or can be sent to the network firmware at a predetermined interval, or can be sent to the network firmware upon receiving a request message of the network firmware.

[0080] In the embodiments of the present disclosure, the electronic device filters the data packet of the data transmission port through the network firmware in the sleep state in multiple ways. The data packet meeting the filtering rule can be prohibited from being transmitted to the kernel layer according to the filtering rule in the filtering instruction. The data packet meeting the filtering rule can also be deleted.

[0081] In the embodiments of the present disclosure, after the electronic device establishes a network connection with other devices, the electronic device can receive data packets sent by other devices and send the data packets to corresponding upper-layer applications for processing. However, the electronic device can receive a certain proportion of data packets without a local listening port (usually referred to as network-unreachable type data packets), which indicates that the port of the data packet is not listened to by the upper-layer application of the electronic device, and thus the data packets of this type cannot be distributed to specific applications and are ultimately discarded by the electronic device. Therefore, the network-unreachable type data packet can also be understood as data without actual meaning.

[0082] It should be noted that when the electronic device is in a sleep state, if a network-unreachable type data packet (a data packet port is not listened to by an upper-layer application) is received, the main processor of the electronic device will still be awakened, and the data without actual meaning will be processed, wasting the resources of the electronic device. When there are many network-unreachable type data packets sent to the electronic device, the electronic device will be frequently awakened, resulting in increased power consumption and reduced standby capability of the electronic device.

[0083] In the embodiments of the present disclosure, the electronic device determines the data transmission port that is not listened to (the port that is not associated with an upper-layer application), and in the sleep state, generates a data transmission port filtering instruction that is not listened to through the application framework layer, and guides the network firmware to filter the data packets of the data transmission port (i.e., invalid data packets that are not associated with an upper-layer application), thereby reducing the situation that the electronic device is frequently awakened in the sleep state, reducing the power consumption of the mobile phone, and improving the standby endurance capability of the mobile phone.

[0084] In some embodiments, the method further includes:

[0085] registering a hook function in the kernel layer, and obtaining the network data packet to be sent by the electronic device by using the hook function;

[0086] The determination of the data transmission port that is not listened to includes:

[0087] detecting the network data packet that is not listened to in the network data packet in the kernel layer, and determining the data transmission port corresponding to the network data packet that is not listened to.

[0088] Figure 3 is a control method framework diagram according to an exemplary embodiment, as shown in Figure 3 As shown in the control method framework diagram, the control method framework diagram includes an application framework layer 301 in a user space, a middleware layer 302, a kernel layer 303 in a kernel space, and a network firmware 304; wherein the middleware layer 302 includes a plurality of adaptation mechanisms, such as a cross-process communication mechanism, a network configuration process, and the like.

[0089] In the embodiments of the present disclosure, the electronic device can receive the data packet through the network firmware 304, and send the data packet to the data processing module of the kernel layer 303. The data processing module sends the data packet to the application program related process in the application framework layer 301 through the adaptation mechanism in the middleware layer 302 for processing. If the corresponding application program of the data packet cannot be found (the data packet is not monitored by the upper layer application), the data packet will be sent back to the data processing module of the kernel layer 301. The data processing module of the kernel layer 301 interacts with the network firmware 304 for data, and sends the data packet not monitored by the application program to the gateway device or the opposite end device establishing direct connection communication with the electronic device.

[0090] In the embodiments of the present disclosure, the electronic device can add a message control module to the kernel layer, register a hook function in the data processing module through the message control module, and obtain the network data packet to be sent by the electronic device by using the hook function. The message control module can be a message protocol control module (IcmpFilter), the data processing module can be a network packet processing module (NetFilter), and the message control module can obtain the network data packet to be sent by the electronic device in the data processing module by using various hook functions.

[0091] In the embodiments of the present disclosure, there are various ways for the electronic device to obtain the network data packet to be sent by the electronic device through the hook function. The network data packet can be obtained in real time through the hook function of the kernel layer. The network data packet can also be obtained at a predetermined sampling interval. The network data packet can also be obtained when the electronic device is in a predetermined state.

[0092] It should be noted that when the application program or process of the electronic device needs to receive data, it will be bound to one or more virtual ports in the electronic device and be in a state of monitoring the port. When the data arrives at the electronic device, the data can be sent to the corresponding port according to the port identifier specified by the data packet, and then the application program or process can receive the data packet and process it. In the embodiments of the present disclosure, the unmonitored network data packet can be understood as a data packet that cannot be sent to the application program process and has no actual business significance. It can be a network data packet without a specified port. It can also be a network data packet whose specified port is not bound to a process or application program. It can also be a process or application program bound to the specified port of the network data packet in an unrunning state.

[0093] In the embodiments of the present disclosure, the electronic device has multiple ways to detect the unmonitored network packet in the kernel layer. The electronic device can obtain a process list entering the background, and determine the network packet associated with the background process as the unmonitored network packet. Alternatively, the electronic device can determine the unmonitored network packet according to the port monitoring identifier corresponding to the network packet. The port monitoring identifier is determined when the network packet is distributed to the upper-layer application process, and can be monitored or unmonitored.

[0094] In the embodiments of the present disclosure, the electronic device detects the network packet in the kernel layer. If the network packet is a monitored network packet, the electronic device returns the network packet to the data processing module. If the network packet is an unmonitored network packet, the electronic device sends the port corresponding to the network packet to the user daemon in the user space through the cross-process communication mechanism, and returns the network packet to the data processing module. In the embodiments of the present disclosure, the electronic device can determine the corresponding data transmission port according to the port identifier of the unmonitored network packet.

[0095] In the embodiments of the present disclosure, the electronic device obtains the network packet to be sent by the electronic device through the hook function in the kernel layer, and determines the data transmission port according to the detected unmonitored network packet. The data transmission port is determined according to the data transmission port (invalid port) corresponding to the invalid network packet, so as to generate a filtering instruction for the invalid port to filter the subsequent data packet sent to the invalid port, thereby improving the accuracy of determining the unmonitored data transmission port, and further improving the accuracy of filtering the data packet.

[0096] In some embodiments, the method further comprises:

[0097] sending the data transmission port determined in the kernel layer to the network stack of the application framework layer;

[0098] In response to the electronic device being in the sleep state, generating the filtering instruction of the data transmission port in the application framework layer, and sending the filtering instruction to the network firmware, comprises:

[0099] In response to the electronic device being in the sleep state, generating the filtering instruction of the data transmission port based on the network stack;

[0100] sending the filtering instruction in the application framework layer to the network driver of the kernel layer by using the cross-process communication mechanism, and sending the filtering instruction to the network firmware through the network driver.

[0101] In the embodiments of the present disclosure, the network stack of the application framework layer is a collection of a series of software components responsible for network communication, which can implement network interface management, network protocol processing, network state monitoring and the like. In the embodiments of the present disclosure, the electronic device can send the data transmission port determined in the kernel layer to the network stack of the application framework layer through the message control module of the kernel layer, wherein the message control module of the kernel layer can send the data transmission port to the network stack based on the user space daemon (Netd).

[0102] In the embodiments of the present disclosure, in response to the electronic device being in the sleep state, the electronic device determines whether the preset filter instruction condition for generating the filter instruction is met based on the data transmission port data received by the network stack, and generates the filter instruction of the data transmission port at the network layer in the case where the preset filter instruction condition is met.

[0103] In the embodiments of the present disclosure, the electronic device sends the filter instruction in the application framework layer to the network driver of the kernel layer by using the cross-process communication (Netlink) mechanism, and sends the filter instruction to the network firmware through the network driver; wherein the network driver can send the filter instruction to the network firmware in real time; or the network driver can send the filter instruction to the network firmware in the case where it is confirmed that the network firmware is idle.

[0104] In the embodiments of the present disclosure, the electronic device receives the data transmission port based on the network stack of the application framework layer and generates the corresponding filter instruction, and then sends the filter instruction to the network driver of the kernel layer by using the cross-process communication mechanism, and further sends the filter instruction to the network firmware by using the network driver to perform data packet filtering. The cross-process communication mechanism is used to transmit the filter instruction, which improves the reliability of the transmission of the instruction between different levels of the system.

[0105] In some embodiments, the generating the filter instruction of the data transmission port through the network stack comprises:

[0106] counting the reporting times of the data transmission port through the network stack;

[0107] generating the filter instruction of the data transmission port in response to the reporting times of the data transmission port being greater than a preset number threshold.

[0108] In the embodiments of the present disclosure, the electronic device counts the reporting times of the data transmission port reported by the kernel layer through the network stack of the application framework layer, and if the reporting times of the data transmission port are greater than a preset number threshold, the electronic device generates the filter instruction of the data transmission port at the application framework layer; otherwise, the electronic device does not generate the corresponding filter instruction for the data transmission port.

[0109] In the embodiments of the present disclosure, the electronic device sends a command generation message through a network stack, instructing a packet filtering mechanism of an application framework layer to generate a filtering instruction corresponding to a data transmission port.

[0110] Figure 4 is a control method flow chart in an off-screen state according to an exemplary embodiment, as Figure 4 As shown in the figure, the control flow of the electronic device in the off-screen mode is as follows:

[0111] In the embodiments of the present disclosure, when the electronic device detects that the screen is off, the (NetworkStack) in the application framework layer 401 in the off-screen mode notifies the user space daemon (Netd) module that the electronic device is off-screen through a cross-process communication (Android Interface Definition Language, AIDL) interface, and needs to open the unreachable port filtering function; and then the Netd module of the user framework layer 401 notifies the message control (IcmpFilter) module of the kernel layer 403 in the off-screen mode through a cross-process communication (Netlink) module to open the unreachable port filtering function.

[0112] In the embodiments of the present disclosure, the IcmpFilter module registers a network hook in the data processing (NetFilter) module, and when there is a data packet from the router in the kernel layer 403 in the off-screen mode, the IcmpFilter module intercepts the network data packet from the router of the NetFilter of the kernel layer 403 in the off-screen mode, and confirms whether the obtained network data packet is a local port unreachable data packet, if not, the IcmpFilter module returns the network data packet to the NetFilter module; if yes, the IcmpFilter module sends the unreachable port to the Netd module of the application framework layer 401 in the off-screen mode through the Netlink through the unreachable message, and returns the local port unreachable data packet to the NetFilter module.

[0113] In the embodiments of the present disclosure, the Netd module sends the unreachable port to the NetworkStack module through the AIDL interface, and then the NetworkStack receives the unreachable message (unreachable port reporting), increases the count of the unreachable port, when the count of the unreachable port is greater than or equal to a preset reporting threshold (for example, it can be set to 3), generates an APF filtering instruction using this unreachable port, and sends the filtering instruction to the network configuration process (Wpa_supplicant) module in the form of AIDL.

[0114] In the embodiment of the present disclosure, in the screen-out mode, the Wpa_supplicant module in the middleware layer 402 sends the filtering instruction to the network driver in the form of Netlink, and the network driver writes the filtering instruction into the network firmware 404 in the screen-out mode. Then, the network firmware directly discards the received network data packet with unreachable port on the network firmware side according to the filtering instruction. Therefore, the data with unreachable port does not wake up the operating system of the electronic device, and the power saving purpose can be achieved.

[0115] In the embodiment of the present disclosure, the electronic device generates the filtering instruction of the data transmission port when the reporting times of the network stack statistical data transmission port are greater than the preset number threshold. The filtering instruction of the data transmission port can be generated directly after the port is reported once, which reduces the misoperation and improves the accuracy of the data packet filtering.

[0116] In some embodiments, the method further includes:

[0117] The network stack sets the data transmission port as an occupied port.

[0118] In the embodiment of the present disclosure, the electronic device can occupy the data transmission port for which the filtering instruction is generated. There are various methods for setting the data transmission port as an occupied port through the network stack. For example, the port state identifier of the data transmission port can be directly set as occupied; or a preset process can be associated with the data transmission port for listening, so as to realize the occupation operation of the port.

[0119] It should be noted that after the electronic device sets the filtering instruction for the data transmission port which is not listened to, the electronic device discards the network data packet associated with the port for which the filtering instruction is set on the network firmware side. Therefore, the electronic device cannot receive the network data packet associated with the port for which the filtering instruction is set from the kernel layer, which causes that even if a new application or process listens to the port for which the filtering instruction is set, the electronic device cannot normally receive and send the network data packet to the new application or process.

[0120] In the embodiment of the present disclosure, the electronic device sets the data transmission port as an occupied port through the network stack. In the case that a subsequent application enables and listens to the data transmission port for which the filtering rule is set, the application or process of the electronic device cannot receive the corresponding network data packet.

[0121] In some embodiments, the method further includes:

[0122] In response to the electronic device being woken up from the sleep state, the network stack sets the data transmission port corresponding to the filtering instruction as an unoccupied port.

[0123] In the embodiments of the present disclosure, the electronic device is woken up from the sleep state, and the data transmission port on which the filtering instruction is generated can be stopped from being occupied. There are various methods for setting the data transmission port as an unoccupied port through the network stack, which can directly set the port state identifier of the data transmission port as unoccupied, or cancel the process or application bound on the data transmission port to stop the port from being occupied.

[0124] It should be noted that the electronic device is woken up from the sleep mode, and the electronic device usually frequently transmits and receives data packets, and the application program can need to re-listen to some original unreachable ports (data transmission ports on which the filtering instruction is set).

[0125] In the embodiments of the present disclosure, the electronic device is woken up from the sleep state, and the data transmission port corresponding to the filtering instruction is set as an unoccupied port through the network stack, so as to release more available port resources for new application programs to re-perform port allocation, increase the available resource amount of the electronic device, and improve the performance of the electronic device.

[0126] In some embodiments, the method further includes;

[0127] In response to the electronic device being woken up from the sleep state, the hook function is unregistered in the kernel layer.

[0128] In the embodiments of the present disclosure, the electronic device can unregister the hook function in the data processing module through the message control module, and no longer acquire the network data packet to be sent by the electronic device by using the hook function.

[0129] In the embodiments of the present disclosure, the electronic device is woken up from the sleep state, and generally does not need to perform filtering processing on the data packet again, and therefore does not need to acquire the network data packet to be sent by the electronic device to guide the generation of the filtering instruction. Unregistering the hook function can reduce the interception of the data packet, improve the transmission speed of the data packet, and improve the running efficiency of the electronic device.

[0130] In some embodiments, the filtering, by the network firmware, of the data packet of the data transmission port according to the filtering instruction in the sleep state includes:

[0131] In the sleep state, in response to receiving the data packet of the data transmission port through the network firmware, the network firmware is prohibited from transmitting the data packet to the kernel layer according to the filtering instruction.

[0132] In the embodiments of the present disclosure, the electronic device in the sleep state can receive a data packet through the network firmware. If it is determined according to the port identifier of the data packet that the data packet of the data transmission port is received, the electronic device can prohibit the network firmware from transmitting the data packet to the kernel layer according to the filtering instruction. The manner of prohibiting the network firmware from transmitting the data packet to the kernel layer can be directly discarding or deleting the data packet, or can be freezing the data packet.

[0133] In the embodiments of the present disclosure, the electronic device in the sleep state prohibits the data packet of the data transmission port from being transmitted to the kernel layer by the network firmware, so as to achieve the effect that invalid data does not wake up the operating system of the electronic device, and save the resources of the electronic device.

[0134] In some embodiments, the method further includes:

[0135] In response to the electronic device being woken up from the sleep state, a clearing instruction is sent to the network firmware through the application framework layer. In the wake-up state, the network firmware clears the filtering instruction according to the clearing instruction so as not to filter the data packet associated with the data transmission port.

[0136] It should be noted that when the electronic device is in the screen-on state (woken up), that is, the electronic device is in the wake-up state. Generally, the electronic device frequently transmits and receives data packets based on the network in the wake-up state, and the newly started application program in the wake-up process may re-listen to some originally unreachable ports (data transmission ports). In this case, filtering the network data packet of the unreachable port has little significance, and even may cause unnecessary risks due to the misfiltration of valid data.

[0137] In this regard, in the embodiments of the present disclosure, in response to the electronic device being woken up from the sleep state, the electronic device can generate a clearing instruction through the application framework layer and send the clearing instruction to the network firmware. The clearing instruction is used to clear the filtering instruction.

[0138] In the embodiments of the present disclosure, the electronic device in the wake-up state clears the filtering instruction according to the clearing instruction through the network firmware so as not to filter the data packet associated with the data transmission port.

[0139] Figure 5 A control method flowchart in a screen-on state is shown according to an exemplary embodiment, as shown in FIG. 8. Figure 5 As shown in FIG. 8, the control flow of the electronic device in the bright mode is as follows:

[0140] In the embodiments of the present disclosure, when the electronic device is woken up and in the bright screen mode, the NetworkStack of the application framework layer 501 releases the unreachable port occupied by the generated filtering instruction in the previous stage, and uses the AIDL interface to inform the Netd to close the unreachable port filtering function, and uses the AIDL interface to inform the Wpa_supplicant of the middleware layer 502 in the bright screen mode to clear the filtering rule instruction set in the previous stage.

[0141] In the embodiments of the present disclosure, the Netd of the application framework layer 501 in the bright screen mode informs the IcmpFilter module of the kernel layer 503 in the bright screen mode to close the unreachable port filtering function through the Netlink mechanism, and the Wpa_supplicant also informs the network driver to clear the filtering rule instruction set in the previous stage through the Netlink mechanism.

[0142] In the embodiments of the present disclosure, the electronic device unregisters the hook function previously registered by the NetFilter module in the kernel layer 503 in the bright screen mode, so that the data packets sent by the NetFilter module to the network are no longer intercepted. In the embodiments of the present disclosure, the network driver informs the network firmware 504 in the bright screen mode to clear the filtering rule instruction, and then the network firmware 504 in the bright screen mode clears the filtering rule and normally receives all network data packets.

[0143] In the embodiments of the present disclosure, in response to the electronic device being woken up from the sleep state and entering the bright screen mode for normal work, as described above, filtering the unreachable data packets in the bright screen mode may reduce the running speed of the electronic device, and even cause unnecessary risks due to the misfiltration of valid data. Therefore, in the embodiments of the present disclosure, the electronic device clears the filtering instruction in the woken-up state to not filter the data packets of the associated data transmission port, thereby improving the running efficiency of the electronic device and improving the reliability of the running.

[0144] In some embodiments, the sending, in response to the electronic device being woken up from the sleep state, of the clearing instruction to the network firmware through the application framework layer comprises:

[0145] In response to the electronic device being woken up from the sleep state, the clearing instruction of the application framework layer is sent to the network driver of the kernel layer by using a cross-process communication mechanism, and the clearing instruction is sent to the network firmware through the network driver.

[0146] In the embodiment of the present disclosure, the electronic device sends the clearing instruction in the application framework layer to the network driver in the kernel layer by using the cross-process communication (Netlink) mechanism, and sends the clearing instruction to the network firmware through the network driver; wherein the network driver can send the clearing instruction to the network firmware in real time; or the clearing instruction can be sent to the network firmware after confirming that the network firmware is idle.

[0147] In the embodiment of the present disclosure, the electronic device is woken up from the sleep state, and the clearing instruction in the application framework layer is sent to the network driver in the kernel layer by using the cross-process mechanism, and then the clearing instruction is sent to the network firmware by using the network driver so as not to perform data packet filtering. The transmission of the clearing instruction is performed by using the cross-process communication mechanism, thereby improving the reliability of the instruction transmission between different levels of the system.

[0148] Figure 6 is a current diagram of an electronic device without enabling a control method according to an exemplary embodiment. As shown in Figure 6 , the electronic device does not enable the control method, and the current of the electronic device is pulled up, resulting in a current peak. When the electronic device receives a port unreachable data packet, the current pull-up phenomenon repeatedly occurs multiple times according to the number of received unreachable data packets, resulting in multiple current peaks 601, that is, the electronic device operating system is frequently woken up. Figure 7 is a current diagram of an electronic device with enabling a control method according to an exemplary embodiment. The electronic device enables the control method, and the electronic device reports once through the application framework layer to generate a filtering instruction, and filters the unreachable data packet on the network firmware side. As shown in Figure 7 , after the electronic device enables the control method, the current of the electronic device is pulled up only after receiving the first unreachable port, resulting in a current peak 701, that is, the electronic device operating system is woken up. If the same port data packet is received subsequently, the current of the electronic device will not be pulled up, that is, the electronic device operating system will not be woken up. In the embodiment of the present disclosure, after the electronic device adopts the control method, in the case that there are many port unreachable data packets, the standby power consumption of the electronic device can be reduced by more than 80%, thereby greatly improving the endurance of the electronic device.

[0149] Figure 8 is a control device block diagram according to an exemplary embodiment. As shown in Figure 8 , the control device 800 mainly includes:

[0150] A determination module 801 is configured to determine a data transmission port that is not monitored.

[0151] A generation module 802 is configured to, in response to the electronic device being in a sleep state, generate a filtering instruction of the data transmission port in an application framework layer, and send the filtering instruction to a network firmware.

[0152] The filtering module 803 is configured to filter, in the sleep state, the data packet of the data transmission port according to the filtering instruction by the network firmware.

[0153] The obtaining module is configured to register a hook function in a kernel layer and obtain a network data packet to be sent by the electronic device by using the hook function.

[0154] The reporting module is configured to send the data transmission port determined in the kernel layer to a network stack in the application framework layer; and the generating module 802 is further configured to generate, in response to the electronic device being in the sleep state, a filtering instruction of the data transmission port based on the network stack; send the filtering instruction in the application framework layer to the network driver in the kernel layer by using a cross-process communication mechanism; and send the filtering instruction to the network firmware by the network driver.

[0155] The generating module 802 is further configured to count the reporting times of the data transmission port by the network stack.

[0156] In response to the reporting times of the data transmission port being greater than a preset number threshold, the filtering instruction of the data transmission port is generated.

[0157] The port occupation module is configured to set the data transmission port as an occupied port by the network stack.

[0158] The port release module is configured to, in response to the electronic device being woken up from the sleep state, set the data transmission port corresponding to the filtering instruction as an unoccupied port by the network stack.

[0159] The unregistration module is configured to, in response to the electronic device being woken up from the sleep state, unregister the hook function in the kernel layer.

[0160] The filtering module 803 is further configured to, in the sleep state, in response to receiving the data packet of the data transmission port by the network firmware, prohibit the network firmware from transmitting the data packet to the kernel layer according to the filtering instruction.

[0161] The clearing module is configured to, in response to the electronic device being woken up from the sleep state, send a clearing instruction to the network firmware by the application framework layer; and in a wake-up state, clear the filtering instruction by the network firmware according to the clearing instruction so as not to filter the data packet associated with the data transmission port.

[0162] The clearing module is further configured to, in response to the electronic device being woken up from the hibernation state, send the clearing instruction of the application framework layer to a network driver of a kernel layer by using a cross-process communication mechanism, and send the clearing instruction to the network firmware through the network driver.

[0163] As to the apparatus in the above-mentioned embodiments, the specific manners in which the respective modules perform operations have been described in detail in the embodiments of the method, and thus will not be described in detail here.

[0164] Figure 9 is a structural block diagram of an apparatus 900 according to an exemplary embodiment. For example, the apparatus 900 can be a mobile phone, a tablet computer, a wearable device, or a vehicle-mounted device, etc.

[0165] Referring to Figure 9 , the apparatus 900 can include one or more of the following components: a processing component 902, a memory 904, a power supply component 906, a multimedia component 908, an audio component 910, an input / output (I / O) interface 912, a sensor component 914, and a communication component 916.

[0166] The processing component 902 usually controls overall operations of the apparatus 900, such as operations associated with display, telephone call, data communication, camera operation, and recording operation. The processing component 902 can include one or more processors 920 to execute instructions to complete all or part of steps of the methods described above. In addition, the processing component 902 can include one or more modules to facilitate the interaction between the processing component 902 and other components. For example, the processing component 902 can include a multimedia module to facilitate the interaction between the multimedia component 908 and the processing component 902.

[0167] The memory 904 is configured to store various types of data to support operations on the device 900. Examples of these data include at least one of instructions for any application or method operating on the device 900, contact data, phonebook data, messages, pictures, and videos. The memory 904 can be implemented by any type of volatile or nonvolatile storage devices or a combination thereof such as static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable programmable read only memory (EPROM), programmable read only memory (PROM), read only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.

[0168] The power component 906 provides power to the various components of the device 900. The power component 906 can include at least one of a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 900.

[0169] The multimedia component 908 includes a screen providing an output interface between the device 900 and the user. In some embodiments, the screen includes a liquid crystal display (LCD) and a touch panel (TP). If the screen includes the touch panel, the screen can be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense a touch, a slide, and a gesture on the touch panel. The touch sensor can not only sense a boundary of a touching or a sliding action, but also detect duration and pressure related to the touching or sliding action. In some embodiments, the multimedia component 908 includes a front camera and / or a back camera. When the device 900 is in an operation mode such as a photographing mode or a video mode, the front camera and / or the back camera can receive external multimedia data. Each of the front camera and the back camera can be a fixed optical lens system or have a focal length and optical zoom capability.

[0170] The audio component 910 is configured to output and / or input audio signals. For example, the audio component 910 includes a microphone (MIC) that is configured to receive an external audio signal when the device 900 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 904 or transmitted via the communication component 916. In some embodiments, the audio component 910 also includes a speaker for outputting an audio signal.

[0171] The I / O interface 912 provides an interface between the processing component 902 and peripheral interface modules, which can be a keyboard, a click wheel, and buttons, etc. The buttons can include, but are not limited to, a home button, a volume button, a start button, and a lock button.

[0172] The sensor component 914 includes one or more sensors for providing various state assessments for the device 900. For example, the sensor component 914 can detect an open / closed state of the device 900, relative positioning of components, such as a display and a keypad of the device 900, a change in position of the device 900 or a component of the device 900, presence or absence of user contact with the device 900, a change in orientation of the device 900 or acceleration / deceleration of the device 900, and a temperature change of the device 900. The sensor component 914 can include a proximity sensor configured to detect presence of a nearby object without any physical touch. The sensor component 914 can further include a light sensor, such as a complementary metal oxide semiconductor (CMOS) or charge coupled device (CCD) image sensor, for use in an imaging application. In some embodiments, the sensor component 914 can further include at least one of an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, and a temperature sensor, but is not limited thereto.

[0173] The communication component 916 is configured to facilitate wired or wireless communication between the device 900 and other devices. The device 900 can access a wireless network based on a communication standard, such as Wi-Fi, 4G, 5G, or a combination thereof. In an example embodiment, the communication component 916 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an example embodiment, the communication component 916 also includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wide Band (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0174] In an example embodiment, the device 900 can be implemented using one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors, or other electronic elements.

[0175] In an example embodiment, a non-transitory computer-readable storage medium including instructions, such as the memory 904 including executable instructions or a computer program, is also provided, which can be executed by the processor 920 of the device 900 to complete the above-described method. For example, the non-transitory computer-readable storage medium can be a ROM, a Random Access Memory (RAM), a Compact Disc Read-Only Memory (CD-ROM), a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0176] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform any one of the control methods described in the embodiments of the present disclosure.

[0177] The embodiment of the disclosure provides a computer program product, which comprises a computer program or executable instruction stored in a computer readable storage medium. The processor of the computer device reads the computer program or executable instruction from the computer readable storage medium, and the processor executes the computer program or executable instruction, so that the computer device executes any one of the control methods in the above embodiment of the disclosure.

[0178] Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the concepts disclosed herein. The disclosure is intended to cover any variations, uses or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice in the art to which the disclosure pertains. The specification and examples are to be regarded as illustrative only, and the true scope and spirit of the disclosure are indicated by the appended claims.

[0179] It should be understood that the present disclosure is not limited to the precise structures as herein described and illustrated in the drawings, and that various modifications and changes can be made without departing from its scope. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A control method, characterized in that, include: Identify the data transmission ports that are not being monitored; In response to the electronic device being in a sleep state, a filtering instruction for the data transmission port is generated at the application framework layer, and the filtering instruction is sent to the network firmware; In the hibernation state, the network firmware filters data packets on the data transmission port according to the filtering instructions.

2. The method according to claim 1, characterized in that, The method further includes: Register hook functions at the kernel level and use the hook functions to obtain network data packets to be sent by the electronic device; The determination of non-monitored data transmission ports includes: The kernel layer detects unlistened network packets in the network data packets and determines the data transmission port corresponding to the unlistened network packets.

3. The method according to claim 2, characterized in that, The method further includes: The data transmission port determined in the kernel layer is sent to the network stack of the application framework layer; In response to the electronic device being in a sleep state, generating a filtering instruction for the data transmission port at the application framework layer and sending the filtering instruction to the network firmware includes: In response to the electronic device being in the sleep state, a filtering instruction for the data transmission port is generated based on the network stack; The filtering instructions in the application framework layer are sent to the network driver in the kernel layer using an inter-process communication mechanism, and then the filtering instructions are sent to the network firmware through the network driver.

4. The method according to claim 3, characterized in that, The filtering instructions generated based on the network stack for the data transmission port include: The number of reports from the data transmission port is counted using the network stack. In response to the number of reports from the data transmission port exceeding a preset threshold, a filtering instruction for the data transmission port is generated.

5. The method according to claim 3, characterized in that, The method further includes: The data transmission port is set to be occupied by the network stack.

6. The method according to claim 3, characterized in that, The method further includes: In response to the electronic device being woken up from the sleep state, the data transmission port corresponding to the filtering instruction is set to an unoccupied port through the network stack.

7. The method according to claim 2, characterized in that, The method further includes; In response to the electronic device being woken from the hibernation state, the hook function is unregistered at the kernel level.

8. The method according to claim 1, characterized in that, In the dormant state, filtering data packets on the data transmission port by the network firmware according to the filtering instructions includes: In the hibernation state, in response to receiving a data packet from the data transmission port through the network firmware, the network firmware is prohibited from transmitting the data packet to the kernel layer according to the filtering instruction.

9. The method according to any one of claims 1-8, characterized in that, The method further includes: In response to the electronic device being woken from the sleep state, a clear command is sent to the network firmware through the application framework layer; In the wake-up state, the network firmware clears the filtering instruction according to the clear instruction so that data packets associated with the data transmission port are not filtered.

10. The method according to claim 9, characterized in that, The step of sending a clear command to the network firmware through the application framework layer in response to the electronic device being woken from the sleep state includes: In response to the electronic device being awakened from the hibernation state, the clearing instruction of the application framework layer is sent to the network driver of the kernel layer using an inter-process communication mechanism, and the clearing instruction is then sent to the network firmware through the network driver.

11. A control device, characterized in that, include: The determination module is used to identify data transmission ports that are not being monitored. A generation module is used to generate a filtering instruction for the data transmission port at the application framework layer in response to the electronic device being in a sleep state, and send the filtering instruction to the network firmware; A filtering module is used in the hibernation state to filter data packets on the data transmission port according to the filtering instructions via the network firmware.

12. An electronic device, characterized in that, include: processor; Memory used to store computer programs or instructions; The processor executes the computer program or instructions to implement the steps of the method according to any one of claims 1 to 10.

13. A non-transitory computer-readable storage medium storing a computer program or instructions, characterized in that, When the computer program or instructions in the storage medium are executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.

14. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 10.