NETWORK CONNECTION METHOD, RELATED APPARATUS, AND SYSTEM

This application discloses a network connection method, a related apparatus, and a system. In the method, an electronic device may continuously borrow a network connection capability of another device to continuously access the internet, may temporarily borrow a web capability of another device to access a captive portal wireless network, or may temporarily borrow a network connection capability of another device to activate an eSIM or a blank SIM. According to the method, the electronic device may smoothly connect to the internet by using the network connection capability or the web capability of the another device, and communicate with the internet, to provide various services for a user.

TECHNICAL FIELD

This application relates to the field of terminal devices and the field of communication technologies, and in particular, to a network connection method, a related apparatus, and a system.

BACKGROUND

With popularization of terminal devices, an individual may have a plurality of terminal devices, for example, a mobile phone, a tablet computer, a large-screen television, a smart sound box, and a smartwatch. Most functions of the terminal device can be used only after the internet is accessed. How the terminal device connects to a network is a research focus in this field.

SUMMARY

This application provides a network connection method, a related apparatus, and a system, so that an electronic device can smoothly connect to the internet, and communicate with the internet.

According to a first aspect, an embodiment of this application provides a network connection method, applied to a communication system including a first device and a second device. The method includes: The first device establishes a first communication connection to the second device, where the first communication connection includes any one of the following: a wireless fidelity peer-to-peer (Wi-Fi P2P) connection, a Bluetooth connection, a near field communication NFC connection, a wired connection, or an Ethernet connection; and the first device communicates with the internet through the second device based on the first communication connection; or the first device sends an activation request to an operator server through the second device based on the first communication connection, and receives a profile sent by the operator server, where the profile is used to activate the first device, and the activated first device has a network connection capability.

According to the network connection method provided in the first aspect, the first device may communicate with the internet or perform an activation operation by using a network connection capability of the second device.

With reference to the first aspect, in a first implementation, the first device is configured to communicate with the internet through the second device based on the first communication connection; and before establishing the first communication connection to the second device, the first device further receives network connection capability information sent by the second device, where the network connection capability information indicates whether the second device connects to a network.

According to the method provided in the first implementation of the first aspect, provided that another device in the communication system can connect to the internet, the electronic device can smoothly connect to the internet by borrowing a network connection capability of the another device.

With reference to the first implementation of the first aspect, in some implementations, the second device may access the internet by using one or more of a WLAN created by a wireless access point, a cellular network, or a wired manner. That is, the second device may share one or more network connection capabilities of the second device with the first device. When the second device shares a plurality of network connection capabilities with the first device, a speed of communication between the first device and the internet can be increased, and user experience can be improved.

With reference to the first implementation of the first aspect, in some implementations, in a process in which the first device communicates with the internet through the second device, the method further includes one or more of the following: The first device connects to a wireless access point AP in the communication system, and accesses the internet by using a wireless local area network WLAN created by the AP; the first device connects to a network device in the communication system, accesses a cellular network through the network device, and accesses the internet by using the cellular network; or the first device accesses the internet in a wired manner.

In the foregoing implementation, when accessing the internet through the second device, the first device may also access the internet, to implement multi-channel network concurrency and increase a speed of communicating with the internet.

With reference to the first implementation of the first aspect, in some implementations, the Wi-Fi P2P connection between the first device and the second device and the connection between the first device and the AP are established by the first device by using a wireless fidelity Wi-Fi network interface controller. That is, even if only one Wi-Fi network interface controller is configured for the electronic device, the electronic device may share a network connection capability of another device by using the method in the first implementation of the first aspect.

With reference to the first implementation of the first aspect, in some implementations, the first device may establish a second communication connection to the second device, and receive, based on the second communication connection, the network connection capability information sent by the second device. After the first device selects the second device, and before the first device communicates with the internet through the second device, the first device may establish the first communication connection to the second device. The first communication connection and the second communication connection are different.

That is, the first device and the second device may use different connections to synchronize the network connection capability information and share the network connection capability.

With reference to the foregoing implementation, the second communication connection includes any one of the following: a communication connection established based on a wireless access point in the communication system, a communication connection established when the second device is in an AP mode, a wireless fidelity peer-to-peer Wi-Fi P2P connection, a Bluetooth connection, a near field communication NFC connection, a wired connection, or a remote connection.

With reference to the first implementation of the first aspect, in some implementations, the first device may establish the first communication connection to the second device, and receive, based on the first communication connection, the network connection capability information sent by the second device.

That is, the first device and the second device may use a same connection to synchronize the network connection capability information and share the network connection capability. In this way, interaction between the devices can be reduced, and network sharing efficiency can be improved.

With reference to the first implementation of the first aspect, in some implementations, before establishing the first communication connection to the second device based on the network connection capability information of the second device, the first device may receive network connection capability information sent by a third device other than the first device and the second device, where the network connection capability information sent by the third device indicates whether the third device connects to a network; and the first device selects the second device from a network-connected device. In this way, the first device may learn whether another device in the communication system connects to a network, and select a proper second device from the network-connected device to borrow a network connection capability of the second device.

With reference to the first implementation of the first aspect, in some implementations, the first device may select the second device from another device in the communication system in any one or more of the following manners.

1. The first device determines, in the network-connected electronic device as the second device, an electronic device selected by a user.

Specifically, the first device displays one or more device options. The device option corresponds to a network-connected device in the another device. The first device receives a first operation performed on the device option, and selects an electronic device corresponding to the device option on which the first operation is performed as the second device.

In the manner 1, the user may independently select the second device based on a requirement, to fully meet an actual requirement of the user and improve user experience.

2. The first device selects a trusted device as the second device from the network-connected electronic device.

The trusted device includes a device that logs in to a same system account as the first device, a device bound to the first device, a device that joins a same group as the first device, or a device that is set by a user.

In the manner 2, the first device may connect to the internet through a trusted and secure electronic device, to ensure data security of the first device and avoid a risk such as data leakage.

3. The first device selects a control device of the first device as the second device from the network-connected electronic device.

4. The network connection capability information further indicates network quality of another device, and the first device selects an electronic device with best network quality as the second device from the another network-connected device.

In this way, a network with best network quality can be shared with the first device, to improve efficiency of accessing the internet by the first device and improve user experience.

5. The first device determines a most recently selected device as the second device.

With reference to the first implementation of the first aspect, in some implementations, the first device may further select a to-be-shared first network connection manner in advance. There may be the following several methods for selecting the first network connection manner.

1. If the first device has a display, the first device may display one or more network connection manner options. The network connection manner option corresponds to a network connection manner, and the network connection manner includes one or more of the following: connecting to a network by using a cellular network or a WLAN, or in a wired manner. The first device receives a second operation performed on the network connection manner option. The first network connection manner is a network connection manner corresponding to the network connection manner option on which the second operation is performed.

2. If the first device does not have an information input/output apparatus, the control device of the first device may select the first network connection manner, and then notify the first device.

3. If the first device does not have a display, the user may enter a voice instruction, and the first device selects the first network connection manner based on the voice instruction.

After determining the first network connection manner, the first device may send indication information of the first network connection manner to the second device, so that the second device uses the first network connection manner to support the first device in communicating with the internet.

With reference to the first implementation of the first aspect, in some implementations, the first device may further select a to-be-shared first network in advance. There may be the following several methods for selecting the first network.

1. If the first device has a display, the first device may display one or more network options. The network option corresponds to a network to which the second device connects and that accesses the internet, and the second device connects to one or more networks that access the internet. The first device receives a third operation performed on the network option. The first network is a network corresponding to the network option on which the third operation is performed.

2. If the first device does not have an information input/output apparatus, the control device of the first device may select the first network, and then notify the first device.

3. If the first device does not have a display, the user may enter a voice instruction, and the first device selects the first network based on the voice instruction.

4. The first device determines a network with best network quality as the first network, determines a network borrowed for a largest quantity of times as the first network, or determines a most recently borrowed network as the first network.

After determining the first network, the first device may send indication information of the first network to the second device, so that the second device uses the first network to support the first device in communicating with the internet.

With reference to the first implementation of the first aspect, in some implementations, the second device may independently determine a first network used to support the first device in communicating with the internet. For example, the first network includes any one or more of the following: a network with best network quality, a most recently selected network, or any network in a network to which the second device connects and that accesses the internet.

With reference to the first implementation of the first aspect, in some implementations, before receiving the network connection capability information sent by the second device, the first device may further enable a first communication service. The first communication service is used by the first device to communicate with the internet through the second device based on the first communication connection to the second device.

A manner of enabling the first communication service may include: The first device receives a fourth operation used to enable the first communication service, and enables the first communication service in response to the fourth operation; or the first device enables the first communication service by default.

With reference to the first implementation of the first aspect, in some implementations, before the first device communicates with the internet through the second device, the first device may send a request message to the second device, where the request message is used by the first device to request to communicate with the internet through the second device; the second device displays third prompt information and a first control in response to the request message, where the third prompt information is used to provide a prompt indicating that the first device requests to communicate with the internet through the second device; and the second device receives a fifth operation performed on the first control, and sends a feedback message to the first device, where the feedback message indicates that the second device agrees to support the first device in communicating with the internet.

In the foregoing implementation, the first device can share the network connection capability of the second device only after the user agrees to share a network, so that the user can have full right to know.

With reference to the first implementation of the first aspect, in some implementations, before the first device communicates with the internet through the second device, the first device may send a request message to the second device, where the request message is used by the first device to request to communicate with the internet through the second device; and after receiving the request message, the second device may determine whether the first device is a trusted device of the second device, and if the first device is a trusted device of the second device, send a feedback message to the first device.

In the foregoing implementation, when the trusted device of the second device initiates the network sharing request, the second device may directly respond to the request, and support the first device in communicating with the internet. In this solution, no user intervention is required, data security of the first device is ensured, and a risk such as data leakage is avoided.

With reference to the first implementation of the first aspect, in some implementations, the communication system further includes a network device and a server. The second device connects to the network device, and accesses a cellular network through the network device. The cellular network accesses the internet. The network device connects to the server. The second device enables a traffic-free service for a first application. The method further includes: The server monitors a data packet transmitted by the second device by using the cellular network; and the server skips calculating traffic fees required for transmitting the data packet from the first application.

In the foregoing implementation, if the second device enables the traffic-free service, when a data packet involved in running of a traffic-free application in the first device is transmitted by using the cellular network of the second device, required traffic fees are not calculated.

With reference to the first aspect, in a second implementation, before sending the activation request to the operator server through the second device based on the first communication connection and receiving the profile sent by the operator server, the first device may further receive an activation instruction sent by the second device. The activation instruction triggers the first device to send the activation request to the operator server.

A subscriber identity module may include an eSIM or a physical blank SIM. The first device may be a first device for which a subscriber identity module is configured, and the second device may be a second device having a network connection capability.

The profile may be specifically an operator profile. The profile may include, for example, but is not limited to a combination of a file system, file content, data, and an application provided on a universal integrated circuit card (UICC), and mainly carries information such as an international mobile subscriber identity (IMSI) and an authentication parameter. After the profile is activated, a mobile network corresponding to the profile may be accessed. In this embodiment of this application, after the profile is activated, the subscriber identity module may connect to the network, and the first device for which the subscriber identity module is configured may be activated, to provide a communication service. The UICC may include a SIM and an eSIM. This is not limited in this application.

According to the method provided in the second implementation of the first aspect, the first device may establish a near field connection to the second device, so that the second device and the first device may serve as two peer network-connected parties, and serve as a server and a client for each other to provide respective services for each other. The first device may obtain the profile from the operator server by using a network of the second device, to activate the first device. In this technical solution, no devices other than the second device and the first device need to participate. This is very convenient, it is easier to meet an activation condition, and user experience is better. In addition, an operator does not need to preset a profile for the eSIM or the blank SIM. This can reduce costs of a device manufacturer and costs of a card manufacturer, and save operator number resources.

With reference to the second implementation of the first aspect, in some possible implementations, the receiving a profile from the operator server through the second device based on the near field connection includes: receiving a fourth data packet from the operator server from the second device based on the near field connection. The fourth data packet is a data packet fed back by the operator server for the activation request, and the fourth data packet carries the profile.

In the foregoing technical solution, the first device may use the second device as a server. After check performed by the operator server on the activation request sent by the first device to the operator server through the second device succeeds, the operator server may send the fourth data packet that carries the profile to the first device through the second device, so that the first device can be successfully activated.

With reference to the second implementation of the first aspect, in some possible implementations, the method further includes: sending management interface data of the first device to the second device based on the near field connection. The management interface data is used to generate a management interface, the management interface is used to enter an activation code and/or setting information, the activation code corresponds to the profile, and the setting information is used to configure a parameter of the first device.

In the foregoing technical solution, the first device may use the second device as a client, and the first device sends the management interface data to the second device based on the near field connection between the first device and the second device, so that the management interface is displayed on the second device, to provide an entry for entering the activation code and/or the setting information for the user, so as to help the user perform an activation operation and/or a setting operation on the first device.

With reference to the second implementation of the first aspect, in some possible implementations, the activation instruction and the activation request carry the activation code.

With reference to the second implementation of the first aspect, in some possible implementations, the method further includes: receiving the setting information from the second device based on the near field connection; and configuring the parameter of the first device based on the setting information.

In the foregoing technical solution, the first device may use the second device as a service end, and may receive the setting information from the second device based on the near field connection to the second device, so that in an activation process, the first device can respond to setting of the first device by the user, and configure the parameter of the first device.

With reference to the second implementation of the first aspect, in some possible implementations, the activation instruction, the activation request, and the profile are activation data, the management interface data and the setting information are setting data, and a transmission path of the activation data is different from a transmission path of the setting data.

In the foregoing technical solution, the first device may perform different processing on activation data and setting data generated by the first device or received from the second device.

With reference to the second implementation of the first aspect, in some possible implementations, that a transmission path of the activation data is different from a transmission path of the setting data includes: A destination address of the activation data is different from a destination address of the setting data.

The destination address of the activation data is different from the destination address of the setting data. The first device may set different destination addresses for the activation data and the setting data generated by the first device, and may further receive the activation data or the setting data from the second device, so that the management interface data of the first device may be sent to the second device, and the activation request of the first device may be sent to the operator server through the second device, to implement activation.

With reference to the second implementation of the first aspect, in some possible implementations, that a transmission path of the activation data is different from a transmission path of the setting data includes a near field connection manner used for transmitting the activation data is different from a near field connection manner used for transmitting the setting data. The near field connection manner includes a Bluetooth connection, a Wi-Fi direct connection, a serial bus (USB) connection, or an Ethernet connection.

When the first device and the second device establish at least two near field connection channels, the near field connection manner used for transmitting the activation data is different from the near field connection manner used for transmitting the setting data. The first device may send the activation data and the setting data generated by the first device to the second device through different near field connection channels, and receive the activation data and the setting data from the second device through different near field connection channels, so that the management interface data of the first device may be sent to the second device, and the activation request of the first device may be sent to the operator server through the second device, to implement activation.

With reference to the second implementation of the first aspect, in some possible implementations, that a transmission path of the activation data is different from a transmission path of the setting data includes: A port through which the activation data is transmitted is different from a port through which the setting data is transmitted.

When each of the first device and the second device has at least two transmission ports, the port through which the activation data is transmitted is different from the port through which the setting data is transmitted. The first device may send the activation data and the setting data generated by the first device to the second device through different ports according to a routing rule, and receive the activation data and the setting data from the second device through different ports, so that the management interface data of the first device may be sent to the second device, and the activation request of the first device may be sent to the operator server through the second device, to implement activation.

In a second implementation of the first aspect, this application provides an access point activation method. The method may be performed by a second device, may be performed by a component (for example, a chip or a chip system) disposed in a second device, or may be implemented by a logical module or software that can implement all or some functions of a second device. This is not limited in this embodiment of this application. The following is merely an example, and the access point activation method provided in this application is described by using the second device as an execution body.

For example, the method includes: sending an activation instruction to an access point, namely, a first device, based on a near field connection to the first device, where the activation instruction is used to download a profile; receiving an activation request from the first device based on the near field connection, where the activation request is used to request to download the profile from an operator server; forwarding the activation request to the operator server; receiving the profile from the operator server; and forwarding the profile to the first device based on the near field connection.

A subscriber identity module may include an eSIM or a physical blank SIM. The second device is a second device having a network connection capability, and the first device may be a first device for which a subscriber identity module is configured.

Based on the foregoing solution, the second device may establish a near field connection to the first device, so that the second device and the first device may serve as two peer network-connected parties, and serve as a server and a client for each other to provide respective services for each other. The second device may obtain the profile from the operator server by using a network of the second device, and forward the profile to the first device, to activate the first device. In this technical solution, no devices other than the second device and the first device need to participate. This is very convenient, it is easier to meet an activation condition, and user experience is better. In addition, an operator does not need to preset a profile for the eSIM or the blank SIM. This can reduce costs of a device manufacturer and costs of a card manufacturer, and save operator number resources.

With reference to the second implementation of the first aspect, in some possible implementations, the receiving the profile from the operator server includes: receiving a fourth data packet from the operator server. The fourth data packet is a data packet fed back by the operator server for the activation request, and the fourth data packet carries the profile.

In the foregoing technical solution, the second device may be used as a server of the first device. After check performed by the operator server on the activation request succeeds, the second device may help the first device receive the fourth data packet that carries the profile from the operator server.

With reference to the second implementation of the first aspect, in some possible implementations, the forwarding the profile to the first device based on the near field connection includes: forwarding the fourth data packet to the first device.

In the foregoing technical solution, the second device may be used as a server of the first device, and the second device may forward the fourth data packet that is received from the operator server and that carries the profile to the first device.

With reference to the second implementation of the first aspect, in some possible implementations, the method further includes: receiving management interface data of the first device from the first device based on the near field connection. The management interface data is used by the second device to display a management interface, the management interface is used to enter an activation code and/or setting information, the activation code corresponds to the profile, and the setting information is used to configure a parameter of the first device.

In the foregoing technical solution, the second device may be used as a client of the first device, receive the management interface data of the first device from the first device based on the near field connection to the first device, and display the management interface of the first device, to provide an entry for entering the activation code and/or the setting information for a user, so as to help the user perform an activation operation and/or a setting operation on the first device.

With reference to the second implementation of the first aspect, in some possible implementations, the activation instruction and the activation request carry the activation code.

With reference to the second implementation of the first aspect, in some possible implementations, the method further includes: sending the setting information to the first device based on the near field connection.

In the foregoing technical solution, the second device may be used as a server of the first device, and may send the setting information to the first device based on the near field connection to the first device in response to the setting operation performed by the user in the management interface of the first device, so that in an activation process, the first device can receive the setting information of the user for the first device.

With reference to the second implementation of the first aspect, in some possible implementations, that a transmission path of activation data is different from a transmission path of setting data includes: A destination address of the activation data is different from a destination address of the setting data.

The destination address of the activation data is different from the destination address of the setting data. The second device may set different destination addresses for activation data and setting data generated by the second device, and may further process or forward activation data or setting data sent by the first device and the operator server, so that the second device can receive the management interface data of the first device that is sent by the first device, and help the first device forward the activation request of the first device to the operator server, to implement activation.

With reference to the second implementation of the first aspect, in some possible implementations, that a transmission path of activation data is different from a transmission path of setting data includes: A near field connection manner used for transmitting the activation data is different from a near field connection manner used for transmitting the setting data. The near field connection manner includes a Bluetooth connection, a Wi-Fi direct connection, a serial bus (universal serial bus, USB) connection, or an Ethernet connection.

When the second device and the first device establish at least two near field connection channels, the near field connection manner used for transmitting the activation data is different from the near field connection manner used for transmitting the setting data. The second device may send activation data and setting data generated by the second device to the first device by using different near field connections, receive activation data and setting data from the first device through different near field connection channels, process the received setting data, and help the first device forward the received activation data to the operator server, to implement activation.

With reference to the second implementation of the first aspect, in some possible implementations, that a transmission path of activation data is different from a transmission path of setting data includes: A port through which the activation data is transmitted is different from a port through which the setting data is transmitted.

When each of the second device and the first device has at least two transmission ports, the port through which the activation data is transmitted is different from the port through which the setting data is transmitted. The second device may send activation data and setting data generated by the second device to the first device through different ports, receive activation data and setting data from the first device through different ports, process the received setting data, and help the first device forward the received activation data to the operator server, to implement activation.

According to a second aspect, this application provides a network connection method. The method is applied to a first device. The method includes an operation performed by the first device in any one of the first aspect or the possible implementations of the first aspect. For details, refer to the foregoing descriptions. Details are not described herein.

According to a third aspect, this application provides a network connection method. The method is applied to a second device. The method includes an operation performed by the second device in any one of the first aspect or the possible implementations of the first aspect. For details, refer to the foregoing descriptions. Details are not described herein.

According to a fourth aspect, this application provides a network connection method. The method is applied to a communication system including a fourth device, a fifth device, and an AP device. The method includes: The AP device is configured to: provide a captive portal wireless network, and send a first data packet to the fourth device after receiving an access request of the fourth device. The first data packet includes page data of a portal website, and the portal website is a login authentication website corresponding to the captive portal wireless network. The fourth device is configured to: obtain the first data packet sent by the AP device, and forward the first data packet to the fifth device. The fifth device is configured to: display a portal website page based on the page data of the portal website in the received first data packet, generate a second data packet corresponding to a login confirmation operation after detecting a fifth operation performed by a user on the portal website page, and send the second data packet to the fourth device. The fourth device is further configured to: receive the second data packet sent by the fifth device, forward the second data packet to the AP device, and determine that login authentication for the captive portal wireless network is completed.

According to the network connection method provided in the fourth aspect, the fourth device that does not have a web capability can display a login authentication page of the portal website by using a web capability of the fifth device, and complete login authentication for captive portal Wi-Fi, to access captive portal Wi-Fi.

With reference to the fourth aspect, that the fourth device determines that login authentication for the captive portal wireless network is completed includes: The fourth device determines, based on a first preset occasion, that login authentication for the captive portal wireless network is completed. The first preset occasion includes one or more of the following content: a state of a received data packet sent by the AP device or a data packet sent by the fifth device is a state indicating that sending of a hypertext transfer protocol HTTP data packet is disabled, a preset period, a preset time point, or a signal that is sent by the fifth device and that is used for confirming completion of login authentication is received.

In some implementations, in a process of forwarding the data packets sent by the AP device and the fifth device, the fourth device may determine, based on a preset login confirmation occasion, whether login authentication is completed, and after determining that login authentication is completed, access captive portal Wi-Fi provided by the AP device.

With reference to any one of the fourth aspect or the implementations of the fourth aspect, that the fourth device determines that login authentication for the captive portal wireless network is completed includes: The fourth device determines, in a first preset manner, that login authentication for the captive portal wireless network is completed. The first preset manner includes: after an HTTP request is sent to the AP device, if a received HTTP status code is not 302, it is determined that login authentication for the captive portal wireless network is completed; and/or after at least two domain name system DNS query requests with different domain names are sent to the AP device, if different internet protocol IP addresses corresponding to the at least two DNS query requests with different domain names are received, it is determined that login authentication for the captive portal wireless network is completed.

In some implementations, if the network provided by the AP device is captive portal Wi-Fi, a redirection technology preconfigured in the AP device includes an HTTP redirection technology or a DNS redirection technology. Therefore, the fourth device can quickly determine, in the first preset manner by using a received request response sent by the AP device, whether the network provided by the AP device is captive portal Wi-Fi. Further, network type determining efficiency can be improved, and network type determining difficulty can be reduced.

With reference to any one of the fourth aspect or the implementations of the fourth aspect, before the fourth device forwards the first data packet to the fifth device, the method further includes: The fourth device establishes a communication connection to the fifth device having a world wide web capability. That the fifth device has a web capability includes that HTTP or the hypertext transfer protocol secure HTTPS is supported, and a web application is installed.

In some implementations, when the fourth device does not have a web capability, and wants to access captive portal Wi-Fi, the fourth device needs to use the web capability of the fifth device. Therefore, after determining that a network type of the to-be-accessed network is captive portal Wi-Fi, the fourth device needs to establish a communication connection to the fifth device having a web capability, to transmit a data packet in a subsequent login authentication process.

With reference to any one of the fourth aspect or the implementations of the fourth aspect, the method further includes: The fourth device sends a disconnection signal to the fifth device. The disconnection signal is used to disconnect the communication connection to the fifth device.

In this way, after completing login authentication by using the web capability of the fifth device, the fourth device disconnects the communication connection to the fifth device, to independently access captive portal Wi-Fi.

With reference to any one of the fourth aspect or the implementations of the fourth aspect, that the fourth device obtains the first data packet sent by the AP device includes: The fourth device sends a network access request to the AP device, where the network access request carries at least one HTTP request and/or at least two DNS query requests with different domain names; receives a third data packet sent by the AP device, where the third data packet includes an address of the portal website; determines that the network provided by the AP device is the captive portal wireless network, and sends an access request of the portal website to the AP device, where the access request carries the address of the portal website; and receives the first data packet sent by the AP device.

In some implementations, when the fourth device needs to access a network, the fourth device needs to send an access request to a network hotspot. In addition, based on the fact that a redirection technology applied when the network provided by the AP device is captive portal Wi-Fi includes the HTTP redirection technology or the DNS redirection technology, the network access request carries at least one HTTP request and/or at least two DNS query requests with different domain names, so that the network type provided by the AP device can be determined based on a network access response.

With reference to any one of the fourth aspect or the implementations of the fourth aspect, the third data packet further includes an HTTP status code, and that the fourth device determines that the network provided by the AP device is the captive portal wireless network includes: If determining that the HTTP status code is 302, the fourth device determines that the network provided by the AP device is the captive portal wireless network.

With reference to any one of the fourth aspect or the implementations of the fourth aspect, that the fourth device determines that the network provided by the AP device is the captive portal wireless network includes: If determining that addresses in the third data packet are a same IP address, the fourth device determines that the network provided by the AP device is the captive portal wireless network.

According to the fourth aspect, after the fifth device sends the second data packet to the fourth device, the method further includes: The fifth device sends a signal for confirming completion of login authentication to the fourth device in response to a seventh operation performed by the user.

According to any one of the fourth aspect or the implementations of the fourth aspect, the fifth device has a world wide web (web) capability; that the fifth device has a web capability includes that the fifth device supports the hypertext transfer protocol HTTP or the hypertext transfer protocol secure HTTPS, and a web application is installed; and before the receiving the first data packet sent by the fourth device, the method further includes: establishing a communication connection to the fourth device.

According to any one of the fourth aspect or the implementations of the fourth aspect, the method further includes the fifth device receives a disconnection signal sent by the fourth device. The disconnection signal is used to disconnect the communication connection to the fourth device.

According to a fifth aspect, this application provides a network connection method. The method is applied to a fourth device. The method includes an operation performed by the fourth device in any one of the fourth aspect or the possible implementations of the fourth aspect. For details, refer to the foregoing descriptions. Details are not described herein.

According to a sixth aspect, this application provides a network connection method. The method is applied to a fifth device. The method includes an operation performed by the fifth device in any one of the fourth aspect or the possible implementations of the fourth aspect. For details, refer to the foregoing descriptions. Details are not described herein.

According to a seventh aspect, this application provides an electronic device, including a memory and one or more processors. The memory is coupled to the one or more processors. The memory is configured to store computer program code, and the computer program code includes computer instructions. The one or more processors invoke the computer instructions to enable the electronic device to perform the method in any one of the second aspect or the implementations of the second aspect, any one of the third aspect or the implementations of the third aspect, any one of the fifth aspect or the implementations of the fifth aspect, or any one of the sixth aspect or the implementations of the sixth aspect.

According to an eighth aspect, this application provides a communication system, including a first device and a second device. The first device is configured to perform the method in any one of the second aspect or the implementations of the second aspect, and the second device is configured to perform the method in any one of the third aspect or the implementations of the third aspect.

According to a ninth aspect, this application provides a communication system, including a fourth device and a fifth device. The fourth device is configured to perform the method in any one of the fifth aspect or the implementations of the fifth aspect, and the fifth device is configured to perform the method in any one of the sixth aspect or the implementations of the sixth aspect.

According to a tenth aspect, this application provides a computer-readable storage medium, including instructions. When the instructions run on an electronic device, the electronic device is enabled to perform the method in any one of the second aspect or the implementations of the second aspect, any one of the third aspect or the implementations of the third aspect, any one of the fifth aspect or the implementations of the fifth aspect, or any one of the sixth aspect or the implementations of the sixth aspect.

According to an eleventh aspect, this application provides a computer program product. When the computer program product runs on a computer, the computer is enabled to perform the method in any one of the second aspect or the implementations of the second aspect, any one of the third aspect or the implementations of the third aspect, any one of the fifth aspect or the implementations of the fifth aspect, or any one of the sixth aspect or the implementations of the sixth aspect.

According to a twelfth aspect, this application provides a circuit system. The circuit system includes a processing circuit. The processing circuit is configured to perform the method in any one of the first aspect or the implementations of the first aspect; or the processing circuit is configured to perform the method in any one of the second aspect or the implementations of the second aspect, any one of the third aspect or the implementations of the third aspect, any one of the fifth aspect or the implementations of the fifth aspect, or any one of the sixth aspect or the implementations of the sixth aspect.

According to a thirteenth aspect, this application provides a chip system, including at least one processor and at least one interface circuit. The at least one interface circuit is configured to: perform a sending and receiving function, and send instructions to the at least one processor. When the at least one processor executes the instructions, the at least one processor performs the method in any one of the second aspect or the implementations of the second aspect, any one of the third aspect or the implementations of the third aspect, any one of the fifth aspect or the implementations of the fifth aspect, or any one of the sixth aspect or the implementations of the sixth aspect.

According to the embodiments provided in this application, the electronic device can smoothly connect to the internet, and communicate with the internet.

DETAILED DESCRIPTION OF ILLUSTRATIVE EMBODIMENTS

The following clearly describes technical solutions in embodiments of this application with reference to the accompanying drawings. In the descriptions of embodiments of this application, unless otherwise specified, “/” indicates “or”. For example, A/B may indicate A or B. The term “and/or” in this specification merely describes an association relationship between associated objects, and indicates that three relationships may exist. For example, A and/or B may indicate the following three cases: Only A exists, both A and B exist, and only B exists. In addition, in the descriptions of embodiments of this application, “a plurality of” means two or more.

A term “user interface (UI)” in the following embodiments of this application is a medium interface for interaction and information exchange between an application or an operating system and a user, and implements conversion between an internal form of information and a form that can be accepted by the user. The user interface is source code written in a specific computer language such as Java or an extensible markup language (XML). The interface source code is parsed and rendered on a terminal device, and finally presented as content that can be identified by the user. The user interface is usually represented in a form of a graphical user interface (GUI), and is a user interface that is related to a computer operation and that is graphically displayed. The user interface may be a visual interface element such as text, an icon, a button, a menu, a tab, a text box, a dialog box, a status bar, a navigation bar, or a widget that is displayed on a display of the terminal device.

The following embodiments of this application provide a network connection method, a related apparatus, and a system. In the network connection method, an electronic device may smoothly connect to the internet by using a capability of another device, and communicate with the internet. The capability that is of the another device and that is used by the electronic device may include, for example, a network connection capability and a web capability. The electronic device may include a terminal device such as a mobile phone, a tablet computer, a large-screen television, a smart sound box, a smartwatch, or an in-vehicle infotainment, and may further include a device that may be used as a wireless access point (AP), for example, a router or customer premises equipment (CPE).

The internet is a collection of information and resources, and may be formed by interconnecting a plurality of subnets. The internet is configured to provide functions such as information search, query, and communication.

After connecting to a network, different electronic devices can communicate with the internet and provide different functions for a user.

For example, after connecting to a network, a terminal device such as a mobile phone, a tablet computer, a large-screen television, a smart sound box, a smartwatch, or an in-vehicle infotainment may provide various services, for example, music playing, video playing, navigation, and a game.

After connecting to a network, a device used as an AP, for example, a router or CPE, may send a wireless fidelity (Wi-Fi) signal, and enable a terminal device that receives the Wi-Fi signal to connect to the network through the AP.

With popularization of terminal devices, an individual may have a plurality of terminal devices. Most functions of the terminal device can be used only after the internet is accessed. The terminal device may connect to a wireless local area network (WLAN) through an AP, may directly connect to a cellular network, or may access the internet by borrowing a cellular network connection capability of another device by using a hotspot.

However, only one set of components, for example, a Wi-Fi network interface controller and an antenna, configured to receive and send a Wi-Fi signal is usually configured for the terminal device. If the terminal device connects to a WLAN generated by a wireless access point, the terminal device cannot borrow a cellular network of another device by using a hotspot.

In the network connection method provided in embodiments of this application, the terminal device may establish a communication connection to another device in a manner different from a hotspot, and the another device connects to the internet. Then, the terminal device may communicate with the internet through the another device based on the communication connection. That is, the terminal device may continuously borrow a network connection capability of the another device to connect to the internet. In this way, provided that another device near the terminal device connects to the internet, the terminal device may connect to the internet by borrowing a network connection capability of the another device. In some other embodiments, the terminal device may connect to the internet by borrowing a network connection capability of a remote device. The network connection capability is a capability of connecting to and accessing the internet.

The AP may be used to provide a public captive portal wireless network (captive portal Wi-Fi) for a user in public places such as an airport, a station, a shopping mall, and a cafe, to meet a network use requirement of the user and ensure network security. Herein, captive portal Wi-Fi is an open wireless network that provides security authentication. When the terminal device used as a station (STA) device requests to access captive portal Wi-Fi, the AP intercepts the request of the STA device, and provides a login portal page for specific authentication or user license agreement description. After determining that the STA device completes authentication or agrees to the license agreement, the AP allows the STA device to access captive portal Wi-Fi. Therefore, the STA device needs to have a world wide web (Web) capability to display a login portal page, complete user authentication or agree to a license agreement, and implement network access. However, some devices that do not have a web capability cannot access captive portal Wi-Fi. Consequently, the network use requirement of the user cannot be met, and user experience is affected.

In the network connection method provided in embodiments of this application, when a terminal device that does not have a web capability needs to access captive portal Wi-Fi, the terminal device may temporarily use a web capability of another terminal device to complete authentication, and access captive portal Wi-Fi, to meet a requirement of a user for different terminal devices to access captive portal Wi-Fi, and improve user experience.

An electronic device that supports an embedded subscriber identity module (eSIM) or a physical blank subscriber identity module (SIM), for example, an AP (for example, CPE), a smartwatch, a smart band, or an in-vehicle infotainment, can use, by using the eSIM or the blank SIM only after the eSIM or the blank SIM is activated, a network (for example, a cellular network) provided by a communication service operator. Usually, a device such as CPE creates a WLAN by using a hotspot, and another device such as a mobile phone connects to the WLAN to log in to a management interface of the CPE, to provide an entry for a user to perform an operation of activating an eSIM or a blank SIM. In addition, the device such as the CPE needs to access a network to complete activation. However, due to a limitation of a hotspot communication protocol, when the CPE is used as a server and a terminal device such as a mobile phone is used as a client to access the management interface of the CPE, the CPE cannot reversely access a network capability of the terminal device such as the mobile phone. Therefore, the device such as the CPE further needs to access the network through another device such as a router. That is, when the device such as the CPE activates the eSIM or the blank SIM, at least two other devices (for example, a mobile phone and a router) are required. One device is used to log in to a management interface of the device such as the CPE, and the other device is used to provide an initial network connection capability for the device such as the CPE. In this activation manner, there are many and complex operation steps, a large quantity of devices are involved, an activation condition is strict, and user experience is poor.

In the network connection method provided in embodiments of this application, an electronic device that supports an eSIM or a blank SIM, for example, CPE, a smartwatch, a smart band, or an in-vehicle infotainment, may establish a connection to a network-connected terminal device, the device such as the CPE may serve as a server to provide a management interface for the terminal device, and the terminal device may serve as a server to provide a network connection capability for the device such as the CPE, so that the device such as the CPE may connect to a network to activate the eSIM or the blank SIM. According to the network connection method, the electronic device that supports the eSIM or the blank SIM may temporarily borrow a network connection capability of another terminal device to successfully activate the eSIM or the blank SIM. In this method, no other devices need to participate. This is very convenient, it is easier to meet an activation condition, and user experience is better.

The following describes in detail the network connection method provided in embodiments of this application.

How a terminal device continuously borrows a network connection capability of another device to connect to a network is first described.

In the network connection method provided in embodiments of this application, the terminal device may establish a communication connection to another device in a manner different from a hotspot, and the another device connects to the internet. Then, the terminal device may communicate with the internet by borrowing a network connection capability of the another device based on the communication connection.

In embodiments of this application, a terminal device that borrows a network connection capability of another device may also be referred to as a client, a primary device, or a host, and another device that provides a network connection capability may also be referred to as a server, an auxiliary device, or an auxiliary machine. For ease of description, subsequently, the terminal device that borrows a network connection capability of another device is referred to as a first device, and the another device that provides a network connection capability is referred to as a second device.

A communication connection established by the first device to the second device in a manner different from a hotspot may include any one of the following: a wireless fidelity direct (Wi-Fi direct)/wireless fidelity peer-to-peer (Wi-Fi peer-to-peer, Wi-Fi P2P) connection, a Bluetooth (BT) connection, a near field communication (NFC) connection, an infrared (IR) connection, a wired connection, an Ethernet connection, a remote connection, or the like. The Bluetooth connection may be a classic Bluetooth connection, or may be a Bluetooth low energy (BLE) connection. The remote connection means that the first device and the second device each connect to a server and communicate with each other through the server.

The hotspot is a technology in which a cellular network signal received by a terminal device is converted into a Wi-Fi signal for sending. Establishing a connection by using a hotspot means that a terminal device works in an AP mode and creates a wireless local area network, and then another terminal device connects to the wireless local area network created by the terminal device, to establish a connection to the terminal device.

The second device may access the internet by using one or more of a WLAN created by a wireless access point, a cellular network, or a wired manner, and then the first device may access the internet by using the communication connection to the second device and a connection between the second device and the internet. That is, the second device may share one or more network connection capabilities of the second device with the first device. When the second device shares a plurality of network connection capabilities with the first device, a speed of communication between the first device and the internet can be increased, and user experience can be improved.

In the network connection method, in a process in which the first device establishes a communication connection to and communicates with the second device, the first device may further access the internet by using one or more of a WLAN created by a wireless access point, a cellular network, or a wired manner. The first device establishes a connection to the second device in a manner different from a hotspot. Therefore, the first device may simultaneously access the internet by using the WLAN created by the wireless access point. That is, the first device accesses the internet, which imposes no impact on borrowing, by the first device, a network connection capability of the second device. In this way, when accessing the internet through the second device, the first device may also access the internet, to implement multi-channel network concurrency and increase a speed of communicating with the internet.

FIG.1is a diagram of an architecture of a communication system10according to an embodiment of this application.

As shown inFIG.1, the communication system10includes a plurality of terminal devices, for example, a terminal device100and a terminal device200, and further includes one or more network devices300and one or more APs400.

The plurality of terminal devices, for example, the terminal device100or the terminal device200, in the communication system10may be of various types. A specific type of the terminal device100or the terminal device200is not limited in this embodiment of this application. For example, the terminal device100or the terminal device200may include a mobile phone, may further include a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, a large-screen television, a smart screen, a wearable device, an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, an in-vehicle infotainment, a smart headset, and a game console, and may further include an internet of things (IoT) device or a smart home device such as a smart sound box, a smart lamp, a smart air conditioner, a smart water heater, or a camera. This is not limited thereto. The terminal device100may further include a non-portable terminal device such as a laptop computer (laptop) having a touch-sensitive surface or a touch panel or a desktop computer having a touch-sensitive surface or a touch panel.

Different software operating systems (OS) may be configured for the plurality of terminal devices in the communication system10, and include but are not limited to Harmony OS, Android®, iOS®, Windows®, Linux®, and the like. A same software operating system may alternatively be configured for the plurality of terminal devices, for example, Harmony OS may be configured for the plurality of terminal devices.

The plurality of terminal devices in the communication system10may communicate with each other by using any one or more of the following technologies: Wi-Fi softAP, a WLAN, BT, Wi-Fi P2P, NFC, IR, a wired technology, or a remote communication technology. For example, the Wi-Fi softAP technology is the same as the hotspot. A terminal device may be implemented as a wireless access point by using software. After another device accesses a WLAN generated by the wireless access point, the terminal device may communicate with the another device by using Wi-Fi softAP. For another example, the terminal device may communicate with another device in a same wireless local area network by using a wireless local area network (WLAN). For another example, the terminal device may discover another nearby device by using a short-range communication technology such as BT or NFC, and communicate with the another device after establishing a communication connection to the another device. For another example, the plurality of terminal devices may log in to a same account, for example, log in to a same system account (for example, a Huawei account), then communicate, by using a cellular network technology such as 3G, 4G, or 5G or a wide area network technology, with a server (for example, a server provided by Huawei) that maintains the system account, and then communicate through the server.

It may be learned that the plurality of terminal devices in the communication system10may be terminal devices at a short distance, or may be terminal devices at a long distance.

The network device300is provided by a communication service operator, and is configured to communicate with the terminal device by using an air interface technology. The air interface technology may include 2G (for example, a global system for mobile communications (GSM)), 3G (for example, a universal mobile telecommunications system (UMTS), wideband code division multiple access (WCDMA), time division-synchronous code division multiple access (TD-SCDMA)), long term evolution (LTE)/4G, and a new radio access technology (new radio access technology, New RAT), for example, 4.5G, 5G, and future 6G.

The network device300may be a base transceiver station (BTS) in GSM or CDMA, may be a NodeB in WCDMA, or may be an evolved NodeB (eNB) or a relay station in LTE, an access network device in a 5G network, an access network device in a public land mobile network (PLMN), or the like.

The network device300is responsible for connecting the terminal device to a core network by using a wired or wireless communication technology, and providing a connection between the terminal device and the internet. The network device300, the core network, and the terminal device construct a cellular network.

The wireless access point400may be a router, CPE, a gateway, a bridge, or the like.

The wireless access point400is configured to create a WLAN. In some embodiments, the wireless access point400may be configured to create a captive portal wireless network (captive portal Wi-Fi). After joining the network created by the wireless access point400, the terminal device may connect to the internet through the wireless access point400.

A device such as a router, a gateway, or a bridge may be configured to convert a wired network into a wireless WLAN, to facilitate access by the terminal device.

The CPE is configured to: receive a mobile signal (namely, a cellular network signal) sent by the network device300, and forward the mobile signal in a form of a Wi-Fi signal. The CPE may simultaneously provide Wi-Fi signals for a plurality of terminal devices, may further enhance the Wi-Fi signals for a second time, and is a widely applied access device.

In this embodiment of this application, the terminal device100may learn of network connection capability information of another terminal device in the communication system10based on communication between terminal devices. The network connection capability information indicates whether the terminal device connects to a network, and may further indicate one or more of a network connection manner of the terminal device, an identifier of a network to which the terminal device connects and that accesses the internet, and quality of the network to which the terminal device connects and that accesses the internet. Specifically, each device may learn of the network connection capability information of the another terminal device by using one or more of a wireless technology such as Wi-Fi P2P, a Wi-Fi software access point (softAP), a WLAN, BT, NFC, or IR, a wired technology, or a remote connection technology.

Then, the terminal device100determines, in a network-connected terminal device, a terminal device that provides a network connection capability. The terminal device that is determined by the terminal device100and that provides the network connection capability may be referred to as the terminal device200. For a policy of determining, by the terminal device100, the terminal device that provides the network connection capability, refer to detailed descriptions in subsequent method embodiments. Details are not described herein. After the terminal device that provides the network connection capability is determined, a communication connection, for example, a Wi-Fi direct/Wi-Fi P2P connection, a BT connection, an NFC connection, an IR connection, a wired connection, an Ethernet connection, or a remote connection, may be established between the terminal device100and the terminal device200in a manner different from a hotspot. Herein, the connection that is established between the terminal device100and the terminal device200and that is different from the hotspot manner may be the same as or different from a communication connection established when the terminal device100obtains network connection capability information of the terminal device200. If the communication connection established when the terminal device100obtains the network connection capability information of the terminal device200is a connection different from the hotspot manner, after selecting the terminal device200, the terminal device100may not need to establish another communication connection.

The terminal device200connects to the internet. The terminal device200may access the WLAN created by the wireless access point400, and connect to the internet through the wireless access point400. The terminal device200may alternatively connect to the network device300, and connect to the internet by using the cellular network. The terminal device200may alternatively connect to the internet in a wired manner, for example, by using a network cable. In addition, the terminal device200may connect to the internet by using a combination of any several of the foregoing manners.

The terminal device100is configured to: access the internet based on the communication connection to the terminal device200and a connection between the second device and the internet, and communicate with the internet.

In a process in which the terminal device100establishes a communication connection to and communicates with the terminal device200, the terminal device100may also access the internet. The terminal device100may access the WLAN created by the wireless access point400, and connect to the internet through the wireless access point400. The terminal device100may alternatively connect to the network device300, and connect to the internet by using the cellular network. The terminal device100may alternatively connect to the internet in a wired manner, for example, by using a network cable. In addition, the terminal device100may connect to the internet by using a combination of any several of the foregoing manners. The terminal device100and the terminal device200may connect to different wireless access points400, or may connect to different network devices300.

In some embodiments, the communication system10may further include a server500provided by the communication service operator. The server500may connect to the network device300in a wired or wireless manner, for example, by using a wide area network (WAN) technology or a local area network (LAN) technology. The server500may be configured to monitor an amount of data transmitted by the terminal device by using the cellular network, that is, may monitor an amount of data transmitted by the terminal device through the network device300. The server500may charge each terminal device based on a detected amount of data transmitted by the terminal device. The communication service operator is a provider of the network device300.

In some embodiments, the server500may perform traffic-free processing on a data packet that is from a traffic-free application and that is transmitted by the terminal device200through the network device300, that is, waive fees required for transmitting the data packet. A data packet involved in communication of the terminal device200includes a data packet from the terminal device100.

For example, in a process in which the terminal device100communicates with the internet through the terminal device200, an involved data packet may further carry an identifier of an application or other information about an application (for example, an identifier or an address of a server that provides a service for the application). If the data packet is from a traffic-free application, the server500may waive fees required for transmitting the data packet. For descriptions of the traffic-free application, refer to descriptions in subsequent method embodiments.

The server500and the network device300may alternatively be combined into a same device. This is not limited herein. For example, the network device300may further perform an operation performed by the server500.

For specific functions of the devices in the communication system10, refer to detailed descriptions in subsequent method embodiments.

The communication system10shown inFIG.1is merely an example. In specific implementation, the communication system10may further include more devices. This is not limited herein. The communication system10may also be referred to as another term such as a distributed system. This is not limited herein.

FIG.2Ais a schematic diagram of a structure of a terminal device according to an embodiment of this application. The terminal device may be the terminal device100or the terminal device200in the communication system shown inFIG.1.

The controller may generate an operation control signal based on an instruction operation code and a time sequence signal, to complete control of instruction fetching and instruction execution.

A wireless communication function of the terminal device may be implemented by using the antenna1, the antenna2, the mobile communication module150, the wireless communication module160, the modem processor, the baseband processor, and the like.

The wireless communication module160may provide a wireless communication solution that is applied to the terminal device and that includes a wireless local area network (WLAN) (for example, a Wi-Fi network), Bluetooth (BT), a global navigation satellite system (GNSS), frequency modulation (FM), a near field communication (NFC) technology, an infrared (IR) technology, or the like. The wireless communication module160may be one or more components into which at least one communication processing module is integrated. The wireless communication module160receives an electromagnetic wave through the antenna2, performs frequency modulation and filtering processing on an electromagnetic wave signal, and sends a processed signal to the processor110. The wireless communication module160may further receive a to-be-sent signal from the processor110, perform frequency modulation and amplification on the signal, and convert the signal into an electromagnetic wave for radiation through the antenna2.

In this embodiment of this application, the terminal device may include one or more network interface controllers (NICs). The network interface controller is equipped with a built-in processor and memory, configured to perform operations such as data encapsulation and decapsulation, link management, and encoding and decoding.

The network interface controller may also be referred to as a network interface card, a physical network interface controller, a physical network interface card, or the like.

The network interface controller in the terminal device in this embodiment of this application may include any one or more of the following.

1. Wi-Fi Network Interface Controller in the Wireless Communication Module160

The Wi-Fi network interface controller supports standards such as 802.11a, 802.11b, 802.11g, and 802.11n formulated by the Institute of Electrical and Electronics Engineers (IEEE) and the Wi-Fi P2P technical specification formulated by the Wi-Fi Alliance. The Wi-Fi network interface controller supports the terminal device in communicating with another device by using the foregoing standard.

In some embodiments, some Wi-Fi network interface controllers may support only standards such as 802.11a, 802.11b, 802.11g, and 802.11n, and some other Wi-Fi network interface controllers may support only the Wi-Fi P2P technical specification.

Standards such as 802.11a, 802.11b, 802.11g, and 802.11n support the terminal device in connecting to a wireless local area network created by a wireless access point400, and further support the terminal device in connecting to a wireless local area network created when another device works in an AP mode. The Wi-Fi P2P technology specification supports the terminal device in establishing a Wi-Fi P2P connection to another device. One Wi-Fi network interface controller can simultaneously support the terminal device in connecting to a wireless local area network and establishing a Wi-Fi P2P connection to another device.

One Wi-Fi network interface controller cannot simultaneously support the terminal device in connecting to two or more wireless local area networks, and supports the terminal device in connecting to only one WLAN at a time. Therefore, one Wi-Fi network interface controller cannot connect to the WLAN created when the another device works in the AP mode while connecting to the WLAN created by the wireless access point400.

In some embodiments, the Wi-Fi network interface controller may further support a Bluetooth wireless communication technology standard formulated by the IEEE, for example, 802.15. The Bluetooth standard supports the terminal device in communicating with another device by using a Bluetooth technology.

2. Cellular Network Interface Controller in the Mobile Communication Module150

The cellular network interface controller supports standards such as GSM, GPRS, CDMA, WCDMA, TD-SCDMA, LTE, and NR. The cellular network interface controller supports the terminal device in communicating with another device by using the foregoing standard.

3. Wired Network Interface Controller

The wired network interface controller refers to an optical Ethernet adapter, which is also referred to as an optical network interface controller. The wired network interface controller connects to a network cable, and communicates with another device through the network cable. The wired network interface controller supports an Ethernet standard, and supports the terminal device in communicating with another device by using the Ethernet standard.

The display194is configured to display an image, a video, and the like. The display194includes a display panel. The display panel may be a liquid crystal display (LCD). The display panel may alternatively be manufactured by using an organic light-emitting diode (OLED), an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (flex light-emitting diode, FLED), a mini LED, a micro LED, a micro OLED, a quantum dot light emitting diode (QLED), or the like. In some embodiments, the terminal device may include one or N displays194, where N is a positive integer greater than 1.

The terminal device may implement a photographing function by using the ISP, the camera193, the video codec, the GPU, the display194, the application processor, and the like.

The internal memory121may include one or more random access memories (random access memory, RAM) and one or more nonvolatile memories (nonvolatile memory, NVM).

The random access memory may include a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (double data rate synchronous dynamic random access memory, DDR SDRAM, for example, a fifth generation DDR SDRAM is usually referred to as a DDR5 SDRAM), and the like. The nonvolatile memory may include a magnetic disk storage device, a flash memory, and the like.

The random access memory may be directly read and written by the processor110, may be configured to store an operating system or an executable program (for example, machine instructions) of another program that is running, and may be further configured to store data of a user, data of an application, and the like.

The nonvolatile memory may also store an executable program, data of a user, data of an application, and the like, which may be loaded into the random access memory in advance for directly reading and writing by the processor110.

The terminal device may implement an audio function, for example, music playing and recording, by using the audio module170, the speaker170A, the receiver170B, the microphone170C, the headset jack170D, the application processor, and the like.

The SIM card interface195is configured to connect to a SIM card. The SIM card may be inserted into the SIM card interface195or removed from the SIM card interface195, to come into contact with and be separated from the terminal device. The terminal device may support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface195may support a nano-SIM card, a micro-SIM card, a SIM card, and the like. A plurality of cards may be simultaneously inserted into a same SIM card interface195. The plurality of cards may be of a same type or of different types. The SIM card interface195is compatible with different types of SIM cards. The SIM card interface195is also compatible with an external storage card. The terminal device interacts with a network by using the SIM card, to implement functions such as a call and data communication. In some embodiments, the terminal device uses an eSIM, namely, an embedded SIM card. The eSIM card may be embedded into the terminal device, and cannot be separated from the terminal device.

The plurality of SIM cards may belong to different communication service operators, or may belong to a same communication service operator. The terminal device interacts, by using the SIM card, with a network device300provided by a communication service operator to which the SIM card belongs, to communicate with a cellular network, and implement functions such as a call and data communication.

Different SIM cards have different identifiers. The identifier of the SIM card may be, for example, an international mobile subscriber identity (IMSI) or a communication number (for example, a mobile phone number) bound to the SIM card.

It may be understood that the structure shown in this embodiment of this application does not constitute a specific limitation on the terminal device. In some other embodiments of this application, the terminal device may include more or fewer components than those shown in the figure, some components may be combined, some components may be split, or a different component arrangement may be used. For example, the terminal device shown inFIG.2Amay not have a component such as a display. The components shown in the figure may be implemented by hardware, software, or a combination of software and hardware.

When the terminal device shown inFIG.2Ais the terminal device100, details are as follows:

The wireless communication module160or the mobile communication module150may be configured to obtain network connection capability information of another terminal device in a communication system10.

The internal memory121is configured to store network connection capability information of the terminal device100, and is further configured to store network connection capability information of another terminal device that is obtained by the terminal device100.

The processor110is configured to select a terminal device as the terminal device200from a network-connected terminal device in the communication system10.

The wireless communication module160or the mobile communication module150is further configured to: establish a communication connection to the terminal device200in a manner different from a hotspot, and communicate with the internet through the terminal device200based on the communication connection, to the terminal device200, that is different from the hotspot.

The display194may be configured to display a user interface that is implemented on the terminal device100and that is provided in subsequent method embodiments.

For details about steps performed by modules in the terminal device100, refer to detailed descriptions in subsequent method embodiments.

When the terminal device shown inFIG.2Ais the terminal device200, details are as follows:

The wireless communication module160or the mobile communication module150may be configured to send network connection capability information of the terminal device200to another terminal device, including the terminal device100, in a communication system10.

The internal memory121is configured to store the network connection capability information of the terminal device200, and is further configured to store network connection capability information of another terminal device that is obtained by the terminal device200.

The wireless communication module160or the mobile communication module150is further configured to: establish a communication connection to the terminal device100in a manner different from a hotspot, and support the terminal device100in communicating with the internet based on the communication connection, to the terminal device100, that is different from the hotspot.

The display194may be configured to display a user interface that is implemented on the terminal device200and that is provided in subsequent method embodiments.

For details about steps performed by modules in the terminal device200, refer to detailed descriptions in subsequent method embodiments.

A software system of a terminal device may use a layered architecture, an event-driven architecture, a microkernel architecture, a micro service architecture, or a cloud architecture. The software system of the terminal device includes but is not limited to Harmony OS, Android®, iOS®, Windows®, Linux®, Unix®, MacOS®, and the like. In embodiments of this application, an Android system of a layered architecture is used as an example to describe a software structure of the terminal device. However, this is not limited in this application.

FIG.2B-1andFIG.2B-2are a block diagram of a software structure of a terminal device according to an embodiment of this application. The terminal device may be the terminal device100or the terminal device200in the communication system shown inFIG.1.

In a layered architecture, software is divided into several layers, and each layer has a clear role and task. The layers communicate with each other through a software interface. In some embodiments, an Android system is divided into five layers: an application layer, an application framework layer, an Android runtime and system library, a hardware abstraction layer (HAL), and a kernel layer from top to bottom.

As shown inFIG.2B-1andFIG.2B-2, the application framework layer may include a distributed network connection service, a system service (SystemService), a connectivity service (ConnectivityService), a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

The distributed network connection service is used to provide a connection between the terminal device and another device, and support the terminal device in accessing the internet by using the connection.

The distributed network connection service may include the following several modules: a network detection module, a dynamic enabling/disabling module, a device management module, a message management module, a traffic statistics collection module, a connection module, and a distributed network interface controller module.

The network detection module is configured to detect and synchronize a network connection capability. The network detection module may specifically include a network connection capability writing module, a network connection capability synchronization module, and a network quality sniffing module. The network connection capability writing module is configured to obtain a network connection capability of the terminal device. The network connection capability synchronization module is configured to send network connection capability information of the terminal device to another terminal device in the communication system10, and is further configured to receive network connection capability information sent by the another terminal device. The network quality sniffing module is configured to detect network quality of the terminal device.

The dynamic enabling/disabling module is responsible for managing enabling or disabling of the “distributed network connection” service. For example, when the terminal device100needs to connect to a network, but currently no network such as Wi-Fi or cellular is available, the dynamic enabling/disabling module automatically enables the “distributed network connection” service, to attempt to borrow a network connection capability of another device. For another example, if the terminal device100is currently borrowing a network connection capability of another device, but the another device suddenly loses the network connection capability, the dynamic enabling/disabling module searches around for another device that can connect to a network, and borrows a network connection capability of the another device.

The device management module is configured to manage another device associated with the terminal device. The device management module may specifically include a device trustlist module and an online/offline monitoring module. The device trustlist module is configured to manage a trustlist. The trustlist may include one or more devices. For specific implementation of the trustlist, refer to detailed descriptions in subsequent method embodiments. The online/offline monitoring module is responsible for sensing a device in the communication system10in which the terminal device100is located, for example, monitoring a device joining or leaving the communication system10.

The message management module is configured to transmit a message. The message management module may include a signaling transmission module configured to transmit signaling and a data encryption/decryption module configured to encrypt/decrypt data.

The traffic statistics collection module is configured to collect statistics on an amount of data transmitted by the terminal device by using a cellular network. Specifically, the traffic statistics collection module may collect statistics on an amount of data transmitted when the terminal device accesses the cellular network, or may collect statistics on an amount of data transmitted when the terminal device accesses the cellular network through another terminal device.

The connection module may be configured to create a communication connection between the terminal device and another terminal device in a manner other than a hotspot. For example, the connection module may be a P2P module or a Wi-Fi P2P service, and is configured to establish a Wi-Fi P2P connection between two terminal devices.

The distributed network interface controller module may include a distributed network connection initialization module and a distributed network connection configuration module. The distributed network connection initialization module is configured to: establish, inside the terminal device100, a distributed network that can sense an application, that is, notify each application that the application currently can borrow a network connection capability of another device to communicate with the internet, and bind the distributed network to the connection module, so that each application can borrow the network connection capability of the another device to access the internet. The distributed network connection configuration module is configured to obtain network configuration information, for example, an internet protocol (internet protocol, IP) address, a domain name, and a network connection status, of another device from which the terminal device borrows a network connection capability.

In the modules of the distributed network connection service, the network detection module may further belong to the connectivity service, and the dynamic enabling/disabling module, the device management module, the message management module, the traffic statistics collection module, the connection module, and the distributed network interface controller module may further belong to the system service.

The window manager is configured to manage a window program. The window manager may obtain a size of a display, determine whether there is a status bar, perform screen locking, take a screenshot, and the like.

The content provider is configured to store and obtain data, and enable the data to be accessed by an application. The data may include a video, an image, audio, calls that are made and answered, a browsing history and bookmarks, an address book, and the like.

The phone manager is configured to provide a communication function of the terminal device, for example, management of a call status (including answering, declining, or the like).

The resource manager provides various resources such as a localized string, an icon, a picture, a layout file, and a video file for an application.

The notification manager enables an application to display notification information in a status bar, and may be configured to convey a notification message that may automatically disappear after a short pause and require no user interaction. For example, the notification manager is configured to: notify download completion, provide a message notification, and the like. The notification manager may alternatively be a notification that appears in a top status bar of the system in a form of a graph or scroll bar text, for example, a notification of an application running in background or a notification that appears on a screen in a form of a dialog window. For example, text information is displayed in the status bar, an alert tone is made, the terminal device vibrates, or an indicator light flashes.

The HAL is an interface layer between a kernel and hardware, and provides an interface for invoking hardware of the terminal device. The HAL may include a plurality of modules, and each module implements a set of interfaces for a particular type of hardware. When the application framework layer invokes the hardware of the terminal device, the terminal device may load a corresponding module in the HAL. For example, the HAL layer may include a local RIL, an RILD, a Netd, a local NIC, a distributed NIC, and the like. The local RIL and the RILD are bridges for communication between telephony and a modem. The Netd is a background daemon program specifically responsible for network management and control. The local NIC provides an interface for invoking a network interface controller to connect the terminal device to the internet. The distributed NIC provides an interface for invoking a network interface controller to connect the terminal device to the internet by borrowing a network connection capability of another device.

The kernel library includes two parts: a function that needs to be invoked in a Java language and a kernel library of Android.

The application layer and the application framework layer run on the virtual machine. The virtual machine executes Java files at the application layer and the application framework layer as binary files. The virtual machine is configured to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

The system library may include a plurality of functional modules, for example, a surface manager (surface manager), a media library (Media Libraries), a three-dimensional graphics processing library (for example, OpenGL ES), and a 2D graphics engine (for example, SGL).

The 2D graphics engine is a drawing engine for 2D drawing.

The following describes, with reference to a series of user interfaces provided in an example of this application, the network connection method provided in embodiments of this application.

FIG.3AtoFIG.3Ishow examples of user interfaces involved when a terminal device100having a display borrows a network connection capability of another device.

In a possible implementation, the device that provides the network connection capability for the terminal device100may be a trusted device of the terminal device100. The trusted device may include but is not limited to at least one of the following devices: a device that logs in to a same account or home account as the terminal device100, a device bound to the terminal device100, a device that joins a same group (for example, a family group) as the terminal device100, a device authenticated by the terminal device100through scanning, a device used by a contact added by the terminal device100, a device that is preset by a user to which the terminal device100belongs, a device located in a same local area network as the terminal device100, a device that is set by a user, or the like. The trusted device provides the network connection capability for the terminal device100, to improve data security of the terminal device100and avoid a risk of data leakage.

In some other embodiments, the device that provides the network connection capability for the terminal device100may be a device in a communication system10in which the terminal device100is located, for example, may be a device, in the communication system10, selected by a user, or may be a device, in the communication system10, selected by the terminal device100by default.

FIG.3Ashows an example user interface31that is on the terminal device100and that is used to display an installed application.

A status bar, a calendar and time indicator, a weather indicator, a page indicator, a tray that includes a frequently used application icon, and other application icons are displayed in the user interface31.

The status bar may include one or more signal strength indicators of a mobile communication signal (which may also be referred to as a cellular signal), a Bluetooth indicator, one or more signal strength indicators of a Wi-Fi signal, a battery status indicator, a time indicator, and the like. The calendar and time indicator indicates a calendar and current time.

The weather indicator indicates weather.

The page indicator may indicate a specific page on which a user is currently browsing an application icon. In this embodiment of this application, application icons may be distributed on a plurality of pages, and the user may slide to the left or to the right to browse application icons on different pages.

Icons of frequently used applications, for example, a phone icon, a messaging icon, a camera icon, and a contacts icon, may be displayed in the tray that includes a frequently used application icon.

The other application icons are used to display icons of some applications installed in the terminal device, for example, may include an icon of a video application, an icon of a wallet, an icon of a file browser, an icon of a calendar, an icon of a device management application, an icon of a settings application, and an icon of a gallery application.

This is not limited thereto. The user interface31shown inFIG.3Amay further include a navigation bar, a sidebar, and the like. In some embodiments, the user interface31shown as an example inFIG.3Amay be referred to as a home screen.

FIG.3BandFIG.3Cshow a manner in which the terminal device100borrows a network connection capability of another device by using a notification bar.

With reference toFIG.3A, the terminal device100may detect a user operation that is of sliding downward from the top and that is performed on the user interface31, and display, in response to the user operation, a notification bar301shown inFIG.3B.

This is not limited to the manner shown inFIG.3A. When displaying another user interface, the terminal device100may display, in response to a detected user operation of sliding downward from the top, a notification bar301shown inFIG.3B.

On/off controls of some functions, for example, a wireless local area network (WLAN) on/off control301a, a cellular network on/off control301b, a “distributed network connection” on/off control301c, a Bluetooth on/off control, a flashlight on/off control, a sound on/off control, an airplane mode on/off control, an auto-rotate on/off control, and a screenshot on/off control, are displayed in the notification bar301.

“Distributed network connection” is a service or function provided by the terminal device, and is used to support the terminal device in establishing, in a manner different from a hotspot, a communication connection to another device that accesses the internet, and communicating with the internet through the another device based on the communication connection. That is, “distributed network connection” supports the terminal device in borrowing a network connection capability of another device and sharing a network of the another device.

“Distributed network connection” is merely a word used in this embodiment, a meaning represented by the word is recorded in this embodiment, and a name of the word cannot constitute any limitation on this embodiment. In some other embodiments of this application, “distributed network connection” may also be referred to as another term such as “network sharing”.

An implementation form of each on/off control of a function in the notification bar301is not limited in this embodiment of this application, for example, may be an icon or text.

In addition, the calendar and time indicator, a settings control, a screen brightness adjustment bar, and the like may be further displayed in the notification bar301.

The terminal device100may detect a user operation (for example, a tap operation or a touch operation) performed on an on/off control of a function in the notification bar301, and enable or disable the function corresponding to the control in response to the user operation.

As shown inFIG.3B, the terminal device may further detect a user operation performed on the “distributed network connection” on/off control301c, and directly borrow a network connection capability of another device in response to the operation, or borrow a network connection capability of another device after the another device agrees. Specifically, the terminal device100selects a network-connected terminal device as a terminal device200from another terminal device in the communication system10, and establishes a communication connection to the terminal device200in a manner different from a hotspot, to borrow a network connection capability of the terminal device200. Herein, for a policy of selecting the terminal device200by the terminal device100and specific implementation in which the terminal device100borrows the network connection capability of the terminal device200, refer to detailed descriptions in subsequent method embodiments.

As shown inFIG.3C, after responding to the user operation performed on the on/off control of the function in the notification bar301, the terminal device100may highlight the corresponding on/off control, to prompt the user with information indicating that the function corresponding to the on/off control is enabled. For example, the wireless local area network (WLAN) on/off control301aand the “distributed network connection” on/off control301care highlighted inFIG.3C, to prompt the user with information indicating that both a WLAN function and a network sharing function are enabled.

FIG.3DtoFIG.3Fshow another manner in which the terminal device100borrows a network connection capability of another device by using a notification bar.

FIG.3DandFIG.3Eshow a manner in which the terminal device100borrows a cellular network capability of another device by using a notification bar.

A user interface31shown inFIG.3Dmay be displayed by the terminal device100in response to the user operation of sliding downward from the top inFIG.3A.

A difference between the user interfaces31shown inFIG.3DandFIG.3Blies in that a notification bar301inFIG.3Ddoes not include a “distributed network connection” on/off control301c, a drop-down control301a-1is added to a wireless local area network (WLAN) on/off control301a, and a drop-down control301b-1is added to a cellular network on/off control301b.

As shown inFIG.3D, the terminal device100may detect a user operation performed on the cellular network on/off control301bor a user operation performed on the drop-down control301b-1, and display a cellular network settings window302shown inFIG.3E.

A cellular network display area302aof this device and a cellular network display area302bof another device are displayed in the cellular network settings window302.

The display area302ais used to display a cellular network option corresponding to a cellular network to which the terminal device100connects, for example, cellular network options302a-1and302a-2.

The display area302bis used to display a cellular network option corresponding to a cellular network to which another terminal device in the communication system10connects, for example, cellular network options302b-1and302b-2.

Each terminal device connects to a cellular network by using a SIM card. Therefore, the cellular network to which the terminal device can connect is a cellular network to which the terminal device can connect by using a SIM card. One terminal device may connect to one or more cellular networks.

In this embodiment of this application, the cellular network option indicates a cellular network, and may include an identifier of a SIM card in the terminal device, for example, a phone number or an international mobile subscriber identity (IMSI). The cellular network option may further include an identifier of an air interface technology currently provided by a network device300to which the terminal device can connect by using the corresponding SIM card, where the air interface technology is, for example, 2G, 3G, 4G, or 5G, so that the user can select a proper air interface technology for the terminal device100to access the cellular network.

In addition to an identifier of a SIM card in the another device, the cellular network option in the display area302bmay further include a device identifier, for example, a name and a model of a device that connects to a corresponding cellular network. That is, the cellular network option inFIG.3Eis also a device option. In this way, it may be convenient for the user to select a proper terminal device200for the terminal device100and borrow a cellular network capability of the terminal device200.

The terminal device100may detect a user operation of selecting the cellular network option in the display area302a, then detect a user operation performed on an OK control302c, and connect to a cellular network corresponding to the cellular network option in response to the operation. In some other embodiments, after detecting a user operation of selecting the cellular network option in the display area302a, the terminal device100may directly connect to a cellular network corresponding to the cellular network option.

The terminal device100may detect a user operation of selecting the cellular network option in the display area302b, then detect a user operation performed on the OK control302c, and in response to the operation, directly borrow a cellular network of a device corresponding to the cellular network option, or request to borrow a cellular network of a device corresponding to the cellular network option.

In some other embodiments, in response to a detected user operation of selecting the cellular network option in the display area302b, the terminal device100may directly borrow a cellular network of a device corresponding to the cellular network option, or request to borrow a cellular network of a device corresponding to the cellular network option.

Herein, the device corresponding to the cellular network option selected by the terminal device100in the display area302bis the terminal device200selected by the terminal device100. For specific implementation in which the terminal device100borrows the cellular network of the terminal device200, refer to detailed descriptions in subsequent method embodiments.

FIG.3DandFIG.3Fshow a manner in which the terminal device100borrows a WLAN capability of another device by using a notification bar.

The terminal device100may further detect a user operation performed on the wireless local area network (WLAN) on/off control301ainFIG.3Dor a user operation performed on the drop-down control301a-1, and display a wireless local area network (WLAN) settings window303shown inFIG.3F.

A WLAN display area303aof this device and a WLAN display area303bof another device are displayed in the WLAN settings window303.

The display area303ais used to display a WLAN option corresponding to a WLAN found by the terminal device100, for example, WLAN options303a-1and303a-2.

The display area303bis used to display a WLAN option corresponding to a WLAN to which another device in the communication system10connects, for example, WLAN options303b-1and303b-2. Herein, all WLANs corresponding to the WLAN options in the display area303baccess the internet.

One terminal device may connect to one or more WLAN networks. The terminal device connects to the WLAN by using a Wi-Fi network interface controller. When a plurality of Wi-Fi network interface controllers are configured for the terminal device, the terminal device may connect to a plurality of WLANs.

The WLAN option may include an identifier of a WLAN, for example, a name of an available WLAN.

In addition to the identifier of the WLAN, the WLAN option in the display area303bmay further include a device identifier, for example, a name and a model of a device that connects to a corresponding WLAN. That is, the WLAN option inFIG.3Fis also a device option. In this way, it may be convenient for the user to select a proper terminal device200for the terminal device100and borrow a WLAN capability of the terminal device200.

The terminal device100may detect a user operation of selecting the WLAN option in the display area303a, then detect a user operation performed on an OK control303c, and connect to a WLAN corresponding to the WLAN option in response to the operation. In some other embodiments, after detecting a user operation of selecting the WLAN option in the display area303a, the terminal device100may directly connect to a WLAN corresponding to the WLAN option.

The terminal device100may detect a user operation of selecting the WLAN option in the display area303b, then detect a user operation performed on the OK control303c, and in response to the operation, directly borrow a WLAN of a device corresponding to the WLAN option, or request to borrow a WLAN of a device corresponding to the WLAN option.

In some other embodiments, in response to a detected user operation of selecting the WLAN option in the display area303b, the terminal device100may directly borrow a WLAN of a device corresponding to the WLAN option, or request to borrow a WLAN of a device corresponding to the WLAN option.

Herein, the device corresponding to the WLAN option selected by the terminal device100in the display area303bis the terminal device200selected by the terminal device100. For specific implementation in which the terminal device100borrows the WLAN of the terminal device200, refer to detailed descriptions in subsequent method embodiments.

FIG.3GtoFIG.3Ishow a manner in which the terminal device100borrows a network connection capability of another device by using a settings application (settings).

FIG.3Gshows a user interface32provided by the settings application installed in the terminal device100. The user interface32may be displayed by the terminal device100in response to a user operation performed on the icon of the settings application in the user interface31shown inFIG.3A, or displayed in response to a user operation performed on the settings control inFIG.3BorFIG.3C. The settings application is an application used to set functions of the terminal device.

As shown inFIG.3G, one or more functional options, for example, a system account option, an airplane mode on/off option, a WLAN option304, a cellular network option305, and a Bluetooth option, are displayed in the user interface32.

The terminal device100may detect a user operation performed on the cellular network option305, and display a user interface33used to set a cellular network. Content displayed in the user interface33is similar to that in the cellular network settings window302inFIG.3E. The user may set, in the user interface33, a cellular network to which the terminal device100of the user connects and a borrowed cellular network of another device. For a specific operation, refer to related descriptions inFIG.3E.

The terminal device100may further detect a user operation performed on the WLAN option304, and display a user interface34used to set a WLAN. Content displayed in the user interface34is similar to that in the WLAN settings window303inFIG.3F. The user may set, in the user interface34, a WLAN to which the terminal device100of the user and a borrowed WLAN of another device. For a specific operation, refer to related descriptions inFIG.3F.

It may be learned from user interfaces31shown inFIG.3EandFIG.3Fthat the user may simultaneously select a plurality of network options. For example, as shown inFIG.3E, the user may select a cellular network option of this device to access a cellular network of this device, or may select a cellular network option of another device in the communication system10to borrow a cellular network of the another device. For example, as shown inFIG.3F, the user may select a WLAN option of this device to access a WLAN of this device, or may select a WLAN option of another device in the communication system10to borrow a WLAN of the another device.

In some other embodiments, after the user selects a plurality of network options, the terminal device100may access or borrow a network corresponding to the network option according to a preset rule. The preset rule is not limited in this embodiment of this application. For example, as shown inFIG.3EorFIG.3F, if the user selects a plurality of network options, the terminal device100may preferentially borrow a network of another device.

This is not limited to simultaneous selection of a plurality of network options. In some embodiments, the terminal device100may allow selection of only one network option at a time. In this way, the terminal device100may directly access or borrow a network corresponding to the network option selected by the user.

This is not limited to the several manners that are shown as examples inFIG.3AtoFIG.3Iand in which the terminal device100borrows a network connection capability of another device. In some other embodiments, the terminal device100may borrow the network connection capability of the another device in another manner. This is not specifically limited herein.

For example, the settings application in the terminal device100may provide a “distributed network connection” on/off control, and after a user operation performed on the on/off control is detected, a network connection capability of another device is borrowed.

For another example, the terminal device100may further display a device option of a network-connected terminal device in the communication system10. Then, the terminal device100may detect a user operation performed on the device option, and borrow a network connection capability of the terminal device corresponding to the device option in response to the user operation. Herein, for details about a network connection manner and a specific network in the network connection capability borrowed by the terminal device100, refer to detailed descriptions in subsequent method embodiments. Details are not described herein.

This is not limited to the cellular network option and the WLAN option shown inFIG.3DtoFIG.3I. The terminal device100may further provide more network connection manner options of other devices, for example, a wired manner, for the user to select.

After successfully borrowing the network connection capability of the another device, the terminal device100may further output prompt information to prompt the user with information indicating that the terminal device100is currently borrowing the network connection capability of the another device.

FIG.3HandFIG.3Ifurther show prompt information output after the terminal device100successfully borrows a network connection capability of another device.

As shown inFIG.3HandFIG.3I, after successfully borrowing the network connection capability of the another device, the terminal device100may display a network sharing identifier306in the status bar. The network sharing identifier306indicates that the terminal device100is currently borrowing the network connection capability of the another device.

In some embodiments, the terminal device100may further display more information in the status bar. For example, indication information307of a network connection manner borrowed by the terminal device100may be further displayed in the status bar. The network connection manner may include connecting to the internet by using a cellular network, a WLAN, a wired network, or the like. The cellular network may further include 2G, 3G, 4G, 5G, 6G, or the like. For example, indication information307inFIG.3Hindicates that the terminal device100currently borrows a 5G cellular network of another device, and indication information307inFIG.3Iindicates that the terminal device100currently borrows a WLAN of another device.

In some embodiments, the terminal device100may further display an identifier of the borrowed network, an identifier of the terminal device200that provides the network connection capability, network quality of the borrowed network, and the like in the status bar.

The foregoing information is not limited to being displayed in the status bar. In some other embodiments, the terminal device100may prompt, in another manner, the user with information indicating that the terminal device100is currently borrowing the network connection capability of the another device, the borrowed network connection manner, the borrowed network, network quality of the terminal device200, and the network quality of the borrowed network. This is not limited herein. For example, the terminal device100may further output voice prompt information.

The terminal device100with the user interfaces shown inFIG.3AtoFIG.3Ihas a display, and the terminal device100having a display may borrow a network connection capability of another device in the manners shown inFIG.3AtoFIG.3I.

This is not limited thereto. A terminal device100that does not have a display may also borrow a network connection capability of another device.

FIG.4AtoFIG.4Cshow examples of user interfaces involved when a terminal device100that does not have a display borrows a network connection capability of another device.

FIG.4AtoFIG.4Cshow user interfaces provided by a control device of the terminal device100, for example, a terminal device300. The terminal device300is also a terminal device in the communication system10shown inFIG.1. For example, the terminal device300may be a mobile phone, and the terminal device100may be a device, for example, a smart sound box, that does not have a display.

A terminal device in the communication system10may be bound to another device. After being bound to the another device, the terminal device may manage functions of the bound another device by using a device management application configured to manage a bound device.

FIG.4Ashows an example of a user interface41provided by a device management application installed in the terminal device300. A tab of one or more devices bound to the terminal device300, for example, a tab401of a smartwatch, a tab402of a tablet computer, and a tab403of a smart sound box, and a control404used to bind a new device are displayed in the user interface41.

The control404may be configured to detect a user operation, and the terminal device300may discover another nearby device in response to the user operation, and be bound to the another nearby device. A manner in which the terminal device300discovers and is bound to the another device is not specifically limited herein. For example, the terminal device300may discover the another device by using a technology such as Bluetooth or Wi-Fi, then send a binding request, and be successfully bound to the another device.

The tab of the device may include a picture and a name of the device, a status of connection to the terminal device100, and the like. The tab of the device may detect a user operation, and the terminal device300may display more information about the device corresponding to the tab in response to the user operation.

As shown inFIG.4A, the terminal device300may detect a user operation performed on the tab403of the terminal device100(namely, the smart sound box), and display, in response to the user operation, a user interface42shown inFIG.4B.

A back button405, a current page indicator406, an information display area407of the smart sound box, a control408, and a control409are displayed in the user interface42.

The back button405is used to monitor a user operation, and the terminal device300may display a previous-level interface in response to the user operation, for example, display the user interface41shown inFIG.4A.

The current page indicator406indicates a current page. For example, text information “smart sound box” indicates that the current page is a page used to manage the smart sound box.

The information display area407is used to display various pieces of information about the smart sound box, for example, may include a picture, a status of connection to the terminal device300, and a remaining battery level.

The control409is configured to monitor a user operation, and the terminal device300may display, in response to the user operation, a page used to set a network connection function of the terminal device100(namely, the smart sound box).

A user interface43shown inFIG.4Cis an example of the page used to set the network connection function of the terminal device100(namely, the smart sound box). A back button, a current page indicator, current network information410, a “distributed network connection” on/off control411, and a network option of one or more other devices, for example, WLAN options412aand412band a cellular network option412c, are displayed in the user interface43.

The back button is used to monitor a user operation, and the terminal device300may display a previous-level interface in response to the user operation, for example, display the user interface42shown inFIG.4B.

The current page indicator indicates a current page. For example, text information “smart sound box and network setting” indicates that the current page is used to set the network connection function of the terminal device100(namely, the smart sound box).

The current network information410is used to display a network to which the terminal device100(namely, the smart sound box) currently connects. As shown inFIG.4C, the terminal device100(namely, the smart sound box) currently connects to a WLAN named “Wi-Fi1”.

The “distributed network connection” on/off control411is configured to monitor a user operation, and the terminal device300may enable or disable “distributed network connection” of the terminal device100(namely, the smart sound box) in response to the user operation.

As shown inFIG.4C, after the terminal device enables distributed network sharing, the terminal device300displays a network option of one or more other devices. For specific implementation of the network option, refer to related descriptions of the cellular network option inFIG.3Eand the WLAN option inFIG.3F.

The terminal device300may trigger, in response to a detected user operation of selecting the network option, the terminal device100(namely, the smart sound box) to borrow a network provided by a device corresponding to the network option. Herein, the device corresponding to the network option is a terminal device200.

This is not limited to the manner shown inFIG.4C. The terminal device300may trigger, in another manner, the terminal device100(namely, the smart sound box) to borrow a network provided by another device. For example, the terminal device300may provide different network options, in different network connection manners, for a user to select. For another example, after enabling distributed network sharing, the terminal device300may further directly trigger the terminal device100to borrow a network provided by another device.

This is not limited to the manner that is shown inFIG.4AtoFIG.4Cand in which the terminal device300is used to trigger the terminal device100to borrow a network connection capability of another device. When the terminal device100does not have a display, the terminal device100may further receive a voice instruction of the user, and borrow a network connection capability of another device in response to the voice instruction. In addition, the terminal device100may further directly borrow a network connection capability of the control device of the terminal device100, a network connection capability of a device that logs in to a same system account as the terminal device100, or the like. For details, refer to detailed descriptions in subsequent method embodiments.

FIG.5AtoFIG.5Cshow user interfaces involved when a terminal device200provides a network connection capability for a terminal device100.

FIG.5Ashows a user interface51displayed when the terminal device200receives a request for borrowing the network connection capability from the terminal device100.

A prompt window501is displayed in the user interface51. Prompt information501a, a control501b, and a control501care displayed in the prompt window501.

The prompt information501ais used to prompt a user with information indicating that the terminal device100currently requests to borrow the network connection capability of the terminal device200. In some embodiments, the prompt information501amay further provide a prompt indicating a type of a network that the terminal device100requests to borrow.

The control501bis configured to monitor a user operation, and the terminal device200may agree, in response to the user operation, to lend the network connection capability to the terminal device100.

The control501cis configured to monitor a user operation, and the terminal device200may decline, in response to the user operation, to lend the network connection capability to the terminal device100.

This is not limited to the prompt window501shown inFIG.5A. The terminal device200may respond, in another manner, to the request for borrowing the network connection capability from the terminal device100. For example, the terminal device100may generate and display a PIN code. After the user enters the same PIN code on the terminal device200, the terminal device200agrees to lend the network connection capability to the terminal device100.

FIG.5Bshows prompt information displayed by the terminal device200after the terminal device100successfully borrows the network connection capability of the terminal device200.

As shown inFIG.5B, the terminal device200may display prompt information502in a form of a notification. The prompt information502is used to prompt the user with information indicating that the terminal device100starts to share the network connection capability of the terminal device200. In some embodiments, the prompt information502may further provide a prompt indicating a type of a network borrowed by the terminal device100. The prompt information502may disappear after being displayed for a period of time, and require no user interaction.

FIG.5Cshows another type of prompt information output by the terminal device200after the terminal device100successfully borrows a network connection capability of another device.

As shown inFIG.5C, after lending the network connection capability to the terminal device100, the terminal device200may display a network sharing identifier503in a status bar. The network sharing identifier503is used to provide a prompt indicating that the terminal device200is currently lending the network connection capability to another device.

In some embodiments, the terminal device200may further display more information in the status bar. For example, indication information504of a network connection manner lent by the terminal device200to the another device may be further displayed in the status bar. The network connection manner may include accessing the internet by using a cellular network, a WLAN, a wired network, or the like. The cellular network may further include 2G, 3G, 4G, 5G, 6G, or the like. For example, the indication information504inFIG.5Cindicates that the terminal device200currently lends a 5G cellular network to the another device.

In some embodiments, the terminal device200may further display an identifier of the terminal device100that borrows the network connection capability, network quality of the borrowed network, and the like in the status bar.

The foregoing information is not limited to being displayed in the status bar. In some other embodiments, the terminal device200may prompt, in another manner, the user with information indicating that the terminal device200is currently lending the network connection capability to the another device, the provided network connection manner, network quality of the terminal device100that borrows the network connection capability, and the network quality of the borrowed network. This is not limited herein. For example, the terminal device200may further output voice prompt information.

FIG.5DandFIG.5Eshow user interfaces involved when the terminal device200sets a trustlist.

FIG.5Dshows a user interface54provided by a settings application installed in the terminal device200. The user interface54may be displayed by the terminal device100in response to a user operation performed on an icon of the settings application on a home screen.

As shown inFIG.5D, one or more functional options, for example, a system account option, an airplane mode on/off option, a WLAN option, a cellular network option, a Bluetooth option, a hotspot option, and a trustlist option505, are displayed in the user interface54.

The terminal device100may detect a user operation performed on the trustlist option505, and display a user interface55that is used to set a trustlist and that is shown inFIG.5E.

As shown inFIG.5E, a status bar, a back button506, a current page indicator507, prompt information508, one or more device options509, and a control510corresponding to the device option are displayed in the user interface55.

The back button506is used to monitor a user operation, and the terminal device200may display a previous-level interface in response to the user operation, for example, display the user interface54shown inFIG.5D.

The current page indicator507indicates a current page. For example, text information “distributed network connection trustlist” indicates that the current page is a page used to set a trustlist.

The prompt information508is used to prompt the user with information indicating that a device added to the trustlist can use the network connection capability of the current device (namely, the terminal device200).

The one or more device options correspond to a device that connects to the terminal device200.

The terminal device200may detect a user operation performed on the control510corresponding to the device option, and in response to the user operation, add a device indicated by the device option corresponding to the control510to the trustlist or delete a device indicated by the device option from the trustlist.

As shown inFIG.5E, the trustlist that is set by the user includes a mobile phone, a watch, and a sound box, that is, the mobile phone, the watch, and the sound box may share the network connection capability of the terminal device200.

This is not limited to the manner that is of setting the trustlist and that is shown inFIG.5DandFIG.5E. In some other embodiments of this application, the terminal device200may set the trustlist in another manner. For example, the terminal device200may further add a device that has historically borrowed the terminal device200to the trustlist, or the terminal device200may add each device bound to the terminal device200to the trustlist.

Based on the communication system10shown inFIG.1, the terminal device described inFIG.2A,FIG.2B-1, andFIG.2B-2, and the user interface provided in the foregoing UI embodiment, the following describes in detail the network connection method provided in embodiments of this application.

FIG.6shows an example of a procedure of a network connection method according to an embodiment of this application. In the network connection method shown inFIG.6, a terminal device100may continuously borrow a network connection capability of another device to continuously access a network.

As shown inFIG.6, the method may include the following steps.

The terminal device100may be any terminal device in a communication system10. The terminal device100may have an information input/output apparatus (for example, a display), for example, may be a mobile phone, a tablet computer, or a large-screen television. Alternatively, the terminal device100may not have an information input/output apparatus (for example, a display), for example, may be a smart sound box or a smart camera.

“Distributed network connection” is a service or function provided by the terminal device, and is used to support the terminal device in establishing, in a manner different from a hotspot, a communication connection to another device that accesses the internet, and communicating with the internet through the another device based on the communication connection. That is, “distributed network connection” supports the terminal device in borrowing a network connection capability of another device.

In some embodiments of this application, the terminal device100may enable “distributed network connection” by default. In this way, the network connection capability of the another device can be borrowed without specially enabling “distributed network connection” on the terminal device100.

In some other embodiments of this application, the terminal device100may enable “distributed network connection” in response to a received user operation (for example, a tap operation or a touch operation). For example, with reference toFIG.3B, an operation used to enable “distributed network connection” may include a user operation performed on the “distributed network connection” on/off control301cin the user interface31shown inFIG.3B. This is not limited thereto. The terminal device100may further respond to another user operation, for example, a user operation performed on a “distributed network connection” on/off control provided by a settings application in the terminal device100, an operation entered on a physical button, or a voice instruction. This is not limited in this embodiment of this application.

In some other embodiments of this application, if the terminal device100does not have an information input/output apparatus, a control device, for example, a terminal device300, of the terminal device100may trigger, in response to a received user operation, the terminal device100to enable “distributed network connection”. For example, with reference toFIG.4C, the terminal device300may detect a user operation (for example, a tap operation or a touch operation) performed on the control411, and send a message indicating to enable “distributed network connection” to the terminal device100in response to the user operation. Herein, for a communication technology used when the terminal device300sends a message to the terminal device100, refer to related descriptions in subsequent step S102.

“Distributed network connection” may also be referred to as a first communication service, and the user operation used to enable “distributed network connection” may be referred to as a fourth operation.

Step S102: The terminal device100obtains network connection capability information of another device in the communication system10.

The communication system10may include a plurality of terminal devices. For types of the plurality of terminal devices, refer to related descriptions inFIG.1. For example, a mobile phone, a tablet computer, a smartwatch, and a smart sound box may be included.

Each terminal device in the communication system10may detect a network connection capability of the terminal device. The network connection capability of the terminal device depends on a hardware configuration and a software setting of the terminal device.

The network connection capability includes whether the terminal device connects to a network. If a SIM card is configured for the terminal device, and a cellular network service and a cellular network function are enabled, the terminal device may access the internet by using a cellular network. If the terminal device joins a WLAN created by a wireless access point400, and the WLAN connects to the internet, the terminal device may access the internet by using the WLAN. If the terminal device may access the internet in a wired manner, the terminal device may access the internet by using a wired network.

In some embodiments, the network connection capability may further include one or more of the following: a network connection manner of the terminal device, an identifier of a network to which the terminal device connects and that accesses the internet, and quality of the network to which the terminal device connects and that accesses the internet.

The network connection manner may include accessing the internet by using a cellular network, a WLAN, a wired network, or the like. The cellular network may further include 2G, 3G, 4G, 5G, 6G, or the like.

The network identifier uniquely indicates a network. A network identifier of the cellular network may include an identifier of a SIM card or an air interface technology used when the terminal device accesses the cellular network, for example, may be “4G 139xxxxxxxx”. A network identifier of the WLAN may include an identifier of a wireless access point400that creates the WLAN or a name of the WLAN, for example, may be “Wi-Fi3”.

The network quality may be determined based on a network speed, for example, an uplink/downlink transmission rate, a packet loss rate, a delay, bandwidth, or signal strength. The network quality may include the foregoing several factors, may be classified into high, medium, low, and other levels, or may be measured by using a score.

The terminal device may connect to one or more networks that access the internet.

For example, Table 1 lists an example of network connection capability information of a terminal device.

A network connection capability of the terminal device shown in Table 1 specifically includes connecting to a network and connecting to the network by using the cellular network, the WLAN, and the wired network. The network to which the terminal device connects and that accesses the internet includes a cellular network whose identifier is “4G 139xxxxxxxx”, a cellular network whose identifier is “5G 139xxxxxxxx”, a wireless local area network whose identifier is “Wi-Fi3”, and a wired network whose identifier is “wired network1”. Network quality of the several networks is respectively high, high, medium, and high.

Terminal devices in the communication system10may communicate with each other by using any one or more of the following technologies: Wi-Fi softAP, a WLAN, BT, Wi-Fi P2P, NFC, IR, a wired technology, or a remote communication technology. For specific implementation of communication between the terminal devices in the communication system, refer to related descriptions inFIG.1.

That is, a connection that is between the devices in the communication system10and that is used to synchronize the network connection capability information includes any one of the following: a communication connection established based on the wireless access point400in the communication system, a communication connection established when another device is in an AP mode, a wireless fidelity peer-to-peer Wi-Fi P2P connection, a Bluetooth connection, a near field communication NFC connection, a wired connection, an Ethernet connection, a remote connection, or the like.

Based on the foregoing listed technologies of communication between devices, the terminal device in the communication system10may synchronize or send network connection capability information of the terminal device to another device in any one of the following cases:

1. After sensing the another device in the communication system10, the terminal device sends the network connection capability information of the terminal device to the sensed another device. The terminal device may sense the another device in the communication system10by using the foregoing listed technologies of communication between devices. In this way, all terminal devices that join the communication system10can learn of the network connection capability information of the another device.

2. The terminal device may periodically send the network connection capability information of the terminal device to the another device in the communication system10. A sending period is not specifically limited, and may be, for example, 1 day or 1 week.

3. When the network connection capability of the terminal device changes or is updated, the terminal device may send the network connection capability information of the terminal device to the another device in the communication system10. In this way, when a network connection capability of a terminal device changes or is updated, it can be ensured that another terminal device in the communication system10can learn of a latest network connection capability of the terminal device.

The network connection capability information specifically indicates a network connection capability of the terminal device. That is, the network connection capability information indicates whether the terminal device connects to a network, and may further indicate one or more of a network connection manner of the terminal device, an identifier of a network to which the terminal device connects and that accesses the internet, and quality of the network to which the terminal device connects and that accesses the internet.

After obtaining the network connection capability information of the another device in the communication system10, the terminal device100may further display the network connection capability information of the another device to a user. In this way, the user can conveniently learn of a network connection capability that is of another device and that can be borrowed by the terminal device100, to trigger the terminal device100to borrow the network connection capability of the another device.

For example,FIG.3E,FIG.3F,FIG.3H, andFIG.3Ishow network connection capability information that is of another device in the communication system10and that is displayed and obtained by the terminal device100. As shown inFIG.3EandFIG.3H, the terminal device100displays a cellular network type and a SIM card identifier of the another device (for example, a tablet or a watch). As shown inFIG.3FandFIG.3H, the terminal device100displays a name of a WLAN network to which the another device (for example, a tablet or a watch) connects.

This is not limited to the network connection capability information that is of the another device and that is displayed by the terminal device100inFIG.3E,FIG.3F,FIG.3H, andFIG.3I. In some other embodiments, the terminal device100may further display more network connection capability information of the another device, for example, may further display signal strength and a signal transmission rate. This is not limited herein.

Step S103: The terminal device100determines, in network-connected terminal devices, a terminal device that provides a network connection capability.

The terminal device100may determine, in the network-connected terminal devices by using any one or a combination of the following policies, the terminal device that provides the network connection capability.

1. The terminal device100determines, in a network-connected terminal device trusted by the terminal device100, the terminal device that provides the network connection capability.

A terminal device trusted by the terminal device100may be referred to as a trusted device of the terminal device100.

The trusted device of the terminal device100includes but is not limited to a device that logs in to a same system account (for example, a Huawei account) as the terminal device100, a device bound to the terminal device100, a device that joins a same group (for example, a family group) as the terminal device100, a device that is set by the user, or the like.

With reference to the user interface32provided by the terminal device100shown inFIG.3Gand the user interface54provided by the terminal device200shown inFIG.5D, it may be learned that both the terminal device100and the terminal device200log in to a Huawei account whose account name is “ID1”.

With reference to the user interface41provided by the terminal device300shown inFIG.4A, the user may bind the terminal device300to another device by tapping the control404. The terminal device100may also be bound to another device in a similar manner. This is not limited thereto. The terminal device100may be further bound to another device in another manner, for example, bound to the another device in a touch manner or by using NFC. This is not limited herein.

After being bound to a plurality of devices, the terminal device100may further add the plurality of devices to a same group or different groups in response to a user operation. For example, the user may create two groups: a family group and an office group, and then add the devices to different groups.

In addition, the user may further manually set the trusted device on the terminal device100. A manner of setting the trusted device is not limited herein. For example, the settings application in the terminal device100may provide a user interface for setting the trusted device, and the user may set the trusted device by using the user interface.

It may be learned that all trusted devices of the terminal device100are related to a user operation, and are secure devices trusted by the user. Herein, if the terminal device100has an information input/output apparatus, the terminal device100may independently complete a related operation related to the trusted device. If the terminal device100does not have an information input/output apparatus, the control device (for example, the terminal device300) of the terminal device100may complete a related operation related to the trusted device. For example, the terminal device300may bind the terminal device100to another device, add the terminal device100and the another device to a same group, and provide a user interface for the user to set the trusted device, and the like.

In the policy1, the terminal device100selects the trusted device as the terminal device that provides the network connection capability, and therefore the terminal device100can connect to the internet through the trusted and secure terminal device, to ensure data security of the terminal device100and avoid a risk such as data leakage.

2. The terminal device100determines, in the network-connected terminal device as the terminal device that provides the network connection capability, a terminal device selected by the user.

Specifically, the terminal device100may provide options of a plurality of network-connected terminal devices for the user to select, and determine, as the terminal device that provides the network connection capability, the terminal device selected by the user.

For example, with reference toFIG.3E, the terminal device100may detect a user operation performed on the cellular network option302b-1in the cellular network display area302bof another device, and determine a terminal device (namely, a tablet computer) corresponding to the cellular network option302b-1as the terminal device that provides the network connection capability.

For another example, with reference toFIG.3F, the terminal device100may detect a user operation performed on the WLAN option303b-1in the WLAN display area303bof another device, and determine a terminal device (namely, a tablet computer) corresponding to the WLAN option303b-1as the terminal device that provides the network connection capability.

For another example, with reference toFIG.3HandFIG.3I, the terminal device100may further detect a user operation performed on the cellular network option or the WLAN option, and determine a corresponding device as the terminal device that provides the network connection capability.

In the policy2, the user may independently determine, based on a requirement, the terminal device that provides the network connection capability, to fully meet an actual requirement of the user and improve user experience.

In the policy2, the user operation used to determine the terminal device that provides the network connection capability may be referred to as a first operation. For example, the first operation may include a user operation performed on the cellular network option302b-1in the cellular network display area302bof another device, a user operation performed on the WLAN option303b-1in the WLAN display area303bof another device, or a user operation performed on the cellular network option or the WLAN option.

3. The terminal device100selects, from the network-connected terminal device, a control device of the terminal device100as the terminal device that provides the network connection capability.

For example, a smartphone may be bound to devices such as a smartwatch, a smart sound box, a door lock, and a smart screen, and is used as a control device to control the devices bound to the smartphone. If the terminal device100is a smartwatch, a smart sound box, a door lock, or a smart screen, the terminal device100may select a control device, that is, select a smartphone, as the terminal device that provides the network connection capability.

This is not limited to the foregoing three policies. In this embodiment of this application, the terminal device100may further determine, based on another policy, the terminal device that provides the network connection capability. This is not limited herein. For example, from the network-connected terminal device, the terminal device100may randomly select a terminal device as the terminal device that provides the network connection capability, select a terminal device with best network quality as the terminal device that provides the network connection capability, select a terminal device whose network connection capability is borrowed for a largest quantity of times as the terminal device that provides the network connection capability, or select a terminal device whose network connection capability is most recently borrowed as the terminal device that provides the network connection capability.

Any several of the foregoing policies may be used in combination. For example, the terminal device100may determine, as the terminal device that provides the network connection capability by using a combination of the policy1and the policy2in a network-connected terminal device trusted by the terminal device100, a terminal device selected by the user.

In some other embodiments of this application, if the terminal device100does not have an information input/output apparatus, the control device, for example, the terminal device300, of the terminal device100may select, for the terminal device100, the terminal device that provides the network connection capability. A policy used when the terminal device300selects, for the terminal device100, the terminal device that provides the network connection capability is the same as the foregoing policy used when the terminal device100selects the terminal device200. The terminal device300may notify the terminal device100of the selected terminal device that provides the network connection capability.

For example, with reference toFIG.4C, the terminal device300may detect a user operation performed on the WLAN option412a, and send an identifier of a terminal device (namely, a tablet computer) corresponding to the WLAN option412ato the terminal device100, and then the terminal device100determines the terminal device (namely, the tablet computer) indicated by the identifier as the terminal device that provides the network connection capability.

When the terminal device100does not have a display, the terminal device100may further receive a voice instruction of the user by using a microphone, and borrow a network connection capability of another device in response to the voice instruction.

In this embodiment of this application, the terminal device that is determined by the terminal device100and that provides the network connection capability may also be referred to as the terminal device200.

Optional step S104: The terminal device100determines a to-be-borrowed network connection manner, and notifies the terminal device200of the network connection manner.

In this embodiment of this application, by performing optional step S104, the terminal device100may determine the to-be-borrowed network connection manner in advance, so that the terminal device100subsequently directly borrows the network connection manner selected in S104, to borrow the network connection capability of the terminal device200.

In S104, the to-be-borrowed network connection manner determined by the terminal device100may include one or more manners. The network connection manner may include accessing the internet by using a cellular network, a WLAN, a wired network, or the like. The cellular network may further include 2G, 3G, 4G, 5G, 6G, or the like.

In some embodiments, the terminal device100may determine the to-be-borrowed network connection manner by default. For example, the terminal device100may determine a manner of accessing the internet by using the cellular network as the to-be-borrowed network connection manner by default.

In some other embodiments of this application, the terminal device100may determine the to-be-borrowed network connection manner in response to a received user operation (for example, a tap operation or a touch operation). For example, the terminal device100may provide one or more network connection manner options, and determine a network connection manner corresponding to a network connection manner option on which the user operation is detected as the network connection manner to be borrowed by the terminal device100. For example, with reference toFIG.3B, the notification bar301may further include an on/off control of a “distributed cellular network”, an on/off control of a “distributed WLAN”, and an on/off control of a “distributed wired network”. The user may tap one or more on/off controls, to determine a network connection manner corresponding to the on/off control as the to-be-borrowed network connection manner. In this way, the user may determine, based on a requirement of the user, the network connection manner to be borrowed by the terminal device100.

After determining the to-be-borrowed network connection manner, the terminal device100may notify the terminal device200of the determined network connection manner, for example, send indication information of the determined network connection manner to the terminal device200.

In some other embodiments of this application, if the terminal device100does not have an information input/output apparatus, the control device, for example, the terminal device300, of the terminal device100may determine the to-be-borrowed network connection manner for the terminal device100, and then notify the terminal device100and the terminal device200of the determined network connection manner.

In S104, the to-be-borrowed network connection manner determined by the terminal device100may be referred to as a first network connection manner. The user operation that is entered by the user and that is used to determine the first network connection manner may be referred to as a second operation.

Optional step S105: The terminal device100determines a to-be-borrowed network, and notifies the terminal device200of the network.

In this embodiment of this application, by performing optional step S105, the terminal device100may determine the to-be-borrowed network in advance based on a network connection capability of the another device in a network to which the another device connects and that accesses the internet, so that the terminal device100subsequently directly borrows the network selected in S105.

In S105, the to-be-borrowed network determined by the terminal device100may include one or more networks. This is not limited in this application.

In some embodiments, the terminal device100may determine a network with best network quality as the to-be-borrowed network, determine a network borrowed for a largest quantity of times as the to-be-borrowed network, or determine a most recently borrowed network as the to-be-borrowed network.

In some other embodiments of this application, the terminal device100may determine the to-be-borrowed network in response to a received user operation (for example, a tap operation or a touch operation). For example, the terminal device100may provide one or more network options, and determine a network corresponding to a network option on which the user operation is detected as the network to be borrowed by the terminal device100. In this way, the user may determine, based on a requirement of the user, the network to be borrowed by the terminal device100.

For example, with reference toFIG.3E, the terminal device100may detect a user operation performed on the cellular network option302b-1in the cellular network display area302bof another device, and determine a network (namely, a cellular network to which a tablet computer connects) corresponding to the cellular network option302b-1as the to-be-borrowed network.

For another example, with reference toFIG.3F, the terminal device100may detect a user operation performed on the WLAN option303b-1in the WLAN display area303bof another device, and determine a network (namely, a WLAN that is named “Wi-Fi3” and to which a tablet computer connects) corresponding to the WLAN option303b-1as the network to be borrowed by the terminal device100.

For another example, with reference toFIG.3HandFIG.3I, the terminal device100may further detect a user operation performed on the cellular network option or the WLAN option, and determine a corresponding network as the to-be-borrowed network.

After determining the to-be-borrowed network, the terminal device100may notify the terminal device200of the determined network, for example, send an identifier of the determined network to the terminal device200.

In some other embodiments of this application, if the terminal device100does not have an information input/output apparatus, the control device, for example, the terminal device300, of the terminal device100may further determine the to-be-borrowed network for the terminal device100, and then notify the terminal device100and the terminal device200of the determined network.

For example, with reference toFIG.4C, the terminal device300may detect a user operation performed on the WLAN option412a, and send an identifier of a network (namely, a WLAN that is named “Wi-Fi3” and that is provided by a tablet computer) corresponding to the WLAN option412ato the terminal device100, and then the terminal device100determines the network (namely, the WLAN that is named “Wi-Fi3” and that is provided by the tablet computer) indicated by the identifier as the to-be-borrowed network.

In S105, the to-be-borrowed network determined by the terminal device100may be referred to as a first network. The user operation that is entered by the user and that is used to determine the first network may be referred to as a third operation.

Step S106: The terminal device100establishes a communication connection to the terminal device200in a manner different from a hotspot.

Establishing a connection by using a hotspot means that the terminal device200works in an AP mode and creates a wireless local area network, and then the terminal device100connects to the wireless local area network created by the terminal device200, to establish a connection to the terminal device200.

In S106, the communication connection established between the terminal device100and the terminal device200may include any one of the following: a Wi-Fi direct/Wi-Fi P2P connection, a BT connection, an NFC connection, an IR connection, a wired connection, an Ethernet connection, a remote connection, or the like. The BT connection may be a classic Bluetooth connection, or may be a Bluetooth low energy (BLE) connection. The remote connection means that the terminal device100and the terminal device200each connect to a server and communicate with each other through the server.

A process of establishing, by the terminal device100, a connection to the terminal device200in S106is an internal device interaction process invisible to the user. In a process of performing S106, no user intervention or operation is required.

For example, if the terminal device100establishes a BT connection to the terminal device200, the following steps do not need to be performed: After finding another nearby device by using a Bluetooth technology, the terminal device100displays an identifier of the another found device. Then, the user taps an identifier of the terminal device200. Then, the terminal device200displays pairing confirmation information. After the user taps to confirm pairing, the terminal device100establishes a Bluetooth connection to the terminal device200.

That is, based on S106in this embodiment of this application, a manual pairing operation performed by the user can be omitted, and user behavior can be simplified, to improve efficiency of establishing a connection between devices, so as to improve user experience.

In some embodiments, the terminal device100may send a request message used to borrow the network connection capability to the terminal device200. After receiving the request message, the terminal device200may directly respond to the request message to establish a communication connection, to the terminal device100, that is different from the hotspot, or may establish a communication connection, to the terminal device100, that is different from the hotspot after outputting prompt information and receiving a user operation. The prompt information may be referred to as third prompt information.

For example, with reference toFIG.5A, after receiving the request message sent by the terminal device100, the terminal device200displays the prompt window501. Then, the terminal device200may send, to the terminal device100in response to a user operation performed on the control501b, a feedback message indicating that the terminal device200agrees to lend the network connection capability, and establish a communication connection, to the terminal device100, that is different from the hotspot, to lend the network connection capability to the terminal device100. The control501bmay be referred to as a first control.

In some other embodiments, after receiving the request message that is sent by the terminal device100and that is used to borrow the network connection capability, the terminal device200may determine whether the terminal device100is a device in a trustlist, or determine whether the terminal device100is a trusted device of the terminal device200. If a determining result is yes, the terminal device200establishes a communication connection, to the terminal device100, that is different from the hotspot, to lend the network connection capability to the terminal device100. The trustlist may be set by the terminal device200. For a manner of setting the trustlist, refer to related descriptions inFIG.5DandFIG.5E. For a definition of the trusted device, refer to related descriptions in S103.

In some embodiments of this application, if the terminal device100and the terminal device200have established a communication connection in a manner different from the hotspot when joining the communication system10, step S106may be omitted. For example, if the terminal device100and the terminal device200have joined the communication system10by establishing a Bluetooth connection, S106may not need to be performed. For another example, if the terminal device100and the terminal device200have joined the communication system10by establishing a remote connection, S106may not need to be performed.

Step S107: The terminal device100communicates with the internet through the terminal device200based on the communication connection to the terminal device200.

When the terminal device100communicates with the internet, an uplink path is terminal device100->terminal device200->internet. Uplink data to be sent by the terminal device100to the internet is transmitted by using the uplink path.

When the terminal device100communicates with the internet, a downlink path is internet->terminal device200->terminal device100. Downlink data to be sent by the internet to the terminal device100is transmitted by using the downlink path.

In a process in which the terminal device100communicates with the internet, the terminal device100communicates with the terminal device200by using the communication connection that is established in S106and that is different from the hotspot, and the terminal device200communicates with the internet by using one or more networks. A network that is used to support the terminal device100in communicating with the internet and that is between the terminal device200and the internet may be referred to as a shared network. That is, the terminal device200shares the shared network with the terminal device100, to support the terminal device100in communicating with the internet. The shared network is a network to which the terminal device connects200and that accesses the internet. There may be one or more shared networks.

In the process in which the terminal device100communicates with the internet, the shared network may be determined in any one or more of the following manners.

1. If the terminal device100performs S104, the terminal device200may select, as the shared network from a connected network that accesses the internet, a network corresponding to the network connection manner determined by the terminal device100in S104.

For example, if the terminal device100determines, in S104, that the to-be-borrowed network connection manner is accessing the internet by using the cellular network, the terminal device200selects the connected cellular network as the shared network.

For another example, if the terminal device100determines, in S104, that the to-be-borrowed network connection manner is accessing the internet by using the WLAN, the terminal device200may select the connected wireless local area network as the shared network.

2. If the terminal device100performs S105, the terminal device200selects, as the shared network, the network determined by the terminal device100in S105.

For example, with reference toFIG.3E, after the terminal device100determines the network (namely, the cellular network to which the tablet computer connects) corresponding to the cellular network option302b-1as the to-be-borrowed network, the terminal device200selects the network (namely, the cellular network to which the tablet computer connects) corresponding to the cellular network option302b-1as the shared network.

For another example, with reference toFIG.3F, after the terminal device100determines the network (namely, the WLAN that is named “Wi-Fi3” and to which the tablet computer connects) corresponding to the WLAN option303b-1as the to-be-borrowed network, the terminal device200selects the network (namely, the WLAN that is named “Wi-Fi3” and that is provided by the tablet computer) corresponding to the WLAN option303b-1as the shared network.

3. If the terminal device100performs neither S104nor S105, the terminal device200may randomly select one or more networks as the shared network from a connected network that accesses the internet, select a network with best network quality as the shared network, select a network shared for a largest quantity of times as the shared network, or select a most recently shared network as the shared network.

This is not limited to the foregoing several manners. In this embodiment of this application, the terminal device200may further determine the shared network in another manner. This is not limited herein. For example, the terminal device200may use all connected networks that access the internet as the shared network. For another example, the user may preset the shared network on the terminal device200, and the terminal device200may select the shared network based on a setting status of the user.

In some embodiments, after determining the shared network, the terminal device200may further notify the terminal device100of the shared network. For example, the terminal device200may send an identifier of the shared network to the terminal device100.

In S107, a network connection manner used by the terminal device200may be referred to as a first network connection manner, and the shared network may be referred to as a first network.

In this embodiment of this application, after S106is performed, in a process of performing S107, both the terminal device100and the terminal device200may display prompt information, to prompt the user with information indicating that the terminal device100is currently sharing the network connection capability of the terminal device200. For a manner of outputting the prompt information by the terminal device100, refer toFIG.3F,FIG.3I, and related descriptions. For a manner of outputting the prompt information by the terminal device200, refer toFIG.5B,FIG.5C, and related descriptions. Herein, the prompt information output by the terminal device100may be referred to as first prompt information, and the prompt information output by the terminal device200may be referred to as second prompt information.

Based on S101to S103, S106, and S107in the network connection method shown inFIG.6, provided that another device near the terminal device100can connect to the internet, the terminal device100may connect to the internet by borrowing a network connection capability of the another device. In some embodiments, the terminal device100may connect to the internet by borrowing a network connection capability of a remote device. In this way, a plurality of terminal devices at a short distance and the remote device may form a communication system, and each terminal device in the communication system may borrow a network connection capability of another device in the system, to implement free flowing of the network connection capability.

When the terminal device100cannot connect to the internet, the method shown inFIG.6may enable the terminal device100to access the internet by borrowing a network connection capability of another device. When network quality of the terminal device100is poor, the terminal device100may enhance a network connection between the terminal device100and the internet by using the method shown inFIG.6. For example, when the terminal device100is a tablet computer and current network quality is poor, the terminal device100may access the internet by using a cellular network of a surrounding mobile phone.

In addition, the terminal device100establishes a communication connection to the terminal device200in a manner different from the hotspot. Therefore, neither the terminal device100needs to display an identifier of a WLAN created when another found device works in an AP mode, nor the user needs to select a WLAN identifier to borrow a network connection capability of the another device. That is, the terminal device100may borrow a network connection capability of another device without performing a complex operation. This is more convenient for the user.

According to S101to S103, S106, and S107in the network connection method shown inFIG.6, even if the terminal device100does not have a display, the terminal device100may borrow a network connection capability of another device. Therefore, there is no case in which the internet cannot be accessed because an information input/output operation (for example, verifying a WLAN) cannot be performed.

According to S101to S103, S106, and S107in the network connection method shown inFIG.6, the terminal device100may share a WLAN of the terminal device200. If the WLAN is a network that can be accessed only after complex verification is performed, the terminal device100may borrow the WLAN without a complex verification process.

In a process of performing the network connection method shown inFIG.6, the terminal device100may further access the internet by using one or more of a WLAN created by the wireless access point400, a cellular network, or a wired manner. A connection relationship between the terminal device100and the internet does not affect borrowing, by the terminal device100, a network connection capability of another device.

The terminal device100establishes a communication connection to the terminal device200in a manner different from the hotspot. Therefore, the terminal device100may simultaneously access the internet by using the WLAN created by the wireless access point400. Even if only one Wi-Fi network interface controller is configured for the terminal device100, the terminal device100may still use the Wi-Fi network interface controller to connect to the WLAN created by the wireless access point400, and establish a communication connection to the terminal device200in a manner different from the hotspot.

In this way, when the terminal device100accesses the internet through the terminal device200, the terminal device100may also access the internet, to implement multi-channel network concurrency and increase a speed and improve efficiency of communicating with the internet.

For example, the terminal device100may implement the following several dual-channel network concurrency scenarios:

The terminal device100accesses the internet by using a WLAN to which the terminal device100connects and a WLAN to which the terminal device200connects.

The terminal device100accesses the internet by using a WLAN to which the terminal device100connects and a cellular network to which the terminal device200connects.

The terminal device100accesses the internet by using a cellular network to which the terminal device100connects and a WLAN to which the terminal device200connects.

The terminal device100accesses the internet by using a cellular network to which the terminal device100connects and a cellular network to which the terminal device200connects.

This is not limited to the dual-channel concurrency scenario. The terminal device100may further implement a three-channel or more-channel network concurrency scenario. For example, the terminal device100may further access the internet by using a WLAN to which the terminal device100connects and a WLAN and a cellular network to which the terminal device200connects. For another example, the terminal device100may further access the internet by using a WLAN and a cellular network to which the terminal device100connects and a WLAN or a cellular network to which the terminal device200connects.

The foregoing listed multi-channel concurrency scenarios are merely examples. In specific implementation, the terminal device100may further have other or more multi-channel concurrency scenarios, which are not listed herein one by one.

Based on S104in the method shown inFIG.6, the terminal device100may determine the to-be-borrowed network connection manner, and notify the terminal device200of the to-be-borrowed network connection manner, and the terminal device200does not need to determine the to-be-provided network connection manner. This can improve efficiency of providing the network connection capability by the terminal device200, and provide better user experience.

Based on S105in the method shown inFIG.6, the terminal device100may determine the to-be-borrowed network, and notify the terminal device200of the to-be-borrowed network, and the terminal device200does not need to determine the to-be-provided network. This can improve efficiency of providing the network connection capability by the terminal device200, and provide better user experience.

In the network connection method shown inFIG.6, the terminal device200may further enable traffic-free services of some or all applications by using a SIM card. An application for which the traffic-free service is enabled may be referred to as a traffic-free application. When the terminal device200runs the traffic-free application, data used for communication with the internet by using a cellular network corresponding to the SIM card is not charged. After the terminal device200enables the traffic-free service, a server500may record a correspondence between a SIM card and a traffic-free application, that is, associate and record an identifier of the SIM card and an identifier of the traffic-free application.

When S107is performed, if the server500detects that data packets (including an uplink data packet and a downlink data packet) involved when the terminal device100communicates with the internet are from a traffic-free application, fees required for transmitting these data packets are waived.

Optionally, the data packet involved when the terminal device100communicates with the internet in S107may carry a corresponding identifier of an application or other information about an application (for example, an identifier or an address of a server that provides a service for the application) and an identifier of a shared network of the terminal device200. After the server500detects the data packet existing when the terminal device100communicates with the internet in S107, if a data packet is from a traffic-free application and carries an identifier of a cellular network corresponding to a SIM card for which the traffic-free service is activated, traffic fees required for transmitting the data packet are waived, and no charging processing is performed on the data packet.

That is, if the terminal device200enables the traffic-free service, when a data packet involved in running of a traffic-free application in the terminal device100is transmitted by using the cellular network of the terminal device200, required traffic fees are not calculated.

In some other embodiments, data packets (including an uplink data packet and a downlink data packet) involved when the terminal device100communicates with the internet in S107may further carry more information, for example, an IP address and a domain name of the terminal device200. This is not limited herein. In this way, the server500considers that all data packets in the communication process in S107are generated when the terminal device200runs, to implement sharing of free traffic.

In the communication system10shown inFIG.1and the method procedure shown inFIG.6that are provided in embodiments of this application, the terminal device100may also be referred to as a first device, and the terminal device200may also be referred to as a second device.

The communication connection established between the terminal device100and the terminal device200in S106in a manner different from the hotspot may be referred to as a first communication connection.

The communication connection that is between the terminal devices, that is used to synchronize the network connection capability information, and that is in S102may be referred to as a second communication connection.

FIG.7is an example of a diagram of a data flowing direction involved when a terminal device100communicates with the internet by using the network connection method provided in embodiments of this application.

As shown inFIG.7, the terminal device100includes an application at an application layer, a distributed network connection service at an application framework layer, a connection module, and a HAL at a bottom layer. A terminal device200includes a distributed network connection service at an application framework layer, a connection module, a network connection module, and a HAL at a bottom layer.

It may be understood that structures of the terminal device100and the terminal device200inFIG.7are of simplified versions. For detailed structures of the terminal device100and the terminal device200and functions of modules, refer to related descriptions inFIG.2A,FIG.2B-1, andFIG.2B-2.

For the terminal device100, the application at the application layer may be an application that needs to interact with the internet, for example, may include a browser application or an online video application. After determining that the terminal device200connects to a network, the distributed network connection service notifies the application at the application layer, so that the application learns that a network can currently connect to the internet and runs normally. Then, the distributed network connection service establishes a connection to the connection module, for example, establishes a socket interface, to bind the distributed network connection service to the connection module, so as to facilitate subsequent communication.

The respective connection modules in the terminal device100and the terminal device200are configured to support the terminal device100and the terminal device200in establishing a communication connection in a manner different from a hotspot. For example, the connection module may include a Bluetooth communication module, configured to support the terminal device100and the terminal device200in establishing a Bluetooth communication. For another example, the connection module may include a Wi-Fi network interface controller that supports a Wi-Fi P2P technical specification, and is configured to support the terminal device100and the terminal device200in establishing a Wi-Fi P2P connection. Herein, the Wi-Fi network interface controller that is in the connection module and that supports the Wi-Fi P2P technical specification may be a physical network interface controller, or may be a result obtained by virtualizing some apparatuses that are in the Wi-Fi network interface controller and that support the Wi-Fi P2P technical specification.

The network connection module in the terminal device200is configured to support the terminal device200in accessing the internet. The network connection module may include one or more of a wireless communication module (for example, including a Wi-Fi network interface controller), a mobile communication module (for example, including a cellular network interface controller), or a wired communication module (for example, including a wired network interface controller), and may further include another related module such as an antenna. The wireless communication module is configured to support the terminal device200in accessing the internet by using a WLAN. The mobile communication module supports the terminal device200in accessing the internet by using a cellular network. The wired communication module supports the terminal device200in accessing the internet by using a wired network.

In both an uplink communication process and a downlink communication process, the terminal device200transmits data by using a network connection module corresponding to a shared network. For example, if the shared network is a cellular network, data is transmitted by using the cellular network interface controller; or if the shared network is a wireless local area network, data is transmitted by using the Wi-Fi network interface controller.

A double-arrow line inFIG.7represents a data flowing direction in a process in which the terminal device100communicates with the internet.

In the uplink communication process, an application in the terminal device100generates a data packet, and the data packet passes through the distributed network connection service and the connection module in the terminal device100, the communication connection between the terminal device100and the terminal device200, and the connection module and the network connection module in the terminal device200, and then flows to the internet.

In the downlink communication process, a data packet returned by the internet is first sent to the network connection module in the terminal device200, then passes through the connection module in the terminal device200, the communication connection between the terminal device100and the terminal device200, and the connection module and the distributed network connection service in the terminal device100, and finally reaches the application in the terminal device100.

If there is one shared network of the terminal device200, the terminal device200transmits data in both the uplink communication process and the downlink communication process by using a network connection module corresponding to the shared network. For example, if the shared network is a cellular network, data is transmitted by using the cellular network interface controller; or if the shared network is a wireless local area network, data is transmitted by using the Wi-Fi network interface controller.

If there are a plurality of shared networks of the terminal device200and a plurality of types, the distributed network connection service in the terminal device100or the terminal device200is further responsible for fragmenting or assembling communication data.

For example, the terminal device100is responsible for data fragmentation and assembly. In the uplink communication process, the distributed network connection service in the terminal device100may classify data packets from the application into different types of shared networks, for example, add a cellular network identifier to some data packets, and add a WLAN identifier to the other data packets. Then, these data packets are transmitted by the distributed network connection service in the terminal device100to the distributed network connection service in the terminal device200without passing through the connection module. Then, the terminal device200transmits different data packets by using different network connection modules, for example, transmits a data packet including the cellular network identifier by using the cellular network interface controller, and transmits a data packet including the WLAN identifier by using the Wi-Fi network interface controller.

In the downlink communication process, the terminal device200may receive, by using a plurality of network connection modules, data packets delivered by the internet, and then transmit the data packets to the distributed network connection service in the terminal device100by using the distributed network connection service. The distributed network connection service in the terminal device100assembles the plurality of data packets, and then transmits the data packets to the upper-layer application.

A process in which the terminal device200fragments and assembles communication data is similar to the process in which the terminal device100fragments and assembles communication data. For details, refer to related descriptions.

The terminal device100inFIG.7may further include a network connection module. A specific structure of the network connection module is similar to a structure of the network connection module in the terminal device200. For details, refer to the foregoing related descriptions.

If the terminal device100accesses the internet and accesses the internet by using the shared network of the terminal device200, the distributed network connection service in the terminal device100is responsible for fragmenting or assembling communication data. Specifically, in the uplink communication process, the distributed network connection service in the terminal device100respectively classifies data packets from the application into a local network and the shared network. The data packet classified into the local network is sent by the distributed network connection service to the network connection module, and then sent to the internet. The data packet classified into the shared network is transmitted by the distributed network connection service to the network connection module in the terminal device200through a path shown inFIG.7, and then sent to the internet. The downlink communication process is a reverse process of the uplink communication process. Details are not described herein. In this way, when the terminal device100accesses the internet through the terminal device200, the terminal device100may also access the internet, to implement multi-channel network concurrency and increase a speed and improve efficiency of communicating with the internet.

In the network connection method provided in embodiments of this application, each device may transmit data by using the transmission control protocol/internet protocol (TCP/IP).

The TCP/IP transmission model includes four layers from bottom to top.

1. A link layer (data link layer/network interface layer) includes a device driver in an operating system and a corresponding network interface controller in a computer. Link layer protocols include the address resolution protocol (ARP), the reverse address resolution protocol (RARP), and the like.

2. A network layer (internet layer) is configured to process an activity of a packet in a network, for example, routing of the packet. Network layer protocols include the internet protocol (IP), the routing information protocol (RIP), the internet control message protocol (ICMP), and the like.

3. A transport layer is configured to provide peer-to-peer communication for applications on two hosts. Transport layer protocols may include the transmission control protocol (TCP), the user datagram protocol (UDP), and the like.

4. An application layer is responsible for processing specific application details. Application layer protocols may include the file transfer protocol (FTP), the hypertext transfer protocol (HTTP), the remote terminal protocol (telent), the simple mail transfer protocol (SMTP), the domain name service (DNS) protocol, and the like.

In a communication process, a data packet has different formats, which are sequentially referred to as a segment, a datagram, a frame, and data from top to bottom, at the layers. The data packet is transmitted downward from the application layer by using a protocol stack. Each time the data packet passes through a layer, a header of a protocol at the corresponding layer is added to the data packet. Finally, the data packet is encapsulated into a frame and sent to a transmission medium. When the data packet reaches a router or a destination host, a header is removed, and the data packet is delivered to an upper-layer party that needs the data packet.

In the network connection method shown inFIG.6, in a process in which the terminal device100borrows the network connection capability of the terminal device200to communicate with the internet, each device differently processes a data packet.

FIG.8shows an example of a manner of processing a data packet by each device in a process in which a terminal device100borrows a network connection capability of a terminal device200to communicate with the internet.

As shown inFIG.8, in the process in which the terminal device100accesses the internet through the terminal device200, because the terminal device100does not directly access the internet, the terminal device100performs processing only at an application layer and a transport layer on the data packet, and does not perform processing at a network layer and a physical layer. The terminal device100and the terminal device200communicate with each other at the application layer and the transport layer, and do not communicate with each other at the network layer and the physical layer. The terminal device200may perform processing at the network layer and the physical layer on a data packet from the internet or the terminal device100, and then send the data packet to the terminal device100or the internet. An internet device, for example, the network device300or the wireless access point400, may perform processing at the foregoing four layers on the data packet.

The method for continuously borrowing, by a terminal device, a network connection capability of another device is described in the foregoing embodiments. The following describes a method for temporarily borrowing, by a terminal device, a web capability of another device to access a captive portal wireless network (captive portal Wi-Fi).

In the network connection method provided in embodiments of this application, when a terminal device that does not have a web capability needs to access captive portal Wi-Fi, the terminal device may temporarily use a web capability of another terminal device to complete authentication, and access captive portal Wi-Fi. Herein, the terminal device that does not have a web capability only temporarily borrows the web capability of the another device, and may no longer borrow the web capability of the another device after accessing captive portal Wi-Fi. A terminal device that requests to access captive portal Wi-Fi may also be referred to as a STA device.

Herein, captive portal Wi-Fi is provided by an AP. The AP may be the wireless access point400described in the foregoing process in which a terminal device borrows a network connection capability of another device. That is, in embodiments described above, the wireless access point400may be configured to provide captive portal Wi-Fi for which authentication needs to be performed.

A web application (for example, a browser application) is usually installed in a STA device having a web capability, and the STA device having a web capability may support the hypertext transfer protocol (HTTP) or the hypertext transfer protocol secure (HTTPS).

Herein, captive portal Wi-Fi is a web-based open wireless network that provides security authentication. When the STA device requests to access a wireless network of this type, if the AP does not store a media access control (MAC) address of the STA device that currently requests access, the AP may provide, by using a redirection technology, a page address of a captive portal website page (web page) for the STA device. If determining that the Wi-Fi type of the wireless network for which access is currently requested is captive portal Wi-Fi, the STA device may display the web page by using the web application (for example, a browser) based on the page address of the portal website page. The web page may require a user to enter authentication information, pay, accept some license agreement terms or other user authorization, or the like. After determining that the user completes a requirement such as authentication for the web page, the STA device sends a confirmation signal to the AP. The AP can provide captive portal Wi-Fi for the STA device only after it is determined, based on the received confirmation signal, that the user completes authentication for the web page. Then, the AP stores the MAC address of the STA device. Within a preset time, when requesting to access captive portal Wi-Fi again, the STA device can directly access captive portal Wi-Fi without performing the login procedure.

The redirection technology includes a hypertext transfer protocol (HTTP) redirection technology. The HTTP redirection technology means that the AP directs all traffic of a world wide web to a preset captive portal website. For example, the STA device sends an HTTP request (namely, a network access request) to the AP based on the HTTP protocol. When determining that the MAC address of the STA device is currently not stored (for example, when the STA device connects to the world wide web through the AP for the first time), the AP feeds back an HTTP 302 status code and an HTTP uniform resource locator (URL) of the portal website to the STA device based on the HTTP request sent by the STA device. Then, the STA device accesses a redirected URL based on the HTTP protocol, logs in to the portal website, and displays the web page. That is, before authentication is completed, when the STA device sends any HTTP requests to the AP, received URLs are URLs of the same portal website, and the HTTP 302 status code can be received. Based on this, the STA device can determine, based on the received HTTP status code, that the wireless network for which access is currently requested is captive portal Wi-Fi.

The redirection technology further includes a domain name system (DNS) redirection technology. The DNS redirection technology means that the AP directs all DNS queries to an internet protocol (IP) address of a preset captive portal website. For example, after receiving any domain name system request (namely, a network access request) sent by the STA device, the AP feeds back the IP address of the portal website to the STA device, that is, the AP uses the IP address of the portal website as a destination address of an internet resource requested by the STA device. Correspondingly, the STA device logs in to the portal website based on the received IP address, and displays the web page. Based on this, after the STA device sends two or more domain name system requests, if the same IP address is received, it is determined that the wireless network for which access is currently requested is captive portal Wi-Fi.

For example, as shown inFIG.9, it is assumed that a wireless network provided by an AP11is captive portal Wi-Fi, a mobile phone12sends a network access request to the AP11, and the AP11sends a URL or an IP address of a captive portal page to the mobile phone12. In this case, the mobile phone12enters the portal website page by using a browser application, and displays an interface201shown inFIG.10, to request a user to perform authentication. Then, after the mobile phone12detects an operation of tapping a control21by the user, it indicates that the user completes authentication, and an authentication confirmation signal is sent to the AP11. After determining, based on the authentication confirmation signal, that the user completes authentication, the AP11stores a MAC address of the mobile phone12, and allows the mobile phone12to access captive portal Wi-Fi.

It may be learned that the STA device (for example, the mobile phone12shown inFIG.9) can complete authentication on the portal website and access captive portal Wi-Fi only when the STA device has a web capability. A web application is usually installed in a STA device having a web capability, and the STA device having a web capability may support HTTP or HTTPS. The web application is an application that can be accessed by using a web, for example, a browser application. However, a device having no screen, a device having an ultra-small screen, or a device that does not have a web capability because a web application is not installed due to low memory or other reasons cannot access or has difficulty in accessing captive portal Wi-Fi. Consequently, a requirement of a user for such a device to access captive portal Wi-Fi cannot be met, and user experience is affected.

Therefore, an embodiment of this application provides a network connection method, so that a terminal device that does not have a web capability can use a terminal device having a web capability to complete access authentication for captive portal Wi-Fi, to meet a requirement of a user for different terminal devices to access captive portal Wi-Fi, and improve user experience.

FIG.11is a schematic diagram of a communication system according to an embodiment of this application. As shown inFIG.11, the communication system includes a terminal device400, a terminal device500, and an AP600. A communication connection is established between the terminal device400and the terminal device500. For example, the AP600may provide captive portal Wi-Fi, the terminal device400does not have a web capability, the terminal device500has a web capability, and a wireless communication connection is established between the terminal device400and the terminal device500. The terminal device400may exchange authentication data by using the wireless communication connection to the terminal device500, to access the AP600.

Optionally, the terminal device400may establish a wireless communication connection to the terminal device500by using a wireless communication technology. The wireless communication technology includes but is not limited to at least one of the following: Bluetooth (BT) (for example, conventional Bluetooth or Bluetooth low energy (BLE)), a wireless local area network (WLAN) (for example, a Wi-Fi network), near field communication (NFC), ZigBee, frequency modulation (FM), infrared (IR), and the like.

In some embodiments, both the terminal device400and the terminal device500support a proximity discovery function. For example, after the terminal device400approaches the terminal device500, the terminal device400and the terminal device500can discover each other, and then establish a wireless communication connection such as a Bluetooth connection or a Wi-Fi peer-to-peer (peer-to-peer, P2P) connection. Then, the terminal device400and the terminal device500can determine capabilities of each other through signal interaction. For example, the terminal device400sends a capability query request to the terminal device500by using a Bluetooth connection, and determines, based on a capability query response, that the terminal device has a web capability.

For example, the terminal device400includes but is not limited to a smart sound box, a wearable device (for example, a smartwatch, a smart band, or smart glasses), another internet of things (IoT) device, and a device that does not have a web capability and cannot or has difficulty in accessing captive portal Wi-Fi, for example, a device in which a web application is not installed due to low memory or other reasons. An operating system may be installed in the terminal device400. The operating system installed in the terminal device400includes but is not limited to iOS®, Android®, Harmony®, Windows®, Linux®, or another operating system. Alternatively, an operating system may not be installed in the terminal device400. A specific type of the terminal device400, whether an operating system is installed, and a type of an installed operating system are not limited in this application.

For example, the terminal device500includes but is not limited to a device that has a web capability and can access captive portal Wi-Fi, for example, a smartphone, a tablet computer, a laptop computer (Laptop), a personal digital assistant (PDA), a vehicle-mounted device, or an artificial intelligence (AI) device. An operating system installed in the terminal device500includes but is not limited to iOS®, Android®, Harmony®, Windows®, Linux®, or another operating system. In some embodiments, the terminal device500may be a stationary device, or may be a portable device. A specific type and an installed operating system of the terminal device500are not limited in this application.

The terminal device400and the terminal device100described in the foregoing embodiment in which a terminal device borrows a network connection capability of another device may be a same device, or may be different devices.

The terminal device500and the terminal device200described in the foregoing embodiment in which a terminal device borrows a network connection capability of another device may be a same device, or may be different devices.

The AP600is configured to provide captive portal Wi-Fi for which authentication needs to be performed. The AP600may be the wireless access point400in the communication system shown inFIG.1, or may be another wireless access point.

It should be noted that a web application is usually installed in a terminal device having a web capability, and the terminal device having a web capability may support a protocol stack for accessing a web page, for example, HTTP or HTTPS. The web application is an application that can be accessed by using a web, for example, a browser application. Details are not described below.

In this embodiment of this application, a structure of the terminal device400that borrows a web capability of another device to access captive portal Wi-Fi is similar to that of the terminal device shown inFIG.3A. For details, refer toFIG.2Aand related descriptions. For example, the terminal device400may include at least one processor, at least one memory, a wireless communication module, a power management module, an audio module, a sensor module, a universal serial bus (USB) port, an indicator, a motor, and the like. The terminal device400does not include a display.

The memory may be configured to store application code, for example, application code used for performing wireless pairing and establishing a connection between the terminal device400and the terminal device500, to establish a wireless connection between the terminal device400and the terminal device500; process a wireless connection service of the terminal device400; charge the terminal device400; and the like.

The processor may be configured to: execute the application code, and invoke a related module to implement the function of the terminal device400in this embodiment of this application. For example, functions such as a wireless Bluetooth connection and wireless network access between the terminal device400and the terminal device500are implemented. For another example, signal interaction between the terminal device400and the terminal device500is implemented, and the terminal device500is used to complete authentication for a portal website of captive portal Wi-Fi.

The wireless communication module may be configured to support data exchange of wireless communication, including BT, a WLAN (for example, Wi-Fi), ZigBee, FM, NFC, IR, a general 2.4G/5G wireless communication technology, or the like, between the terminal device400and the terminal device500.

In some embodiments, the wireless communication module may be a Bluetooth chip. The terminal device400may be paired with and establish a wireless connection to the Bluetooth chip in the terminal device500by using the Bluetooth chip, to implement wireless communication and service processing between the terminal device400and the terminal device500by using the wireless connection. Usually, the Bluetooth chip may support Bluetooth basic rate (BR)/enhanced data rate (EDR) and Bluetooth low energy (BLE), for example, may receive/send paging information, and receive/send a BLE broadcast message. The Bluetooth chip may alternatively be a Bluetooth transceiver. The terminal device400may establish a wireless connection to the terminal device500by using the Bluetooth transceiver, to implement short-distance data exchange between the terminal device400and the terminal device500, for example, exchange portal website data and control data.

In some embodiments, the wireless communication module may be a Wi-Fi chip. The terminal device400may detect, by using the Wi-Fi chip, an AP that provides a wireless network, and request to access the AP, to access the wireless network.

In this embodiment of this application, a structure of the terminal device500that provides a web capability is similar to that of the terminal device shown inFIG.2A. For details, refer toFIG.2Aand related descriptions.

The terminal device500may include a processor110, an external memory interface120, an internal memory121, a universal serial bus (USB) port130, a charging management module140, a power management module141, a battery142, an antenna1, an antenna2, a mobile communication module150, a wireless communication module160, an audio module170, a sensor module180, a button190, a motor191, an indicator192, a camera193, a display194, a subscriber identity module (SIM) card interface195, and the like.

In some embodiments, the terminal device500receives a data packet that corresponds to the portal website and that is sent by the terminal device400, and displays a portal website page by using the display194based on the data packet. Then, the terminal device500detects, by using a touch sensor, an authentication operation performed by a user on the portal website page. The terminal device500generates a corresponding data packet based on the authentication operation performed by the user, and sends the data packet to the terminal device400.

A software system of a terminal device may use a layered architecture, an event-driven architecture, a microkernel architecture, a micro service architecture, or a cloud architecture. In embodiments of this application, an Android system of a layered architecture is used as an example to describe a software structure of the terminal device.

FIG.12is a block diagram of software structures of a terminal device400and a terminal device500according to an embodiment of this application.

In a layered architecture, software is divided into several layers, and each layer has a clear role and task. The layers communicate with each other through a software interface. In some embodiments, an Android system is divided into four layers: an application layer, an application framework layer, a hardware abstraction layer (HAL), and a kernel layer from top to bottom.

The application layer may include a series of application packages. The application packages may include applications such as Camera, Gallery, Calendar, Phone, Map, Navigation, WLAN, Bluetooth, Music, Video, and Messaging.

For example, as shown inFIG.12, an application layer of the terminal device500may include applications such as Browser, Music, and Call. The browser application is a web application. An application layer of the terminal device400does not include a web application. That is, the terminal device400does not have a web capability, and the terminal device500has a web capability.

Optionally, the block diagram of the software structure shown in this embodiment of this application does not constitute a specific limitation on the terminal device. For example, the terminal device may not include an application layer, that is, no application is installed in the terminal device.

For example, as shown inFIG.12, an application framework layer of the terminal device400may include a network detection service, a Wi-Fi connection service, a near field secure transmission service, and the like. An application framework layer of the terminal device500may include a web service, a near field secure transmission service, and the like.

In some embodiments, the network detection service is used to determine whether a hotspot for which a connection is requested is a captive portal Wi-Fi hotspot, and perform processing such as data transmission in a process of requesting to access this type of hotspot.

The Wi-Fi connection service is used to control an on or off state of Wi-Fi, scan for a nearby Wi-Fi device, establish a Wi-Fi connection, and the like.

The near field secure transmission service is used for discovery, authentication, authorization, and information transmission between near field devices. For example, by using the near field secure transmission service, the terminal device400and the terminal device500discover each other, complete authentication and authorization, and then may perform data transmission. In some embodiments, the terminal device400that does not have a web capability can establish, by using the near field secure transmission service, a wireless connection to the terminal device500that has a web capability. In addition, the terminal device400determines, through signal interaction with the terminal device500, that the terminal device500has a web capability.

The web service is used to provide HTTP access and interaction support for an application. In some embodiments, if the terminal device500has a web capability, the web service is configured at the application framework layer, to implement HTTP access of a web application (for example, a browser) and display a portal website of captive portal Wi-Fi.

The HAL is located between the kernel layer and the application framework layer, and is configured to: define an interface for implementation of driver application hardware, and convert a value implemented by the driver hardware into a software implementation programming language. For example, in the terminal device500shown inFIG.12, a HAL identifies a value of a camera driver, converts the value into a software programming language, and uploads the software programming language to the application framework layer, to invoke a camera service system.

For example, as shown inFIG.12, a HAL in the terminal device400may include a Wi-Fi driver interface, a Wi-Fi direct/Bluetooth/USB/Ethernet interface, and the like, and the HAL in the terminal device500may include a Wi-Fi direct/Bluetooth/USB/Ethernet interface, and the like.

The kernel layer is a layer between hardware and software. The kernel layer may include a display driver, a camera driver, an audio driver, a sensor driver, and the like.

For example,FIG.13is a schematic diagram of a network connection method according to an embodiment of this application. In the network connection method shown inFIG.13, a terminal device400may temporarily borrow a web capability of another device to access captive portal Wi-Fi.

As shown inFIG.13, the method may include the following steps.

Step S701: The terminal device400sends a network access request to an AP600, to request to access a wireless network provided by the AP600.

In some embodiments, when detecting, by using the network detection service at the application framework layer shown inFIG.12, a Wi-Fi hotspot provided by the AP600, the terminal device400sends the network access request to the AP600, to request to access the wireless network provided by the AP600. The network access request carries a MAC address of the terminal device400. Correspondingly, the AP600receives the network access request sent by the terminal device400.

Step S702: The AP600sends a portal website data packet to the terminal device400.

The portal website data packet may be referred to as a first data packet.

If a Wi-Fi type provided by the AP600is captive portal Wi-Fi, the AP600determines, based on the MAC address in the received network access request, whether the MAC address is locally stored. If the MAC address is stored, the AP600may allow the terminal device400to directly access the wireless network, and send an access acknowledgment response to the terminal device400, or send network data corresponding to the network access request. If the MAC address is not stored, it is determined that portal website login authentication needs to be performed on the terminal device400.

In some embodiments, if the AP600does not store the MAC address of the terminal device400, the AP600may directly send the portal website data packet to the terminal device400in response to the network access request received in S701.

In some other embodiments, if the AP600does not store the MAC address of the terminal device400, the AP600may send, to the terminal device400in response to the network access request received in S701, a network access response that carries an address of a portal website (which may also be referred to as a portal website address). Herein, a data packet of the network access response that carries the portal website address may be referred to as a third data packet.

The terminal device400receives and parses the network access response sent by the AP600, and determines, based on the network access response, whether the Wi-Fi type is captive portal Wi-Fi. If the Wi-Fi type provided by the AP600is captive portal Wi-Fi, after receiving and parsing the network access response, the terminal device400obtains the portal website address, and determines that login authentication needs to be performed.

In some embodiments, as described above, corresponding to an HTTP redirection technology and a DNS redirection technology of the AP600, the terminal device400determines, by using two methods, whether the Wi-Fi type is captive portal Wi-Fi. One method is to determine, based on an HTTP status code received after an HTTP request is sent, whether the Wi-Fi type is captive portal Wi-Fi. The other method is to determine, based on whether IP addresses received after DNS query requests with different domain names are sent are the same, whether the Wi-Fi type is captive portal Wi-Fi.

For example, in step S701, if the network access request sent by the terminal device400to the AP600includes an HTTP request, the terminal device400determines the Wi-Fi type based on an HTTP status code carried in the received network access response. If the HTTP status code carried in the network access response received by the terminal device400is 302, it is determined that the Wi-Fi type is captive portal Wi-Fi. Correspondingly, if the HTTP status code carried in the network access response received by the terminal device400is another status code (for example, 204), it is determined that the Wi-Fi type is not captive portal Wi-Fi. The HTTP request sent by the terminal device400may be an HTTP request corresponding to any website address.

For another example, in step S701, if the network access request sent by the terminal device400to the AP600includes at least two DNS query requests with different domain names, in step S703, the terminal device400determines the Wi-Fi type based on IP addresses carried in the received network access response.

Specifically, if the AP600does not provide captive portal Wi-Fi, after DNS query requests with different domain names are received, the network access response carries different IP addresses corresponding to the DNS query requests with different domain names. If the AP600provides captive portal Wi-Fi, after DNS query requests with different domain names are received, an IP address of the portal website is returned for each DNS query request. In this case, the network access response carries a same IP address, and the IP address is the address of the portal website. Therefore, if the IP addresses carried in the network access response received by the terminal device400are a same IP address, it is determined that the Wi-Fi type is captive portal Wi-Fi; or if the network access response received by the terminal device400carries different IP addresses, it is determined that the Wi-Fi type is not captive portal Wi-Fi.

In some embodiments, a redirection technology preconfigured in the AP600for application includes an HTTP redirection technology or a DNS redirection technology, and the terminal device400neither knows in advance whether the AP600provides captive portal Wi-Fi, nor knows a redirection technology currently applied to the AP600. Therefore, based on the foregoing two redirection technologies, in step S701, the network access request sent by the terminal device400includes at least one HTTP request and at least two DNS query requests with different domain names. Therefore, after receiving the network access request, the AP600may implement redirection of the portal website address by using the HTTP redirection technology or the DNS redirection technology, and send a network access response carrying an HTTP status code and a URL to the terminal device400, or send a network access response carrying an IP address to the terminal device400. Alternatively, the terminal device400sends two network access requests that respectively carry at least one HTTP request and at least two DNS query requests with different domain names to the AP600, so that a corresponding network access response can be received regardless of a redirection technology applied to the AP600.

In some other embodiments, if the terminal device400learns in advance of a redirection technology applied to the AP600, in step S701, the terminal device400sends a network access request carrying corresponding data to the AP600based on the redirection technology applied to the AP600. For example, if learning in advance that the redirection technology applied to the AP600is an HTTP redirection technology, the terminal device400sends a network access request carrying at least one HTTP request to the AP600. For another example, if learning in advance that the redirection technology applied to the AP600is a DNS redirection technology, the terminal device400sends a network access request carrying at least two DNS query requests with different domain names to the AP600.

In some embodiments, the portal website address carried in the network access response obtained by the terminal device400includes, for example, a URL or an IP address, and a portal website access request may be sent to the AP600based on the portal website address, to request to access the portal website. Correspondingly, after receiving the portal website access request, the AP600may send the corresponding portal website data packet to the terminal device400.

In S702, the portal website data packet sent by the AP600to the terminal device400includes page data corresponding to the portal website, and is used to display a portal website login page.

Step S703: The terminal device400forwards the portal website data packet to a terminal device500.

In some embodiments, the terminal device400does not have a web capability, after determining that the Wi-Fi type of the hotspot that needs to be accessed is captive portal Wi-Fi, may determine that the hotspot needs to be accessed by using a web capability of another device, and therefore needs to establish a communication connection to the nearby terminal device500having a web capability. The communication connection between the terminal device400and the terminal device500may be a Bluetooth connection, a Wi-Fi direct connection, or the like.

For example, the terminal device400scans for a nearby device that can establish a Bluetooth connection, for example, obtains the terminal device500through scanning, and establishes a Bluetooth connection to the terminal device500. Then, a capability request signal is sent to the terminal device500based on the Bluetooth connection, to determine whether the terminal device500has a web capability. If determining, based on signal feedback sent by the terminal device500, that the terminal device500has a web capability, the terminal device400may transmit data to the terminal device500based on the Bluetooth connection, for example, send the portal website data packet to the terminal device500. If determining, based on signal feedback sent by the terminal device500, that the terminal device500does not have a web capability, the terminal device400may disconnect the Bluetooth connection, and rescan to access another terminal device having a web capability.

Optionally, in a process of establishing a communication connection (for example, a Bluetooth connection), the terminal device400may further determine, through signal interaction, whether a to-be-connected terminal device has a web capability. If the to-be-connected terminal device has a web capability, a communication connection is established. If the to-be-connected terminal device does not have a web capability, no communication connection is established. An occasion for determining the web capability of the terminal device500is not specifically limited in this embodiment of this application.

It should be noted that an occasion for establishing, by the terminal device400, a communication connection to the terminal device500is not limited in this embodiment of this application. For example, the terminal device400may establish a communication connection to the terminal device500before step S701(that is, before requesting to access the hotspot). For another example, after determining that the Wi-Fi type is captive portal Wi-Fi and the terminal device400does not have a web capability, the terminal device400establishes a communication connection to the terminal device500having a web capability.

In addition, an occasion for determining, by the terminal device400, a nearby device having a web capability is not limited in this embodiment of this application. For example, before step S701(that is, before requesting to access the hotspot), the terminal device400first scans for a nearby device, to determine one or more devices having a web capability. Then, when needing to access captive portal Wi-Fi, the terminal device400directly establishes a communication connection to any determined device (for example, the terminal device500) having a web capability, and forwards the portal website data packet to the device. Further, the terminal device400may scan for a nearby device based on a preset period, and update a list of nearby devices having a web capability, to avoid a case in which a communication connection cannot be established because a device moves beyond a communication distance.

In some implementations, the terminal device400establishes, by using the near field secure transmission service at the application framework layer shown inFIG.12, a communication connection to the terminal device500having a web capability. Then, the terminal device400forwards the received portal website data packet to the terminal device500. Correspondingly, the terminal device500receives the portal website data packet sent by the terminal device400.

Step S704: The terminal device500displays a portal website page, detects a user operation, and generates a data packet corresponding to the user operation.

In some embodiments, after receiving the portal website data packet, the terminal device500renders the portal website page in a browser application or another web application by using a web service based on the portal website data packet, and displays the portal website page visible to a user, to receive a login confirmation operation performed by the user in a login authentication process.

For example, for the interface201shown inFIG.10, the terminal device500may display the interface201, to detect a login authentication operation performed by the user, and generate a data packet corresponding to the user operation. For example, if detecting an operation of tapping the control21by the user, the terminal device500generates data corresponding to the operation of tapping the control21.

In some embodiments, when another application is run in foreground (for example, when the user is playing a game and a game interface is displayed), if the portal website data packet is received, the terminal device500may first display prompt information (for example, display the prompt information by using a notification bar or display the prompt information by using a prompt card) after receiving the portal website data packet, to prompt the user to determine whether to help the terminal device400perform Wi-Fi login authentication. Then, after detecting an operation of tapping an OK control by the user, the terminal device500displays the portal website interface, to avoid a case in which an operation that is being performed by the user is disturbed because the portal website page is directly displayed.

In addition, if detecting a non-confirmation operation (for example, an operation of tapping a cancel control) performed by the user, the terminal device500sends a display failure response to the terminal device400, to notify the terminal device400that the portal website fails to be displayed, so that the terminal device400reselects another terminal device having a web capability to establish a communication connection and perform Wi-Fi login authentication.

Further, if the terminal device400does not receive, within a preset response time, a response signal (for example, the data packet that corresponds to the user operation and that is sent by the terminal device500in the following step S705) sent by the terminal device500, it may be determined that Wi-Fi login authentication on the terminal device500fails, and another terminal device having a web capability needs to be reselected to establish a communication connection and perform Wi-Fi login authentication.

In some other embodiments, when receiving the portal website data packet in a screen-locked state, the terminal device500displays prompt information, to prompt the user with information indicating that the portal website page used to help the terminal device400perform Wi-Fi login authentication currently needs to be displayed. After receiving a confirmation operation and an unlock operation performed by the user, the terminal device500may display the portal website page.

The login confirmation operation detected in step S704may be referred to as a sixth operation, and the data packet generated in S704may be referred to as a second data packet.

Step S705: The terminal device500sends the data packet corresponding to the user operation to the terminal device400.

In some embodiments, the web service in the terminal device500monitors a data packet generated in the browser application or another web application, and then forwards the data packet to the terminal device400. Correspondingly, the terminal device400receives the data packet corresponding to the user operation. For example, in the scenario that is shown inFIG.10and that is in the example in step S704, the terminal device500generates the corresponding data packet after detecting the operation of tapping the control21by the user, packages the data packet, and then sends the data packet to the terminal device400. The data packet can indicate the login confirmation operation performed by the user. The operation that is of tapping the control21by the user and that is detected by the terminal device500may be referred to as a seventh operation.

In some embodiments, in a process of performing a step (for example, step S704) related to accessing the AP600by the terminal device400, the terminal device500may further perform a step of accessing a network by the terminal device500, for example, accessing a hotspot, and receiving and sending a network message. For example, the web service in the terminal device500may selectively monitor and forward, in a preset manner, a network data packet (for example, the data packet corresponding to the user operation) related to login authentication on the terminal device400for captive portal Wi-Fi, and send such a data packet to the terminal device400, instead of directly exchanging such a data packet with the AP600. The preset manner includes, for example, presetting a special system interface, presetting a specific field of a data packet, or another manner. A network data packet corresponding to the terminal device400and a network data packet of the terminal device400are distinguished in the preset manner.

Step S706: The terminal device400forwards the data packet corresponding to the user operation to the AP600.

In some embodiments, after receiving the data packet that corresponds to the user operation and that is sent by the terminal device500, the terminal device400forwards the data packet to the AP600by using a source address and a source port of the terminal device400, and performs login authentication interaction with the AP600for the portal website. The AP600determines, based on the address and the port corresponding to the received data packet, to perform login authentication on the terminal device400. In this case, only after subsequent login authentication succeeds, the AP600can allow the terminal device400with the source address and the source port to perform data interaction with the AP600.

That is, in a login authentication process for the portal website corresponding to the terminal device400, the terminal device500needs to send, to the terminal device400, a received feedback data packet of a data packet sent by the terminal device400, and then the terminal device400forwards the feedback data packet to the AP600. Correspondingly, a data packet sent by the AP600to the terminal device400also needs to be forwarded by the terminal device400to the terminal device500. That is, the data packet corresponding to the terminal device400is not directly transmitted between the terminal device500and the AP600, and the terminal device400plays a role of data packet forwarding.

It should be noted that step S707to step S709in a dashed line box shown inFIG.13may be performed for a plurality of times until login authentication for captive portal Wi-Fi is completed. For example, in some embodiments, after receiving the data packet corresponding to the user operation, the AP600determines a data meaning of the data packet corresponding to the user operation, to determine whether login authentication is completed or whether further login authentication is required. If further authentication is required, S704to S706further need to be performed again. In this case, in a process of displaying the portal website page, the terminal device500receives one or more login confirmation operations performed by the user.

For example, if a login authentication manner for the portal website is SMS verification code login authentication, the portal website page displayed by the terminal device500is an SMS verification page. After detecting that the user enters a phone number (the phone number may be a phone number corresponding to the terminal device500or a phone number corresponding to another terminal device) and determining an operation of sending a verification code (that is, step S704), the terminal device500sends the data packet corresponding to the user operation to the terminal device400(that is, step S705). The terminal device400forwards the data packet to the AP600(that is, step S706). After receiving the data packet, the AP600sends the verification code to the terminal device corresponding to the received phone number by using a module such as an SMS service center connected in background, and sends a response data packet to the terminal device400. The response data packet indicates that the verification code is successfully requested. The terminal device400forwards the response data packet to the terminal device500. Then, the user views the verification code on the terminal device that receives the verification code, and enters the verification code on the portal website page displayed by the terminal device500(that is, step S704). After detecting an operation of entering the verification code by the user and confirming that filling of the verification code is completed, the terminal device500sends the corresponding data packet to the terminal device400(that is, step S705), and then the terminal device400forwards the data packet to the AP600(that is, step S706).

After step S704to step S706are performed for one or more times, the AP600may determine that login authentication on the terminal device400for the portal website succeeds, and allow the terminal device400to access captive portal Wi-Fi provided by the AP600. In this case, the terminal device400successfully accesses, by temporarily borrowing the web capability of the terminal device500in S704, captive portal Wi-Fi provided by the AP600.

Based on steps S701to S706, when the terminal device400that does not have a web capability needs to access captive portal Wi-Fi, the terminal device400may temporarily use a web capability of another terminal device (for example, the terminal device500) to complete authentication, and access captive portal Wi-Fi, to meet a requirement of the user for different terminal devices to access captive portal Wi-Fi, and improve user experience.

Optional step S707to step S709: The AP600notifies that the terminal device400successfully accesses captive portal Wi-Fi.

In some embodiments, after allowing the terminal device400to access captive portal Wi-Fi, the AP600may notify the terminal device400that the terminal device400successfully accesses captive portal Wi-Fi. In this way, the terminal device can learn, in a timely manner, that the terminal device accesses captive portal Wi-Fi, to provide various services for the user.

Certainly, in some embodiments, the AP600may not need to notify the terminal device400that the terminal device400successfully accesses captive portal Wi-Fi, but only needs to provide a normal service for the terminal device400by using captive portal Wi-Fi. The terminal device400is not notified, so that communication resources between devices can be saved.

Optional step S707: The AP600sends a response data packet to the terminal device400.

The response data packet may be a data packet indicating that login authentication is completed.

Optional step S708: The terminal device400forwards the response data packet to the terminal device500.

In some embodiments, if the terminal device400does not have a web capability, the terminal device400forwards the received response data packet to the terminal device500for processing.

Optional step S709: The terminal device400determines that login authentication is completed.

In some embodiments, in a process of forwarding data packets sent by the AP600and the terminal device500, the terminal device400may determine, in a preset login confirmation manner based on a preset login confirmation occasion, whether login authentication is completed, and then after determining that login authentication is completed, access captive portal Wi-Fi provided by the AP600. The preset login confirmation occasion may be referred to as a first preset occasion.

In some embodiments, the preset login confirmation occasion includes, for example, one or more of the following content: a state corresponding to a data packet that is sent by the AP600and that is received by the terminal device400or a data packet sent by the terminal device500is a state indicating that sending of an HTTP data packet is disabled, a preset period, a preset time point, or a signal that is sent by the terminal device500and that is used for confirming completion of login authentication is received. The terminal device400may select the preset login confirmation occasion based on conditions such as a performance requirement and a power consumption requirement of the terminal device400, and determine whether login authentication is completed.

For example, in an HTTP data packet interaction process between two devices, when either device confirms that transmission of all HTTP data packets is completed, the device sends a data packet whose state is a state indicating that sending of the HTTP data packet is disabled to the peer device, for example, sends an HTTP data packet carrying a “byebye signal”. Therefore, the terminal device400may determine, based on states of the data packets forwarded in step S705and step S707, whether it needs to determine, in the preset login confirmation manner, that login authentication is completed.

For another example, in a login authentication process, the terminal device400determines, in a preset login confirmation manner based on a preset period, whether login authentication is completed. The preset login confirmation manner may also be referred to as a first preset manner.

For another example, the terminal device400periodically determines, in a preset login confirmation manner based on a preset time point, whether login authentication is completed.

For still another example, the terminal device500displays a confirmation interface, and the user confirms whether all login authentication operations are completed.

For example, in an interface801shown inFIG.14, the terminal device500(for example, a mobile phone) displays a prompt box81, to prompt the user whether to confirm that login authentication is completed. If detecting an operation of tapping an OK control82by the user, the terminal device500sends a signal for confirming completion of login authentication to the terminal device400. Then, after receiving the signal for login authentication, the terminal device400determines, in the preset login confirmation manner, whether login authentication is completed. If the terminal device500detects an operation of tapping a “determine to re-access” control83by the user, step S705to step S708are repeated, and login authentication is performed again.

In some embodiments, the preset login confirmation manner may include, for example, sending an HTTP request to the AP600, and determining, based on an HTTP status code carried in a received network access response, whether login authentication for captive portal Wi-Fi is completed. If the HTTP status code is any status code in200to207, it may be determined that login authentication for captive portal Wi-Fi is completed. Alternatively, at least two DNS query requests with different domain names are sent to the AP600, and it is determined, based on whether IP addresses carried in a received network access response are a same IP address, whether login authentication for captive portal Wi-Fi is completed. If the IP addresses are different, it is determined that login authentication for captive portal Wi-Fi is completed.

It should be noted that as described in the foregoing steps, the terminal device400may not know a specific redirection technology used by the AP600. Therefore, in a process of determining, in the preset login confirmation manner, whether login authentication is completed, the preset login confirmation manner includes: The terminal device400sends an HTTP request and/or at least two DNS query requests with different domain names to the AP600.

In some embodiments, after determining that login authentication on the terminal device400for the portal website succeeds, the AP600directly sends a corresponding network resource to the terminal device400based on the network access request sent by the terminal device400to the AP600in step S701. In this case, the terminal device400may not need to perform the step of determining that login authentication is completed in step S709, and directly determine, based on the received network resource, that login authentication for the portal website is completed, to access captive portal Wi-Fi. That is, step S709is an optional step.

In this way, the terminal device400that does not have a web capability can display a login authentication page of the portal website by using the web capability of the terminal device500, and complete login authentication for captive portal Wi-Fi, to access captive portal Wi-Fi.

In some scenarios, after determining that login authentication is completed, the terminal device400may be disconnected from the terminal device500. Therefore, after step S709, optional step S710may be further included.

Optional step S710: The terminal device400sends a disconnection signal to the terminal device500.

In some embodiments, after determining that login authentication for captive portal Wi-Fi is completed, the terminal device400no longer needs to send a data packet related to login authentication for captive portal Wi-Fi to the terminal device500, and may send the disconnection signal to the terminal device500, to disconnect the communication connection to the terminal device500and independently access captive portal Wi-Fi.

Optionally, after receiving the disconnection signal, the terminal device500may further disconnect the communication connection to the terminal device400, and send a disconnection response to the terminal device400, to confirm disconnection.

In this way, after completing login authentication by using the web capability of the terminal device500, the terminal device400disconnects the communication connection to the terminal device500, to independently access captive portal Wi-Fi.

Based on S701to S706, the terminal device400successfully borrows the web capability of the terminal device500to access captive portal Wi-Fi, and subsequently does not need to borrow the web capability of the terminal device500again. The connection between the terminal device400and the terminal device500is disconnected in S710, so that communication resources of the terminal device400can be saved, and communication between the terminal device500and captive portal Wi-Fi is not affected.

In the network connection method shown inFIG.13, in a process in which the terminal device400borrows the web capability of the terminal device500to access captive portal Wi-Fi, each device differently processes a data packet.

FIG.15shows an example of a manner of processing a data packet by each device in a process in which a terminal device400borrows a web capability of a terminal device500to access captive portal Wi-Fi.

As shown inFIG.15, in the process in which the terminal device400borrows the web capability of the terminal device500to access captive portal Wi-Fi, because the terminal device400does not have a web capability, the terminal device400performs processing only at a transport layer, a network layer, and a physical layer on the data packet, and does not perform processing at an application layer, and the terminal device500performs processing at the application layer on the data packet. The terminal device400may transparently transmit an application layer data packet from the internet to the terminal device500, and the terminal device500performs processing at the application layer on the data packet. The terminal device400may further perform processing at the transport layer, the network layer, and the physical layer on an application layer data packet from the terminal device500, and then send the data packet to the internet. An internet device, for example, the AP600, may perform processing at the foregoing four layers on the data packet.

The method for temporarily borrowing, by a terminal device, a web capability of another device to access a captive portal wireless network (captive portal Wi-Fi) is described above in detail with reference toFIG.13. With reference toFIG.16andFIG.17, the following describes in detail a Wi-Fi authentication apparatus provided in an embodiment of this application.

In a possible design,FIG.16is a schematic diagram of a structure of a terminal device400according to an embodiment of this application. As shown inFIG.16, the terminal device400used as a Wi-Fi authentication apparatus may include a transceiver unit1001and a processing unit1002. The terminal device400may be configured to implement the function of the terminal device in the foregoing method embodiments. The terminal device does not have a web capability. A web application is usually installed in a terminal device having a web capability, and the terminal device having a web capability supports the HTTP/HTTPS protocol.

Optionally, the processing unit1002is configured to support the terminal device400in performing S709inFIG.13.

The transceiver unit may include a receiving unit and a sending unit, may be implemented by a transceiver or a transceiver-related circuit component, and may be a transceiver or a transceiver module. Operations and/or functions of the units in the terminal device400are respectively intended to implement corresponding procedures of the network connection method in the foregoing method embodiments. All related content of the steps in the foregoing method embodiments may be cited in function descriptions of the corresponding functional units. For brevity, details are not described herein.

Optionally, the terminal device400shown inFIG.16may further include a storage unit (not shown inFIG.16), and the storage unit stores a program or instructions. When the transceiver unit1001and the processing unit1002execute the program or the instructions, the terminal device400shown inFIG.16may perform the network connection method in the method embodiment inFIG.13.

For technical effects of the terminal device400shown inFIG.16, refer to the technical effects of the network connection method in the foregoing method embodiment. Details are not described herein.

In addition to a form of the terminal device400, the technical solutions provided in this application may be implemented by a functional unit or a chip in a terminal device, or an apparatus used together with a terminal device.

In a possible design,FIG.17is a schematic diagram of a structure of a terminal device500according to an embodiment of this application. As shown inFIG.17, the terminal device500used as a Wi-Fi authentication apparatus may include a transceiver unit1101, a display unit1102, and a processing unit1103. The terminal device500may be configured to implement the function of the terminal device in the foregoing method embodiments. The terminal device has a web capability. A web application is usually installed in a terminal device having a web capability, and the terminal device having a web capability supports the HTTP/HTTPS protocol.

Optionally, the transceiver unit1101is configured to support the terminal device500in performing S703, S705, S708, and S710inFIG.13.

Optionally, the display unit1102is configured to support the terminal device500in performing S704inFIG.13.

Optionally, the processing unit1103is configured to support the terminal device500in performing S704inFIG.13.

The transceiver unit may include a receiving unit and a sending unit, may be implemented by a transceiver or a transceiver-related circuit component, and may be a transceiver or a transceiver module. Operations and/or functions of the units in the terminal device500are respectively intended to implement corresponding procedures of the network connection method in the foregoing method embodiments. All related content of the steps in the foregoing method embodiments may be cited in function descriptions of the corresponding functional units. For brevity, details are not described herein.

Optionally, the terminal device500shown inFIG.17may further include a storage unit (not shown inFIG.17), and the storage unit stores a program or instructions. When the transceiver unit1101, the display unit1102, and the processing unit1103execute the program or the instructions, the terminal device500shown inFIG.17may perform the network connection method in the foregoing method embodiments.

For technical effects of the terminal device500shown inFIG.17, refer to the technical effects of the network connection method in the foregoing method embodiment. Details are not described herein.

In addition to a form of the terminal device500, the technical solutions provided in this application may be implemented by a functional unit or a chip in a terminal device, or an apparatus used together with a terminal device.

In the embodiments inFIG.13toFIG.17, the terminal device400that needs to use a web capability provided by another device to access captive portal Wi-Fi may be referred to as a fourth device, and the terminal device500that provides a web capability may be referred to as a fifth device.

The method for temporarily borrowing, by a terminal device, a web capability of another device to access a captive portal wireless network (captive portal Wi-Fi) is described in the foregoing embodiments. The following describes a method for temporarily borrowing, by a terminal device, a network connection capability of another device to activate an eSIM or a blank SIM, to access the internet.

An electronic device that supports the eSIM or the blank SIM may include, for example, a network-side device such as an AP (for example, CPE), and may further include a terminal device such as a smartwatch, a smart band, or an in-vehicle infotainment. Subsequent implementation is mainly described by using the AP as an example. Subsequent embodiments do not limit the protection scope of this application. In the network connection method provided in embodiments of this application, another electronic device that supports the eSIM or the blank SIM and that is different from the AP may also use the network connection method to activate the eSIM or the blank SIM by using a network connection capability of another device. This is not limited herein.

The CPE is an access device that receives a mobile signal and forwards the mobile signal in a form of a Wi-Fi signal. The CPE may simultaneously provide Wi-Fi signals for a plurality of terminals, may further enhance the Wi-Fi signals for a second time, and is a widely applied access device.

FIG.18shows an activation scenario of CPE. As shown inFIG.18, in this scenario, a terminal and a router need to be used to activate the CPE that supports an eSIM card. The CPE connects to the router by using a network cable, so that the CPE can obtain a network connection capability. After purchasing the CPE that supports an eSIM card, a user may purchase a package from an online store of an operator by using the terminal, and obtain an activation code of the eSIM, or a user may purchase a package from a physical operator store, and obtain an activation code of the eSIM. In step401, the CPE may provide management interface data of the CPE for the terminal, so that a management interface of the CPE may be displayed on the terminal. In step402, the user may enter the activation code of the eSIM in the management interface that is of the CPE and that is displayed by the terminal, to generate an activation instruction, and send the activation instruction to the CPE. In step403, the CPE generates an activation request based on the activation instruction, and transmits the activation request to the router by using the network cable. In step404, the router may forward the activation request from the CPE to an operator server. In step405, the operator server may check data carried in the activation request sent by the CPE. If the check succeeds, the operator server sends a profile to the router. In step406, the router helps the operator server forward the profile to the CPE, to activate the eSIM card. However, in an actual scenario, the CPE may not have a condition for connecting to the router. In this case, an activation operation cannot be performed on the eSIM.

In the foregoing scenario, the router provides a network service for the CPE, the router is a server, and the CPE is a client. In addition, the CPE provides a service for the terminal to log in to the management interface of the CPE, the CPE is a server, and the terminal is a client.

In the foregoing scenario, if the router that provides a network service for the CPE is replaced with a terminal that can provide a network service for the CPE by using a hotspot, where for ease of description, the terminal may be referred to as a first terminal, and the terminal used to log in to the management interface of the CPE is referred to as a second terminal, the first terminal is a server of the CPE, the CPE is a client of the first terminal, and the CPE is a server of the second terminal. However, in an actual scenario, there may not be a condition that the first terminal and the second terminal coexist. That is, when only one terminal with a network connection capability is available, if the terminal is used as the first terminal to provide a network service for the CPE, the terminal cannot be used as a client to log in to the management interface of the CPE, or if the terminal is used as the second terminal to log in to the management interface of the CPE, the terminal cannot be used as a server of the CPE to provide a network service for the CPE. In this case, an activation operation also cannot be performed on the eSIM.

Therefore, an embodiment of this application provides a network connection method. An AP and a terminal may exchange data by using a near field transmission connection, so that the terminal and the AP may serve as two peer network-connected parties, and serve as a server and a client for each other to provide respective services for each other. In this way, a user can perform an activation operation on a blank SIM or an eSIM by using one terminal with a network connection capability, and may further perform a setting operation on the AP in a process of implementing the activation operation. For example, the setting operation may include setting a user name and a password of the AP. The setting operation may further include setting a parameter of a quantity of terminal devices that can be simultaneously allowed to access the AP, and the like.

It should be understood that for ease of description, data related to the activation operation on the blank SIM or the eSIM may be referred to as activation data. For example, a profile, an activation instruction, an activation request, and a fourth data packet fed back by an operator for an activation request of the AP may all be considered as the activation data. Data related to the setting operation on the AP is referred to as setting data, for example, management interface data that is of the AP and that is provided by the AP for the terminal and setting information sent by the terminal to the AP. The setting information may include, for example, related information about setting, by the terminal, the user name and the password of the AP. The setting information may further include related information about controlling the quantity of terminal devices that can be simultaneously allowed to access the AP. The setting information in this application includes but is not limited this.

In this embodiment of this application, near field transmission may mean that devices (for example, the AP and the terminal described above) may communicate with each other in a near field condition, for example, perform data transmission. For example, communication between the devices may be implemented based on a communication function of a wireless communication module in the terminal. A prerequisite for near field transmission is to establish a near field connection. The establishing a near field connection may include, for example, discovery of a near field device, check on the near field device, and connection establishment between the devices. It should be understood that in this embodiment of this application, a connection is established between the devices only after the check on the near field device succeeds, and communication can be performed between the devices only after the connection is successfully established. Otherwise, connection establishment between the devices fails, and communication cannot be performed between the devices.

For example, in a possible implementation, the devices communicate with each other by using Bluetooth. A Bluetooth communication protocol may implement device discovery within a range of 50 meters. All electronic devices having a Bluetooth function in a circular area range in which the device whose Bluetooth function is enabled is used as a center and a radius is 50 meters are near field devices (including the device whose Bluetooth function is enabled). However, it may be understood that only when a Bluetooth function is enabled, a device in this circular range can establish a Bluetooth connection to a device in the center and communicate with the device by using Bluetooth.

It should be understood that an implementation of near field transmission is not limited to Bluetooth. For example, two devices may establish a near field connection by using Wi-Fi direct. For another example, two devices may establish a near field connection by using a universal USB port. For another example, two devices may establish a near field connection by using a network cable and an Ethernet interface. A manner of establishing the near field connection is not limited in this application.

The near field device may be a device in a near field condition, for example, an AP device (for example, a router or CPE) or a terminal device (for example, a mobile phone or a notebook computer). The near field condition in this embodiment of this application may mean that a near field connection may be established between devices.

The profile may be an operator profile. The profile may include, for example, but is not limited to a combination of a file system, file content, data, and an application installed on a UICC, and mainly carries information such as an IMSI and an authentication parameter. After the profile is activated, a mobile network corresponding to the profile may be accessed. In this embodiment of this application, after the profile is activated, the subscriber identity module may connect to the network, and the AP for which the subscriber identity module is configured may be activated, to provide a communication service. The UICC may include a SIM and an eSIM. This is not limited in this application.

FIG.19is a schematic diagram of a communication system according to an embodiment of this application. As shown inFIG.19, the communication system includes a terminal device700, an AP800, and a server900provided by a communication service operator.

The terminal device700may also be referred to as a mobile device or the like. The terminal device may include a wireless terminal and a wired terminal. In this embodiment of this application, the terminal device700may include but is not limited to a mobile phone, a tablet computer, a smartwatch, a wearable device, a vehicle-mounted device, an augmented reality (AR)/virtual reality (VR) device, a notebook computer, a personal computer (PC), an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a distributed device, and the like.

The terminal device700has a network connection capability. That is, the terminal may access the operator server900in a plurality of manners such as a cellular mobile network, a WLAN, Ethernet, a USB, and Bluetooth.

The terminal device700may be the network-connected terminal device200in the communication system shown inFIG.1, may be the terminal device500in the communication system shown inFIG.11, or may be another network-connected terminal device. This is not limited herein.

The AP800is an access point for a wireless terminal to access a wired network, is mainly used in a broadband home, a building, a campus, a park, a warehouse, a factory, and other places that require wireless monitoring, typically covers a distance of dozens of meters to hundreds of meters, may also be used for long-distance transmission, and may cover a longest distance of approximately 30 kilometers. The AP800is equivalent to a bridge that connects a wired network to a wireless network. A main function of the AP800is to connect wireless network clients together, and then connect the wireless network to the Ethernet. A router, CPE, a gateway, a bridge, or another device may be used as the AP800.

The AP800is configured to create a WLAN. After joining the network created by the AP800, the terminal device may connect to the internet through the AP800.

A device such as a router, a gateway, or a bridge may be configured to convert a wired network into a wireless WLAN, to facilitate access by the terminal device.

The CPE is configured to: receive a mobile signal (namely, a cellular network signal) sent by a network device (for example, a base station), and forward the mobile signal in a form of a Wi-Fi signal. The CPE may simultaneously provide Wi-Fi signals for a plurality of terminal devices, may further enhance the Wi-Fi signals for a second time, and is a widely applied access device.

The AP800may be the wireless access point400in the communication system shown inFIG.1, may be the AP600in the communication system shown inFIG.11, or may be another wireless access point.

The terminal device700communicates with the AP800based on a near field connection. The terminal device700is configured to send an activation instruction to the AP800. The activation instruction is used to download a profile. The AP800is configured to send an activation request to the terminal device700in response to the received activation instruction. The activation request is used to request to download the profile from the operator server900. The terminal device700is configured to forward the activation request to the operator server900, and is configured to forward the profile received from the operator server900to the AP800.

The server900may communicate with the terminal device700, and is configured to: receive an activation request sent by the terminal device700, and send the profile to the terminal device700in response to the activation request. The server900and the terminal device700may communicate with each other in a plurality of manners such as a cellular mobile network, a WLAN, Ethernet, a USB, and Bluetooth. This is not limited herein.

The server900and the server500in the communication system10shown inFIG.1may be a same server or different servers. This is not limited herein.

In this embodiment of this application, a structure of the terminal device700that provides a network connection capability to activate an eSIM or a blank SIM is similar to that of the terminal device shown inFIG.2A. For details, refer toFIG.2Aand related descriptions.

A memory may be configured to: store application code, for example, application code used by the terminal device700to provide the network connection capability to activate the eSIM or the blank SIM, to establish a near field transmission connection between the terminal device700and the AP800; process a wireless connection service of the terminal device700; and the like.

A processor may be configured to: execute the application code, and invoke a related module to implement the function of the terminal device700in this embodiment of this application. For example, functions such as a near field transmission connection between the terminal device700and the AP800are implemented.

A wireless communication module may be configured to support data exchange of wireless communication, including BT, a WLAN (for example, Wi-Fi), ZigBee, FM, NFC, IR, a general 2.4G/5G wireless communication technology, or the like, between the terminal device700and the AP800.

FIG.20is a block diagram of software and hardware structures of a terminal device700that provides a network connection capability to activate an eSIM or a blank SIM.

As shown inFIG.20, a software architecture of the terminal device700may include four layers: an application layer, an application framework layer, a system library, and a kernel layer. Functions of the layers in the terminal device700are similar to those of the software architecture shown inFIG.2B-1andFIG.2B-2. For details, refer toFIG.2B-1,FIG.2B-2, and related descriptions.

A difference lies in that the application layer in the terminal device700may include at least a browser and/or a CPE management application. The browser may be used to access a world wide web (Web) application, and the terminal device700may access, by using the browser, a CPE management service provided by CPE. The CPE management application may be used to manage and control an application of the CPE, and the terminal device700may access and control the CPE management service by using the application of the CPE.

As shown inFIG.20, the application framework layer in the terminal device700may include at least a routing management service, a near field transmission module, and the like.

The routing management service in the terminal device700may be used to manage transmission of data to be exchanged between the terminal device700and the CPE.

The near field transmission module in the terminal device700is a functional module abstracted based on a near field communication capability such as Bluetooth, a WLAN, a USB, or Ethernet. The near field transmission module does not necessarily actually physically exist, but in terms of function implementation, the module may implement a corresponding function by using program code. The near field transmission module may be used for near field transmission between the terminal device700and the CPE, and may include device discovery, identity authentication, check, and transmission in a plurality of manners between the terminal device700and the CPE, so that instructions, information, network data, and the like can be transmitted between the terminal device700and the CPE.

It should be understood that at a physical level, the near field transmission module may use a physical communication element, including but not limited to a Bluetooth communication element, a WLAN communication element, a Wi-Fi direct communication element, an Ethernet interface, a USB port, and the like, in a near field and/or a local area network. At a system level, the near field transmission module may be configured to discover a nearby device, may be further configured to authenticate whether devices that need to establish a connection belong to a same user, and may be further configured to transmit information between devices that establish a connection.

The kernel layer in the terminal device700may include network routing and local routing.

FIG.21is a block diagram of software and hardware structures of CPE that borrows a network connection capability of another device to activate an eSIM or a blank SIM.

As shown inFIG.21, a software architecture of the CPE may include four layers: an application layer, an application framework layer, a system library, and a kernel layer. Functions of the layers in the CPE are similar to those of the software architecture shown inFIG.2B-1andFIG.2B-2. For details, refer toFIG.2B-1,FIG.2B-2, and related descriptions.

As shown inFIG.21, the CPE is used as an example of an AP800, and the application framework layer in the CPE may include at least a CPE management service, a SIM management service, a routing management service, and a near field transmission module.

The CPE management service of the CPE may be in a form of a hypertext transfer protocol (HTTP) service, and is used for visual display of a terminal and control over each configuration of the CPE.

The routing management service in the CPE may be used to manage transmission of data to be exchanged between the CPE and the terminal.

The SIM management service may be used to manage activation of a SIM, for example, generate an activation request based on an activation instruction of the terminal. A CPE control service may be used to set or control the CPE, for example, make a corresponding setting response based on setting information of the terminal. It should be understood that when the CPE is CPE that supports an eSIM, the SIM management service may be an eSIM management service.

The near field transmission module in the CPE may be the same as or similar to the near field transmission module in the terminal. For brevity, details are not described herein. For detailed descriptions, refer to the near field transmission module in the terminal.

The kernel layer in the CPE may also include network routing and local routing.

Currently, in the market, CPE supports two types of data cards: a SIM card and an eSIM card. When CPE that supports insertion of a physical blank SIM is used, for example, the blank SIM is a SIM provided with the CPE, or when CPE that supports an eSIM card is used, a user may purchase a package online, perform real-name authentication, remotely perform self-service account opening and cancellation, and independently select a to-be-used network. However, this manner has a problem of initial network connection and activation of the CPE. That is, after the user purchases the CPE that supports insertion of a physical blank SIM or the CPE that supports an eSIM card, an operator server needs to be connected to activate the blank SIM or the eSIM card. However, before the blank SIM or the eSIM card is activated, the CPE cannot connect to a network, and needs to use another device with a network connection capability to provide a network. However, there is usually no such an activation condition.

It should be understood that before the blank SIM and the eSIM are activated, a profile that can provide a service is not configured, and therefore no service can be provided. Therefore, even if a SIM is inserted into the CPE, if the SIM is a blank SIM, the CPE still cannot connect to a network; or if the CPE is CPE that supports the eSIM, before the eSIM is activated, the CPE still cannot connect to a network. Activating the blank SIM or activating the eSIM may be understood as downloading a profile from the operator server, activating the profile, and then configuring the profile in the blank SIM or the eSIM. The blank SIM and the eSIM can provide a service after the activated profile is configured. Therefore, the CPE has a network connection capability, and can externally provide a service, that is, the CPE is activated.

For better understanding of the method provided in this application, the following describes, with reference toFIG.22,FIG.23,FIG.24A, andFIG.24B, in detail the network connection method provided in embodiments of this application.

FIG.22is a schematic flowchart of a network connection method according to an embodiment of this application. The method may include the following steps.

Step S801: A terminal device700and an AP800establish a near field transmission connection.

It should be understood that as described above, the AP800and the terminal device700may establish a near field connection by using Bluetooth, Wi-Fi direct, a USB, an Ethernet interface, and the like.

For example, when both the AP800and the terminal device700have a Bluetooth communication element, the AP800and the terminal device700may establish a near field connection by using Bluetooth. Alternatively, when both the AP800and the terminal device700have a Wi-Fi direct communication element, the AP800and the terminal device700may establish a near field connection by using Wi-Fi direct. Alternatively, when both the AP800and the terminal device700have a USB port, the AP800and the terminal device700may establish a near field connection by using the USB port with assistance of a data line, and sometimes may establish a near field connection by using the USB port with assistance of a data line and an adapter. Alternatively, when both the AP800and the terminal device700have an Ethernet interface, the AP800and the terminal device700may establish a near field connection by using the Ethernet interface with assistance of a network cable.

Optional step S802: The AP800and the terminal device700negotiate a routing rule.

A transmission path of activation data and a transmission path of setting data may be preset by using the routing rule.

The routing rule may indicate a transmission path of data. Alternatively, it may be understood as that the routing rule indicates the transmission path of the activation data and the transmission path of the setting data. The activation data may include data related to an activation operation on a physical blank SIM or an eSIM. The setting data may include data related to a setting operation on the AP800. The transmission path of the activation data is different from the transmission path of the setting data.

Specifically, the routing rule may be used to direct the terminal device700and the AP800to process received data, for example, forward the data or perform corresponding processing on the data. For the AP800, the routing rule may indicate a transmission path of data that is to reach the AP800. For the terminal device700, the routing rule may indicate a transmission path of data that is to reach the terminal device700. That is, the routing rule is a rule that should be followed during data transmission between the AP800and the terminal device700. The routing rule may be prestored in routing management services in the AP800and the terminal device700, so that the AP800and the terminal device700can properly process data related to the activation operation and data related to the setting operation.

There may be a plurality of routing rules, for example, a destination address-based routing rule, a routing rule based on a manner of establishing a near field connection, or a routing rule based on a network transmission port. It should be understood that the network transmission port is a logical port, for example, may be a port supporting the transmission control protocol (transmission control protocol, TCP). This is not limited in this application.

The AP800and the terminal device700may select a corresponding routing rule based on a manner of establishing a near field connection.

Several routing rules are provided as examples below.

In the routing rule, a destination address of the activation data is different from a destination address of the setting data.

For example, for data received from the AP800or an operator server and data generated by the terminal device700, the terminal device700may determine whether the data is setting data by determining whether a destination address of the data is the terminal device700. If the destination address is the terminal device700, the data is setting data. If the destination address is the operator server or the AP800, the data is activation data. For the activation data, the terminal device700needs to forward the data to the operator server or the AP800based on the destination address. For the setting data, the terminal device700may send the data to the AP800, or perform corresponding processing.

Routing rule based on a manner of establishing a near field connection.

In the routing rule, a near field connection manner used for transmitting the activation data is different from a near field connection manner used for transmitting the setting data.

There may be a plurality of near field connection manners between the AP800and the terminal device700, and the AP800and the terminal device700may simultaneously establish a near field connection in a plurality of manners. Therefore, there may be a plurality of routing rules based on the manner of establishing a near field connection. After the AP800and the terminal device700establish the near field connection, the AP800and the terminal device700may determine a specific routing rule based on the manner of establishing a near field connection. This implementation may be applied to a case in which the AP800and the terminal device700establish at least two near field connections. For example, when the AP800and the terminal device700simultaneously establish two near field connections: a Wi-Fi direct connection and a USB near field connection, the AP800and the terminal device700may negotiate to transmit the setting data by using the Wi-Fi direct near field connection, and transmit other data including the activation data by using the USB near field connection.

Routing rule based on a network transmission port.

In the routing rule, a port through which the activation data is transmitted is different from a port through which the setting data is transmitted.

This implementation may be applied to a case in which each of the AP800and the terminal device700has at least two same transmission ports. The AP800and the terminal device700need to agree on a transmission port in advance. For example, the AP800has two transmission ports: a port1and a port2, and the terminal device700also has two ports, namely, a port1and a port2, corresponding to the AP800. In this case, the AP800and the terminal device700may negotiate to determine that the routing rule is to transmit the setting data through the port1and transmit data including the activation data through the port2, or the routing rule may be to transmit the activation data through the port1and transmit other data including the setting data through the port2. It should be understood that the port described herein may be a logical port, or may be a physical port, provided that the AP800and the terminal device700negotiate a specific port through which a specific type of data is to be transmitted. This is not limited in this application.

Correspondingly, after the AP800and the terminal device700determine the routing rule through negotiation, the AP800also needs to process data according to the routing rule.

For example, the AP800may set a destination address of activation data generated by the AP800to the server, and set a destination address of setting data generated by the AP800to the terminal device700.

Routing rule based on a manner of establishing a near field connection.

For example, the AP800may send, by using a USB port, data including activation data generated by the AP800, and send, by using Wi-Fi direct, setting data generated by the AP800.

Routing rule based on a network transmission port.

The AP800needs to send, according to a specific routing rule determined by the AP800and the terminal device700and by using the determined routing rule, data generated by the AP800. For example, according to the routing rule, the AP800may send, through the port1, data including activation data generated by the AP800, and send, through the port2, setting data generated by the AP800; or according to the routing rule, may send, through the port2, data including activation data generated by the AP800, and send, through the port1, setting data generated by the AP800. It should be understood that after the AP800and the terminal device700establish the near field connection, data transmission between the AP800and the terminal device700is performed by using the near field connection. It should be further understood that after the AP800and the terminal device700establish the near field connection, the AP800and the terminal device700may know internet protocol (IP) addresses of each other. For example, the AP800may serve as a dynamic host configuration protocol server to allocate an IP address to the terminal device700, and the AP800provides management interface data of the AP800for the terminal device700by using a fixed IP address, so that the AP800and the terminal device700may know the IPs of each other. For example, when a terminal device700performs a setting operation on the AP800, the AP800may know the terminal device700that performs the setting operation on the AP800. A user may directly open a management application of the AP800, for example, a CPE management application, in the terminal device700, to directly display a management interface of CPE. Alternatively, the fixed IP address of the AP800may be presented on the AP800in a form of a two-dimensional code or text, and a user may log in to a management interface of the AP800by scanning the two-dimensional code of the IP address of the AP800by using the terminal device700, or may log in to a management interface of the AP800by entering the IP address of the AP800in a browser in the terminal device700. Display data of the management interface of the AP800may be considered as data related to the setting operation. The AP800sends the data to the terminal device700by using the near field connection, and the terminal device700displays the management interface of the AP800by using the browser or the management application of the AP800.

The terminal device700and the AP800may transmit data based on the near field connection, and determine, according to the routing rule, transmission paths and processing manners of data generated by the terminal device700and the AP800and data received from the peer device.

Based on optional step S802, the terminal device700and the AP800may negotiate the routing rule, so that subsequently the transmission paths and the processing manners of the data generated by the terminal device700and the AP800and the data received from the peer device are determined according to the routing rule, to support the AP800in borrowing a network connection capability of the terminal device700to activate an eSIM or a blank SIM.

Step S803: The AP800receives an activation instruction from the terminal device700based on the near field connection to the terminal device700.

In some embodiments, based on the near field connection, the terminal device700may request to access the management interface of the AP800by using the fixed IP address of the AP800, and the AP800may send the management interface data of the AP800to the terminal device700.

The management interface data of the AP800is used to generate the management interface. The management interface data is sent to the terminal device700, so that the terminal device700displays the management interface of the AP800. The management interface of the AP800is used by the user to enter an activation code and/or setting information. The activation code corresponds to a profile, and the setting information is used to configure a parameter of the AP800.

As described above, after purchasing the CPE, the user may purchase a package from an online store of an operator by using the terminal device700, and may obtain an activation code, or the user may purchase a package from a physical operator store, and obtain an activation code.

After accessing the management interface of the AP800by using the terminal device700, the user may perform an operation in the management interface of the AP800, for example, an activation operation on a physical blank SIM or eSIM. As described above, the activation operation may be, for example, entering the activation code in the management interface of the AP800displayed by the terminal device700. The setting operation may be, for example, setting, in the management interface of the AP800displayed by the terminal device700, a user name and a password of the AP800, and a maximum quantity of terminal devices700for which simultaneous access can be implemented.

The user may enter the activation code in the management interface of the AP800displayed by the terminal device700. The terminal device700generates the activation instruction in response to the operation performed by the user, and sends the activation instruction to the AP800by using the near field connection. Correspondingly, the AP800receives the activation instruction from the terminal device700by using the near field connection.

The activation instruction is used to download the profile. The activation instruction may include a download instruction for the profile. The download instruction for the profile may carry the activation code, and may further include an activation instruction for the profile. The activation instruction for the profile may carry an integrated circuit card identity (ICCID) of the profile. The ICCID is a unique identifier of the profile. After the profile is configured in the SIM or the eSIM, it may be considered that the ICCID is a unique identifier of the SIM or the eSIM.

As described above, the activation instruction may specifically include the download instruction for the profile and the activation instruction for the profile. The download instruction for the profile may carry the activation code, and the activation instruction for the profile may carry the ICCID. The activation instruction may indicate the AP800to activate the blank SIM or the eSIM. The activation instruction may be understood as a carrier used to carry an activation code of the blank SIM or the eSIM. This is not limited in this application.

As described above, the activation instruction, an activation request, and the profile are activation data, and the management interface data and the setting information are setting data.

Optionally, a transmission path of the activation data is different from a transmission path of the setting data.

Step S804: The AP800sends an activation request to the operator server through the terminal device700based on the near field connection in response to the activation instruction.

The activation request is used to request to download the profile from the operator server. The AP800generates the activation request in response to the activation instruction sent by the terminal device700. The activation request may be understood as a download request for the profile, or the activation request is a series of HTTP request data used to download the profile stored in the operator server. A destination address of the activation request is the operator server. The AP800currently has no network connection capability. Therefore, the AP800may first transmit the activation request to the terminal device700by using the near field secure transmission connection according to the routing rule pre-determined with the terminal device700. The terminal device700may help the AP800forward the activation request to the operator server according to the routing rule. For example, the terminal device700may forward the activation request to the operator server by using a network of the terminal device700.

Step S805: The AP800receives a profile from the operator server from the terminal device700based on the near field connection.

After check performed by the operator server on the activation request sent by the AP800to the operator server through the terminal device700, the operator server may send the profile to the terminal device700, and the terminal device700forwards the profile to the AP800.

In a possible implementation, the AP800receives a fourth data packet from the operator server from the terminal device700based on the near field connection.

The fourth data packet may be specifically a data packet that is generated by the operator server and that is used to feed back the activation request, and the fourth data packet carries the profile. For example, after receiving the activation request sent by the AP800, the operator server may respond to the activation request, and generate the corresponding data packet for feeding back the activation request. For example, the operator server checks request data sent by the AP800. If the check succeeds, the operator server sends the profile to the AP800. In this case, the fourth data packet includes the profile. If the check fails, the operator server feeds back data indicating that activation fails to the AP800. In this case, the fourth data packet does not include the profile. For ease of differentiation and description, the data packet generated by the operator server for the activation request is recorded as the fourth data packet herein.

Step S806: The AP800activates the profile, and configures the profile in a subscriber identity module.

It should be understood that the subscriber identity module may be a physical blank SIM or an eSIM.

The AP800may activate the downloaded profile based on the activation instruction for the profile included in the activation instruction, and configure the activated profile in the subscriber identity module, to activate the blank SIM or the eSIM. This may also be understood as activation of the AP800.

Based on steps S801and S803to S806, the terminal device700and the AP800may exchange data by using the near field transmission connection, so that the terminal device700and the AP800may serve as two peer network-connected parties, and serve as a server and a client for each other to provide respective services for each other. In this way, the user can perform an activation operation on the blank SIM or eSIM by using one terminal device700with a network connection capability.

In some embodiments, the user may further set a configuration parameter of the AP800by using the terminal device700. The method shown inFIG.22may further include the following optional steps.

Optional step S807: The terminal device700sends the setting information to the AP800based on the near field transmission connection.

After accessing the management interface of the AP800by using the terminal device700, the user may perform an operation in the management interface of the AP800, for example, a setting operation on the CPE. As described above, the setting operation may be, for example, setting, in the management interface of the AP800displayed by the terminal device700, a user name and a password of the AP800, and a maximum quantity of terminal devices700for which simultaneous access can be implemented.

The setting information may be used to set or control the AP800. For example, the setting information may include related information about setting the user name and the password of the AP800. The setting information may further include related information about controlling the quantity of terminal devices700that can be simultaneously allowed to access the AP800. This application includes but is not limited to this.

Optional step S808: The AP800sets the configuration parameter of the AP800based on the setting information.

For example, if the user wants to change a user name and a login password of the AP800, the user may change, in the management interface of the AP800displayed by the terminal device700, an initial user name and password of the AP800to a user name and a password defined by the user. The AP800may change the user name and the password of the AP800based on the setting information sent by the terminal device700. After the change succeeds, the AP800may provide a service for the terminal device700based on the changed user name and password. The service may include a network service, or may include a display service of the management page of the AP800displayed by the terminal device700.

Based on optional steps S807and S808, the user may further set the configuration parameter of the AP800by using the terminal device700. In this way, an actual requirement of the user can be met, and better user experience can be provided.

It should be understood that steps S801and S803to S806may be understood as steps of activating the AP800, and steps S807and S808may be understood as steps of setting the CPE. In a process of performing steps S801and S803to S806, steps S807and S808may also be performed, that is, in a process of performing an activation operation on the AP800, a setting operation may be further performed on the AP800.

It should be noted that the terminal device700in the network connection method provided in this embodiment of this application needs to be a terminal device700with a network connection capability, that is, the terminal device700may access the operator server in a plurality of manners such as a cellular mobile network, a WLAN, Ethernet, a USB, and Bluetooth, so that the terminal device700can help the CPE send the activation request to the operator server, and help the CPE receive the fourth data packet from the operator server. For example, the terminal device700may help the CPE forward the activation request to the operator server by using a cellular mobile network of the terminal device700, and may further help the CPE receive the fourth data packet from the operator server by using the cellular mobile network of the terminal device700. A network connection manner of the terminal device700is not limited in this application.

The AP800may be an AP800for which an eSIM is configured or into which a physical blank SIM is inserted. The terminal device700is a terminal device700with a network connection capability. The AP800may establish a near field connection to the terminal device700, so that the terminal device700and the AP800may serve as two peer network-connected parties, and serve as a server and a client for each other to provide respective services for each other. The AP800may receive the activation instruction from the terminal device700, further send the activation request to the operator server through the terminal device700, receive the profile from the operator server through the terminal device700, activate the profile, and configure the profile in the subscriber identity module in the AP800, so that the AP800can be activated by using one terminal device700with a network connection capability. In addition, the AP800and the terminal device700establish a near field connection, and the AP800and the terminal device700may further determine the routing rule under a condition that the near field connection is established, to implement data exchange between the AP800and the terminal device700, so that the terminal device700and the AP800may serve as two peer network-connected parties, and serve as a server and a client for each other to provide respective services for each other. Therefore, when the user performs the setting operation on the AP800by using the terminal device700, no other device needs to be used to connect to a network to activate the blank SIM or the eSIM. When the user activates the blank SIM or the eSIM by using the network provided by the terminal device700, no other device needs to be used to perform the setting operation on the AP800. The user may activate the blank SIM or the eSIM and perform the setting operation on the AP800by using a same terminal device700, that is, the AP800can be activated by using one terminal device700. An operation is convenient, it is easier to meet an activation condition, and user experience is better.

To better understand the method provided in embodiments of this application, the following provides descriptions with reference to a specific scenario.FIG.23is a schematic diagram of a scenario of a network connection method according to an embodiment of this application. As shown inFIG.23, in this application scenario, CPE is used as an example of an AP800, and there is a near field transmission connection between a terminal device700and the CPE.

In step601, the CPE may send management interface data of the CPE to the terminal device700by using a near field transmission module, so that the terminal device700displays a management interface of the CPE, and a user may enter an activation code in the management interface that is of the CPE and that is displayed by the terminal device700, or a user may scan a two-dimensional code carrying an activation code by using a scanning function in the management interface of the CPE, to identify the activation code.

It should be understood that the terminal device700displays the management interface of the CPE not only when the CPE sends the management interface data to the terminal device700, but also when the terminal device700scans a two-dimensional code carrying the management interface of the CPE, or the terminal device700may respond to an operation of entering, by the user, a website address of the management interface of the CPE in a browser in the terminal device700, or the like. It should be further understood that in some possible implementations, step60imay not be performed. This is not limited in this application.

In step602, in response to the operation performed by the user, the terminal device700may generate an activation instruction, and send the activation instruction to the CPE.

It should be understood that step601and step602merely provide a method for receiving, by the CPE, the activation instruction from the terminal device700, but should not constitute a limitation on this application.

In step603, the CPE may generate an activation request based on the activation instruction, and may transmit the activation request to the terminal device700by using the near field transmission module.

In step604, the terminal device700may forward the activation request of the CPE to an operator server.

In step605, the operator server may check data carried in the activation request sent by the CPE. If the check succeeds, the operator server may send a profile to the terminal device700.

In step606, the terminal device700may forward the profile to the CPE, to activate a blank SIM or an eSIM.

It should be noted that in a process in which the CPE sends the activation request to the operator server through the terminal device700and obtains the profile from the operator server through the terminal device700, the terminal device700may further perform a setting operation on the CPE. That is, in a process of performing an activation operation, a setting operation may be further performed. For example, in a process of performing step602to step606, step607may be further performed.

In step607, the user may perform a setting operation on the CPE in the management interface that is of the CPE and that is displayed by the terminal device700. In response to the operation performed by the user, the terminal device700generates setting information, and transmits the setting information to the CPE by using a near field transmission module, to set the CPE.

It should be understood thatFIG.23is merely an example, and step610to step607are merely possible implementation steps, and should not constitute any limitation on this application.

The following uses the CPE as an example of the AP800again to describe, with reference toFIG.24AandFIG.24B, the network connection method provided in embodiments of this application. It should be understood that the CPE inFIG.24AandFIG.24Bis CPE that supports an eSIM.

As shown inFIG.24AandFIG.24B, a near field transmission module in the CPE may first establish a connection to a near field transmission module in a terminal device700, so that data to be exchanged between the CPE and the terminal device700may be subsequently transmitted based on the near field connection. After the near field connection is established between the CPE and the terminal device700, a routing management service in the CPE and a routing management service in the terminal device700may negotiate and determine a routing rule, and subsequently data to be exchanged between the CPE and the terminal device700may be transmitted according to the determined routing rule. A user may access a management interface of the CPE by using a browser in the terminal device700and a fixed IP address of the CPE. The routing management service in the terminal device700sends a request for accessing the fixed IP address of the CPE to the routing management service in the CPE. The routing management service in the CPE accesses a CPE management service in the CPE. The CPE management service sends management interface data of the CPE to the routing management service in the CPE, then the routing management service in the CPE sends the management interface data to the routing management service in the terminal device700, and then the routing management service in the terminal device700sends the management interface data to the browser in the terminal device700, so that the browser in the terminal device700can display the management interface of the CPE. In response to an activation operation and/or a setting operation performed by the user in the management interface that is of the CPE and that is displayed by the terminal device700, the browser in the terminal device700sends a generated activation instruction and/or setting information to the routing management service in the CPE through the routing management service and the near field transmission module in the terminal device700and the near field transmission module in the CPE. The CPE management service in the CPE sends the activation instruction to an eSIM management service in the CPE. The eSIM management service in the CPE generates, based on the activation instruction sent by the terminal device700, an activation request to be sent to an operator server, and sends the activation request to the operator server through the terminal device700by using a cellular mobile network of the terminal device700. The operator server sends, through the terminal device700, data for feeding back the activation request to the eSIM management service in the CPE. In a process in which the CPE performs data interaction with the operator server through the terminal device700based on the activation instruction, the CPE management service in the CPE may set a configuration parameter of the CPE management service based on the setting information sent by the terminal device700.

It should be understood that as described above, the terminal device700in the network connection method provided in embodiments of this application needs to be a terminal device700with a network connection capability, that is, the terminal device700may access the operator server in a plurality of manners such as a cellular mobile network, a WLAN, Ethernet, a USB, and Bluetooth. In the foregoing descriptions, that “the activation request is sent to the operator server through the terminal device700by using a cellular mobile network of the terminal device700” is merely an example. If the terminal device700accesses the Ethernet by using a network cable, the activation request may be sent to the operator server through Ethernet to which the terminal device700connects. This is not limited in this application, provided that the terminal device700is a terminal device700with a network connection capability, and can access the operator server.

It should be further understood that the steps in the foregoing methods may be completed by using an integrated logic circuit of hardware in the processor, or by using instructions in a form of software. The steps in the methods disclosed with reference to embodiments of this application may be directly performed and completed by a hardware processor, or may be performed and completed by using a combination of hardware in the processor and a software module. The software module may be located in a mature storage medium in the art, for example, a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, or a register. The storage medium is located in the memory, and the processor reads information in the memory, and completes the steps in the foregoing methods in combination with the hardware in the processor. To avoid repetition, details are not described herein.

Optionally, the AP800is further configured to send management interface data of the AP800to the terminal device700. The terminal device700is further configured to display a management interface based on the received management interface data. The management interface is used to enter an activation code and/or setting information. The activation code corresponds to a profile, and the setting information is used to configure a parameter of the AP800.

Optionally, the activation instruction, the activation request, and the profile are activation data, the management interface data and the setting information are setting data, and a transmission path of the activation data is different from a transmission path of the setting data.

In the network connection method shown inFIG.22,FIG.23,FIG.24A, andFIG.24B, in a process in which the AP800borrows the network connection capability of the terminal device700to activate the eSIM or the blank SIM, each device differently processes a data packet.

FIG.25shows an example of a manner of processing a data packet by each device in a process in which an AP800borrows a network connection capability of a terminal device700to activate an eSIM or a blank SIM.

As shown inFIG.25, the process in which the AP800borrows the network connection capability of the terminal device700to activate the eSIM or the blank SIM is divided into two phases.

In one phase, the AP800sends the management interface data to the terminal device700, the terminal device700serves as a client, and the AP800serves as a server. In this phase, a data packet may be transmitted between the terminal device700and the AP800by using a four-layer model, or a data packet may be transmitted by using only an application layer and a transport layer. Data transmission at a network layer and a physical layer that are at a bottom layer is replaced with a near field transmission connection between the terminal device700and the AP800.

In the other phase, the AP800obtains the profile from the server900through the terminal device700, the terminal device700serves as a server, and the AP800serves as a client. In this phase, because the AP800does not have a network connection capability, the AP800performs processing only at the application layer and the transport layer on the data packet, and does not perform processing at the network layer and the physical layer, and the terminal device700performs processing at the network layer and the physical layer on the data packet. The terminal device700may perform processing at the network layer and the physical layer on a data packet from the internet or the AP800, and then send the data packet to the AP800or the internet. The server900may perform processing at the foregoing four layers on the data packet.

In the embodiments shown inFIG.18toFIG.25in this application, the AP800may also be referred to as a first device, and the terminal device700may also be referred to as a second device. The near field transmission connection between the AP800and the terminal device700may also be referred to as a first communication connection.

It should be understood that the steps in the foregoing method embodiments may be completed by using an integrated logic circuit of hardware in the processor, or by using instructions in a form of software. The steps in the methods disclosed with reference to embodiments of this application may be directly performed and completed by a hardware processor, or may be performed and completed by using a combination of hardware in the processor and a software module.

This application further provides an electronic device. The electronic device may include a memory and a processor. The memory may be configured to store a computer program. The processor may be configured to invoke the computer program in the memory, so that the electronic device performs the method performed by any one of the terminal device100, the terminal device200, the network device300, the terminal device400, the terminal device500, the AP600, the terminal device700, the AP800, or the server900in any one of the foregoing embodiments.

This application further provides a chip system. The chip system includes at least one processor, configured to implement a function in the method performed by any one of the terminal device100, the terminal device200, the network device300, the terminal device400, the terminal device500, the AP600, the terminal device700, the AP800, or the server900in any one of the foregoing embodiments, for example, receive or process data and/or information in the foregoing method.

In a possible design, the chip system further includes a memory. The memory is configured to store program instructions and data, and the memory is located inside the processor or outside the processor.

The chip system may include a chip, or may include a chip and another discrete component.

Optionally, there may be one or more processors in the chip system. The processor may be implemented by using hardware, or may be implemented by using software. When the processor is implemented by using hardware, the processor may be a logic circuit, an integrated circuit, or the like. When the processor is implemented by using software, the processor may be a general-purpose processor, and is implemented by reading software code stored in the memory.

Optionally, there may also be one or more memories in the chip system. The memory may be integrated with the processor, or may be disposed separately from the processor. This is not limited in this embodiment of this application. For example, the memory may be a non-transitory processor, for example, a read-only memory ROM. The memory and the processor may be integrated into a same chip, or may be separately disposed on different chips. A type of the memory and a manner of disposing the memory and the processor are not specifically limited in this embodiment of this application.

For example, the chip system may be a field programmable gate array (FPGA), an application-specific integrated circuit (ASIC), a system-on-a-chip (SoC), a central processing unit (CPU), a network processor (NP), a digital signal processing circuit, a microcontroller unit (MCU), a programmable controller (PLD), or another integrated chip.

This application further provides a computer program product. The computer program product includes a computer program (which may also be referred to as code or an instruction). When the computer program is run, a computer is enabled to perform the method performed by any one of the terminal device100, the terminal device200, the network device300, the terminal device400, the terminal device500, the AP600, the terminal device700, the AP800, or the server900in any one of the foregoing embodiments.

This application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program (which may also be referred to as code or an instruction). When the computer program is run, a computer is enabled to perform the method performed by any one of the terminal device100, the terminal device200, the network device300, the terminal device400, the terminal device500, the AP600, the terminal device700, the AP800, or the server900in any one of the foregoing embodiments.

In addition, an embodiment of this application further provides an apparatus. The apparatus may be specifically a component or a module, and the apparatus may include one or more processors and memories that connect to each other. The memory is configured to store a computer program. When the computer program is executed by one or more processors, the apparatus is enabled to perform the network connection method in the foregoing method embodiments.

The apparatus, the computer-readable storage medium, the computer program product, or the chip provided in embodiments of this application is configured to perform the corresponding method provided above. Therefore, for beneficial effects that can be achieved by the apparatus, the computer-readable storage medium, the computer program product, or the chip, refer to the beneficial effects in the corresponding method provided above. Details are not described herein.

The implementations of this application may be randomly combined, to achieve different technical effects.

In conclusion, the foregoing descriptions are merely embodiments of the technical solutions of this application, and are not intended to limit the protection scope of this application. Any modification, equivalent replacement, improvement, and the like made based on the disclosure of this application shall fall within the protection scope of this application.