Network sharing method and system, electronic equipment and readable storage medium

By establishing a P2P link between electronic devices and using the network of the second electronic device for data forwarding, the problem of low network sharing efficiency in the prior art is solved, and convenient network sharing and multi-service coexistence is achieved.

CN119155767APending Publication Date: 2024-12-17HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310724620.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-16
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

In the prior art, electronic devices need to manually enter the connection password when connecting to the network hotspot of another device, resulting in low network sharing efficiency.

Method used

By establishing a P2P link between the first electronic device and the second electronic device, and using the network of the second electronic device to forward data, the step of manually inputting the connection password is avoided, and operation convenience and network sharing efficiency are improved.

Benefits of technology

It realizes network sharing without manually entering the connection password, improves operational convenience and efficiency, and supports multi-service coexistence without affecting hyper-terminal services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119155767A_ABST
    Figure CN119155767A_ABST
Patent Text Reader

Abstract

The invention discloses a network sharing method and system, electronic equipment and a readable storage medium, and belongs to the technical field of terminals. The method comprises the steps that under the condition that a first electronic device and a second electronic device log in the same device account, in response to the fact that the distance between the first electronic device and the second electronic device is smaller than a preset distance, a first window is displayed, and the first window comprises device information of the second electronic device, the second electronic equipment can access the network at present and start the network sharing function. And establishing a first P2P link with the second electronic device in response to receiving a connection operation for the second electronic device in the first window. And after the first electronic equipment establishes the first P2P link with the second electronic equipment, in response to the network service, sending the network data packet to be transmitted to the second electronic equipment for forwarding through the first P2P link. Therefore, the user does not need to manually input the connection password, and the network sharing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a network sharing method, system, electronic device and readable storage medium. Background Art

[0002] In the related art, if an electronic device A needs to connect to the network hotspot of another electronic device B, it needs to obtain the connection password of the network hotspot of electronic device B, for example, the user enters the connection password in the hotspot sharing window provided by electronic device A, and then electronic device A connects to the network hotspot of electronic device B.

[0003] After electronic device A connects to the network hotspot of electronic device B, it uses electronic device B as a router to forward data during network services, thereby enabling Internet access. Summary of the invention

[0004] The present application provides a network sharing method, system, electronic device and readable storage medium, which can solve the problem of low network sharing efficiency in related technologies. The technical solution is as follows:

[0005] In a first aspect, a network sharing method is provided, which is applied to a first electronic device, where the first electronic device and a second electronic device log in to the same device account, and the method includes:

[0006] In response to the distance between the first electronic device and the second electronic device being less than a preset distance, the first electronic device displays a first window, the first window including device information of the second electronic device, wherein the second electronic device is currently able to access a network and has a network sharing function enabled;

[0007] In response to receiving a connection operation for the second electronic device in the first window, the first electronic device establishes a first P2P link with the second electronic device;

[0008] After the first electronic device establishes the first P2P link with the second electronic device, in response to network services, the first electronic device sends a network data packet to be transmitted to the second electronic device through the first P2P link, so that the network data packet is forwarded by the second electronic device.

[0009] In this way, by establishing a first P2P link with the second electronic device, the network data packet is sent to the second electronic device through the first P2P link during the transmission of the network data packet, and the network of the second electronic device is used for data forwarding. This avoids the need for the user to manually enter a connection password, improves the convenience of operation, and thus improves the efficiency of network sharing.

[0010] As an example of the present application, the method further includes:

[0011] After the first electronic device establishes the first P2P link with the second electronic device, the first electronic device displays a second window, wherein the second window includes a sharing success and a disconnection control;

[0012] In response to the operation on the disconnection control, the first electronic device disconnects the first P2P link between the first electronic device and the second electronic device.

[0013] In this way, by displaying the second window, the user can manually disconnect the network sharing when the first electronic device does not need to share the network of the second electronic device, thereby improving the user experience.

[0014] As an example of the present application, in response to the distance between the first electronic device and the second electronic device being less than a preset distance, the first electronic device displays a first window, including:

[0015] In response to the distance between the first electronic device and the second electronic device being less than the preset distance, the first electronic device sends a capability query request to the second electronic device, wherein the capability query request is used to query whether the second electronic device currently has a network sharing capability;

[0016] The first electronic device receives capability information fed back by the second electronic device, where the capability information is used to indicate whether the second electronic device currently has a network sharing capability;

[0017] When the capability information indicates that the second electronic device currently has the network sharing capability, the first electronic device displays the first window and displays device information of the second electronic device in the first window.

[0018] In this way, the first electronic device actively sends a capability query request to the second electronic device, so as to automatically display the first window when it is determined that the second electronic device has the network sharing capability. That is, when it actively discovers that the second electronic device is capable of network sharing, the first window is displayed, so that the user can trigger the first electronic device to share the network of the second electronic device based on the first window, avoiding the need to scan or enter a password, etc., thereby improving the efficiency of sharing the network.

[0019] As an example of the present application, in response to receiving a connection operation for the second electronic device in the first window, the first electronic device establishing a first P2P link with the second electronic device includes:

[0020] In response to receiving a connection operation for the second electronic device in the first window, the first electronic device sends a channel establishment request to the second electronic device, where the channel establishment request is used to request to establish a P2P channel with the second electronic device;

[0021] The first electronic device establishes the P2P channel with the second electronic device;

[0022] After receiving the notification of successful channel establishment sent by the second electronic device, the first electronic device performs routing configuration on the P2P channel to establish the first P2P link.

[0023] In this way, after the first window receives the connection operation, the first electronic device establishes a P2P link with the second electronic device to achieve network sharing through the first P2P link, avoiding the need for password input and other operations, thereby improving the convenience of operation.

[0024] As an example of the present application, the first electronic device includes a first system service module, a first network sharing service module, a first link module, and a first distributed gateway;

[0025] In response to receiving a connection operation for the second electronic device in the first window, the first electronic device sending a channel establishment request to the second electronic device includes:

[0026] The first system service module calls the first network sharing service module in response to receiving a connection operation for the second electronic device in the first window;

[0027] The first system service module sends a network sharing instruction to the first network sharing service module, wherein the network sharing instruction carries device information of the second electronic device;

[0028] In response to the network sharing instruction, the first network sharing service module sends a channel opening request to the first link module, wherein the channel opening request carries device information of the second electronic device;

[0029] In response to the channel opening request, the first linking module sends the channel establishing request to the second electronic device;

[0030] After receiving the notification of successful channel establishment sent by the second electronic device, the first electronic device performs routing configuration on the P2P channel to establish the first P2P link, including:

[0031] After receiving the notification of successful establishment of the channel, the first link module sends first channel configuration information to the first network sharing service module, where the first channel configuration information includes information required to configure the P2P channel;

[0032] The first network sharing service module sends a first configuration indication to the first distributed gateway, where the first configuration indication carries the first channel configuration information;

[0033] The first distributed gateway performs routing configuration on the P2P channel based on the first channel configuration information to establish the first P2P link.

[0034] In this way, a first network sharing service module is added to the first electronic device, and a first P2P link is established between the first electronic device and the second electronic device through the first network sharing service module, thereby realizing network sharing.

[0035] As an example of the present application, the first electronic device includes a first system service module, a first device management service module and a first link module; the method further includes:

[0036] In response to the distance between the first electronic device and the second electronic device being less than the preset distance, the first link module senses the second electronic device through a self-discovery function and acquires device information of the second electronic device from the second electronic device;

[0037] The first link module sends a first device online notification to the first device management service module, wherein the first device online notification carries device information of the second electronic device;

[0038] The first device management service module sends a first device online notification to the first system service module;

[0039] In response to the distance between the first electronic device and the second electronic device being less than the preset distance, the first electronic device sending a capability query request to the second electronic device includes:

[0040] After receiving the online notification of the first device, the first system service module sends the capability query request to the second electronic device through the first link module.

[0041] In this way, when the first electronic device is close to the second electronic device, the first electronic device senses the second electronic device through the first link module and notifies the first system service module. The first system service module sends a capability query request to the second electronic device through the first link module, thereby inquiring whether the second electronic device currently has the network sharing capability, so that the first window is actively popped up when it is determined that the second electronic device has the network sharing capability.

[0042] As an example of the present application, after the first electronic device establishes the first P2P link with the second electronic device, in response to a network service, the first electronic device sends a network data packet to be transmitted to the second electronic device through the first P2P link, further comprising:

[0043] The first electronic device receives a first operation;

[0044] In response to the first operation, the first electronic device sends a first traffic query instruction to the second electronic device through the first P2P link, where the first traffic query instruction is used to request to query the network traffic consumed by the first electronic device by the second electronic device;

[0045] The first electronic device receives first network traffic sent by the second electronic device, where the first network traffic is network traffic determined by the second electronic device in response to the first traffic query instruction;

[0046] The first electronic device displays the first network traffic in a notification bar.

[0047] In this way, in the process of the first electronic device sharing the second electronic device, network traffic statistics are performed through the second electronic device, and when the first operation is received, the currently consumed network traffic is queried and displayed, so that the user can know the consumption of network traffic and improve the user experience.

[0048] As an example of the present application, the method further includes:

[0049] After the screen of the first electronic device is turned off, if the incremental network traffic consumed by the first electronic device from the second electronic device is less than a first network traffic threshold within a preset time period, the first electronic device disconnects the first P2P link with the second electronic device.

[0050] In this way, when the first electronic device no longer needs to use the network of the second electronic device, the first electronic device automatically turns off network sharing, thereby reducing the operating power consumption of the first electronic device, improving battery life, and saving the consumption of network traffic of the second electronic device.

[0051] As an example of the present application, the method further includes:

[0052] The first electronic device performs a collaborative service with the second electronic device through the first P2P link, and the collaborative service includes any one or more of the following:

[0053] Screen projection service, wherein the screen projection service refers to projecting the user interface of the first electronic device onto the screen of the second electronic device for display, and allowing the user to operate the user interface of the first electronic device in the second electronic device, and to perform specified operations in the second electronic device;

[0054] A keyboard and mouse collaboration service, wherein the keyboard and mouse collaboration service means that the first electronic device and the second electronic device can share each other's input device;

[0055] A call collaboration service, wherein when the first electronic device receives an incoming voice call or video call, an incoming call interface is synchronously displayed on the second electronic device;

[0056] The notification cooperation service refers to synchronously displaying the notification message in the second electronic device when the first electronic device receives the notification message.

[0057] In this way, the super terminal service and network sharing can share the first P2P link, that is, the super terminal service can be realized while the network is shared, thereby improving the coexistence capability of multiple services.

[0058] As an example of the present application, before the first electronic device establishes the first P2P link with the second electronic device, the first electronic device cannot access the network.

[0059] In this way, the first electronic device will only share the network when it cannot access the network, avoiding pop-up windows when the first electronic device does not need network sharing when the first electronic device and the second electronic device can communicate in near field, thereby avoiding causing trouble to the user.

[0060] As an example of the present application, the first electronic device, the second electronic device, and the third electronic device are logged in to the same device account, the distance between the first electronic device and the third electronic device is less than the preset distance, the third electronic device is currently able to access the network and the network sharing function is turned on, and the first window also includes the device information of the third electronic device.

[0061] In this way, when there are multiple electronic devices capable of network sharing, the first electronic device displays device information of each of the multiple electronic devices, so that the user can select any one for network sharing according to needs, thereby improving user experience.

[0062] As an example of the present application, the method further includes:

[0063] In response to receiving a connection operation for the third electronic device in the first window, the first electronic device establishes a second P2P link with the third electronic device;

[0064] After the first electronic device establishes the second P2P link with the third electronic device, in response to network services, the first electronic device sends the network data packet to the third electronic device through the second P2P link, so that the network data packet is forwarded by the third electronic device.

[0065] In this way, when the user selects the third electronic device, the first electronic device establishes a second P2P link with the third electronic device, so that the user can access the Internet through the third electronic device.

[0066] In a second aspect, a network sharing method is provided, which is applied to a second electronic device, where the second electronic device and the first electronic device log in to the same device account, and the method includes:

[0067] When the distance between the second electronic device and the first electronic device is less than a preset distance, if the first electronic device requests network sharing, the second electronic device establishes a first P2P link with the first electronic device, wherein the second electronic device is currently able to access the network and has a network sharing function enabled;

[0068] After the second electronic device establishes the first P2P link with the first electronic device, the second electronic device receives the network data packet to be transmitted sent by the first electronic device through the first P2P link;

[0069] The second electronic device forwards the network data packet.

[0070] In this way, when the first electronic device requests network sharing, a first P2P link is established with the first electronic device, so that during the process of transmitting the network data packet, the network data packet to be transmitted by the first electronic device is received through the first P2P link, and the data is forwarded. This avoids the need for the user to manually enter a connection password, improves the convenience of operation, and thus improves the efficiency of network sharing.

[0071] As an example of the present application, the method further includes:

[0072] The second electronic device displays a first interface, wherein the first interface includes a network sharing setting control;

[0073] In response to a touch operation on the network sharing setting control on the first interface, the second electronic device displays a second interface, wherein the second interface includes a network sharing switch control;

[0074] In response to the turning on operation of the network sharing switch control in the second interface, the second electronic device turns on the network sharing function.

[0075] In this way, by providing users with a network sharing switch control, users can turn on or off the network sharing service as needed, thereby improving the user experience.

[0076] As an example of the present application, the second electronic device includes a second network sharing service module, a second link module, and a second distributed gateway;

[0077] The method of establishing a first P2P link between the second electronic device and the first electronic device when the distance between the second electronic device and the first electronic device is less than a preset distance and the first electronic device requests network sharing comprises:

[0078] When the distance between the second electronic device and the first electronic device is less than the preset distance, the second link module receives a channel establishment request from the first electronic device;

[0079] In response to the channel establishment request, the second link module establishes a P2P channel with the first electronic device;

[0080] After the second link module successfully builds the P2P channel, the second link module sends second channel configuration information to the second network sharing service module, where the second channel configuration information includes information required to configure the P2P channel;

[0081] The second network sharing service module sends a second configuration indication to the second distributed gateway, where the second configuration indication carries the second channel configuration information;

[0082] The second distributed gateway performs routing configuration on the P2P channel based on the second channel configuration information to establish the first P2P link.

[0083] In this way, by adding the second network sharing service module, network sharing is achieved through the second network sharing service module during the network sharing process.

[0084] As an example of the present application, the second electronic device includes a second virtual network card module and a second network filtering module, and the second virtual network card module is created in the process of establishing the P2P channel;

[0085] The second electronic device receives, through the first P2P link, a network data packet to be transmitted sent by the first electronic device, including:

[0086] The second virtual network card module receives the network data packet;

[0087] The second virtual network card module sends the network data packet to the second network filtering module;

[0088] The second electronic device forwards the network data packet, including:

[0089] The second network filtering module analyzes the network data packet to obtain an analysis result;

[0090] After the second network filtering module determines, based on the analysis result, that the destination address of the network data packet is not the second electronic device, the second network filtering module forwards the network data packet.

[0091] In this way, the network data packet is parsed by the second network filtering module, and when it is determined that the network data packet is a data packet to be forwarded, it is forwarded, thereby achieving the purpose of the first electronic device surfing the Internet using the network of the second electronic device.

[0092] As an example of the present application, when the distance between the second electronic device and the first electronic device is less than a preset distance, if the first electronic device requests network sharing, after the second electronic device and the first electronic device establish a first P2P link, the method further includes:

[0093] The second electronic device sets a hook according to the P2P address information of the first electronic device;

[0094] The second electronic device collects statistics of the network traffic consumed by the first electronic device according to the P2P address information of the first electronic device in the forwarded network data packet through the hook;

[0095] When receiving the traffic query instruction sent by the first electronic device, the second electronic device queries the corresponding network traffic value according to the P2P address information of the first electronic device to obtain the first network traffic value;

[0096] The second electronic device sends the first network traffic value to the first electronic device.

[0097] In this way, by setting a hook, the network traffic consumed by the first electronic device can be counted in the process of forwarding the network data packet of the first electronic device. That is, with the second electronic device with network sharing capability as the core, the network traffic consumed by the first electronic device is counted according to the P2P address information of the connected first electronic device, and the first electronic device does not need to count separately, so that no matter how many first electronic devices are connected, they can adapt themselves and will not increase the workload of the connected first electronic devices.

[0098] As an example of the present application, the method further includes:

[0099] When the network traffic increment currently being queried is greater than a second network traffic threshold, the second electronic device displays the first network traffic value consumed by the first electronic device.

[0100] In this way, when the network traffic increment is large, displaying the network traffic consumed by the first electronic device in the second electronic device can facilitate timely prompting to the user of the second electronic device, thereby improving the user experience.

[0101] As an example of the present application, the second electronic device includes a second network sharing service module and a second network filtering module;

[0102] The second electronic device sets a hook according to the P2P address information of the first electronic device, including:

[0103] The second network sharing service module constructs the hook based on the P2P address information of the first electronic device;

[0104] The second network sharing service module sets the hook in the second network filtering module, so that the second network filtering module counts the network traffic consumed by the first electronic device according to the P2P address information of the first electronic device through the hook.

[0105] In this way, by setting the hook in the second network filtering module, when data is forwarded through the second network filtering module, the hook can be used to implement network traffic statistics.

[0106] In a third aspect, a network sharing system is provided, the network sharing system comprising a first electronic device and a second electronic device, the first electronic device and the second electronic device being logged into the same device account, comprising:

[0107] The first electronic device is configured to display a first window in response to a distance between the first electronic device and the second electronic device being less than a preset distance, wherein the first window includes device information of the second electronic device, wherein the second electronic device is currently able to access a network and has a network sharing function enabled;

[0108] The first electronic device is configured to establish a first P2P link with the second electronic device in response to receiving a connection operation for the second electronic device in the first window;

[0109] The second electronic device is configured to establish the first P2P link with the first electronic device after the first electronic device requests network sharing;

[0110] The first electronic device is configured to send a network data packet to be transmitted to the second electronic device via the first P2P link in response to a network service;

[0111] The second electronic device is used to forward the network data packet after receiving the network data packet through the first P2P link.

[0112] In a fourth aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the network sharing method described in the first aspect or the second aspect when executing the computer program.

[0113] In a fifth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is executed on a computer, the computer executes the network sharing method described in the first aspect or the second aspect.

[0114] In a sixth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the network sharing method described in the first aspect or the second aspect.

[0115] The technical effects obtained by the above-mentioned second, third, fourth, fifth and sixth aspects are similar to the technical effects obtained by the corresponding technical means in the above-mentioned first and / or second aspects, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0116] Figure 1 is a schematic diagram showing an application scenario according to an exemplary embodiment;

[0117] Figure 2 is a schematic diagram of an application scenario according to another exemplary embodiment;

[0118] Figure 3 is a schematic diagram of an application scenario according to another exemplary embodiment;

[0119] Figure 4 is a schematic diagram of an application scenario according to another exemplary embodiment;

[0120] Figure 5 is a schematic diagram of an application scenario according to another exemplary embodiment;

[0121] Figure 6 is a schematic diagram of an application scenario according to another exemplary embodiment;

[0122] Figure 7 is a schematic diagram of an application scenario according to another exemplary embodiment;

[0123] Figure 8 is a schematic diagram of the architecture of a software system of an electronic device according to an exemplary embodiment;

[0124] Fig. 9 is a schematic diagram showing a network sharing framework according to an exemplary embodiment;

[0125] Fig.10 is a flow chart showing a network sharing method according to an exemplary embodiment;

[0126] Fig.11 is a schematic diagram of an application scenario according to another exemplary embodiment;

[0127] Fig.12 is a schematic diagram of a data transmission process according to an exemplary embodiment;

[0128] Fig.13 is a schematic diagram showing a data flow according to an exemplary embodiment;

[0129] Fig.14 is a schematic diagram of an application scenario according to another exemplary embodiment;

[0130] Fig.15 is a schematic diagram of an application scenario according to another exemplary embodiment;

[0131] Fig.16 is a schematic diagram of an application scenario according to another exemplary embodiment;

[0132] Fig.17 is a flow chart of a method for traffic query according to an exemplary embodiment;

[0133] Fig.18 It is a flowchart of a method for closing network sharing after turning off the screen according to an exemplary embodiment;

[0134] Fig.19 is a schematic diagram of a process of closing network sharing according to an exemplary embodiment;

[0135] Fig. 20 is a flow chart of a network sharing method according to another exemplary embodiment;

[0136] Fig.21 is a flow chart of a network sharing method according to another exemplary embodiment;

[0137] Fig. 22 The diagram is a schematic structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0138] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0139] It should be understood that the "multiple" mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, the words "first" and "second" are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not limit them to be different.

[0140] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0141] With the rapid development of terminal technology, various electronic devices have been widely promoted, such as mobile phones, personal computers (PC), tablets (PAD), car computers, large screens, smart watches, netbooks, digital cameras, augmented reality (AR) and virtual reality (VR) devices, personal digital assistants (PDA), ultra-mobile personal computers (UMPC), sports cameras (GoPro), etc. In order to bring a better experience to users, electronic devices provide short-range communication capabilities, so that multiple electronic devices can communicate when they are close to each other when they are logged in to the same device account (such as Honor account). For example, electronic devices provide a smart interconnection function, which can discover nearby electronic devices logged in to the same account through an automatic discovery function. In some examples, these multiple electronic devices that can communicate in close proximity are said to be in the same ring, and the multiple electronic devices in the same ring can also be said to constitute a super terminal. For example, Figure 1 As shown, after a PC, PAD, mobile phone and large screen log in to the same device account, they can achieve close-range communication through the smart interconnection function when they are close to each other. At this time, these electronic devices are said to be in the same ring. For multiple electronic devices in the same ring, in an environment without wireless fidelity (WiFi) or weak network, if a user needs to use one of the multiple electronic devices (such as a PC, PAD, car computer or large screen, etc.) to access the Internet, he can usually access the Internet with the network of a mobile phone that can access the Internet in the ring, that is, the mobile phone can share its own network with other electronic devices in the ring.

[0142] In some embodiments, if the electronic device that the PAD is waiting to connect to wants to use the network hotspot of the mobile phone, it is usually necessary to obtain the connection password of the network hotspot of the mobile phone. In this way, the user needs to manually enter the connection password in the electronic device that the PAD is waiting to connect to, or obtain it by scanning a QR code or the like. This method makes the network sharing efficiency low. In order to improve the efficiency of network sharing, an embodiment of the present application provides a method of network sharing, so that the electronic device to be connected establishes a peer-to-peer (P2P) connection with the mobile phone, and uses the P2P link to send the network data packet to be transmitted to the mobile phone, thereby realizing data forwarding through the network of the mobile phone, thereby achieving the purpose of Internet access, and avoiding the need for the electronic device to be connected to obtain the connection password of the network hotspot.

[0143] For ease of understanding, before introducing the method provided in the embodiment of the present application, the application scenario of the network sharing method provided in the embodiment of the present application is first introduced.

[0144] In one example, the electronic device to be connected is a PAD. Figure 2 When the PAD and the mobile phone are in the same ring, when the user needs to share the cellular network of the mobile phone with the PAD, the mobile phone can display the smart interconnection interface S1 through the path of "Settings-Smart Interconnection", such as Figure 2 The Smart Connectivity Interface S1 provides a "Network Sharing" option. After the user triggers the "Network Sharing" option, please refer to Figure 2 In (b), in response to the user's triggering operation on the "network sharing" option, the mobile phone displays the network sharing interface S2, which includes the "network sharing" switch control 21. The user triggers the switch control 21 to the on state. In response to the user's on-triggering operation on the switch control 21, the mobile phone turns on the network sharing function. When the mobile phone turns on the network sharing function, the PAD side finds that there are mobile phones nearby that can access the Internet. At this time, please refer to Figure 2 In Figure (c), the PAD displays a network sharing window 22, which includes the device information of a mobile phone that can access the Internet, such as "Honor Magic5", and the network sharing window 22 also includes a "Connect Now" control and a "Cancel" control. In this way, the user can trigger the "Connect Now" control provided in the device network sharing window 22, and in response to the user's triggering operation, a P2P link is established between the PAD and the mobile phone. After the P2P link is established, the PAD can use the mobile phone's cellular network to access the Internet through the P2P link. As an example and not a limitation, after the PAD successfully establishes a P2P link with the mobile phone, a sharing success notification may be displayed, such as a sharing success notification such as Figure 2 As shown in 23 of (d) of the figure, it includes the prompt content "Using the mobile data network of "Honor Magic5" to surf the Internet", so that the user can know that the network sharing is successful. In addition, the sharing success notification can also include a "disconnect" control. During the network sharing process, when the user does not need the PAD to use the cellular network of the mobile phone to surf the Internet, the "disconnect" control can be triggered. In response to the triggering operation, the PAD disconnects the P2P link between the mobile phone and the mobile phone to stop the mobile phone's network sharing service for the PAD.

[0145] Of course, after the PAD displays the network sharing window 22, if the user does not need the PAD to use the cellular network of the mobile phone, the user can click the "Cancel" control in the network sharing window 22. Accordingly, in response to the user's click operation on the "Cancel" control, the PAD closes the network sharing window 22, and the PAD does not establish a P2P link with the mobile phone. In one example, the PAD also provides a resident network sharing entry. After the user clicks the "Cancel" control in the network sharing window 22, if the user wants the PAD to use the cellular network shared by the mobile phone, the PAD can be triggered to share the mobile phone's cellular network from the provided resident network sharing entry. For example, please refer to Figure 3 , users can use the "Settings-WLAN" path to enable the PAD to display the WLAN interface, such as Figure 3 As shown in Figure (a), the WLAN interface includes the "Mobile Shared Network" item, and the device information of the mobile phone is displayed below the "Mobile Shared Network" item, that is, "Honor Magic5". The user can trigger the displayed device information. In response to the user's triggering operation on the mobile phone's device information, the PAD establishes a P2P link with the mobile phone to share the mobile phone's cellular network. Please refer to Figure 3 In (b) of Figure 30, after the network sharing is successful, the PAD interface displays a prompt message "Connected".

[0146] It should be noted that the above is explained using the example of a mobile phone sharing a cellular network. In another example, the mobile phone may also be connected to a WiFi network. In this case, the mobile phone shares the WiFi network to which it is connected. At this time, the network connection window 22 may display prompt information such as "Use the "Magic5" WiFi network to access the Internet."

[0147] In another example, it is also possible that a PC (connected to a WiFi network) can perform network sharing, where the PC's smart interconnection interface is as follows: Figure 4 As shown in S3 in the figure, the smart interconnection interface S3 provides a switch control 41 of "network sharing". After the user turns on the switch control 41 of "network sharing", the PAD side finds that there are PCs around that can access the Internet. At this time, the PAD displays something like Figure 2 The network sharing window 22 shown in Figure (b) is provided for the user to select whether to connect to the PC's network.

[0148] In one example, there may be multiple electronic devices around the PAD that can share the network. For example, please refer to Figure 5, there are two electronic devices, a mobile phone and a PC, that can share the network. In this case, after both the mobile phone and the PC have turned on the network sharing function, the PAD finds that there are mobile phones and PCs nearby that can access the Internet. The network sharing window 22 displayed on the mobile phone includes not only the device information of the mobile phone, but also the device information of the PC (Honor MagicBook X14), and if Figure 5 As shown, the device information of the mobile phone and the device information of the PC both have corresponding options. In this way, the user can choose which electronic device's network the PAD uses to access the Internet according to the needs. For example, the user selects the option corresponding to the device information of the mobile phone, and then clicks the "Connect Now" control. Accordingly, the PAD establishes a P2P link with the mobile phone, thereby sharing the network of the mobile phone.

[0149] It should be noted that the above description is based on the example that the electronic device to be connected is a PAD. In another example, when the electronic device to be connected is a PC, after the PC finds that the surrounding mobile phones can access the Internet, a network sharing window is displayed such as Figure 6 As shown in 60 in (a) of the figure, the user can trigger the PC to share the mobile phone's network based on the network sharing window 60. After the sharing is successful, see Figure 6 In (b) of FIG. 1 , the PC displays a sharing success notification 61, which includes a prompt message "Using the mobile data network of "Honor Magic5" to surf the Internet", and may also include a control for disconnecting the sharing service. As an example and not a limitation, the sharing success notification 61 may automatically disappear after being displayed for 5 seconds.

[0150] When the PC displays the network sharing window 60, if the user does not click the "Connect Now" control within a certain period of time (for example, 2 minutes), it means that the user may not need the PC to use the network. At this time, the network sharing window 60 disappears, that is, the PC can no longer display the network sharing window 60, thus avoiding the need for the user to manually close it. In one example, after the network sharing window 60 disappears, when the user wants the PC to share the cellular network of the mobile phone again, the user can open the PC Manager side notification bar, for example, Figure 7 As shown in FIG. 1 (a), the user can click on the PC manager control 70 of the PC. In response to the user's triggering operation on the PC manager control 70, the PC displays the PC manager side notification bar, such as Figure 7 As shown in Figure (b), it includes a network sharing notification 71, and the user can trigger the PC to share the cellular network of the mobile phone based on the network sharing notification 71.

[0151] It should be noted that the above-mentioned application scenarios are merely exemplary and do not constitute a limitation on the application scenarios of the methods provided in the embodiments of the present application.

[0152] The method provided in the embodiment of the present application is implemented by the interaction between the first electronic device and the second electronic device. The first electronic device is the electronic device to be connected, such as the first electronic device is the PAD in the above application scenario; the second electronic device is an electronic device that is in the same ring as the first electronic device and has network sharing capabilities, such as the second electronic device is the mobile phone in the above application scenario. The number of first electronic devices may be one or more, and the number of second electronic devices may also be one or more. In the case where the number of first electronic devices is multiple, each of the multiple first electronic devices can share the network of the second electronic device through the method provided in the embodiment of the present application.

[0153] For ease of understanding, the software system of the electronic device is described below. As an example of this application, please refer to Figure 8 , Figure 8 This is a schematic diagram of the architecture of a software system of an electronic device according to an exemplary embodiment. The software system of the electronic device can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system with a layered architecture as an example to exemplify the software system of the electronic device.

[0154] Please refer to Figure 8 The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: application layer, application framework layer, native service layer, and kernel layer.

[0155] As an example of this application, please refer to Figure 8 In Figure (a), the application layer of the first electronic device may include but is not limited to a first system service module and a first application. The first system service module is a module that interacts with the user, including prompting the user to turn on or off network sharing, displaying the network sharing status to the user, and prompting the user of the network traffic consumption status. In one example, the first system service module is a system application in the first electronic device, such as a setting application in a PAD. In another example, the first system service module is a PC manager in a PC. The first application is an Internet application, such as applications such as video, calls, games, instant messaging, browsers, and screen projection.

[0156] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions. As an example of this application, Figure 8As shown in Figure (a), the application framework layer of the first electronic device mainly includes but is not limited to a first network sharing service module, a first link module, a first device management service module, a first distributed gateway, and a first connection management module.

[0157] The first network sharing service module is pulled up when network sharing is required, and is used to manage events related to network sharing, such as triggering the first electronic device to establish a P2P link with the second electronic device to start network sharing. For example, it can also be used to query the network traffic value consumed by the first electronic device in the process of sharing the network of the second electronic device from the second electronic device, and report the queried network traffic value to the first system service module for display. For example, it can also be used to trigger the first electronic device to disconnect the P2P link between it and the second electronic device to close network sharing, etc. In one example, the first network sharing service module includes multiple modules, such as the multiple modules include a basic function module, a traffic statistics module, a maintenance module, a network setting module, and an event notification module. The basic function module can be used to turn on and off network sharing; the traffic statistics module can be used to count the network traffic consumed after network sharing is turned on, and synchronize it to the peer device; the maintenance and measurement module can be used to provide key process tracking and error code reporting, as well as data statistics such as usage time; the network setting module is used to instruct the first distributed gateway to perform P2P channel configuration; the event notification module can be used to provide notifications of some key events to the upper layer, such as key events including network sharing service being turned on, turned off, etc., or it can also report events such as abnormal disconnection of network sharing service due to anomalies, as well as the value of consumed network traffic, etc.

[0158] The first link module provides a self-discovery and self-organizing network function. In this way, when the first electronic device and the second electronic device are in the same ring, the first link module can autonomously discover the second electronic device and exchange information with the second electronic device, such as exchanging respective device information. The device information may include a device unique identifier, device name, device model, device type, etc. The first link module can also be used to establish a P2P channel. It is worth noting that before a P2P link is established between the first electronic device and the second electronic device, the information exchange between the first electronic device and the second electronic device can be achieved through the first link module.

[0159] The first device management service module can be used to manage the device information of the second electronic device obtained by the first link module. For example, when the first link module obtains the device information of the second electronic device, the first device management service module sends the device information of the second electronic device to the first system service module to notify the first system service module that the second electronic device is online, that is, the first electronic device is currently in the same ring as the second electronic device.

[0160] The first distributed gateway provides capabilities such as Internet Protocol (IP) address forwarding, Address Resolution Protocol (ARP) proxy, Network Address Translation (NAT) address conversion, gateway configuration, Domain Name System (DNS) configuration, etc. After the P2P channel is established, the first distributed gateway can configure the P2P channel to establish a P2P link. In one example, Figure 8 As shown in Figure (a), the first distributed gateway includes a network factory module and a network agent module, the network factory module is used to provide network connection building conditions, and the network agent module is used to perform network configuration according to the building conditions provided by the network factory module. In some embodiments, the network factory module is named P2P NetworkFactory, and the network agent module is named NetworkAgent.

[0161] The first connection management module can be used to manage the network connected to the first electronic device. For example, after configuring the P2P channel, the first distributed gateway can register with the first connection management module, so that the first connection management module knows that there is currently a P2P link that can be used to communicate with the second electronic device. In one example, Figure 8 As shown in Figure (a), the first connection management module includes a connection action management module and a connection action service module. The connection action management module is used to provide a callable interface for the upper-layer application, so that the upper-layer application can query whether there is an available network. The connection action service module is used to monitor the network establishment status in the first electronic device. In some embodiments, the connection action management module is named ConnectivityManager, and the connection action service module is named ConnectivityService.

[0162] Please refer to Figure 8 In (a) of FIG. 1 , the local service layer of the first electronic device may include some functional modules customized by technicians. For example, the local service layer of the first electronic device includes a first network management framework and a first network module, and the first network management framework is used to set a firewall. In some examples, the first network management framework is called Iptables. The first network module can be used to pass network data packets to the kernel layer, and in some examples, the first network module is called Netd.

[0163] Please refer to Figure 8In (a) of the figure, the kernel layer of the first electronic device may include but is not limited to a kernel protocol stack, a first virtual network card module and a first network card device driver, wherein the kernel protocol stack includes a kernel interface, a transport layer, a first network filter module, a network layer and a network interface. Among them, the kernel interface is used to be called by the upper layer so that the upper layer can interact with the kernel protocol stack. The transport layer is mainly responsible for overall data transmission and data control. The first network filter module has routing and relay functions, and can be used to implement the proxy and forwarding of network data packets. In some embodiments, the first network filter module is called Netfilter. The network layer is used to establish a network connection and provide services for the upper layer. The network interface is used for the network layer to call so that the kernel protocol stack interacts with the first virtual network module. The first virtual network card module is used to send a network data packet to the second electronic device via a P2P link. In one example, the first virtual network card module is created by the first link module when establishing a P2P channel. The first network card device driver is used to drive the network card to use the network card to access the Internet.

[0164] As an example of this application, please refer to Figure 8 In (b) of FIG. 1 , the application layer of the second electronic device may include a second system service module, a second application, etc. The second system service module has similar functions to the first system service module. The second application may be, but is not limited to, screen projection, call, video, short message, instant messaging, browser, and other applications.

[0165] Please refer to Figure 8 In Figure (b), the application framework layer of the second electronic device mainly includes a second network sharing service module, a second link module, a second device management service module, a second distributed gateway, and a second connection management module.

[0166] The second network sharing service module has the same or similar functions as the first network sharing service module. Figure 8 As shown in Figure (b), the second network sharing service module includes a basic function module, a traffic statistics module, a maintenance module, a network setting module and an event notification module. The functions of each module in the second network sharing service module can be found above and will not be repeated here.

[0167] In addition, the second link module has the same or similar functions as the first link module. The second device management service module has the same or similar functions as the first device management service module. The second distributed gateway has the same or similar functions as the first distributed gateway. In one example, Figure 8 As shown in Figure (b), the second distributed gateway also includes a network factory module and a network agent module. The functions of each module in the second distributed gateway can also be found above.

[0168] The second connection management module and the first connection management module have the same or similar functions. Figure 8 As shown in FIG. 5( b ), the second connection management module includes a connection action management module and a connection action service module. The functions of each module in the second connection management module can also be found above.

[0169] Please refer to Figure 8 In (b) of the figure, the local service layer of the second electronic device includes a second network management framework and a second network module. The second network management framework is used to set a firewall. In some examples, the second network management framework is called Iptables. The second network module can be used to pass network packets to the kernel layer. In one example, the second network module is called Netd.

[0170] Similar to the first electronic device, the kernel layer of the second electronic device may also include, but is not limited to, a kernel protocol stack, and further include a second virtual network card module and a second network card device driver. The kernel protocol stack of the second electronic device includes a kernel interface, a transport layer, a second network filtering module, a network layer, and a network interface. The functions of each module of the kernel layer of the second electronic device can refer to the functions of the corresponding modules in the kernel layer of the first electronic device, for example, the functions of the second virtual network card module can refer to the functions of the first virtual network card module, etc., which will not be described in detail here.

[0171] The first electronic device Figure 8 The multiple functional modules shown in (a) in FIG. 1 interact with the second electronic device, and the second electronic device interacts with the second electronic device through Figure 8 The multiple functional modules shown in (b) of FIG. 1 interact with the first electronic device to achieve network sharing. Fig. 9 , Fig. 9 This is a framework diagram of a network sharing according to an exemplary embodiment. When the first electronic device needs to share the network of the second electronic device, a P2P link is established between the two electronic devices through the first link module and the second link module. Afterwards, when transmitting network data packets, the first electronic device uses the first virtual network card module to send the network data packets to the second electronic device using the P2P link. The second virtual network card module in the second electronic device then forwards the network data packets through the second network card device driver that can access the Internet. In this way, the first electronic device can access the Internet using the network of the second electronic device. For details, please refer to Fig.10 , Fig.10 The present invention is a flowchart of a network sharing method according to an exemplary embodiment. The method may include part or all of the following contents:

[0172] Step 1001: The first system service module registers the device online monitoring with the first device management service module.

[0173] In one example, the first system service module is a resident process, for example, the first system service module is a setting application. After the first electronic device is turned on, the first system service module runs, and then the first system service module registers the device online monitoring with the first device management service module, so that the first device management service module notifies the first system service module when determining that the second electronic device is in the same ring as the first electronic device.

[0174] Step 1002: The second system service module registers the device online monitoring with the second device management service module.

[0175] Similarly, for the second electronic device, after the second electronic device is turned on, the second system service module registers the device online monitoring to the second device management service module, so that the second device management service module notifies the second system service module when it determines that the first electronic device and the second electronic device are in the same ring.

[0176] It should be noted that there is no strict execution order between step 1001 and step 1002.

[0177] Step 1003: After the second link module senses the first electronic device, it obtains device information of the first electronic device.

[0178] As mentioned above, the second link module has the function of self-discovery and self-organizing networking, so when the second electronic device and the first electronic device are logged in to the same device account and are close to each other, the second link module of the second electronic device can automatically discover the first electronic device. In this case, the second link module obtains the device information of the first electronic device.

[0179] Step 1004: the second link module sends a device online notification n1 (carrying device information of the first electronic device) to the second device management service module.

[0180] The device online notification n1 is used to indicate that the second electronic device and the first electronic device are currently sensed to be in the same ring, that is, the first electronic device can perform short-range communication with the second electronic device.

[0181] Step 1005: The second device management service module sends a device online notification n1 to the second system service module.

[0182] Since the second system service module has registered the device online monitoring, when the second device management service module learns that the second electronic device and the first electronic device are in the same ring, it can send a device online notification n1 to the second system service module to prompt the user through the second system service module.

[0183] Step 1006: The second system service module displays a device online notification n1.

[0184] For example, please refer to Figure 2 In the figure (a), the first electronic device is a PAD. After the second system service module receives the device online notification n1, it displays the Honor PAD in the vicinity in the smart interconnection interface S1. In this way, the user can know from the second electronic device that the first electronic device and the second electronic device are in the same ring.

[0185] Step 1007: After the first link module senses the second electronic device, it obtains device information of the second electronic device.

[0186] Step 1008: The first link module sends a device online notification n2 to the first device management service module.

[0187] The device online notification n2 may carry device information of the second electronic device, and the device online notification n2 is used to indicate that the second electronic device and the first electronic device are currently perceived to be in the same ring, that is, there is a second electronic device that can perform close-range communication with the first electronic device.

[0188] Step 1009: The first device management service module sends a device online notification n2 to the first system service module.

[0189] Similarly, when the first electronic device and the second electronic device log in to the same device account and are close to each other, on the first electronic device side, after the first link module discovers the second electronic device, it obtains the device information of the second electronic device, and then sends the device online notification n2 to the first device management service module. The first device management service module sends the device online notification n2 to the first system service module, thereby notifying the first system service module that the first electronic device and the second electronic device are in the same ring. In one example, after receiving the device online notification n2, the first system service module can prompt the user.

[0190] It should be noted that there is no strict execution order between steps 1003 to 1006 and steps 1007 to 1009. For any electronic device among the first electronic device and the second electronic device, the corresponding online prompt process is started after sensing the other device.

[0191] Step 1010: The first system service module sends a capability query request to the second electronic device through the first link module.

[0192] The capability query request is used to query whether the second electronic device currently has the network sharing capability.

[0193] That is, after the first system service module receives the device online notification n2, it determines that the second electronic device is in the same ring as the first electronic device. In this case, the first system service module can query whether the second electronic device has the network sharing capability, so as to determine whether the network of the second electronic device can be shared according to the query result. Because before the P2P link is established between the first electronic device and the second electronic device, information is exchanged with the second link module through the first link module, so the first system service module sends a capability query request to the first link module. After receiving the capability query request, the first link module sends a capability query request to the second electronic device, so as to query the network sharing capability of the second electronic device through the first link module.

[0194] As an example of the present application, before sending a capability query request to the first link module, the first system service module may also determine whether the first electronic device currently needs to share a network. For example, if the first electronic device currently has an available network, it is determined that the network of the second electronic device does not need to be shared. Otherwise, if the first electronic device currently does not have an available network, it is determined that the network of the second electronic device needs to be shared. In one example, since the first connection management module is capable of monitoring the network establishment in the first electronic device, the first system service module may call the first connection management module to query whether there is an available network from the first connection management module. If there is no available network, the first system service module sends a capability query request to the first link module. Otherwise, if there is an available network, subsequent operations may not be performed, that is, the network of the second electronic device is not shared.

[0195] Step 1011: After receiving the capability query request, the second link module sends it to the second system service module.

[0196] As described above, the second electronic device exchanges information with the first electronic device through the second link module, so the second electronic device receives the capability query request through the second link module. Afterwards, the second link module forwards the capability query request to the second system service module to instruct the second system service module to determine whether the second electronic device currently has the network sharing capability.

[0197] Step 1012: The second system service module determines capability information, where the capability information is used to indicate whether the network sharing capability is currently available.

[0198] The second system service module can query the status of the network sharing switch in the second electronic device, the network status, and whether there is overheat protection, etc., so as to determine the capability information according to the query results. In one example, the capability information may only include the first indication information, and the first indication information is used to indicate that the second electronic device currently has the network sharing capability, that is, the second system service module can determine the indication information directly used to indicate whether the network sharing capability is currently available according to the query results. For example, the network sharing switch in the second electronic device is currently in the on state (such as Figure 2 In the case where the second electronic device is currently connected to an Internet-accessible network (such as a cellular network or a WiFi network) and has no overheat protection, the second system service module determines that the first indication information is 1, indicating that the second electronic device currently has the network sharing capability. In this way, the first electronic device can directly determine that the second electronic device currently has the network sharing capability based on the capability information.

[0199] In another example, the capability information may include multiple indication information, and different indication information is used to indicate the status of a certain indicator related to the network sharing capability. Exemplarily, the capability information includes second indication information, third indication information, and fourth indication information, the second indication information is 1, which is used to indicate that the second electronic device has turned on the network sharing switch; the third indication information is 1, which is used to indicate that the second electronic device is currently connected to a network with Internet access; and the fourth indication information is 1, which is used to indicate that the second electronic device currently does not have overheat protection.

[0200] It should be noted that the embodiment of the present application is explained by taking the capability information indicating that the second electronic device has the network sharing capability as an example. In another example, when the second electronic device has not turned on the network sharing switch, and / or is not currently connected to a network with internet access, and / or currently has overheating protection, the capability information determined by the second system service module is used to indicate that the second electronic device does not have the network sharing capability. For example, the capability information includes first indication information, and the first indication information is 0, indicating that the second electronic device currently does not have the network sharing capability. For another example, the capability information includes second indication information, third indication information, and fourth indication information, and the second indication information is 0, indicating that the network sharing switch is not turned on; the third indication information is 0, indicating that the second electronic device is not currently connected to a network with internet access; the fourth indication information is 0, indicating that overheating protection currently exists.

[0201] It is worth mentioning that, when the capability information includes multiple indication information, when the capability information indicates that the second electronic device cannot share the network, the first electronic device can be informed of the reason why the second electronic device cannot share the network.

[0202] Step 1013: The second system service module feeds back capability information and monitors the service launch broadcast.

[0203] The service launch broadcast is used to indicate that the second network sharing service module is launched.

[0204] After determining the capability information, the second system service module sends the capability information to the second link module, so that the capability information is sent to the first electronic device through the second link module.

[0205] In addition, when the first electronic device queries the network sharing capability of the second electronic device, it indicates that the first electronic device may need to share a network. In this case, the second system service module starts to monitor the service launch broadcast of the second network sharing service module, that is, monitors whether the second network sharing service module is launched, so as to determine whether to monitor the service status of the network sharing, thereby facilitating effective prompts to the user.

[0206] It should be noted that the embodiment of the present application is described by taking the capability information indicating that the second electronic device has the network sharing capability as an example. In another example, if the second electronic device currently does not have the network sharing capability, the second system service module does not monitor the service launch broadcast. That is, if the second electronic device does not have the network sharing capability, the second system service module does not need to monitor whether the second network sharing service module is launched.

[0207] Step 1014: After receiving the capability information, the first link module sends the capability information to the first system service module.

[0208] The first electronic device receives the capability information through the first link module, and then the first link module forwards the capability information to the first system service module. In this way, the first system service module obtains the capability information of the second electronic device, so as to determine whether the second electronic device currently has the network sharing capability. For example, if the capability information includes the first indication information and the first indication information is 1, it can be determined that the second electronic device currently has the network sharing capability.

[0209] Step 1015: The first system service module displays a network sharing window, which includes information about the second electronic device.

[0210] When it is determined based on the capability information that the second electronic device has the network sharing capability, the first electronic device can use the network of the second electronic device. In this case, in order to facilitate the user to choose whether to share the network of the second electronic device, the first system service module displays a network sharing window and displays the device information of the second electronic device in the network sharing window, so that when the user needs the first electronic device to use the network of the second electronic device, the network sharing window can be used to trigger the first electronic device to quickly share the network of the second electronic device. For example, please refer to Figure 2 Please refer to Figure (c) in Figure 6 In Figure (a), the network sharing window includes the device information of the mobile phone, namely "Honor Magic 5", so that the user can know which electronic device can perform network sharing. In addition, the network sharing window includes a "Connect Now" control, and the user can click the "Connect Now" control to trigger the first electronic device to quickly share the network of the second electronic device.

[0211] It should be noted that if the first system service module determines through capability query that the second electronic device currently does not have the network sharing capability, the network sharing window may not be displayed. Alternatively, a notification that the network cannot be shared may be displayed so that the user can be informed that the second electronic device cannot share the network. Optionally, when the capability information includes the second indication information, the third indication information, and the fourth indication information, and when it is determined based on the capability information that the second electronic device currently does not have the network sharing capability, the first system service module may also display the reason why the network cannot be shared, so that the user can quickly locate the problem of the network cannot be shared.

[0212] Step 1016: After receiving the operation of sharing the network of the second electronic device in the network sharing window, the first system service module calls the first network sharing service module and registers sharing monitoring with the first network sharing service module.

[0213] For example, see Figure 2 In Figure (b), the user clicks the "Connect Now" control in the network sharing window 22. In this case, it means that the user needs the first electronic device to share the network of the second electronic device. To this end, the first system service module pulls up the first network sharing service module to achieve network sharing through the first network sharing service module.

[0214] In addition, in order to enable the first network sharing service module to notify the first system service module after network sharing succeeds or fails, the first system service module registers sharing monitoring with the first network sharing service module, so that the first network sharing service module will notify the first system service module after determining whether the first electronic device shares the network with the second electronic device successfully or fails.

[0215] It is worth mentioning that the first network sharing service module is only pulled up when a shared network is needed, otherwise the first network sharing service module does not work, which can reduce the operating burden of the first electronic device and reduce the operating power consumption of the first electronic device.

[0216] Step 1017: The first system service module sends a network sharing instruction (carrying device information of the second electronic device) to the first network sharing service module.

[0217] After the first network sharing service module is pulled up, the first system service module enables the first network sharing service module, that is, sends a network sharing instruction to the first network sharing service module, and carries the device information of the second electronic device in the network sharing instruction to instruct the first network sharing service module to establish a P2P link between the first electronic device and the second electronic device, thereby realizing network sharing.

[0218] Step 1018: The first network sharing service module registers channel monitoring with the first link module.

[0219] According to the previous records, the first electronic device and the second electronic device exchange information through the first link module and the second link module before the P2P link is established, so the first network sharing service module registers channel monitoring with the first link module to notify the first network sharing service module after the first link module and the second electronic device establish a P2P channel.

[0220] Step 1019: The first network sharing service module sends a channel opening request (carrying device information of the second electronic device) to the first link module.

[0221] The channel opening request is used to request the first link module to establish a P2P channel with the second electronic device. Exemplarily, the channel opening request is an Open session request.

[0222] Step 1020: In response to the channel opening request, the first linking module sends a channel establishing request to the second electronic device.

[0223] The first link module sends a channel establishment request to the second electronic device to request to establish a P2P channel with the second electronic device.

[0224] Step 1021: After receiving the channel establishment request, the second link module establishes a P2P channel with the first link module.

[0225] After receiving the channel establishment request, the second link module establishes a P2P channel with the first link module. In the process of establishing the P2P channel, the second link module creates a second virtual network card module and allocates P2P address information to the second virtual network card module, and the first link module creates a first virtual network card module and allocates P2P address information to the first virtual network card module, and the first link module and the second link module exchange their respective P2P address information.

[0226] After the P2P channel is successfully established, the second link module performs the following operation of step 1025 .

[0227] In addition, in order to enable the user to check whether the network is shared successfully on the second electronic device, the second link module further performs the following operations from step 1022 to step 1024 after receiving the channel establishment request.

[0228] Step 1022: The second link module pulls up the second network sharing service module.

[0229] After receiving the channel establishment request, the second link module pulls up the second network sharing service module, so as to implement the network sharing service through the second network sharing service module later.

[0230] It is worth mentioning that the second network sharing service module is passively pulled up, that is, it is pulled up when the first electronic device needs to share the network of the second electronic device, which can reduce the operating power consumption of the second electronic device.

[0231] Step 1023: The second network sharing service module publishes a service broadcast.

[0232] After the second network sharing service module is started, the external broadcast service starts broadcasting, so that the monitoring module can know that the second network sharing service module has been running.

[0233] Step 1024: After receiving the service launch broadcast, the second system service module registers for shared monitoring with the second network sharing service module.

[0234] As mentioned above, when the second system service module feeds back capability information to the first electronic device, it starts to monitor the service launch broadcast, so after the second network sharing service module broadcasts the service launch broadcast, the second system service module will monitor it. When the second network sharing service module is launched, it means that the second electronic device and the first electronic device are establishing a P2P link for network sharing. In order to determine whether the network sharing service is successful and to prompt the user, the second system service module registers the sharing monitoring with the second network sharing service module, so that the second network sharing service module notifies the second system service module after achieving network sharing.

[0235] It should be noted that the above steps 1022 to 1024 are optional operations. In another example, the second network sharing service module may have been pulled up, for example, other electronic devices are already sharing the network of the second electronic device. In this case, the second electronic device does not perform these optional operations after receiving the channel establishment request from the first electronic device.

[0236] Step 1025: After completing the channel establishment, the second link module sends a channel establishment success notification to the first electronic device, and sends channel configuration information m1 to the second network sharing service module.

[0237] The channel establishment success notification is used to indicate that the P2P channel has been successfully established. As an example but not a limitation, the channel establishment success notification is an Open session success notification.

[0238] The channel configuration information m1 includes the channel information of the P2P channel that needs to be configured on the second electronic device side, for example, the channel configuration information m1 includes the P2P address information of the first electronic device, the P2P adapter information of the second electronic device, etc. As an example but not a limitation, the channel configuration information m1 can be sent to the second network sharing service module via the On session opened structure.

[0239] Step 1026: The second network sharing service module sends a configuration indication Set1 (carrying m1) to the second distributed gateway.

[0240] After the second network sharing service module receives the channel configuration information m1 sent by the second link module, it determines that the P2P channel needs to be configured. In this case, the second network sharing service module instructs the second distributed gateway to perform configuration, that is, sends a configuration indication Set1 to the second distributed gateway, and carries the channel configuration information m1 in the configuration indication Set1.

[0241] Step 1027: The second distributed gateway performs P2P channel configuration.

[0242] In implementation, the second distributed gateway performs gateway and DNS configuration on the second virtual network card module based on the P2P information of the first electronic device and the P2P adapter information of the second electronic device, thereby determining the P2P route, which is a virtual route.

[0243] Step 1028: After the second distributed gateway configuration is completed, the configured P2P route is sent to the second network filtering module for storage, and a configuration success notification is sent to the second network sharing service module.

[0244] The configuration success notification is used to indicate that the P2P channel has been successfully configured.

[0245] In implementation, the second distributed gateway stores the set P2P route in the second network filtering module, so that in the subsequent process of transmitting network data packets with the first electronic device, the second network filtering module uses the P2P link to transmit data according to the P2P route. In addition, after the second distributed gateway completes the configuration of the P2P channel, it notifies the second network sharing service module.

[0246] Step 1029: The second network sharing service module sends a configuration completion notification to the first electronic device.

[0247] In one example, if Fig.10 As shown, the second network sharing service module sends a configuration end notification to the second link module, and the second link module sends a configuration end notification to the first electronic device. The first electronic device receives the configuration end notification through the first link module, and then sends the configuration end notification to the first network sharing service module.

[0248] Step 1030: After receiving the notification of successful channel establishment, the first link module sends channel configuration information m2 to the first network sharing service module.

[0249] For the first electronic device side, after receiving the notification of successful channel establishment, the P2P channel configuration is also performed. Specifically, since the first network sharing service module registered the channel monitoring with the first link module before sending the channel opening request to the first link module, after the first link module receives the notification of successful channel establishment from the second electronic device, that is, after determining that the P2P channel is successfully established, it sends the channel configuration information m2 to the first network sharing service module. The channel configuration information m2 includes the channel information of the P2P channel that needs to be configured on the first electronic device side, such as the P2P address information of the second electronic device and the P2P adapter information of the first electronic device.

[0250] Step 1031: The first network sharing service module sends a configuration indication Set2 (carrying m2) to the first distributed gateway.

[0251] After receiving the channel configuration information m2, the first network sharing service module instructs the first distributed gateway to perform network configuration on the P2P channel. To this end, a configuration instruction Set2 is sent to the first distributed gateway, and the channel configuration information m2 is carried in the configuration instruction Set2.

[0252] Step 1032: The first distributed gateway performs P2P channel configuration.

[0253] In implementation, the first distributed gateway performs gateway and DNS configuration on the first virtual network card module based on the P2P information of the second electronic device and the P2P adapter information of the first electronic device, thereby determining the P2P route.

[0254] Step 1033: After the configuration of the first distributed gateway is completed, the configured P2P route is sent to the first network filtering module for storage, and a configuration success notification is sent to the first network sharing service module.

[0255] Step 1034: upon receiving the configuration success notification and the configuration end notification, the first network sharing service module sends a sharing success notification to the first system service module and sends a sharing success notification to the second electronic device.

[0256] The sharing success notification is used to indicate that the first electronic device has successfully shared the network of the second electronic device, which means that the first electronic device can use the network of the second electronic device to access the Internet.

[0257] In the case of receiving the configuration success notification sent by the first distributed gateway, it can be determined that the P2P channel has been successfully configured on the first electronic device side, and in the case of receiving the configuration end notification, it can be determined that the P2P channel has been successfully configured on the second electronic device side. In this case, it is determined that the P2P link is established, so that it is determined that the first electronic device can use the network of the second electronic device to access the Internet, that is, network sharing is achieved. According to the previous records, since the first system service module registers the sharing listener after the first network sharing service module is pulled up, when the first network sharing service module realizes network sharing, it sends a sharing success notification to the first system service module, thereby notifying the first system service module that the first electronic device has successfully shared the network of the second electronic device. In addition, the first network card sharing service module sends a sharing success notification to the second electronic device to notify the second electronic device that the network sharing is successful.

[0258] It should be noted that the method for establishing a P2P link provided in the embodiment of the present application is optional. In another embodiment, the P2P link can also be established through a standard P2P establishment method, which is not limited in the embodiment of the present application.

[0259] In one example, after the P2P link is established, the interaction between the first electronic device and the second electronic device can be achieved through the P2P link. Therefore, the first network sharing service module can send the successful sharing notification to the first network filtering module during the process of sending the successful sharing notification to the second electronic device. Since the first network filtering module is provided with a P2P route, the first network filtering module determines to send the successful sharing notification through the P2P link based on the P2P route. Therefore, the second network filtering module sends the successful sharing notification to the first virtual network card module, and the first virtual network card module sends the successful sharing notification to the second electronic device through the P2P link.

[0260] Step 1035: The first system service module displays a sharing success notification.

[0261] In one example, a sharing success notification is as follows: Figure 2 As shown in (d) of FIG. 23 , the user can view the network of the second electronic device that has been successfully shared from the first electronic device.

[0262] Step 1036: After receiving the sharing success notification, the second network sharing service module sends a sharing success notification to the second system service module.

[0263] In one example, the second electronic device receives the sharing success notification sent by the first electronic device through the second virtual network card module, and then sends the sharing success notification to the second network filtering module, so that the sharing success notification is sent to the second network sharing service module through the second network filtering module. Similarly, since the second system service module registers the sharing listener in the second network sharing service module, after receiving the sharing success notification, the second network sharing service module sends the sharing success notification to the second system service module to notify the second system service module that the network sharing is successful.

[0264] Step 1037: The second system service module displays a sharing success notification.

[0265] For example, please refer to Fig.11 In (a) of FIG. 1 , the second electronic device displays a sharing success notification 1100 in the user interface, and see Fig.11 In FIG. 1( b ), the second electronic device displays a sharing success notification 1110 in the notification bar. In this way, the user can view that the first electronic device is sharing the network from the second electronic device.

[0266] It should be noted that the embodiment of the present application is described by taking the second electronic device completing the configuration of the P2P channel first as an example. In another example, the first electronic device may complete the configuration operation of the P2P channel first. In this case, the first network sharing service module sends a configuration end notification to the second electronic device. Accordingly, after the second network sharing service module receives the configuration end notification from the first electronic device and the configuration success notification sent by the second distributed gateway, it sends a sharing success notification to the first electronic device and sends a sharing success notification to the second system service module. Details will not be repeated here.

[0267] In an embodiment of the present application, when the first electronic device determines that it can communicate with the second electronic device in close proximity, and the second electronic device currently has network sharing capabilities, the first electronic device displays a network sharing window, and displays the device information of the second electronic device in the network sharing window, so that the user can choose whether to share the network of the second electronic device based on the network sharing window. When the user chooses to connect, the first electronic device establishes a P2P link with the second electronic device, so that the network data packet is sent to the second electronic device through the P2P link during the transmission of the network data packet, and the network of the second electronic device is used for data forwarding. In this way, the user is prevented from manually entering the connection password, which improves the convenience of operation and thus improves the efficiency of network sharing.

[0268] After the first electronic device successfully shares the network of the second electronic device, data can be forwarded through the network of the second electronic device. Fig.12 , Fig.12 This is a schematic diagram of a data forwarding process according to an exemplary embodiment, which mainly includes part or all of the following contents:

[0269] Step 1201: The first application receives an Internet access operation.

[0270] The first application is any application in the first electronic device that can access the Internet. For example, the first application can be an instant messaging application, a browser, a video player, or a game application.

[0271] When the user uses the first application to surf the Internet, an Internet surfing operation is triggered in the first application. For example, taking the first application as an instant messaging application, when the user makes a video call in the first application, the first application receives the Internet surfing operation.

[0272] It should be noted that the embodiment of the present application is described by taking the user triggering the first application to go online as an example. In another example, other conditions may also trigger the first application to go online, such as automatic update of the application.

[0273] Step 1202: The first application sends a network query instruction to the first connection management module.

[0274] The network query instruction is used to request whether there is an available network at present.

[0275] When the first application needs to transmit a network data packet, it can first query the first connection management module whether there is a network available. For example, when a user uses an instant messaging application to make a video call, or when a user uses a browser application to download a file, a network data packet needs to be transmitted. In this case, the first application sends a network query request to the first connection management module to determine whether the first electronic device has a network available.

[0276] In one example, the first connection management module may provide a network query interface, such as a getactivitynetwork interface. The first application may call the getactivitynetwork interface and send a network query request to the first connection management module through the getactivitynetwork interface to query whether there is a currently available network.

[0277] Step 1203: In response to the network query instruction, the first connection management module queries the network status.

[0278] As mentioned above, the first connection management module is used to monitor the network status of the first electronic device. Therefore, after receiving the network query request, the first connection management module can determine whether there is a usable network currently.

[0279] Step 1204: The first connection management module feeds back the query result to the first application.

[0280] The query result is used to indicate whether there is a usable network.

[0281] In this way, after the first application calls the getactivitynetwork interface provided by the first connection management module, it can be known whether there is an available network.

[0282] Step 1205: When the query result indicates that there is an available network, the first application creates a socket.

[0283] A socket is an abstraction layer through which an application can send or receive network packets.

[0284] When the first application determines through query that there is an available network, a socket is created to send the network data packet to be transmitted to the kernel protocol stack of the first electronic device through the socket, thereby sending data through the kernel protocol stack.

[0285] It should be noted that the above steps 1201 to 1205 are optional operations. Generally, the first application will perform the above operations when surfing the Internet after startup, and then the first application will no longer perform the above operations during the data transmission process, but directly perform the following step 1206. Of course, when the network is unavailable, the first connection management module will notify the first application, and accordingly, the first application will notify the user of the data transmission failure.

[0286] Step 1206: The first application sends the network data packet to be transmitted to the first network filtering module through the socket.

[0287] Since the first network filter module has the functions of routing selection and relaying, the first application sends the network data packet to the first network filter module for routing processing. In an example, please refer to Figure 8 In Figure (a), the first application sends a network data packet to the kernel interface through a socket, and then transmits it to the transport layer through the kernel interface. After passing through the transport layer, the network data packet is transmitted to the first network filtering module.

[0288] Step 1207: The first network filtering module sends a network data packet to the first virtual network card module.

[0289] According to the above records, P2P routing is set in the first network filtering module. Therefore, after receiving the network data packet, the first network filtering module sends the network data packet to the first virtual network card module, so that the network data packet is transmitted to the second electronic device through the first virtual network card module using the P2P link.

[0290] In implementation, please refer to Figure 8 In Figure (a), the first network filtering module sends the network data packet to the first virtual network card module through the network layer and the network interface layer in sequence.

[0291] Step 1208: The first virtual network card module sends a network data packet to the second electronic device.

[0292] The first virtual network card module sends a network data packet to the second electronic device using a P2P link.

[0293] Step 1209: The second virtual network card module receives the network data packet.

[0294] That is, the second electronic device receives the network data packet sent by the first electronic device through the second virtual network card module.

[0295] Step 1210: The second virtual network card module sends a network data packet to the second network filtering module.

[0296] Similarly, the second network filter module has the functions of routing and relaying, so all data packets must be routed through the second network filter module. Therefore, after the second virtual network card module receives the network data packet, it sends the network data packet to the second network filter module. For example, see Figure 8 In Figure (b), the second virtual network card module transmits the network data packet to the second network filtering module through the network interface layer and the network layer in sequence.

[0297] Step 1211: The second network filtering module sends the network data packet to the second network card device driver.

[0298] In one example, after receiving a network data packet, the second network filtering module parses the network data packet to determine the destination address carried in the network data packet. When it is determined based on the destination address that the network data packet does not need to be sent to the second electronic device but needs to be forwarded, the second network filtering module can convert the network data packet according to the NAT conversion rules on the second electronic device side, and then send the converted network data packet to the second network card device driver for forwarding through the second network card device driver.

[0299] For example, please refer to Fig.13 The second network filtering module includes a first data link, a forwarding link, and a second data link. The second virtual network card module sends the network data packet received from the first electronic device to the first data link. The first data link parses it and determines whether the destination is the local device based on the parsing result. If it is not the local device, the first data link sends the network data packet to the forwarding link, which is forwarded to the second data link through the forwarding link, and then the second data link sends the network data packet to the second network card device driver.

[0300] Step 1212: The second network card device driver forwards the network data packet.

[0301] Please refer to Fig.13 After the second network filtering module sends the network data packet to the second network card device driver, the second network card device driver forwards the network data packet, so that the first electronic device can access the Internet through the network of the second electronic device.

[0302] It should be noted that the present application embodiment is described by taking the example of the first electronic device sending a network data packet. In another example, the first electronic device may also send a data packet to be transmitted to the second electronic device. For example, in the case of screen projection, after the first electronic device projects the screen to the second electronic device, the first electronic device sends a screen projection data packet to the second electronic device. In this case, Fig.13As shown, after the second network filtering module parses the screen projection data packet, it determines that the screen projection data packet is sent to the second electronic device according to the destination address carried in the screen projection data packet, and then the second network filtering module passes the screen projection data packet to the upper layer to pass the screen projection data packet to the second application program in the upper layer. Please refer to Figure 8 In Figure (b), the screen projection data packet is transmitted to the second application through the transport layer and the kernel interface in sequence.

[0303] It should also be noted that the above is explained using the example of the second electronic device forwarding the uplink network data packet of the first electronic device. When applied, there will also be downlink network data packets during the first electronic device's Internet access process. For example, in the process of downloading a file package from a server, after sending a file package download request to the server, the server will return the requested download file package (i.e., the downlink network data packet). In this case, after the second electronic device receives the downlink network data packet, it forwards the downlink network data packet to the first electronic device. The forwarding process for the downlink network data packet can refer to the following steps:

[0304] Step 1213: The second network card device driver receives a network data packet from the network.

[0305] Step 1214: The second network card device driver sends the received network data packet to the second network filtering module.

[0306] Step 1215: The second network filtering module sends the network data packet to the second virtual network card module.

[0307] That is, after the second network filtering module determines that the destination address is the first electronic device by analyzing the downstream network data packet, it converts the downstream network data packet according to the NAT conversion rule on the second electronic device side and sends the converted network data packet to the second virtual network card module.

[0308] Step 1216: The second virtual network card module sends the network data packet to the first electronic device.

[0309] In this way, the network data packet to be transmitted downstream is forwarded to the first electronic device.

[0310] Step 1217: The first virtual network card module receives the network data packet.

[0311] Step 1218: The first virtual network card module sends the network data packet to the first network filtering module.

[0312] For the first electronic device side, the downlink network data packet is received through the first virtual network card module and then sent to the first network filtering module.

[0313] Step 1219: The first network filtering module sends the network data packet to the first application.

[0314] The first network filtering module receives the downlink network data packet and parses it. After determining that the data packet is sent to the local device according to the parsed destination address, the first network filtering module sends the network data packet to the first application program at the upper layer.

[0315] In the embodiment of the present application, during the transmission of a network data packet, the first electronic device sends the network data packet to be transmitted to the second electronic device through a P2P link. After the second electronic device determines that the network data packet is an Internet access data packet based on the destination address carried in the network data packet, it forwards the network data packet through the network to which it is connected, thereby enabling the first electronic device to access the Internet through the available network of the second electronic device.

[0316] It is also worth noting that when sharing a network hotspot, the first electronic device and the second electronic device work in station (STA) mode and wireless access point (AP) mode respectively. In this case, due to hardware limitations, a P2P link cannot be established between the first electronic device and the second electronic device, resulting in the inability to perform super terminal services (or collaborative services). In other words, network hotspot sharing and P2P links cannot coexist, so if the second electronic device is used as a router for data forwarding, it will affect the super terminal service. In an embodiment of the present application, the super terminal service and network sharing can share a P2P link, so that while sharing the network, super terminal services can also be realized, such as super terminal services including but not limited to screen projection services, application continuation collaborative services, call collaborative services, notification collaborative services, and keyboard and mouse collaborative services.

[0317] Among them, screen projection service: refers to projecting the user interface of the first electronic device onto the screen of the second electronic device for display, and allowing the user to operate the user interface of the first electronic device in the second electronic device, and by performing specific operations in the second electronic device (for example: dragging files from the user interface of the second electronic device to the user interface of the first electronic device), transferring files in the second electronic device to the first electronic device, realizing cross-device operations and cross-device file transfers between the first electronic device and the second electronic device, etc. Among them, the user interface of the first electronic device can be displayed in any area of ​​the screen of the second electronic device, or it can be displayed in full screen.

[0318] Keyboard and mouse collaborative service: refers to the first electronic device and the second electronic device can share each other's original input devices, such as: mouse, keyboard, etc. For example, the input device of the first electronic device is shared with the second electronic device, and the shared input device can be used for input in both the first electronic device and the second electronic device. In addition, in the keyboard and mouse sharing type, files can also be transferred between the first electronic device and the second electronic device.

[0319] Application continuation collaborative service: refers to the user running an application on the first electronic device, and the interface of the second electronic device can prompt the user to open the application running on the first electronic device on the second electronic device, so as to transfer to the second electronic device for continuation operations, such as watching videos, editing documents, etc. For example: the first electronic device is running a document application, which can be a memo, word, etc., and the user is editing a document on the first electronic device. When the second electronic device and the first electronic device are close to each other, a prompt message is displayed on the second electronic device, and the user clicks the prompt message on the second electronic device. In response to the user's click operation, the second electronic device opens the document application and displays the location where the user is editing, so as to transfer to the second electronic device to continue editing, etc. Call collaborative service: refers to when the first electronic device receives an incoming voice call or video call, the second electronic device can synchronously display the incoming call interface, so that the user can choose to answer or hang up the call on the second electronic device.

[0320] Notification collaboration service: when a first electronic device receives a notification message, the notification message can be synchronously displayed in a second electronic device, and the user can also perform operations such as reply, delete, and read the notification message in the second electronic device.

[0321] It should be noted that, in one possible case, before the first electronic device shares the network of the second electronic device, the first electronic device may have been performing a super terminal service with the second electronic device, and a first P2P link already exists between the first electronic device and the second electronic device. In this case, the first electronic device can directly use the first P2P link to share the network of the second electronic device, and the super terminal service between the first electronic device and the second electronic device will not be interrupted during the network sharing process. In another possible case, before the first electronic device shares the network of the second electronic device, there is no super terminal service between the first electronic device and the second electronic device. After the P2P link is established between the first electronic device and the second electronic device, the first electronic device can reuse the P2P link to perform a super terminal service with the second electronic device.

[0322] It should also be noted that, during the process of the first electronic device sharing the network of the second electronic device through the P2P link, the first electronic device can also perform super terminal services with other electronic devices (such as the fourth electronic device). Similarly, the second electronic device can also perform super terminal services with other electronic devices (such as the fifth electronic device).

[0323] In network sharing, that is, the process of data forwarding by the first electronic device through the cellular network shared by the second electronic device, users usually pay more attention to the network traffic consumed by the first electronic device of the second electronic device, and when there are other networks such as PCs, large screens, etc. where the first electronic device shares the network of the second electronic device, users usually also pay attention to the total network traffic consumed by the first electronic device of each shared network of the second electronic device. In some embodiments, the second electronic device can count the network traffic consumption of the second electronic device through a traffic management application. However, the traffic management application can only count the network traffic used by a certain application in the second electronic device, and cannot count the network traffic used by the first electronic device of a single shared network in the case of network sharing. To this end, the embodiment of the present application also provides a network traffic statistics method in network sharing, so that the second electronic device, in the case of sharing the network, counts the network traffic consumed by each first electronic device sharing the network, so that each first electronic device and second electronic device sharing the network can display the counted network traffic value to the user.

[0324] In an example, the application scenario involved in the embodiment of the present application is introduced by taking the first electronic device that shares the network as a PAD and the second electronic device that performs network sharing as a mobile phone as an example. Fig.14 In Figure (a), when the user wants to check the network traffic consumed by the mobile phone from the PAD, the user can pull down the notification bar. In response to the user's operation of pulling down the notification bar, the PAD queries the mobile phone for the network traffic consumed by the mobile phone, and after the query, displays the network sharing notification in the notification bar. The network sharing notification includes the queried network traffic value, and the queried network traffic value includes the network traffic value consumed this time. Optionally, the network sharing notification can also include the total network traffic consumed this month. For example, please refer to Fig.14 In Figure (b), the network sharing notification displays a message that reads "100MB of magic5 mobile data traffic has been consumed this time, and 300MB of magic5 mobile data traffic has been consumed this month", where magic5 is the device information of the mobile phone. In this way, the user can pull down the notification bar on the PAD to display the network traffic value consumed by the mobile phone in the notification bar, so that the user can know the network traffic consumption during the network sharing process.

[0325] As an example of this application, the amount of network traffic consumed by the PAD can also be displayed on the mobile phone side. For example, please refer to Fig.15 As shown in Figure (a), when the PAD is sharing the mobile phone's network, the mobile phone can display a traffic consumption notification in the user interface, or Fig.15 As shown in Figure (b) in the figure, the traffic consumption notification can also be displayed in the notification bar. The traffic consumption notification includes the network traffic consumed by the PAD this time. For example, please refer to Fig.15 As shown in Figure (b) in the figure, the traffic consumption notification shows "Sharing mobile data network..1 device connected, 100MB of mobile data traffic consumed this month". Furthermore, the traffic consumption notification can also display the network traffic currently consumed by the PAD ( Fig.15 not shown).

[0326] In one possible case, if in addition to the PAD sharing the mobile phone's network, there is also a PC sharing the mobile phone's network, in this case, the mobile phone side displays the total network traffic consumed by the PAD and PC in the notification bar. For example, the mobile phone can display the prompt message "Multiple devices have consumed 280MB of the mobile data traffic of this machine."

[0327] For PC, after successfully sharing the mobile phone network, a sharing success notification can be displayed in the form of a floating window. For example, please refer to Fig.16 , the sharing notification window is as follows Fig.16 The sharing notification window 1600 shows the network traffic consumed by the mobile phone this time, that is, the mobile data traffic consumed by magic5 this time is 100MB. Further, the sharing notification window 1600 can also show the network traffic consumed by the mobile phone by the PC this month, for example Fig.16 As shown in FIG. 1 , 300 MB is consumed this month. In one example, after the PC displays the sharing notification window 1600 for a certain period of time, if the user does not perform any operation on the sharing notification window 1600, the sharing notification window 1600 may no longer be displayed. Later, if the user wants to check how much network traffic the PC consumes during the sharing of the mobile phone's network again, he can click on the Fig.16 In the traffic query control 1610, in response to the user clicking the traffic query control 1610, the PC queries the consumed network traffic value from the mobile phone, and then displays the shared notification window 1600 again, and displays the queried result in the shared notification window 1600.

[0328] In the above Figure 8 Based on the first electronic device and the second electronic device shown, the following describes the traffic statistics method in network sharing in the embodiment of the present application. Fig.17 , Fig.17is a flow chart of a method for counting traffic in network sharing according to an exemplary embodiment. The method is implemented by the interaction of a first electronic device and a second electronic device. The first electronic device Figure 8 The multiple modules in (a) of FIG. 1 interact with the second electronic device, and the second electronic device interacts with the second electronic device through Figure 8 The multiple modules in (b) of FIG. 1 interact with the first electronic device. The method may include part or all of the following contents:

[0329] Step 1701: After the network sharing is successful, the second network sharing service module sets a hook according to the P2P address information of the first electronic device, and the hook is used for network traffic statistics.

[0330] A hook is a packet filtering hook with filtering function.

[0331] As an example, step 1701 in the above Fig.10 In the embodiment, step 1034 is executed after that, that is, when the second network sharing service module receives the sharing success notification from the first electronic device, it is determined that the first electronic device successfully shares the network of the second electronic device. In this case, the second network sharing service module sets a hook according to the P2P address information of the first electronic device, so that the network traffic consumed by the first electronic device can be counted when the first electronic device subsequently uses the network of the second electronic device to access the Internet.

[0332] In one example, the second network sharing service module can set the hook through the following command: iptables-IFORWARD-s srcIp; iptables-I FORWARD-d dstIp, where srcIp represents the source address, and dstIp represents the destination address, both of which are P2P address information of the first electronic device. Since the network data packets transmitted by the first electronic device during the process of surfing the Internet through the second electronic device include uplink network data packets and downlink network data packets, when setting the hook, it is necessary to set the source address and the destination address respectively for the P2P address information of the first electronic device, so that when filtering the message, the hook can filter and count the uplink network data packets of the first electronic device based on the source address of the first electronic device, and can filter and count the downlink network data packets of the first electronic device based on the destination address of the first electronic device.

[0333] Step 1702: The second network sharing service module sends a hook to the second network filtering module.

[0334] In one example, when the second network sharing service module sets a hook to the second network filtering module, it can call the network management service of the application framework layer and send the above command to the network management service. The network management service calls the interface provided by the second network module and sends the command to the second network module. Then the second network module sets the hook to the second network filtering module in the kernel protocol stack through the second network management framework.

[0335] Step 1703: The second network filtering module filters the network data packets of the first electronic device through the hook.

[0336] For an example, see Fig.13 The second network filtering module sets the hook in the forwarding chain and filters the network data packets of the first electronic device through the hook during the process of forwarding the network data packets.

[0337] As mentioned above, after the second virtual network card module receives the network data packet from the first electronic device, it sends the network data packet to the second network filtering module for routing. That is, after the second network filtering module receives the network data packet, it determines whether the sending object of the network data packet is the second electronic device through the first data link. If the first data link determines that the sending object is not the local device, the network data packet is forwarded to the forwarding chain. The forwarding chain forwards the network data packet to the second data link, so as to forward it to the second network card device driver of the second electronic device through the second data link, thereby forwarding the network data packet. Since the forwarding chain is provided with filtering rules for the P2P address information of the second electronic device, the forwarding chain filters out network data packets whose source address is the P2P address information of the first electronic device according to the filtering rules.

[0338] Of course, if a downlink network data packet is received, the second network filtering module will receive it through the second data link, and if it is determined that the destination address is the first electronic device, the downlink network data packet will be forwarded to the forwarding chain. At this time, the forwarding chain filters out the downlink network data packet whose destination address is the P2P address information of the first electronic device according to the filtering rules.

[0339] Step 1704: The second network filtering module collects statistics and records the filtered network data packets.

[0340] The second network filtering module counts the number of filtered network data packets and the size of a single network data packet, so as to determine the network traffic value consumed by forwarding the network data packet of the first electronic device, which is the product of the size of a single network data packet and the number of network data packets. The second network filtering module records the counted network traffic value, for example, the counted network traffic value can be stored in correspondence with the P2P address information of the first electronic device.

[0341] Step 1705: The second network sharing service module sends a traffic query instruction (carrying the P2P address information of the first electronic device) to the second network filtering module every time period a.

[0342] The duration a can be set according to the requirements, for example, the duration a can be 5 seconds.

[0343] As an example but not limitation, the traffic query instruction may be iptables -L FOEWARD -nvx.

[0344] That is, after the second network sharing service module sets a hook in the second network filtering module, it can periodically query the second network filtering module for the size of network traffic consumed by the second electronic device forwarding the network data packet of the first electronic device.

[0345] In implementation, the second network sharing service module calls the network management service and sends a flow query instruction to the network management service. The network management service calls the second network module and passes the flow query instruction to the second network module. After that, the second network module sends the flow query instruction to the second network filtering module of the kernel protocol stack through the second network management framework.

[0346] Step 1706: In response to the traffic query instruction, the second network filtering module feeds back the network traffic value consumed by the first electronic device in the current query period to the second network sharing service module.

[0347] Since the second network sharing service module queries periodically, in order to avoid repeated reporting, the second network filtering module only reports the size of the network data packet forwarded by the first electronic device counted in the current query period.

[0348] Step 1707: The second network sharing service module stores the P2P address information of the first electronic device and the queried network traffic value in correspondence.

[0349] Step 1708: When the network traffic increment is greater than or equal to the traffic threshold a, the second network sharing service module reports the network traffic value consumed by the first electronic device to the second system service module.

[0350] The flow threshold a can be set according to demand, and the embodiment of the present application does not limit this.

[0351] The network traffic increment refers to the increment of the network traffic value in the time period from the last time the network traffic value was reported to the second system service module to the current time.

[0352] If the network traffic increment is greater than or equal to the traffic threshold a, it means that the network traffic consumed by the first electronic device is large. In this case, the second network sharing service module reports to the second system service module so that the user can be promptly prompted through the second system service module.

[0353] It should be noted that the above is described by taking the second network sharing service module reporting the network traffic value to the second system service module when the network traffic increment is greater than or equal to the traffic threshold a as an example. In another example, the second network sharing service module may also periodically report to the second system service module, and the reporting period may be duration b. As an example but not limitation, duration b is greater than duration a, for example, duration b is 10 minutes.

[0354] It should be noted that the above is described by taking the network where only one first electronic device shares the second electronic device as an example. In another example, if there are multiple first electronic devices sharing the network of the second electronic device, when it is determined that the network traffic increment of the multiple first electronic devices is greater than or equal to the traffic threshold a, the second network sharing service module reports the total network traffic value consumed by the multiple first electronic devices to the second system service module.

[0355] Step 1709: The second system service module displays the network traffic value.

[0356] In this way, the user can check the network traffic consumption in real time from the second electronic device.

[0357] The above description is based on the second electronic device displaying the network traffic consumption. In one example, the user can also query the network traffic consumed by the first electronic device, which may include the following content:

[0358] Step 1710: After receiving the pull-down notification bar operation, the first system service module sends a traffic query instruction c1 to the first network sharing service module.

[0359] It should be noted that the first electronic device is a PAD. Fig.16 In the case where the first electronic device is a PC, after the first system service module receives the user's trigger operation on the traffic consumption query control 1610, it sends a traffic query instruction to the first network sharing service module.

[0360] Step 1711: The first network sharing service module sends a traffic query instruction c1 to the first link module.

[0361] Step 1712: The first link module sends a flow query instruction c1 to the second electronic device through the P2P link.

[0362] In implementation, the first link module can send a traffic query request to the first network filtering module, and the first network filtering module sends a traffic query instruction to the first virtual network card module according to P2P routing, and then the first virtual network card module sends a traffic query instruction to the second electronic device.

[0363] Step 1713: The second link module receives the traffic query instruction c1 through the P2P link.

[0364] In implementation, the second electronic device receives the traffic query instruction c1 through the second virtual network card module, the second virtual network card module sends the traffic query instruction c1 to the second network filtering module, and the second network filtering module sends the traffic query instruction c1 to the second link module.

[0365] Step 1714: the second link module sends a flow query instruction c2 (carrying the P2P address information of the first electronic device) to the second network sharing service module.

[0366] In order to facilitate the second network sharing service module to know which electronic device's network traffic is to be queried, the second link module carries the P2P address information of the first electronic device in the traffic query instruction c2.

[0367] Step 1715: The second network sharing service module obtains the corresponding network traffic value according to the P2P address information of the first electronic device.

[0368] The unit of the traffic value can be KB, MB, etc.

[0369] Since the second network sharing service module stores the P2P address information of the first electronic device in correspondence with the queried network traffic value each time after querying the network traffic value consumed by the first electronic device, when the first electronic device requests to query the amount of network traffic it consumes, the second network sharing service module can obtain the corresponding network traffic value based on the P2P address information of the first electronic device.

[0370] Step 1716: The second network sharing service module sends the queried network traffic value to the second link module.

[0371] Step 1717: The second link module sends the queried network traffic value to the first electronic device.

[0372] In implementation, the second link module sends the queried network traffic value to the second network filtering module, the second network filtering module sends the network traffic value to the second virtual network card module, and then the second virtual network card module sends the network traffic value to the first electronic device.

[0373] It should be noted that there is no strict execution order between the above steps 1708 to 1709 and steps 1710 to 1717.

[0374] Step 1718: After receiving the network traffic value, the first link module sends the network traffic value to the first network sharing service module.

[0375] Step 1719: The first network sharing service module sends the network traffic value to the first system service module.

[0376] Step 1720: The first system service module displays the network traffic value.

[0377] In this way, the user can view the network traffic of the second electronic device consumed by the first electronic device during the network sharing process from the notification bar of the first electronic device.

[0378] In the embodiment of the present application, the second electronic device with network sharing capability is taken as the core, and the network traffic consumed by the first electronic device is counted according to the P2P address information of the connected first electronic device. When the first electronic device queries, the counted network traffic value is sent to the first electronic device for display, which solves the limitation that the traffic management application can only count traffic according to the application dimension, so that the user can know the network traffic consumed by the first electronic device during the network sharing process. Moreover, there is no need for the first electronic device to count separately, so that no matter how many first electronic devices are connected, they can adapt themselves and will not increase the workload of the connected first electronic device.

[0379] Based on the above embodiment, during the network sharing process, if the user turns off the screen of the first electronic device, it means that the user does not use the first electronic device. In this case, the first electronic device can also automatically turn off the network sharing service. For details, please refer to Fig.18 , which may include the following:

[0380] Step 1801: After the first system service module detects the screen-off event, it queries the currently consumed network traffic value Q1 from the second electronic device through the first network sharing service module and starts timing.

[0381] The specific implementation of the first system service module querying the current consumed network traffic value Q1 from the second electronic device through the first network sharing service module can be seen in Fig.17 Steps 1711 to 1719 in the illustrated embodiment will not be described in detail in the embodiment of the present application.

[0382] Step 1802: When the timing duration reaches duration c, the first system service module sends a flow query instruction c1 to the first network sharing service module.

[0383] The duration c can be set according to actual needs, for example, the duration c is 10 minutes.

[0384] That is, when the screen is off, the first system service module queries again the network traffic value consumed by the first electronic device within the duration c through the first network sharing service module.

[0385] Step 1803: The first network sharing service module sends a flow query instruction c1 to the second electronic device through the first link module.

[0386] Step 1804: After receiving the traffic query instruction c1, the second link module sends a traffic query instruction c2 (carrying the P2P address information of the first electronic device) to the second network sharing service module.

[0387] Step 1805: The second network sharing service module determines a network traffic value Q2 consumed by the first electronic device.

[0388] Step 1806: the second network sharing service module sends the queried network traffic value Q2 to the first electronic device through the second link module.

[0389] Step 1807: After receiving the network traffic value Q2, the first link module sends the network traffic value Q2 to the first network sharing service module.

[0390] Step 1808: The first network sharing service module sends the network traffic value Q2 to the first system service module.

[0391] Step 1809: The first system service module determines the increment of network traffic consumed within the duration c.

[0392] In one example, the first system service module subtracts the queried network traffic value Q2 from the queried network traffic value Q1 when the screen is off to obtain a network traffic increment.

[0393] Step 1810: When the first system service module determines that the network traffic increment is less than the traffic threshold b, network sharing is turned off.

[0394] The specific implementation process of turning off network sharing can be found below Fig.19 The embodiment shown.

[0395] It is worth mentioning that when the increase in network traffic consumed by the first electronic device of the second electronic device is less than the traffic threshold b, it means that the first electronic device no longer needs to use the network of the second electronic device. In this case, the first electronic device automatically turns off network sharing, thereby reducing the operating power consumption of the first electronic device, improving battery life, and saving the consumption of network traffic of the second electronic device.

[0396] See also Fig.19 , Fig.19 This is a flow chart of shutting down a network sharing service according to an exemplary embodiment. It mainly includes the following contents:

[0397] Step 1901: The first system service module sends a disconnection instruction to the first network sharing service module.

[0398] The disconnect command is used to instruct to close the network sharing service.

[0399] In one example, when the screen is off, after a period of time c, if it is determined that the incremental network traffic consumed by the first electronic device within the period of time c is less than the traffic threshold b, the first system service module sends a disconnect instruction to the first network sharing service module.

[0400] It should be noted that the above description is based on the example of the first electronic device automatically turning off sharing after the screen is turned off. In another example, when the user does not need the first electronic device to share the network of the second electronic device, the first electronic device can also be actively triggered to turn off network sharing. For example, please refer to Fig.14 Figure (b) or Fig.16 When the user does not need the first electronic device to use the network of the second electronic device, the user can click the "disconnect" control to trigger the first electronic device to disconnect the P2P link between the first electronic device and the second electronic device, thereby closing the network sharing.

[0401] It should be noted that the above is described by taking the example of a user triggering to close network sharing through a first electronic device. In another example, sharing can also be disconnected from a second electronic device, for example, please refer to Figure 2 As shown in Figure (b), the switch control 21 of "network sharing" can be triggered to the off state in the network sharing interface S2 of the second electronic device, thereby turning off the network sharing capability. The specific implementation process is similar to the above and will not be repeated here.

[0402] Step 1902: The first network sharing service module sends a disconnection instruction to the first link module.

[0403] Step 1903: The first link module sends a disconnection instruction to the second electronic device through the P2P link.

[0404] As an example, the first link module sends a disconnection instruction to the first network filter module, and the first network filter module sends a disconnection instruction to the first virtual network card module according to the P2P route. Afterwards, the first virtual network card module sends a disconnection instruction to the second electronic device.

[0405] Step 1904: After a period of time d, the first network sharing service module sends a configuration destruction instruction to the first distributed gateway and sends a channel closing instruction to the first link module.

[0406] The duration d can be set according to requirements, for example, the duration d is 200ms.

[0407] The configuration destroy instruction is used to instruct to destroy the routing configuration of the P2P link.

[0408] The channel closing instruction is used to instruct the closing of a P2P channel.

[0409] As an example of the present application, since the P2P channel is established by the first link module at the instruction of the first network sharing service module, based on the principle of who opens and who closes, the P2P channel can be closed by the first network sharing service module. After 200ms, it can be considered that the disconnection instruction has been sent to the second electronic device. In this case, the first network sharing service module instructs the first link module to disconnect the P2P channel and destroy the P2P route.

[0410] Step 1905: The first distributed gateway destroys the P2P route of the P2P link.

[0411] Step 1906: The first link module closes the P2P channel.

[0412] Step 1907: The first link module sends a channel disconnection notification to the first network sharing service module.

[0413] The channel disconnect notification is used to indicate that the P2P channel has been closed.

[0414] Step 1908: After receiving the channel disconnection notification, the first network sharing service module sends a sharing closing notification to the first system service module.

[0415] The sharing shutdown notification is used to instruct to shut down the sharing service of the network.

[0416] That is, after closing the P2P channel, the first link module may notify the first system service module. In one example, after receiving the sharing closing notification, the first system service module may display the sharing closing notification to prompt the user.

[0417] As an example, after the first network sharing service module sends a sharing shutdown notification to the first system service module, the first network sharing service module goes offline and is pulled up by the first system service when the first electronic device needs to share the network of the second electronic device again. This can reduce the operating power consumption of the first electronic device.

[0418] Step 1909: The second link module receives a disconnection instruction via the P2P link.

[0419] In one example, the second electronic device receives a disconnection instruction through the second virtual network card module, sends the disconnection instruction to the second network filtering module, and the second network filtering module sends the disconnection instruction to the second link module.

[0420] Step 1910: The second link module closes the P2P channel.

[0421] Step 1911: The second link module sends a disconnection instruction to the second network sharing service module.

[0422] Step 1912: The second network sharing service module sends a configuration destruction instruction to the second distributed gateway.

[0423] Step 1913: The second distributed gateway destroys the routing configuration of the P2P link.

[0424] Step 1914: After disconnecting the P2P channel, the second link module sends a channel disconnection notification to the second network sharing service module.

[0425] Step 1915: After receiving the channel disconnection notification, the second network sharing service module sends a sharing closing notification to the second system service module.

[0426] The sharing shutdown notification is used to indicate that the service of sharing the network to the first electronic device has been shut down.

[0427] In one example, after receiving the sharing closing notification, the second system service module may display the sharing closing notification to prompt the user.

[0428] As an example of the present application, for the second electronic device, when network sharing ends, the second network sharing service module deletes the hook set in the second network filtering module. For example, the second network sharing service module can send a hook deletion command to the second network filtering module. The hook deletion command can be iptables-D FORWARD-ssrcIp, iptables-D FORWARD-d dstIp. Correspondingly, the second network sharing service module deletes the hook set on the forwarding chain. In this way, the subsequent statistical work efficiency of the forwarding chain can be improved.

[0429] As an example, after the second network sharing service module sends a sharing shutdown notification to the second system service module, if there are no other electronic devices sharing the network of the second electronic device, the second network sharing service module goes offline and will be passively pulled up when network sharing is needed again in the future. This can reduce the operating power consumption of the second electronic device.

[0430] In an embodiment of the present application, if the first electronic device does not need to access the Internet for a period of time after the screen is turned off, or if an operation of shutting down network sharing triggered by a user is detected, the first electronic device automatically triggers the disconnection of the P2P link and shuts down the network sharing service, which can effectively reduce power consumption and improve battery life.

[0431] Please refer to Fig. 20 , Fig. 20 This is a flow chart of a network sharing method according to another exemplary embodiment. The method is executed by a first electronic device. The first electronic device and a second electronic device log in to the same device account. The method may include part or all of the following contents:

[0432] Step 2001: In response to the distance between the first electronic device and the second electronic device being less than a preset distance, the first electronic device displays a first window including device information of the second electronic device, wherein the second electronic device is currently able to access a network and has a network sharing function enabled.

[0433] The preset distance can at least satisfy the requirement for the first electronic device and the second electronic device to achieve close distance communication. The preset distance can be set according to requirements.

[0434] In one example, the first window is Figure 2 (c) The network sharing window shown in 22 in FIG. 1 , or Figure 6 The network sharing window shown at 60 in (a) of FIG.

[0435] As an example of the present application, the specific implementation of step 2001 may include: in response to the distance between the first electronic device and the second electronic device being less than a preset distance, the first electronic device sends a capability query request to the second electronic device, the capability query request being used to request whether the second electronic device currently has network sharing capability. The first electronic device receives capability information fed back by the second electronic device, the capability information being used to indicate whether the second electronic device currently has network sharing capability. When the capability information indicates that the second electronic device currently has network sharing capability, the first electronic device displays a first window, and displays device information of the second electronic device in the first window.

[0436] For example, the specific implementation process of step 2001 can be found in the above Fig.10 Steps 1003 to 1015 in the illustrated embodiment.

[0437] In this way, after the first electronic device senses the second electronic device, it actively inquires whether the second electronic device has network sharing capabilities, and when the second electronic device has network sharing capabilities, that is, the second electronic device can access the network and the network sharing function is turned on, the first electronic device displays a first window so that the user can directly trigger the first electronic device to share the network of the second electronic device based on the first window, avoiding the need for the user to manually enter the network connection information, improving the convenience of operation, and thus improving the efficiency of network sharing.

[0438] Optionally, before the first electronic device sends a capability query request to the second electronic device, the first link module senses the second electronic device through a self-discovery function and obtains device information of the second electronic device from the second electronic device. The first link module sends a first device online notification to the first device management service module, and the first device online notification carries the device information of the second electronic device. The first device management service module sends a first device online notification to the first system service module. After the first system service module receives the first device online notification, in response to the first electronic device and the second electronic device logging into the same device account and the distance being less than a preset distance, the first system service module sends a capability query request to the second electronic device through the first link module.

[0439] As an example of the present application, the first electronic device displays the first window when the first electronic device is currently unable to access the network. Otherwise, if the first electronic device is currently able to access the network, the first window is not displayed.

[0440] Step 2002: In response to receiving a connection operation for a second electronic device in the first window, the first electronic device establishes a first P2P link with the second electronic device.

[0441] The first P2P link refers to a P2P link established between the first electronic device and the second electronic device.

[0442] In one example, the specific implementation of step 2002 may include: in response to receiving a connection operation for the second electronic device in the first window, the first electronic device sends a channel establishment request to the second electronic device, where the channel establishment request is used to request to establish a P2P channel with the second electronic device. The first electronic device establishes a P2P channel with the second electronic device. After receiving a notification of successful channel establishment sent by the second electronic device, the first electronic device performs routing configuration on the P2P channel to establish a first P2P link.

[0443] In the implementation, the first system service module calls the first network sharing service module in response to receiving a connection operation for the second electronic device in the first window. The first system service module sends a network sharing instruction to the first network sharing service module, and the network sharing instruction carries the device information of the second electronic device. In response to the network sharing instruction, the first network sharing service module sends a channel opening request to the first link module, and the channel opening request carries the device information of the second electronic device. In response to the channel opening request, the first link module sends a channel establishment request to the second electronic device. After the first link module receives the notification of successful channel establishment, it sends the first channel configuration information to the first network sharing service module, and the first channel configuration information includes the information required to configure the P2P channel. The first network sharing service module sends a first configuration indication to the first distributed gateway, and the first configuration indication carries the first channel configuration information. The first distributed gateway performs routing configuration on the P2P channel based on the first channel configuration information to establish a first P2P link.

[0444] Exemplarily, the first channel configuration information is Fig.10 In the embodiment shown, the channel configuration information m2, the first configuration indication is Fig.10 The configuration indication Set2 in the embodiment shown is shown. For specific implementation, please refer to the above Fig.10 Steps 1016 to 1020, and steps 1030 to 1032 in the illustrated embodiment.

[0445] In this way, by establishing the first P2P link to achieve network sharing, the super terminal service and network sharing can share the first P2P link, that is, while sharing the network, the super terminal service can also be achieved, thereby improving the service capability.

[0446] Step 2003: After the first electronic device establishes a first P2P link with the second electronic device, in response to network services, the first electronic device sends a network data packet to be transmitted to the second electronic device via the first P2P link, so that the network data packet is forwarded by the second electronic device.

[0447] For specific implementation, please refer to the above Fig.12 The embodiment shown.

[0448] Optionally, after the first electronic device establishes the first P2P link with the second electronic device, the first electronic device displays a second window, such as Fig.16 As shown in 1600 in FIG. 1 , the second window includes a sharing success notification and a disconnection control. In response to a touch operation on the disconnection control, the first electronic device disconnects the first P2P link between the first electronic device and the second electronic device. For specific implementation, see the above Fig.19 The embodiment shown.

[0449] As an example of the present application, after a first electronic device establishes a first P2P link with a second electronic device, the second electronic device can count the network traffic consumed by the first electronic device, so that the first electronic device can query according to demand. The specific implementation may include the following steps.

[0450] Step 2004: The first electronic device receives a first operation.

[0451] For example, see Fig.14 In Figure (a), the first operation can be to pull down the notification bar. Fig.16 The first operation is to click on the traffic query control 1610 .

[0452] Step 2005: In response to the first operation, the first electronic device sends a first traffic query instruction to the second electronic device via the first P2P link, where the first traffic query instruction is used to request to query the network traffic consumed by the first electronic device on the second electronic device.

[0453] For example, see Fig.17 , the first traffic query instruction may be a traffic query instruction c1.

[0454] In one example, the specific implementation of step 2005 can be found in Fig.17 Steps 1710 to 1712 in the illustrated embodiment.

[0455] Step 2006: The first electronic device receives first network traffic sent by the second electronic device, where the first network traffic is network traffic determined by the second electronic device in response to the first traffic query instruction.

[0456] For its specific implementation, please refer to Fig.17 Steps 1718 to 1719 in the illustrated embodiment.

[0457] Step 2007: The first electronic device displays the first network traffic in a notification bar.

[0458] For its specific implementation, please refer to Fig.17 Step 1720 in the illustrated embodiment.

[0459] Optionally, after the screen of the first electronic device is turned off, if the network traffic increment consumed by the first electronic device from the second electronic device is less than a first network traffic threshold within a preset time period, the first electronic device disconnects the first P2P link with the second electronic device. Fig.18 The first network traffic threshold can be set according to the requirements, for example, the first network traffic threshold is Fig.18 The flow rate threshold b in the illustrated embodiment.

[0460] In an embodiment of the present application, when the first electronic device determines that it can communicate with the second electronic device in close proximity, and the second electronic device currently has network sharing capabilities, the first electronic device displays a network sharing window, and displays the device information of the second electronic device in the network sharing window, so that the user can choose whether to share the network of the second electronic device based on the network sharing window. When the user chooses to connect, the first electronic device establishes a P2P link with the second electronic device, so that the network data packet is sent to the second electronic device through the P2P link during the transmission of the network data packet, and the network of the second electronic device is used for data forwarding. In this way, the user is prevented from manually entering the connection password, which improves the convenience of operation and thus improves the efficiency of network sharing.

[0461] It should be noted that the above is an example of a first electronic device sharing a network of a second electronic device. In another example, the first electronic device, the second electronic device, and the third electronic device are all logged into the same device account. If the distance between the third electronic device and the first electronic device is also less than the preset distance, for example Figure 5 As shown, in this case, the first window also includes the device information of the third electronic device. In response to receiving a connection operation for the third electronic device in the first window, the first electronic device establishes a second P2P link with the third electronic device. After the first electronic device establishes the second P2P link with the third electronic device, in response to the network service, the first electronic device sends a network data packet to the third electronic device through the second P2P link to forward the network data packet through the third electronic device. That is, when the device information of the second electronic device and the device information of the third electronic device are displayed simultaneously in the first window, in response to the second electronic device or the third electronic device selected by the user, the first electronic device shares the network. The specific implementation of the first electronic device sharing the network of the third electronic device can refer to the specific implementation process of the first electronic device sharing the network of the second electronic device, which will not be repeated here.

[0462] Please refer to Fig.21 , Fig.21 This is a flow chart of a network sharing method according to another exemplary embodiment. The method is executed by a second electronic device. The second electronic device and the first electronic device log in to the same device account. The method may include part or all of the following contents:

[0463] Step 2101: When the distance between the second electronic device and the first electronic device is less than a preset distance, if the first electronic device requests network sharing, the second electronic device establishes a first P2P link with the first electronic device, wherein the second electronic device can currently access the network and the network sharing function is turned on.

[0464] For its specific implementation, please refer to Fig.10 Steps 1021 to 1029 in the illustrated embodiment.

[0465] Step 2102: After the second electronic device establishes a first P2P link with the first electronic device, the second electronic device receives a network data packet to be transmitted sent by the first electronic device through the first P2P link.

[0466] The specific implementation can be found in the above Fig.12 Step 1209 in the illustrated embodiment.

[0467] Step 2103: The second electronic device forwards the network data packet.

[0468] The specific implementation can be found in the above Fig.12 Steps 1210 to 1212 in the illustrated embodiment.

[0469] Optionally, before establishing the first P2P link with the first electronic device, the second electronic device may also enable network sharing capability. Specifically, the second electronic device displays a first interface, which includes a network sharing setting control. In response to a touch operation on the network sharing setting control on the first interface, the second electronic device displays a second interface, which includes a network sharing switch control. In response to a turn-on operation on the network sharing switch control on the second interface, the second electronic device enables the network sharing function.

[0470] For example, see Figure 2 , the first interface is as follows Figure 2 As shown in S1 in Figure (a), the network sharing setting control is as follows Figure 2 The second interface is shown in (a) of the figure. Figure 2 As shown in S2 in Figure (b), the network sharing switch control is as follows Figure 2 As shown in (b) of Figure 21.

[0471] As an example of the present application, when the distance between the second electronic device and the first electronic device is less than the preset distance, if the first electronic device requests network sharing, then after the second electronic device establishes a first P2P link with the first electronic device, it also includes: the second electronic device sets a hook according to the P2P address information of the first electronic device, and the second electronic device uses the hook to count the network traffic consumed by the first electronic device according to the P2P address information of the first electronic device in the forwarded network data packet. When receiving the traffic query instruction sent by the first electronic device, the second electronic device queries the corresponding network traffic value according to the P2P address information of the first electronic device to obtain the first network traffic value. The second electronic device sends the first network traffic value to the first electronic device. For its specific implementation, please refer to Fig.17 The embodiment shown.

[0472] As an example of the present application, when the network traffic increment of the current query is greater than the second network traffic threshold, the second electronic device displays the first network traffic value consumed by the first electronic device.

[0473] In an embodiment of the present application, when the first electronic device determines that it can communicate with the second electronic device in close proximity, and the second electronic device currently has network sharing capabilities, the first electronic device displays a network sharing window, and displays the device information of the second electronic device in the network sharing window, so that the user can choose whether to share the network of the second electronic device based on the network sharing window. When the user chooses to connect, the first electronic device establishes a P2P link with the second electronic device, so that the network data packet is sent to the second electronic device through the P2P link during the transmission of the network data packet, and the network of the second electronic device is used for data forwarding. In this way, the user is prevented from manually entering the connection password, which improves the convenience of operation and thus improves the efficiency of network sharing.

[0474] Fig. 22 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, and the electronic device may be the first electronic device or the second electronic device in each of the above embodiments. Fig. 22 The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0475] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0476] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0477] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0478] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0479] In some embodiments, the processor 110 may include one or more interfaces, such as an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0480] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0481] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device 100 through the power management module 141.

[0482] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193 and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0483] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0484] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0485] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0486] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0487] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. GNSS may include the global positioning system (GPS), the global navigation satellite system (GLONASS), the Beidou navigation satellite system (BDS), the quasi-zenith satellite system (QZSS) and / or the satellite based augmentation system (SBAS).

[0488] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0489] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is an integer greater than 1.

[0490] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0491] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0492] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created by the electronic device 100 during use (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0493] The electronic device 100 can implement audio functions, such as music playback, recording, etc., through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D and the application processor.

[0494] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor 180K can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0495] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is an integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0496] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (such as: coaxial cable, optical fiber, data subscriber line (Digital Subscriber Line, DSL)) or wireless (such as: infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a digital versatile disc (DVD)), or a semiconductor medium (such as a solid state disk (SSD)).

[0497] The above are optional embodiments provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the technical scope disclosed in the present application shall be included in the protection scope of the present application.

Claims

1. A network sharing method, characterized in that: Applied to a first electronic device, where the first electronic device and a second electronic device log in to the same device account, the method includes: In response to the distance between the first electronic device and the second electronic device being less than a preset distance, the first electronic device displays a first window, the first window including device information of the second electronic device, wherein the second electronic device is currently able to access a network and has a network sharing function enabled; In response to receiving a connection operation for the second electronic device in the first window, the first electronic device establishes a first P2P link with the second electronic device; After the first electronic device establishes the first P2P link with the second electronic device, in response to network services, the first electronic device sends a network data packet to be transmitted to the second electronic device through the first P2P link, so that the network data packet is forwarded by the second electronic device.

2. The method according to claim 1, characterized in that The method further comprises: After the first electronic device establishes the first P2P link with the second electronic device, the first electronic device displays a second window, wherein the second window includes a sharing success and a disconnection control; In response to the operation on the disconnection control, the first electronic device disconnects the first P2P link between the first electronic device and the second electronic device.

3. The method according to claim 1 or 2, characterized in that In response to the distance between the first electronic device and the second electronic device being less than a preset distance, the first electronic device displays a first window, comprising: In response to the distance between the first electronic device and the second electronic device being less than the preset distance, the first electronic device sends a capability query request to the second electronic device, wherein the capability query request is used to query whether the second electronic device currently has a network sharing capability; The first electronic device receives capability information fed back by the second electronic device, where the capability information is used to indicate whether the second electronic device currently has a network sharing capability; When the capability information indicates that the second electronic device currently has the network sharing capability, the first electronic device displays the first window and displays device information of the second electronic device in the first window.

4. The method according to any one of claims 1 to 3, characterized in that In response to receiving a connection operation for the second electronic device in the first window, the first electronic device establishing a first P2P link with the second electronic device includes: In response to receiving a connection operation for the second electronic device in the first window, the first electronic device sends a channel establishment request to the second electronic device, where the channel establishment request is used to request to establish a P2P channel with the second electronic device; The first electronic device establishes the P2P channel with the second electronic device; After receiving the notification of successful channel establishment sent by the second electronic device, the first electronic device performs routing configuration on the P2P channel to establish the first P2P link.

5. The method according to claim 4, characterized in that The first electronic device includes a first system service module, a first network sharing service module, a first link module, and a first distributed gateway; In response to receiving a connection operation for the second electronic device in the first window, the first electronic device sending a channel establishment request to the second electronic device includes: The first system service module calls the first network sharing service module in response to receiving a connection operation for the second electronic device in the first window; The first system service module sends a network sharing instruction to the first network sharing service module, wherein the network sharing instruction carries device information of the second electronic device; In response to the network sharing instruction, the first network sharing service module sends a channel opening request to the first link module, wherein the channel opening request carries device information of the second electronic device; In response to the channel opening request, the first linking module sends the channel establishing request to the second electronic device; After receiving the notification of successful channel establishment sent by the second electronic device, the first electronic device performs routing configuration on the P2P channel to establish the first P2P link, including: After receiving the notification of successful establishment of the channel, the first link module sends first channel configuration information to the first network sharing service module, where the first channel configuration information includes information required to configure the P2P channel; The first network sharing service module sends a first configuration indication to the first distributed gateway, where the first configuration indication carries the first channel configuration information; The first distributed gateway performs routing configuration on the P2P channel based on the first channel configuration information to establish the first P2P link.

6. The method according to claim 3, characterized in that The first electronic device includes a first system service module, a first device management service module and a first link module; The method further comprises: In response to the distance between the first electronic device and the second electronic device being less than the preset distance, the first link module senses the second electronic device through a self-discovery function and acquires device information of the second electronic device from the second electronic device; The first link module sends a first device online notification to the first device management service module, wherein the first device online notification carries device information of the second electronic device; The first device management service module sends a first device online notification to the first system service module; In response to the distance between the first electronic device and the second electronic device being less than the preset distance, the first electronic device sending a capability query request to the second electronic device includes: After receiving the online notification of the first device, the first system service module sends the capability query request to the second electronic device through the first link module.

7. The method according to any one of claims 1 to 6, characterized in that After the first electronic device and the second electronic device establish the first P2P link, in response to a network service, the first electronic device sends a network data packet to be transmitted to the second electronic device through the first P2P link, further comprising: The first electronic device receives a first operation; In response to the first operation, the first electronic device sends a first traffic query instruction to the second electronic device through the first P2P link, where the first traffic query instruction is used to request to query the network traffic consumed by the first electronic device by the second electronic device; The first electronic device receives first network traffic sent by the second electronic device, where the first network traffic is network traffic determined by the second electronic device in response to the first traffic query instruction; The first electronic device displays the first network traffic in a notification bar.

8. The method according to claim 7, characterized in that The method further comprises: After the screen of the first electronic device is turned off, if the incremental network traffic consumed by the first electronic device from the second electronic device is less than a first network traffic threshold within a preset time period, the first electronic device disconnects the first P2P link with the second electronic device.

9. The method according to any one of claims 1 to 8, characterized in that The method further comprises: The first electronic device performs a collaborative service with the second electronic device through the first P2P link, and the collaborative service includes any one or more of the following: Screen projection service, wherein the screen projection service refers to projecting the user interface of the first electronic device onto the screen of the second electronic device for display, and allowing the user to operate the user interface of the first electronic device in the second electronic device, and to perform specified operations in the second electronic device; A keyboard and mouse collaboration service, wherein the keyboard and mouse collaboration service means that the first electronic device and the second electronic device can share each other's input device; A call collaboration service, wherein the call collaboration service refers to synchronously displaying an incoming call interface on the second electronic device when the first electronic device receives an incoming voice call or video call; The notification cooperation service refers to synchronously displaying the notification message in the second electronic device when the first electronic device receives the notification message.

10. The method according to any one of claims 1 to 9, characterized in that Before the first electronic device establishes the first P2P link with the second electronic device, the first electronic device cannot access a network.

11. The method according to any one of claims 1 to 5, characterized in that The first electronic device, the second electronic device, and the third electronic device are logged into the same device account, the distance between the first electronic device and the third electronic device is less than the preset distance, the third electronic device is currently able to access the network and the network sharing function is turned on, and the first window also includes device information of the third electronic device.

12. The method according to claim 11, characterized in that The method further comprises: In response to receiving a connection operation for the third electronic device in the first window, the first electronic device establishes a second P2P link with the third electronic device; After the first electronic device establishes the second P2P link with the third electronic device, in response to network services, the first electronic device sends the network data packet to the third electronic device through the second P2P link, so that the network data packet is forwarded by the third electronic device.

13. A network sharing method, characterized in that: Applied to a second electronic device, where the second electronic device and the first electronic device are logged into the same device account, the method includes: When the distance between the second electronic device and the first electronic device is less than a preset distance, if the first electronic device requests network sharing, the second electronic device establishes a first P2P link with the first electronic device, wherein the second electronic device is currently able to access the network and has a network sharing function enabled; After the second electronic device establishes the first P2P link with the first electronic device, the second electronic device receives the network data packet to be transmitted sent by the first electronic device through the first P2P link; The second electronic device forwards the network data packet.

14. The method according to claim 13, characterized in that The method further comprises: The second electronic device displays a first interface, wherein the first interface includes a network sharing setting control; In response to a touch operation on the network sharing setting control on the first interface, the second electronic device displays a second interface, wherein the second interface includes a network sharing switch control; In response to the turning on operation of the network sharing switch control in the second interface, the second electronic device turns on the network sharing function.

15. The method according to claim 13, characterized in that The second electronic device includes a second network sharing service module, a second link module, and a second distributed gateway; The method of establishing a first P2P link between the second electronic device and the first electronic device when the distance between the second electronic device and the first electronic device is less than a preset distance and the first electronic device requests network sharing comprises: When the distance between the second electronic device and the first electronic device is less than the preset distance, the second link module receives a channel establishment request from the first electronic device; In response to the channel establishment request, the second link module establishes a P2P channel with the first electronic device; After the second link module successfully builds the P2P channel, the second link module sends second channel configuration information to the second network sharing service module, where the second channel configuration information includes information required to configure the P2P channel; The second network sharing service module sends a second configuration indication to the second distributed gateway, where the second configuration indication carries the second channel configuration information; The second distributed gateway performs routing configuration on the P2P channel based on the second channel configuration information to establish the first P2P link.

16. The method according to claim 15, characterized in that The second electronic device includes a second virtual network card module and a second network filtering module, and the second virtual network card module is created during the process of establishing the P2P channel; The second electronic device receives, through the first P2P link, a network data packet to be transmitted sent by the first electronic device, including: The second virtual network card module receives the network data packet; The second virtual network card module sends the network data packet to the second network filtering module; The second electronic device forwards the network data packet, including: The second network filtering module analyzes the network data packet to obtain an analysis result; After the second network filtering module determines, based on the analysis result, that the destination address of the network data packet is not the second electronic device, the second network filtering module forwards the network data packet.

17. The method according to any one of claims 13 to 16, characterized in that In the case where the distance between the second electronic device and the first electronic device is less than a preset distance, if the first electronic device requests network sharing, after the second electronic device and the first electronic device establish a first P2P link, the method further includes: The second electronic device sets a hook according to the P2P address information of the first electronic device; The second electronic device collects statistics of the network traffic consumed by the first electronic device according to the P2P address information of the first electronic device in the forwarded network data packet through the hook; When receiving the traffic query instruction sent by the first electronic device, the second electronic device queries the corresponding network traffic value according to the P2P address information of the first electronic device to obtain the first network traffic value; The second electronic device sends the first network traffic value to the first electronic device.

18. The method according to claim 17, characterized in that The method further comprises: When the network traffic increment currently being queried is greater than a second network traffic threshold, the second electronic device displays the first network traffic value consumed by the first electronic device.

19. The method according to claim 17, characterized in that The second electronic device includes a second network sharing service module and a second network filtering module; The second electronic device sets a hook according to the P2P address information of the first electronic device, including: The second network sharing service module constructs the hook based on the P2P address information of the first electronic device; The second network sharing service module sets the hook in the second network filtering module, so that the second network filtering module counts the network traffic consumed by the first electronic device according to the P2P address information of the first electronic device through the hook.

20. A network sharing system, characterized in that: The network sharing system includes a first electronic device and a second electronic device, wherein the first electronic device and the second electronic device log in to the same device account, including: The first electronic device is configured to display a first window in response to a distance between the first electronic device and the second electronic device being less than a preset distance, wherein the first window includes device information of the second electronic device, wherein the second electronic device is currently able to access a network and has a network sharing function enabled; The first electronic device is configured to establish a first P2P link with the second electronic device in response to receiving a connection operation for the second electronic device in the first window; The second electronic device is configured to establish the first P2P link with the first electronic device after the first electronic device requests network sharing; The first electronic device is configured to send a network data packet to be transmitted to the second electronic device via the first P2P link in response to a network service; The second electronic device is used to forward the network data packet after receiving the network data packet through the first P2P link.

21. An electronic device, characterized in that: The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method according to any one of claims 1 to 12, or implements the method according to any one of claims 13 to 19.

22. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 12, or implement the method according to any one of claims 13 to 19.