Search

CN-114630325-B - Network access method, electronic equipment and storage medium

CN114630325BCN 114630325 BCN114630325 BCN 114630325BCN-114630325-B

Abstract

The embodiment of the application provides a network access method, electronic equipment and a storage medium, which are applied to the electronic equipment, wherein the method comprises the steps of determining a first application category corresponding to a first application under the condition of being in a screen-off state, wherein the first application is an running application; searching a first network access rule corresponding to a first application category from the corresponding relation between the preset application category and the network access rule, and controlling the first application to access the data network of the terminal in the off-screen state based on the first network access rule.

Inventors

  • LUO WEIPING

Assignees

  • OPPO广东移动通信有限公司

Dates

Publication Date
20260512
Application Date
20201210

Claims (8)

  1. 1. A network access method, wherein the method is applied to a scenario in which an electronic device uses a personal hotspot of a terminal to perform network connection, the method comprising: Under the condition of being in a screen-off state, determining a first application class corresponding to a first application, wherein the first application is an running application, the first application class corresponding to the first application is determined based on a setUidPolicy function in NetworkPolicyManagerService, and the setUidPolicy function is used for setting a strategy corresponding to UId of the first application; Searching a first network access rule corresponding to a first application category from the corresponding relation between the preset application category and the network access rule, wherein the first network access rule comprises a rule for allowing the application of a foreground application to temporarily access traffic in an application blacklist; Updating the network access policy of the first application based on the first network access rule to control the first application to access the data network of the terminal in the off-screen state, wherein the updating the network access policy of the first application is based on at least the values of isForeground and isBlacklisted Boolean variables in a control updateRulesForDataUsageRestrictionsULInner function and/or adding a direct judgment logic implementation in a updateRulesForDataUsageRestrictionsULInner function; the determining the first application category corresponding to the first application includes: Judging whether the first application is a background application or not based on a preset judging rule to obtain a first judging result; Judging whether the first application is in an application blacklist or not based on a preset blacklist, and obtaining a second judging result; determining the first application category according to the first judgment result and the second judgment result; The step of judging whether the first application is a background application based on a preset judgment rule to obtain a first judgment result comprises the following steps: acquiring a process running state corresponding to the first application; When the running state of the process is smaller than or equal to a preset threshold value, determining that the first application is not a background application according to the first judgment result; And when the running state of the process is greater than the preset threshold, determining that the first judgment result is that the first application is a background application.
  2. 2. The method according to claim 1, wherein the searching for the first network access rule corresponding to the first application class from the corresponding relation between the preset application class and the network access rule comprises: And under the condition that the first judging result is that the first application is a background application and the second judging result is that the first application is in an application blacklist, determining that the first network access rule is forbidden to access a data network from the corresponding relation between the preset application category and the network access rule.
  3. 3. The method of claim 2, wherein controlling the first application to access the data network of the terminal in the off-screen state based on the first network access rule comprises: And limiting the data network request of the first application in the off-screen state.
  4. 4. A method according to claim 3, wherein said restricting data network requests of said first application comprises: disconnecting a source address interface corresponding to the data network request; And/or disconnecting the destination address interface corresponding to the data network request.
  5. 5. The method of claim 1, wherein the controlling the first application after accessing the data network of the terminal in the off-screen state based on the first network access rule further comprises: And under the condition of switching from the off-screen state to the on-screen state, recovering the first network access rule of the first application into the network access rule corresponding to the on-screen state.
  6. 6. An electronic device applied to a scenario where the electronic device uses a personal hotspot of a terminal for network connection, the electronic device comprising: the system comprises a determining module, a setUidPolicy function and a control module, wherein the determining module is used for determining a first application class corresponding to a first application under the condition of being in an off-screen state, wherein the first application is an running application, the first application class corresponding to the first application is determined based on a setUidPolicy function in NetworkPolicyManagerService, and the setUidPolicy function is used for setting a strategy corresponding to UId of the first application; The system comprises a searching module, a searching module and a searching module, wherein the searching module is used for searching a first network access rule corresponding to a first application category from the corresponding relation between the preset application category and the network access rule, wherein the first network access rule comprises an application temporary access flow rule for a foreground application in an application blacklist; The network access control module is used for updating the network access strategy of the first application based on the first network access rule so as to control the first application to access the data network of the terminal in the off-screen state, wherein the updating of the network access strategy of the first application is at least based on the values of isForeground and isBlacklisted of two Boolean variables in a control updateRulesForDataUsageRestrictionsULInner function, and/or a direct judgment logic implementation is added in a updateRulesForDataUsageRestrictionsULInner function; The acquisition module is used for acquiring the process running state corresponding to the first application; the determining module is further configured to determine that the first application is not a background application when the running state of the process is less than or equal to a preset threshold; the judging module is used for judging whether the first application is a background application or not based on a preset judging rule to obtain a first judging result; The determining module is further configured to determine the first application class according to the first determination result and the second determination result.
  7. 7. An electronic device comprising a processor, a memory and a communication bus, wherein the processor implements the method of any of claims 1-5 when executing an operating program stored in the memory.
  8. 8. A storage medium having stored thereon a computer program which, when executed by a processor, implements the method of any of claims 1-5.

Description

Network access method, electronic equipment and storage medium Technical Field The present application relates to the field of electronic technologies, and in particular, to a network access method, an electronic device, and a storage medium. Background At present, the electronic equipment such as the wearable equipment can realize the internet surfing function by using a personal hot spot of a mobile phone end or a card inserting mode, and for realizing the internet surfing function in the card inserting mode, a clamping groove is additionally arranged on the electronic equipment, so that the electronic equipment such as the wearable equipment has universality by using the personal hot spot of the mobile phone end to surf the internet. The management software installed on the electronic device is a direct setup application that allows or prohibits access to the network. An application that is set to prohibit access to the network is not able to access the network at any time, and if access to the network is required, only the permission to access the network is reset to continue use. If the system and instant messaging applications are forbidden to access the network, the normal operation and communication of the electronic equipment can be directly affected. In the process that the electronic equipment uses the personal hot spot of the mobile phone end to access the network, a plurality of applications request to access the network, especially after screen deactivation or screen locking, a large number of background applications access the network, a large amount of electric quantity is consumed, and the frequent network access can also cause the electronic equipment to be unable to enter a sleep state or a dormant state. Disclosure of Invention The embodiment of the application provides a network access method, electronic equipment and a storage medium, which can save electricity and enable the electronic equipment to quickly enter a sleep state or a dormant state in a screen-off state. The technical scheme of the application is realized as follows: In a first aspect, an embodiment of the present application proposes a network access method, applied to an electronic device, where the method includes: under the condition of being in a screen-off state, determining a first application category corresponding to a first application, wherein the first application is an running application; Searching a first network access rule corresponding to the first application category from the corresponding relation between the preset application category and the network access rule; and controlling the first application to access the data network of the terminal in the off-screen state based on the first network access rule. In a second aspect, an embodiment of the present application proposes an electronic device, including: the system comprises a determining module, a control module and a control module, wherein the determining module is used for determining a first application category corresponding to a first application under the condition of being in a screen-off state, and the first application is an running application; the searching module is used for searching a first network access rule corresponding to the first application category from the corresponding relation between the preset application category and the network access rule; and the network access control module is used for controlling the first application to access the data network of the terminal in the off-screen state based on the first network access rule. In a third aspect, an embodiment of the present application provides a terminal, where the electronic device includes a processor, a memory, and a communication bus, and the method is implemented when the processor executes an operating program stored in the memory. In a fourth aspect, an embodiment of the present application proposes a storage medium having stored thereon a computer program, characterized in that the computer program, when executed by a processor, implements a method as described above. The embodiment of the application provides a network access method, electronic equipment and a storage medium, wherein the method comprises the steps of determining a first application category corresponding to a first application under the condition of being in a screen-off state, wherein the first application is an running application; searching a first network access rule corresponding to a first application category from the corresponding relation between the preset application category and the network access rule, and controlling the first application to access the data network of the terminal in the off-screen state based on the first network access rule. According to the implementation scheme, the application type and network access rule corresponding relation is preset in the electronic equipment, the electronic equipment can set different network access authorities for different type