US-12621757-B2 - Communication method and apparatus
Abstract
This application provides a communication method and an apparatus. The method includes: accessing, by an electronic device, a first network; performing network probing on the first network, where it is detected that the Internet cannot be accessed through the first network; and transmitting, in the first network and a second network, to-be-transmitted data through a network that matches the to-be-transmitted data, where the first network is different from the second network, and the electronic device can access the second network and maintain a connection to the first network. The Internet can be accessed through the second network. Even if the Internet cannot be accessed through the first network, the electronic device can still access the Internet through the second network, and is not disconnected from the first network, maintaining the capability of the first network to transmit data.
Inventors
- Ruiqing Zhao
- Qiao LUO
Assignees
- HONOR DEVICE CO., LTD.
Dates
- Publication Date
- 20260505
- Application Date
- 20221215
- Priority Date
- 20220114
Claims (20)
- 1 . A communication method, comprising: accessing, by a first electronic device, a wireless local area network provided by a second electronic device, wherein the first electronic device cannot access the Internet through the wireless local area network provided by the second electronic device, and the first electronic device accesses the Internet through a cellular network; generating, by the first electronic device, a data transmission request; performing the following: sending the data transmission request to the second electronic device through the wireless local area network in a case that a target address of the data transmission request is an address of the second electronic device; or sending the data transmission request through the cellular network in a case that a target address of the data transmission request is not an address of the second electronic device; in a case that a network parallel control setting of the first electronic device is disabled, in response to a first operation of a user, accessing, by the first electronic device, the cellular network, and breaking the connection to the wireless local area network; and in a case that the network parallel control setting of the first electronic device is disabled, in response to a second operation of the user, accessing, by the first electronic device, the wireless local area network, and breaking a connection to the cellular network.
- 2 . The method according to claim 1 , further comprising: displaying, based on the Internet cannot be accessed through the wireless local area network, a first interface, wherein the first interface comprises a first prompt information, and the first prompt information indicates whether to continue using the wireless local area network, and displaying, when the user feeds back to continue using the wireless local area network, a second interface, wherein the second interface comprises a second prompt information, and the second prompt information whether to enable the network parallel control setting, and receiving an operation of enabling the network parallel control setting.
- 3 . The method according to claim 1 , further comprising: adding, in response to enabling of the network parallel control setting by the user, a routing rule of the wireless local area network to a routing rule of the first electronic device, wherein a priority of the routing rule of the wireless local area network is higher than a priority of a routing rule of the cellular network, and the routing rule of the wireless local area network comprises a condition for transmitting the data transmission request through the wireless local area network.
- 4 . The method according to claim 1 , wherein an identifier of a network device or an address of the network device is recorded in a routing rule of the wireless local area network, and the first electronic device sends the data transmission request to the second electronic device through the network device indicated by the identifier of the network device or the address of the network device.
- 5 . The method according to claim 1 , further comprising: sending a probe request through the wireless local area network; receiving a status code through the wireless local area network; and in a case that the status code indicates that the Internet cannot be accessed through the wireless local area network, and the network parallel control setting of the first electronic device is enabled, accessing, by the first electronic device, the cellular network, and maintaining a connection to the wireless local area network.
- 6 . The method according to claim 5 , further comprising: displaying, by the first electronic device in a case that the status code indicates that the Internet cannot be accessed through the wireless local area network, a prompt box; determining, by the first electronic device in response to a third operation of a user, that the network parallel control setting is enabled; and determining, by the first electronic device in response to a fourth operation of the user, that the network parallel control setting is disabled.
- 7 . The method according to claim 5 , further comprising: searching, by the first electronic device in a case that the status code indicates that the Internet cannot be accessed through the wireless local area network, for a setting result of the network parallel control setting in a setting interface, wherein the setting result indicates that the network parallel control setting of the first electronic device is enabled or disabled.
- 8 . The method according to claim 1 , further comprising: deleting a routing rule of the wireless local area network from a routing rule of the first electronic device in a case that the first electronic device breaks the connection to the wireless local area network; and adding the routing rule of the wireless local area network to the routing rule of the first electronic device in a case that the first electronic device re-accesses the wireless local area network and the network parallel control setting is enabled.
- 9 . An electronic device, comprising: a memory and a processor, wherein the memory stores instructions executable by the processor, and when the processor executes the instructions, the electronic device is caused to: access a wireless local area network provided by a second electronic device, wherein the electronic device cannot access the Internet through the wireless local area network provided by the second electronic device, and the electronic device accesses the Internet through a cellular network; generate a data transmission request; perform the following: send the data transmission request to the second electronic device through the wireless local area network in a case that a target address of the data transmission request is an address of the second electronic device; or send the data transmission request through the cellular network in a case that a target address of the data transmission request is not an address of the second electronic device; in a case that a network parallel control setting of the electronic device is disabled, in response to a first operation of a user, access the cellular network, and break the connection to the wireless local area network; and in a case that the network parallel control setting of the electronic device is disabled, in response to a second operation of the user, access the wireless local area network, and break a connection to the cellular network.
- 10 . The electronic device according to claim 9 , wherein when the processor executes the instructions, the electronic device is further caused to: display, based on the Internet cannot be accessed through the wireless local area network, a first interface, wherein the first interface comprises a first prompt information, and the first prompt information indicates whether to continue using the wireless local area network, display when the user feeds back to continue using the wireless local area network, a second interface, wherein the second interface comprises a second prompt information, and the second prompt information whether to enable the network parallel control setting, and receive an operation of enabling the network parallel control setting.
- 11 . The electronic device according to claim 9 , wherein when the processor executes the instructions, the electronic device is further caused to: add, in response to enabling of the network parallel control setting by the user, a routing rule of the wireless local area network to a routing rule of the electronic device, wherein a priority of the routing rule of the wireless local area network is higher than a priority of a routing rule of the cellular network, and the routing rule of the wireless local area network comprises a condition for transmitting the data transmission request through the wireless local area network.
- 12 . The electronic device according to claim 9 , wherein an identifier of a network device or an address of the network device is recorded in a routing rule of the wireless local area network, and the electronic device sends the data transmission request to the second electronic device through the network device indicated by the identifier of the network device or the address of the network device.
- 13 . The electronic device according to claim 9 , wherein when the processor executes the instructions, the electronic device is further caused to: send a probe request through the wireless local area network; receive a status code through the wireless local area network; and in a case that the status code indicates that the Internet cannot be accessed through the wireless local area network, and the network parallel control setting of the electronic device is enabled, access the cellular network, and maintain a connection to the wireless local area network.
- 14 . The electronic device according to claim 13 , wherein when the processor executes the instructions, the electronic device is further caused to: display, in a case that the status code indicates that the Internet cannot be accessed through the wireless local area network, a prompt box; determine, in response to a third operation of the user, that a network parallel control setting is enabled; and determine, in response to a fourth operation of the user, that the network parallel control setting is disabled.
- 15 . The electronic device according to claim 13 , wherein when the processor executes the instructions, the electronic device is further caused to: search, in a case that the status code indicates that the Internet cannot be accessed through the wireless local area network, for a setting result of the network parallel control setting in a setting interface, wherein the setting result indicates that the network parallel control setting of the electronic device is enabled or disabled.
- 16 . The electronic device according to claim 9 , wherein when the processor executes the instructions, the electronic device is further caused to: delete a routing rule of the wireless local area network from a routing rule of the electronic device in a case that the electronic device breaks the connection to the wireless local area network; and add the routing rule of the wireless local area network to the routing rule of the electronic device in a case that the electronic device re-accesses the wireless local area network and the network parallel control setting is enabled.
- 17 . A non-transitory computer-readable storage medium, storing a computer program, wherein the computer program, when run by a processor of an electronic device, causes the electronic device to: access a wireless local area network provided by a second electronic device, wherein the electronic device cannot access the Internet through the wireless local area network provided by the second electronic device, and the electronic device accesses the Internet through a cellular network; generate a data transmission request; and perform the following: send the data transmission request to the second electronic device through the wireless local area network in a case that a target address of the data transmission request is an address of the second electronic device; or send the data transmission request through the cellular network in a case that a target address of the data transmission request is not an address of the second electronic device; in a case that a network parallel control setting of the electronic device is disabled, in response to a first operation of a user, access the cellular network, and break the connection to the wireless local area network; and in a case that the network parallel control setting of the electronic device is disabled, in response to a second operation of the user, access the wireless local area network, and break a connection to the cellular network.
- 18 . The non-transitory computer-readable storage medium according to claim 17 , wherein when the computer program is run by the processor of the electronic device, the computer program causes the electronic device to further: display, based on the Internet cannot be accessed through the wireless local area network, a first interface, wherein the first interface comprises a first prompt information, and the first prompt information indicates whether to continue using the wireless local area network, display when the user feeds back to continue using the wireless local area network, a second interface, wherein the second interface comprises a second prompt information, and the second prompt information whether to enable the network parallel control setting, and receive an operation of enabling the network parallel control setting.
- 19 . The non-transitory computer-readable storage medium according to claim 17 , wherein when the computer program is run by the processor of the electronic device, the computer program causes the electronic device to further: add, in response to enabling of the network parallel control setting by the user, a routing rule of the wireless local area network to a routing rule of the electronic device, wherein a priority of the routing rule of the wireless local area network is higher than a priority of a routing rule of the cellular network, and the routing rule of the wireless local area network comprises a condition for transmitting the data transmission request through the wireless local area network.
- 20 . The non-transitory computer-readable storage medium according to claim 17 , wherein an identifier of a network device or an address of the network device is recorded in a routing rule of the wireless local area network, and the electronic device sends the data transmission request to the second electronic device through the network device indicated by the identifier of the network device or the address of the network device.
Description
CROSS-REFERENCE TO RELATED APPLICATIONS This application is a national stage of International Application No. PCT/CN2022/139340, filed on Dec. 15, 2022, which claims priority to Chinese Patent Application No. 202210042354.7, filed on Jan. 14, 2022, and Chinese Patent Application No. 202210870512.8, filed on Jul. 22, 2022. The disclosures of all the aforementioned applications are hereby incorporated by reference in their entireties. TECHNICAL FIELD This application relates to the field of communication technologies, and in particular, to a communication method and an apparatus. BACKGROUND An electronic device may support multiple network access manners, including cellular network access, wireless network access, Ethernet access, and universal serial bus (universal serial bus, USB) network sharing. At a moment, the electronic device may access, in a network access manner, a network corresponding to the network access manner. If another network needs to be accessed, a user may manually change the network access manner of the electronic device. SUMMARY This application provides a communication method and an apparatus, to resolve a problem that an electronic device accesses a network in one network access manner. To achieve the foregoing objective, this application provides the following technical solutions. This application provides a communication method. The method includes: accessing, by an electronic device, a first network; performing network probing on the first network, where it is detected that the Internet cannot be accessed through the first network; and transmitting, in the first network and a second network, to-be-transmitted data through a network that matches the to-be-transmitted data, where the first network is different from the second network, and the electronic device accesses the second network and maintains a connection to the first network. The Internet can be accessed through the second network. Even if the Internet cannot be accessed through the first network, the electronic device can still access the Internet through the second network, and is not disconnected from the first network, maintaining the capability of the first network to transmit data. As a result, the electronic device can access two different types of networks at the same time, and transmit data by using the two different types of networks. The two different types of networks may correspond to different network access manners, for the electronic device to access different types of networks in different network access manners. For example, the first network is a wireless local area network, and the second network is a cellular network. When the Internet cannot be accessed through the wireless local area network, the electronic device may access the Internet through the cellular network. In this case, the electronic device can transmit, through the wireless local area network, data to a device in a same wireless local area network as the electronic device, and can access the Internet through the cellular network, so that the electronic device has the capabilities of interaction within a local area network and accessing a wide area network (the Internet). Optionally, the transmitting, in the first network and a second network, to-be-transmitted data through a network that matches the to-be-transmitted data includes: transmitting first to-be-transmitted data through the first network that matches the first to-be-transmitted data; and transmitting second to-be-transmitted data through the second network that matches the second to-be-transmitted data, where the first to-be-transmitted data and the second to-be-transmitted data may be transmitted at the same time. When transmitting data through the first network and the second network, the electronic device transmits to-be-transmitted data through a network that matches the to-be-transmitted data, and can transmit data through the first network and the second network at the same time. Optionally, the method further includes: controlling the electronic device to access the second network and maintain the connection to the first network; and adding a routing rule of the first network, where a priority of the routing rule of the first network is higher than a priority of a routing rule of the second network, and the routing rule of the first network is a condition for transmission through the first network. The transmitting, in the first network and a second network, to-be-transmitted data through a network that matches the to-be-transmitted data includes: transmitting, in the first network and the second network based on a network parameter of the to-be-transmitted data and the routing rule of the first network, the to-be-transmitted data through the network that matches the to-be-transmitted data. In the embodiments, the electronic device may access the second network and then maintain the connection to the first network; and in order to transmit data through the first network