Network sharing method and related equipment

By controlling the P2P link between electronic devices through a state machine, the problems of device inability to connect and cumbersome operation in multi-device network sharing are solved, realizing low-latency and low-power network sharing, improving user experience and the flexibility of network sharing between devices.

CN121815449APending Publication Date: 2026-04-07HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

When a user has multiple electronic devices, some devices may not be able to connect to the network on their own, especially in environments without WiFi, resulting in the devices being unable to access the internet. Existing network sharing methods suffer from poor security and cumbersome operation.

Method used

By establishing P2P links between electronic devices through state machine control, network sharing can be achieved without sharing password information, supporting any type of network sharing, and handling complex network sharing scenario switching through state machine state transitions.

Benefits of technology

It achieves low-latency, low-power network sharing, supports flexible network state switching, improves user experience, and reduces device power consumption and traffic consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121815449A_ABST
    Figure CN121815449A_ABST
Patent Text Reader

Abstract

The invention discloses a network sharing method and related equipment, and belongs to the technical field of terminals. Comprising the steps that when a state machine of first electronic equipment is in a client idle state, in response to an internet access demand event of the first electronic equipment, the state machine triggers to send a first query request to second electronic equipment, and when the state machine is in the client idle state, the first electronic equipment is in a non-networking state; after a first query response of the second electronic equipment is received, the state machine triggers to establish a first P2P link with the second electronic equipment, the first P2P link is used for the first electronic equipment to share a first network of the second electronic equipment, and the first query response indicates that the second electronic equipment has the network sharing capability at present; and the state machine is transferred from the client idle state to the client connection state. According to the method and the device, the P2P link is triggered to be established between the first electronic equipment and the second electronic equipment through the state machine to realize network sharing, password information sharing among the equipment is not needed, and sharing of any type of network is supported.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of terminal, in particular to a network sharing method and related equipment. BACKGROUND

[0002] With the rapid development of terminal technology, electronic devices such as mobile phones, tablets, and notebooks are emerging in an endless stream. A user can usually have multiple electronic devices at the same time, and these electronic devices can usually achieve near field communication through Bluetooth and the like.

[0003] In some scenarios, a user can need to connect multiple electronic devices to a network. However, one or more electronic devices can not be able to autonomously connect to the network. For example, a tablet computer only supports connecting to a wireless fidelity (WiFi) network, and if there is no WiFi network in the scenario, the tablet computer will not be able to access the network. SUMMARY

[0004] The present application provides a network sharing method and related equipment, which can control network sharing between electronic devices through a state machine, so that the electronic devices can be normally connected to a network. The technical solution is as follows:

[0005] In a first aspect, a network sharing method is provided, applied to a first electronic device, the first electronic device comprising a state machine, and the method comprising:

[0006] When the state machine is in a client idle state, in response to an online demand event of the first electronic device, the state machine triggers sending a first query request to a second electronic device, and the first electronic device is in an unconnected state when the state machine is in the client idle state; after receiving a first query response of the second electronic device, the state machine triggers establishing a first P2P link with the second electronic device, the first P2P link being used for the first electronic device to share a first network of the second electronic device, and the first query response indicating that the second electronic device currently has network sharing capability; and after the first P2P link is successfully established, the state machine is transferred from the client idle state to a client connected state.

[0007] In one example, the online demand event includes the first electronic device being online, the first electronic device being unlocked and screen-on, or a white-list application being opened, and the like.

[0008] The first query request is used to request querying whether the second electronic device currently has network sharing capability, and the first query request is exemplarily QUERY1.

[0009] The first query response is a REPLY message fed back by the second electronic device to the first electronic device according to the current state of the second electronic device after receiving the first query response.

[0010] The first P2P link is a P2P link between the first electronic device and the second electronic device.

[0011] In this way, network sharing is achieved without sharing password information, and any type of network can be shared.

[0012] Through state machine control, the electronic device can act as a service provider and a service receiver, and the capabilities of the client and the server are unified, which facilitates maintenance, and because it is implemented in one module, that is, through a state machine module event, the time delay is low, and because cross-process implementation is not required, the power consumption of the electronic device can be reduced.

[0013] In addition, whether as a service provider or a service receiver, the state of network sharing can be flexibly switched, and complete network sharing multi-scene coverage capabilities are constructed.

[0014] In addition, the network sharing capability architecture provided by the embodiments of the present application is easy to extend, for example, when other requirements exist, only the input conditions need to be increased, and the state transition of the state machine needs to be controlled.

[0015] As an example of the present application, after receiving the first query response of the second electronic device, the state machine triggers the establishment of the first P2P link between the first electronic device and the second electronic device, including: after receiving the first query response, the state machine triggers the display of network sharing prompt information; in response to a first operation on the network sharing prompt information, the state machine triggers the establishment of the first P2P link between the first electronic device and the second electronic device.

[0016] In this way, by displaying network sharing prompt information to the user, after receiving the first operation of the user, the state machine triggers the establishment of the first P2P link between the first electronic device and the second electronic device, that is, a network sharing recommendation service is provided, and the user authorizes the link establishment, thereby improving the user experience.

[0017] As an example of the present application, the method further includes: when the state machine is in the client connection state, in response to a shared network disconnection event, the state machine transitions from the client connection state to the client idle state.

[0018] In this way, after the shared network is disconnected, the state machine performs state transition, that is, transitions to the client idle state, so that the state machine triggers the next network sharing.

[0019] As an example of the present application, the method further includes: when the state machine is in the client connection state, in response to a shared network trigger event, the state machine triggers the display of first prompt information, the shared network trigger event refers to a request to share the network with a third electronic device that is not connected to a network, and the first prompt information is used to prompt that the current operation is not supported, and the third electronic device and the first electronic device can communicate in a near field.

[0020] For example, the trust circle includes the first electronic device, the second electronic device, and the third electronic device, during the first electronic device is sharing the network of the second electronic device, the user drags and drops the network sharing service card to the device icon of the third electronic device on the trust circle display interface of the first electronic device and releases, in this case, the first electronic device displays the first prompt information.

[0021] In this way, in the case that the first electronic device is sharing the network of the second electronic device, cascading sharing is not supported, that is, the network is not shared to the third electronic device, so as to avoid too much cascading leading to excessive consumption of the second electronic device.

[0022] As an example of the present application, the method further comprises: when the state machine is in the client idle state, if the first electronic device switches from the unconnected state to the connected state, the state machine transfers from the client idle state to the server idle state, and triggers to broadcast the first network change message, the first network change message is used to indicate that the first electronic device currently has network sharing capability.

[0023] Exemplarily, the first network change message is UPDATE1.

[0024] In this way, in the case that the first electronic device is connected to the network, the first network change message is broadcasted to push the network sharing service to other unconnected electronic devices, and since the state machine transfers to the server idle state, when other electronic devices request network sharing, the state machine can directly trigger the first electronic device to share the network with other electronic devices in the server idle state.

[0025] As an example of the present application, the method further comprises: when the state machine is in the client connection state, if the first electronic device connects to the second network, and the second network is a mobile data network, the state machine triggers to disconnect the first P2P link, transfers from the client connection state to the server idle state, and triggers to broadcast the first network change message, the first network change message is used to indicate that the first electronic device currently has network sharing capability, and the second network is not the shared network.

[0026] For example, the mobile data network is a 5G network.

[0027] In this way, in the case that the first electronic device shares the network of the second electronic device, if it is connected to the mobile data network, since the mobile data network is relatively stable and the transmission speed is usually accelerated, the state machine can trigger the first electronic device to disconnect the network sharing service and transfer to the server idle state, so as to be able to share the network for other unconnected electronic devices.

[0028] As an example of the present application, the method further comprises: in response to a network disconnection event, the state machine triggers broadcasting of a second network change message when the state machine is in the server idle state, the second network change message being used to indicate that the first electronic device currently does not have the network sharing capability, the network disconnection event being that the first electronic device switches from a network-connected state to a network-unconnected state; and the state machine transitions from the server idle state to the client idle state.

[0029] The second network change message is an UPDATE message, but the UPDATE message at this time is used to indicate that the first electronic device currently does not have the network sharing capability.

[0030] In this way, in the case where the first electronic device is not connected to a network, the second network change message is broadcasted to make the electronic device that is ready to share the network of the first electronic device know that it has been unable to share the network. In addition, the state machine transitions from the server idle state to the client idle state to wait for an input condition to satisfy a network sharing condition, and then triggers the first electronic device to share the network of the other electronic device.

[0031] As an example of the present application, the method further comprises: in response to a network sharing event, the state machine triggers establishment of a second P2P link with a fourth electronic device if the network to which the first electronic device is connected is a WiFi network when the state machine is in the server idle state, the network sharing event being that the fourth electronic device shares a third network with the first electronic device, and the fourth electronic device and the first electronic device being capable of near field communication. After the second P2P link is successfully established, the state machine transitions from the server idle state to the client connected state.

[0032] The second P2P link is a P2P link between the first electronic device and the fourth electronic device.

[0033] In this way, since the first electronic device can not be able to access the network when the network to which the first electronic device is connected is a WiFi network, the first electronic device can share the network of the other electronic device when there is another electronic device sharing the network with the first electronic device, the state machine transitions from the server idle state to the client connected state, and at this time the first electronic device does not have the network sharing capability.

[0034] As an example of the present application, the method further comprises: in response to a second query request, the state machine triggers sending of a second query response to a fifth electronic device when the state machine is in the server idle state, the second query request being sent by the fifth electronic device and being used to request querying whether the first electronic device currently has the network sharing capability, the fifth electronic device and the first electronic device being capable of near field communication; in response to a link establishment request, the state machine triggers establishment of a third P2P link with the fifth electronic device; and the state machine transitions from the server idle state to the server connected state.

[0035] The second query request is a QUERY message.

[0036] The third P2P link is a P2P link between the first electronic device and a fifth electronic device.

[0037] In this way, the third P2P link is established between the first electronic device and the fifth electronic device, so that the network of the first electronic device is shared with the fifth electronic device.

[0038] As an example of the present application, the method further comprises: when the state machine is in the server connection state, in response to a network disconnection event, the state machine triggers broadcasting of a second network change message and triggering disconnection of the third P2P link, the second network change message being used to indicate that the first electronic device currently does not have network sharing capability, and the network disconnection event being that the first electronic device switches from a networked state to an un-networked state; and the state machine transitions from the server connection state to a client idle state.

[0039] In this way, in the case of network disconnection of the first electronic device, the state machine transitions to the idle state, so as to subsequently trigger the first electronic device to share the network of other electronic devices.

[0040] As an example of the present application, the method further comprises: when the state machine is in the server connection state, in response to a device high-temperature change event, the state machine triggers broadcasting of a second network change message and triggering disconnection of the third P2P link, the second network change message being used to indicate that the first electronic device currently does not have network sharing capability; and the state machine transitions from the server connection state to a server idle state.

[0041] In this way, when the temperature of the electronic device is too high, the third P2P link is disconnected to disconnect the network sharing service, so as to reduce the power consumption of the first electronic device. Moreover, the state machine transitions from the server connection state to the server idle state, so as to subsequently continue to trigger the first electronic device to share the network after the temperature of the first electronic device decreases.

[0042] As an example of the present application, the method further comprises: when the state machine is in the server idle state, in response to a device low-temperature change event, the state machine triggers broadcasting of a first network change message. In this way, after the state machine transitions from the server connection state to the server idle state, when the temperature of the first electronic device decreases, the state machine triggers the first electronic device to broadcast the first network change message, so that un-networked electronic devices in the trust circle know that the first electronic device currently has network sharing capability.

[0043] As an example of the present application, the method further comprises: when the state machine is in the service end connection state, in response to a third query request, the state machine determines a number of devices currently sharing the fourth network of the first electronic device, the third query request being sent by a sixth electronic device and used to query whether the first electronic device currently has a network sharing capability, the sixth electronic device being capable of near field communication with the first electronic device; and when the number of devices is less than or equal to a preset number, the state machine triggers sending of a third query response to the sixth electronic device, the third query response being used to indicate that the first electronic device currently has the network sharing capability.

[0044] The third query request is a QUERY message.

[0045] In this way, by limiting the number of devices sharing the network, it is possible to avoid excessive power consumption of the electronic device sharing the network, and to avoid excessive traffic of the electronic device sharing the network.

[0046] As an example of the present application, the method further comprises: when the state machine is in the initial state, in a case where the service switch has been turned on and the first electronic device is not connected to a network, the state machine is transferred from the initial state to the client idle state, the service switch being used to trigger turning on or off of a network sharing service.

[0047] In this way, when the state machine is in the initial state and the service switch has been turned on and the first electronic device is not connected to a network, by triggering the state machine to be transferred from the initial state to the client idle state to wait for an input condition to meet a triggering condition of network sharing, the state machine triggers the first electronic device to share the network of the second electronic device.

[0048] As an example of the present application, the method further comprises: when the state machine is in the initial state, in a case where the service switch has been turned on and the first electronic device is in a connected state, the state machine is transferred from the initial state to the service end idle state.

[0049] In this way, when the state machine is in the initial state and the service switch has been turned on and the first electronic device is in a connected state, by controlling the state machine to be transferred from the initial state to the service end idle state to wait for an input condition to meet a triggering condition of network sharing, the state machine triggers the first electronic device to share the network.

[0050] As an example of the present application, the method further comprises: when the state machine is in any one of a plurality of states, in a case where the service switch is switched from an on state to an off state, the state machine is transferred from the any one of the plurality of states to the initial state, the plurality of states including the client idle state, the client connection state, the service end idle state and the service end connection state.

[0051] Thus, in the network sharing process, if the service switch is switched from the on state to the off state, the state machine can be transferred from any state machine to the initial state, so as to close the network sharing service and wait for the next opening.

[0052] In a second aspect, an electronic device is provided, including one or more processors, and a memory; the memory is coupled with the one or more processors, and is configured to store computer program codes, the computer program codes including computer instructions, and the one or more processors are configured to invoke the computer instructions to enable the electronic device to perform the network sharing method according to any one of the first aspect.

[0053] In a third aspect, a chip system is provided, which is applied to an electronic device, and includes one or more processors, and the one or more processors are configured to invoke computer instructions to enable the electronic device to perform the network sharing method according to any one of the first aspect.

[0054] In a fourth aspect, a computer readable storage medium is provided, which includes instructions, and when the instructions are run on an electronic device, enable the electronic device to perform the network sharing method according to any one of the first aspect.

[0055] In a fifth aspect, a computer program product is provided, which includes instructions, and when the instructions are run on a computer, enable the computer to perform the network sharing method according to the first aspect.

[0056] The technical effects obtained by the second aspect, the third aspect, the fourth aspect and the fifth aspect are similar to the technical effects obtained by the corresponding technical means in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS

[0057] Figure 1 is a schematic diagram of an application scenario according to an example embodiment;

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

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

[0060] Figure 4 is a schematic diagram of a state diagram according to an example embodiment;

[0061] Figure 5 is a schematic diagram of a network sharing architecture according to an example embodiment;

[0062] Figure 6 is a schematic diagram of a software system of an electronic device according to an example embodiment;

[0063] Figure 7 is a flowchart of a network sharing method according to an example embodiment;

[0064] Figure 8 is a flowchart of a network sharing method according to another example embodiment;

[0065] Figure 9 is an architectural diagram of an electronic device according to an example embodiment. DETAILED DESCRIPTION

[0066] In order to make the objects, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.

[0067] It should be understood that the "multiple" mentioned in the present application refers to two or more than two. In the description of the present application, unless otherwise specified, " / " represents the meaning of or, for example, A / B can represent A or B; "and / or" in the present application is only a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone. In addition, in order to clearly describe the technical solutions of the present application, the same items or similar items with basically the same function and role are distinguished by using "first", "second", etc. The skilled in the art can understand that "first", "second", etc. do not limit the quantity and execution order, and "first", "second", etc. also do not limit the difference.

[0068] In the present application, the reference to "one embodiment" or "some embodiments" means that the specific features, structures or characteristics described in connection with the embodiment are included in one or more embodiments of the present application. Therefore, the statements "in one embodiment", "in some embodiments", "in other some embodiments", "in other some embodiments" and the like appearing in different places in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. The terms "include", "contain", "have" and their variants mean "include but not limited to", unless otherwise specifically emphasized.

[0069] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.

[0070] At present, there are various types of electronic devices, and a user usually has multiple electronic devices, such as mobile phones, tablet computers, and notebook computers. Multiple electronic devices can log in to the same device account (such as a Honor account), and in this case, the multiple electronic devices can realize near field communication through Bluetooth and the like. In some embodiments, the multiple electronic devices are referred to as forming a trust ring, or the electronic devices are referred to as being online.

[0071] In some scenarios, a user can need to connect multiple electronic devices to a network. Usually, the user needs to perform operations on each of the multiple electronic devices to trigger each electronic device to connect to the network. For example, an electronic device supports connecting to a WiFi network, and the user needs to input WiFi connection information on the electronic device, and trigger the electronic device to connect to the WiFi network, wherein the WiFi connection information includes a WiFi password and can also include a WiFi account. In this way, the operation is relatively cumbersome, and if an electronic device only supports connecting to a WiFi network, but a WiFi network is not deployed in the current scenario, the electronic device cannot access the network.

[0072] In some embodiments, the electronic device provides a network sharing service, so that network sharing can be realized between electronic devices. The network sharing service refers to a service of sharing a network from a service provider to a service receiver. The service provider is an electronic device that is connected to a network, such as a WiFi network or a mobile data network (such as a 5G network); the service receiver is an electronic device that is not connected to a network. In some examples, the service provider can share the network with the service receiver through a hot spot sharing manner, such as sharing a 5G network connected by the service provider to the service receiver. In other examples, the service provider can share the network with the service receiver through a password sharing manner, such as sharing a WiFi password of a WiFi network connected by the service provider to the service receiver, so that the service receiver connects to the WiFi network connected by the service provider based on the WiFi password, thereby realizing network sharing.

[0073] However, sharing the network in a hotspot sharing manner only supports sharing the mobile data network, resulting in limited network sharing services. Sharing the network in a password sharing manner has relatively poor security because the WiFi password needs to be shared between devices, i.e., WiFi password transmission is required, and information leakage is likely to occur during the transmission process.

[0074] To this end, an embodiment of the present application provides a network sharing method. The method controls the establishment of a P2P link between a service provider and a service receiver by using a state machine, so that the service receiver can use the P2P link to access the network through the network of the service provider, i.e., network sharing is achieved. The network connected by the service provider can be any type of network, which can be understood as that the service provider can share any type of network for the service receiver, and does not need to share password information. In addition, the control by the state machine can enable the electronic device to handle complex network sharing scenario switching.

[0075] As an example, the service provider can provide the service receiver with network query capability, network connection capability, and active recommendation capability. The network query capability means that the service receiver can query whether the service provider has network sharing capability; the network connection capability means that the service provider can share the network with the service receiver; and the active recommendation capability means that the service provider can actively recommend the network connected by the service provider to the service receiver.

[0076] Correspondingly, the service receiver can provide the user with active recommendation of flow service, display of available network service, and initiation of connection capability of network sharing service. The active recommendation of flow service means that the network sharing service is recommended to the user through a pop-up window or the like; the display of available network service means that the network connected by the service provider can be displayed in a network list; and the initiation of connection capability of network sharing service means that the user is supported to trigger the sharing of the network of the service provider by the service receiver.

[0077] As an example of the present application, the service provider can be a mobile phone, and can also be an electronic device such as a tablet computer or a notebook computer. The service receiver can also be a mobile phone, a tablet computer, a notebook computer, or the like, and the embodiments of the present application do not limit this. For example, a mobile phone connected to a mobile data network can share the mobile data network with another mobile phone that is not connected to a network, and a tablet computer connected to a WiFi network can share the WiFi network with a mobile phone that is not connected to a network.

[0078] The multiple electronic devices involved in the embodiments of the present application form a trust ring, e.g., multiple electronic devices log in to the same device account and can perform near field communication through Bluetooth or the like. On this basis, the application scenarios involved in the embodiments of the present application are introduced through the following examples:

[0079] As an example, the electronic device A is in a networked state, and the electronic device B is in an un-networked state. After the electronic device A forms a trust circle with the electronic device B, the electronic device B can actively query whether the electronic device A has a network sharing capability. If the electronic device A has the network sharing capability, the electronic device B recommends a network sharable by the electronic device A to the user. For example, refer to Figure 1 , Figure 1 is a schematic diagram of an application scenario according to an example embodiment. After the electronic device B opens an application program (such as Xiaohongshu) or unlocks the screen, the electronic device B can actively query whether the electronic device A has a network sharing capability. If it is determined that the electronic device A has the network sharing capability, the electronic device B can display a network sharing prompt information. For example, as shown in 10 of Figure 1 , the electronic device B displays the network sharing prompt information in the form of a side bar capsule, which includes a prompt information of "discover available network" and a "connect" control 101. In response to a click operation of the "connect" control 101 by the user, a P2P link is established between the electronic device B and the electronic device A, so that the electronic device B realizes online access through the electronic device A by using the P2P link.

[0080] In another example, in a case where it is determined that the electronic device A has the network sharing capability, the electronic device B can also display the network connected by the electronic device A in a network list. For example, refer to Figure 2 , when the user wants the electronic device B to use the network of the electronic device A, the electronic device B can be triggered to display a network setting interface S1, and the network setting interface S1 displays a network list. The network list displays an option 20 corresponding to the network sharable by the electronic device A. In response to a click operation of the option 20 by the user, a P2P link is established between the electronic device B and the electronic device A, so that the electronic device B realizes online access through the electronic device A by using the P2P link.

[0081] In yet another example, refer to Figure 3 , Figure 3 is a schematic diagram of an application scenario according to another example embodiment. In response to a trigger operation of the user, the electronic device B displays a trust circle display interface S2, and the trust circle display interface S2 displays device icons of each electronic device in the trust circle. For example, as shown in (a) of Figure 3 , the trust circle display interface S2 displays a device icon 31 of the electronic device A and a device icon 32 of the electronic device B. In a case where the electronic device is not networked, the device icon thereof can be displayed in gray. In a case where a certain electronic device has a network sharing capability, the device icon thereof can be displayed in a highlighted color, such as blue, and the like. In this way, the user can distinguish which electronic device can perform network sharing. For example, as shown in Figure 3As shown in (a), when electronic device A has network sharing capabilities, device icon 31 of electronic device A is highlighted (illustrated as black in the figure). In response to a user's click on device icon 31 of electronic device A, as follows... Figure 3 As shown in (b), electronic device B displays several options in the area near device icon 31, including "Network Sharing" option 33. See also Figure 3 In step (c), in response to the user's click on the "Network Sharing" option 33, electronic device B displays the Network Sharing Service Card 34 in the Trust Ring display interface S2. Electronic device B allows the user to drag and drop the Network Sharing Service Card 34. In response to the user dragging and releasing the Network Sharing Service Card 34 onto the application icon 32 of electronic device B, a P2P link is established between electronic device B and electronic device A, thereby enabling internet access through electronic device A via this P2P link.

[0082] Optionally, in Figure 3 In the application scenario shown, after network sharing is completed, electronic device B can display a network sharing icon in the area near its device icon 32, for example... Figure 3 As shown in (d) 35, this indicates that electronic device B is using a shared network. Optionally, the network sharing icon 35 may be displayed in blue.

[0083] Optionally, after successful network sharing, both electronic device B and electronic device A can display a network sharing icon in their status bars. For example, see [link to example]. Figure 3 In (d), electronic device B displays a network sharing icon 36 in the status bar so that the user can intuitively know that the electronic device is sharing the network.

[0084] Users can manually disconnect the network sharing service when they no longer wish to share the network. Figure 3 For example, see the application scenario shown. Figure 3 In step (d), when a user does not want to share the network, they can drag the network sharing icon 35 until the color changes from blue to another color (such as gray or white), and then release the network sharing icon 35. In response to this operation by the user, electronic device B disconnects the P2P link with electronic device A, thereby disconnecting the network sharing service.

[0085] It should be noted that, Figure 3 The illustrated embodiment uses the example of a user triggering a shared network operation on electronic device B as an example. Of course, the user can also trigger the shared network operation on electronic device A. Figure 3 The process shown triggers the shared network.

[0086] It should be noted that the above is an example of electronic device B actively querying whether electronic device A has network sharing capability. In another example, electronic device A can also actively recommend a shareable network to electronic device B after being online (i.e., logging in to a device account). Correspondingly, electronic device B can display network sharing prompt information, and / or display the shareable network in the network list of the network setting interface S1, and / or display the device icon of electronic device A in the trust ring display interface S2 in a highlighted color.

[0087] It should be noted that the above Figure 1 to Figure 3 The application scenarios shown are only exemplary and do not limit the application scenarios of the embodiments of the present application.

[0088] The network sharing method provided by the embodiments of the present application is implemented by a state machine. The state machine is a program model running on a processor, and the state machine defines a plurality of states and the migration between the states. The state machine runs by responding to a series of input events, and when the input events meet certain trigger conditions, the state machine can be transferred from the current state to the next state, and / or output a control instruction to trigger the electronic device to perform a corresponding operation.

[0089] As an example of the present application, the input events of the state machine can be divided into:

[0090] (1) Initialization message (init).

[0091] The initialization message is used to trigger the initialization of the state machine.

[0092] (2) Device online, unlock screen, white list application opening.

[0093] Device online refers to the electronic device joining the trust ring, for example, the electronic device logging in to a device account.

[0094] Unlocking the screen refers to the electronic device unlocking the screen after the screen is turned on, i.e., entering the use state.

[0095] White list application opening refers to the electronic device running a white list application, which can be set according to needs, for example, the white list application includes Little Red Book, WeChat, learning application, etc.

[0096] The above input events can be understood as online demand events, i.e., input events triggered when there is an online demand.

[0097] (3) Device state change.

[0098] The device state change includes network change and temperature change.

[0099] Network changes include: electronic devices changing from a networked state to an offline state, or from an offline state to a networked state.

[0100] A network disconnection event is triggered when an electronic device changes from an online to an offline state. A network connection event is triggered when an electronic device changes from an online to an online state.

[0101] Temperature changes include: changes in the temperature of electronic devices that exceed a certain threshold, i.e., the electronic device enters a high-temperature state, which triggers a high-temperature change event; or changes in the temperature of electronic devices that fall below a certain threshold, i.e., the electronic device enters a low-temperature state, which triggers a low-temperature change event.

[0102] (4) The user clicks on the network sharing prompt message, the user clicks on the network that can be shared in the network list, and the user drags and drops the network sharing service card.

[0103] For example, a scenario where a user clicks on a network sharing notification message can be seen in [the following text is a separate, unrelated sentence]. Figure 1 In the illustrated embodiment, after the electronic device displays a network sharing prompt, the user clicks the displayed "Connect" control 101.

[0104] For example, see the scenario where a user clicks on a shareable network in the network list. Figure 2 In the embodiment shown, after the electronic device displays the network device interface S1, the user clicks the option 20 corresponding to the network that can be shared in the network list.

[0105] For example, you can refer to the scenario where a user drags and drops a network sharing service card. Figure 3 In the illustrated embodiment, after the network sharing service card 34 is displayed in the trust ring display interface S2, the user drags the network sharing service card 34 onto the application icon 32 of another non-networked electronic device (electronic device B) and then releases it.

[0106] The above input event is a request to share the network event.

[0107] (5) RePly message.

[0108] A RePly message is a reply message. For example, after the local end requests a query from the remote end to check whether the remote end has network sharing capability, the remote end sends a RePly message back to the local end. As an example, a RePly message can be used to indicate that the remote end has network sharing capability.

[0109] (6) QUERY message.

[0110] A QUERY message is a query message. For example, a peer sends a QUERY message to this peer to request whether this peer has network sharing capabilities.

[0111] (7) UPDATE message.

[0112] The UPDATE message is a network change message, which is sent by a peer to a local end. For example, the peer has network sharing capability. If the peer changes from an unconnected state to a connected state, the peer can broadcast an UPDATE message. At this time, the UPDATE message indicates that the peer currently has network sharing capability. If the peer changes from a connected state to an unconnected state, the peer can also broadcast an UPDATE message. At this time, the UPDATE message indicates that the peer currently does not have network sharing capability.

[0113] (8) Internet service callback message, device offline.

[0114] The Internet service callback message is used to indicate that the Internet underlying service state changes, such as network sharing service disconnection.

[0115] The device offline refers to that the electronic device exits the trust ring, for example, the electronic device disconnects the Bluetooth connection, and for another example, the electronic device logs out of the device account.

[0116] (9) User triggers network sharing service disconnection.

[0117] The user can trigger network sharing service disconnection in various ways. For example, the user can trigger network sharing service disconnection based on a trust ring display interface. For details, refer to (d) in Figure 3 . The user can also trigger disconnection based on a network list, and the like.

[0118] The above-mentioned (8) and (9) two types of input events belong to network sharing disconnection events.

[0119] (10) Service switch change.

[0120] The service switch is a switch used to turn on or turn off the network sharing service.

[0121] The service switch change includes that the service switch changes from an on state to an off state, or the service switch changes from an off state to an on state.

[0122] It should be noted that the input events in this embodiment are exemplary only, and the input events can also include other events, for example, a service end connection message can also be included. The service end connection message is used to request the state machine of the service provider to trigger the establishment of a P2P link with the service receiver.

[0123] The state machine runs according to the state diagram based on the above-mentioned input events. As an example of the present application, the state diagram is as follows: Figure 4As shown, the plurality of states defined by the state machine includes an initial state (init), a client idle state (client_idle), a client connected state (client_connected), a server idle state (server_idle) and a server connected state (server_connected):

[0124] In the initial state, the state machine is in an initialization state;

[0125] In the client idle state, the electronic device itself is not connected to a network, the network sharing service is turned on, but the network of other electronic devices in the sharing trust ring is not currently shared;

[0126] In the client connected state, the electronic device is sharing the network of other electronic devices in the sharing trust ring;

[0127] In the server idle state, the electronic device itself is connected to a network, the network sharing service is turned on, but the network of other electronic devices in the trust ring is not currently shared;

[0128] In the server connected state, the electronic device is sharing the network of other electronic devices in the trust ring.

[0129] It should be noted that since one electronic device can act as a service provider and a service receiver, when the electronic device acts as a service provider, it can be understood as a server side, and when the electronic device acts as a service receiver, it can be understood as a client side, so the plurality of states of the state machine includes client side states and server side states, the client side states include the client idle state and the client connected state, and the server side states include the server idle state and the server connected state.

[0130] Next, the response logic of the state machine to the corresponding input events when in different states is introduced:

[0131] Referring to Figure 4 , the state machine responds to the input event (1) or (10) and enters the initial state.

[0132] When the state machine is in the initial state, the init message is processed, and state transition is made according to the device state determination. Specifically:

[0133] Under the case 1 trigger condition, the state machine is transferred from the initial state to the client idle state, wherein the case 1 includes that the service switch is turned on and the electronic device is not connected to a network;

[0134] Under the case 2 trigger condition, the state machine is transferred from the initial state to the server idle state, wherein the case 2 includes that the service switch is turned on and the electronic device enters a connected state;

[0135] In case 3 trigger condition, the state machine stays in the current state, i.e. continues to stay in the initial state, wherein the case 3 includes that the service switch is not turned on.

[0136] As an example, when the state machine is in the client idle state, the responding input events include (2), (3), (4), (5), (7) and (10), and other input events can not be processed. See Figure 4 When the input events meet certain trigger conditions, the state machine can be transferred from the client idle state to the client connection state, the server idle state or the initial state. Illustratively, the input events processed by the state machine when in the client idle state can include:

[0137] 1. In response to the input event (2), the state machine triggers sending of a QUERY related message.

[0138] For example, after the electronic device is online, the state machine triggers sending of a QUERY message to the opposite end to query whether the opposite end has network sharing capability. For another example, in the case of joining a trust circle, after the electronic device is unlocked and the screen is turned on, the state machine triggers sending of a QUERY message to the opposite end.

[0139] 2. In response to the input event (3), the state machine can be transferred to the server idle state.

[0140] For example, if the electronic device changes from a non-networking state to a networking state, the state machine is transferred from the client idle state to the server idle state, and the state machine can trigger sending of an UPDATE related message, for example, broadcasting of an UPDATE message in the trust circle to notify non-networking electronic devices that the current end can share network.

[0141] 3. In response to the input event (4), the state machine is transferred from the client idle state to the client connection state.

[0142] Illustratively, when the user drags the network sharing service card, the state machine triggers establishment of a P2P link between the current end and the electronic device capable of sharing network, and after the P2P link is established, the state machine is transferred from the client state to the client connection state.

[0143] 4. In response to the input event (5), the state machine makes service recommendation.

[0144] Illustratively, in the case that a REPLY message is received from the opposite end and the REPLY message indicates that the opposite end has network sharing capability, the state machine can make service recommendation to the user to prompt the user that the network of the opposite end can be shared. For example, service recommendation can be made by displaying network sharing prompt information.

[0145] 5. In response to the input event (7), the state machine processes the UPDATE message.

[0146] Exemplarily, when the UPDATE message of the peer is received and the UPDATE message indicates that the peer has the network sharing capability, the state machine can make service recommendation to prompt the user that there is a network to be shared.

[0147] 6. In response to the input event (10), the state machine can transfer from the client idle state to the initial state.

[0148] Exemplarily, when the service switch is switched from the on state to the off state, the state machine transfers from the client idle state to the initial state.

[0149] As an example, when the state machine is in the client connection state, the input events in response include (3), (4), (8), (9) and (10), and other input events can not be processed. See Figure 4 When the input event meets certain trigger conditions, the state machine can transfer from the client connection state to the client idle state, the server idle state or the initial state. Exemplarily, the input events processed by the state machine when in the client connection state can include:

[0150] 1. In response to the input event (3), the state machine can transfer to the server idle state.

[0151] Exemplarily, when the electronic device is self-networked and the network connected by itself is a mobile data network, since the mobile data network is relatively stable and has a fast transmission speed, such as a 5G network, the state machine can trigger the electronic device to disconnect the network sharing service, use the network connected by itself to surf the Internet, and transfer the state machine from the client connection state to the server idle state.

[0152] Optionally, when the state machine is in the client connection state, if the electronic device enters a high-temperature state, the state machine can also trigger the electronic device to disconnect the network sharing service, and at this time the state machine transfers from the client connection state to the client idle state.

[0153] 2. In response to the input event (4), the state machine can prompt the user that the current operation is not supported.

[0154] Since the electronic device has a network (a shared network) when the state machine is in the client connected state, a network that can be shared and supports user triggering can be displayed in the network list of the electronic device, or the user can drag a network sharing service card to a device icon of an unconnected electronic device based on a trust ring display interface, and at this time, a network sharing triggering event is triggered. As an example of the present application, when the electronic device is using a shared network, the electronic device can not support sharing the network to other unconnected electronic devices, that is, if the network sharing triggering event is triggered and the user triggers the electronic device to share the network to other unconnected electronic devices, the state machine can prompt the user that the current operation is not supported. Illustratively, the state machine can trigger the electronic device to display prompt information "network sharing, current operation not supported".

[0155] 3. In response to the input event (8), the state machine makes a state transition, and can trigger a transition to the client idle state.

[0156] Illustratively, if the network sharing service being used by the electronic device is disconnected, for example, the electronic device exits the trust ring or the underlying actively disconnects due to a long time without being online, the state machine transitions from the client connected state to the client idle state.

[0157] 4. In response to the input event (9), the state machine transitions to the client idle state.

[0158] Illustratively, the user manually triggers the electronic device to disconnect the network sharing service, and the state machine transitions from the client connected state to the client idle state.

[0159] 5. In response to the input event (10), the state machine transitions to the initial state.

[0160] Illustratively, when the service switch is switched from the on state to the off state, the state machine transitions from the client connected state to the initial state.

[0161] As an example, when the state machine is in the server idle state, the input events in response include (3), (4), (6) and (10), and other input events can not be processed. See Figure 4 When the input event meets certain triggering conditions, the state machine can transition from the server idle state to the client idle state, the client connected state, the server connected state or the initial state. Illustratively, the input events processed by the state machine when in the server idle state can include:

[0162] 1. In response to the input event (3), the state machine makes an UPDATE message broadcast, and the state can transition to the client idle state.

[0163] As an example, when the electronic device switches from the network-connected state to the network-unconnected state, since network sharing cannot be performed at this time, the state machine can trigger the electronic device to broadcast an UPDATE message to notify other electronic devices that the electronic device enters the network-unconnected state, so that other electronic devices delete the service recommendation. In addition, the state machine is transferred from the service end idle state to the client end idle state.

[0164] As an example, when the electronic device high-temperature state changes to the low-temperature state, since network sharing is not performed at high temperature in order to save power consumption, and network sharing can be performed at low temperature, the state machine can trigger the electronic device to broadcast an UPDATE message to notify other electronic devices that the electronic device currently has network sharing capability. Of course, the state machine does not make state transition at this time, that is, it still stays in the service end idle state.

[0165] 2. In response to the event of the user dragging the network sharing service card in the input event (4), the state machine can use the network shared by the service provider, and be transferred to the client end connected state.

[0166] The electronic device in the embodiment of the present application is in a network-connected state, which means that the electronic device is connected to a WiFi network or a mobile data network. In the case of connecting to a WiFi network, the electronic device may or may not have the WiFi password of the WiFi network. Therefore, in one possible case, the network connected by the electronic device is a WiFi network, but it cannot be used normally due to the lack of WiFi password. In this case, if the network is shared with other electronic devices, the other electronic devices will also be unable to access the network. Therefore, as an example of the present application, when the user drags the network sharing service card to trigger the electronic device to use the network shared by the service provider, if the network currently connected by the electronic device is a WiFi network, the state machine can trigger the electronic device to use the network shared by the service provider, that is, to establish a P2P link with the service provider, and then be transferred from the service end idle state to the client end connected state, so that the electronic device can access the network, and avoid the situation that the other electronic devices cannot access the network after the network is shared with them due to the unavailability of the connected WiFi network.

[0167] 3. In response to the input event (6), the state machine triggers the reply of the REPLY message.

[0168] In one example, when the state machine is in the service end idle state, it can receive a QUERY message sent by a service receiver to request whether it has network sharing capability. In this case, the state machine can trigger the electronic device to reply to the REPLY message to indicate whether the electronic device has network sharing capability.

[0169] 4. In response to the input event (10), the state machine is transferred to the initial state.

[0170] Exemplarily, when the service switch is switched from the on state to the off state, the state machine is transferred from the server idle state to the initial state.

[0171] As an example, when the state machine is in the server connection state, the responding input events include (3), (4), (8), (9) and (10), and other input events can not be processed. See Figure 4 When the input events meet certain trigger conditions, the state machine can be transferred from the server connection state to the client idle state, the server idle state or the initial state. Exemplarily, the input events processed by the state machine when in the server connection state can include:

[0172] 1. In response to the input event (3), the state machine can be transferred to the client idle state.

[0173] In one example, when the electronic device is switched from the networked state to the un-networked state, the state machine triggers the network sharing service to be disconnected, i.e., the P2P link is disconnected, and the state machine is transferred from the server connection state to the client idle state. Optionally, the state machine can trigger the electronic device to broadcast an UPDATE message to inform the other end that the current network sharing capability is not available.

[0174] In one example, if the temperature of the electronic device is too high, the state machine can trigger the network sharing service to be disconnected to reduce the power consumption of the electronic device. At this time, the state machine is transferred from the server connection state to the server idle state.

[0175] After being transferred to the server idle state, if the temperature of the electronic device decreases, the state machine can trigger the UPDATE message to inform other electronic devices that the current network sharing capability is available.

[0176] 2. In response to the input event (4), the state machine prompts whether the network sharing service is available according to the current number of devices.

[0177] The number of devices refers to the number of electronic devices that are sharing the network of the electronic device.

[0178] As an example, the number of devices that can share the network of an electronic device can be limited, for example, to a preset number. When the state machine is in the server connection state, i.e., is sharing the network, if the user requests to continue sharing the network to a new service receiver, i.e., the input event (4) is triggered, the state machine can query the current number of devices. If the number of devices is less than or equal to the preset number, the state machine triggers the electronic device to prompt that the network sharing service is available; otherwise, if the number of devices is greater than the preset number, the state machine triggers the electronic device to prompt that the network sharing service is not available.

[0179] The preset number can be set according to actual needs, for example, can be 2 or 3, and the embodiment of the application does not limit this.

[0180] In this way, by setting the number of devices, the power consumption of the service provider can be avoided to be too high. In addition, if the network shared by the service provider is a mobile data network, by setting the number of devices, the service provider can avoid the traffic consumption being too large due to sharing the network.

[0181] 3. In response to the input event (8), the state is transferred, and it is possible to transfer to the service end idle state.

[0182] In one possible case, the electronic device exits the trust ring, in which case the network sharing service is disconnected, and the state machine is transferred from the service end connection state to the service end idle state.

[0183] In another possible case, the underlying network sharing service can be automatically disconnected due to a long time without data transmission, i.e., the service receiver has not been online through the network of the service provider for a long time, in which case the state machine is transferred from the service end connection state to the service end idle state.

[0184] 4. In response to the input event (9), the network sharing service is disconnected, and the state is transferred to the service end idle state.

[0185] In one example, the user actively triggers the electronic device to disconnect the network sharing service, in which case the state machine triggers the electronic device to disconnect the network sharing service, and is transferred from the service end connection state to the service end idle state.

[0186] 5. In response to the input event (10), the state machine is transferred to the initial state.

[0187] Exemplarily, when the service switch is switched from the open state to the closed state, the state machine is transferred from the service end idle state to the initial state.

[0188] In addition, when the state machine is in the service end idle state, or in the service end connection state and can continue to share the network, the state machine also responds to the service end connection message to trigger the electronic device to establish a P2P link with the service receiver.

[0189] In this way, referring to Figure 5, the state machine enables the electronic device as a client or a server by listening to some input events, such as the input events including device on and off, unlocking the screen, whitelisted application opening, device state change, and the like, to realize network sharing. In this process, the electronic device can make service recommendations, network list display, traffic prompts, or status bar icon display in the interface. Among them, the traffic prompt refers to showing the user the traffic information of the network being shared, for example, the prompt can be made in the pull-down notification bar; the status bar icon display refers to displaying the network sharing icon in the status bar after the network sharing is successful, for example, the network sharing icon is as shown in (d) of Figure 3 .

[0190] It is worth noting that through the state machine control, the electronic device can both serve as a service provider and a service receiver, unifying the client and server capability construction, which is convenient for maintenance, and since it is implemented in one module, that is, through a state machine module event, the time delay is low, and in addition, since it does not need to be implemented across processes, the power consumption of the electronic device can be reduced.

[0191] In addition, whether as a service provider or a service receiver, the state of network sharing can be flexibly switched, and a complete network sharing multi-scene coverage capability is constructed.

[0192] In addition, the network sharing capability architecture provided by the embodiments of the present application is easy to extend, for example, when there are other needs, only the input conditions need to be increased, and the state transition of the state machine needs to be controlled.

[0193] Next, the specific implementation process of network sharing will be introduced. In order to facilitate understanding, the software system of the electronic device will be first described. The software system of the electronic device can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The embodiments of the present application take the Android system with a layered architecture as an example to exemplarily describe the software system of the electronic device.

[0194] Figure 6 is a block diagram of a software system of an electronic device provided by the embodiments of the present application. Referring to Figure 6 , the layered architecture divides the software into several layers, and each layer has a clear role 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, the application layer (App layer), the application framework layer (FWK layer), the Andriod runtime, the Native layer, and the kernel layer.

[0195] The application layer can include a series of application packages for directly interacting with the user. These application packages can be system built-in application packages or non-system level application packages. These application packages can have icons and application interfaces, or can have application interfaces without icons, or can have neither icons nor application interfaces.

[0196] As an example, as shown in Figure 6 the application packages can include a device control center and a device service sharing center. The device control center can provide an interface for the user to use the network sharing service, such as supporting the user to trigger the network sharing service in a drag-and-drop manner, or can also make service recommendations to the user in the form of a smart island, etc. The device service sharing center can also provide an interface for the user to use the network sharing service, such as making service recommendations to the user in the form of a side bar capsule. Optionally, when receiving a confirmation sharing operation triggered by the user based on the side bar capsule, the user can be requested to authorize, such as requesting the user to authorize in the form of a pop-up window, and the electronic device performs network sharing after the user authorizes.

[0197] In one example, the device control center is defined as DeviceControlCenter, and the device service sharing center is defined as HnCrossDeviceServiceShare.

[0198] In addition, the application packages can also include Little Red Book, WeChat, Camera, Gallery, Weather, Call, Map, Navigation, Bluetooth, Music, Video, Short Message, etc. application packages (not shown in the figure).

[0199] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the application layer application packages. The application framework layer includes some pre-defined functions. As shown in Figure 6 the application framework layer can include settings, systemUI, a network sharing module, a network connection service, and a network management module.

[0200] The settings application can provide a service switch, and the user can trigger the service switch to be turned on or off through the settings application. The settings application can also display the shareable networks to the user in the form of a network list.

[0201] The systemUI can be used to display prompt information related to the network sharing service. For example, in the case of successful network sharing, a network sharing icon can be displayed in the status bar, such as in the form of a bubble. For another example, the traffic prompt can also be displayed in the drop-down notification bar to prompt the traffic information used by the network sharing.

[0202] The network sharing module includes a state machine. As an example, the network sharing module can also include a device property monitoring module, a data management module, a client enabling module, a server enabling module, a listening module, and a data transceiving module.

[0203] The state machine is used to respond to input events, perform task allocation and state transition, to implement network sharing between electronic devices.

[0204] The device property monitoring module can be used to monitor whether the electronic device is online, and to query whether the network sharing service is enabled.

[0205] The data management module can be used to display a UI for network sharing. For example, when a service is recommended, the data management module can trigger the device service sharing center to display a sidebar capsule, thereby prompting the user that there is a network that can be shared.

[0206] The client enabling module is used to enable a network connection service, to trigger the network connection service to establish a P2P link with a peer, thereby implementing network sharing. In this case, the electronic device is a service receiver.

[0207] Similarly, the server enabling module is used to enable a network connection service, to trigger the network connection service to establish a P2P link with a peer, thereby implementing network sharing. In this case, the electronic device is a service provider.

[0208] The listening module can be used to listen to various input events, such as listening to an unlock screen-on input event.

[0209] The data transceiving module can be used to exchange information with a peer through near field communication such as Bluetooth.

[0210] As an example but not limitation, the state machine is defined as DataNetworkSharingState, the device property monitoring module is defined as NetworkSharingProfileManager, the data management module is defined as NetworkSharingManager, the client enabling module is defined as NetworkSharingClientManager, the server enabling module is defined as NetworkSharingServerManager, the listening module is defined as NetworkSharingMonitor, and the data transceiving module is defined as NetworkSharingMagicLinkDelegate.

[0211] The network connection service can be used to trigger the underlying to establish a P2P link with the peer through the network management module. As an example, the network connection service can be defined as NetworkSynergySerivice, including NetworkSynergyClient and NetworkSynergyServer, when the electronic device is a service provider, the NetworkSynergyServer is used to interact with the underlying to establish a P2P link with the peer, and when the electronic device is a service receiver, the NetworkSynergyClient is used to interact with the underlying to establish a P2P link with the peer.

[0212] The network management module interacts with the Native layer of the underlying to establish a P2P link with the peer through the Native layer. As an example, the network management module includes OemNetdService and NetworkManager, and the network management module can interact with the Native layer through OemNetdService and NetworkManager.

[0213] In addition, the application framework layer can also include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc. (not shown in the figure). The window manager is used to manage window programs. The content provider is used to store and obtain data, and makes the data accessible to applications, which can include video, image, audio, etc. The view system can be used to build the display interface of the application, which can be composed of one or more views. The phone manager is used to provide communication functions. The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables applications to display notification information in the status bar, which can be used to convey notification type messages that can automatically disappear after a short stay without user interaction.

[0214] The Android Runtime includes a core library and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.

[0215] The Native layer includes a netd module for establishing a P2P link with the peer. As an example, the netd module includes an appproxy and at least one ip forward, and the netd module establishes a P2P link with the peer through the appproxy and the at least one ip forward, which will not be described in detail in the embodiments of the present application.

[0216] The kernel layer is a layer between hardware and software. The kernel layer at least includes display driver, camera driver, audio driver, sensor driver. Through these drivers, the display screen, front / rear camera, audio player, sensor, etc. can be driven.

[0217] It should be noted that, Figure 6 The network architecture shown is only exemplary and does not limit the software system of the electronic device.

[0218] Based on the embodiment shown, Figure 6 The network sharing method provided by the embodiment of the present application will be described in detail next. Referring to Figure 7 , Figure 7 is a flowchart of a network sharing method according to an exemplary embodiment. The method can be implemented by the first electronic device and the second electronic device in interaction. In this embodiment, the first electronic device is in an unconnected state, and the second electronic device is in a connected state. The first electronic device and the second electronic device both have Figure 6 the software system shown. The first electronic device and the second electronic device interact through the internal modules. The method can include the following parts or all of the contents:

[0219] S701: After the first electronic device is powered on, the first network sharing module of the first electronic device triggers the initialization of the first state machine of the first electronic device, and triggers the initialization of the first device attribute monitoring module of the first electronic device.

[0220] The first network sharing module runs after the first electronic device is powered on.

[0221] As an example, after the first electronic device is powered on, the first network sharing module can trigger the initialization of the first state machine, and trigger the initialization of the first device attribute monitoring module at the same time.

[0222] In one example, the first network sharing module can trigger the initialization of the first state machine by sending an init message to the first state machine, and trigger the initialization of the first device attribute monitoring module by sending an init message to the first device attribute monitoring module.

[0223] S702: After the initialization of the first state machine is completed, it is determined that the local end is not connected.

[0224] After the initialization of the first state machine is completed, the first state machine enters an initial state. In addition, the first state machine can query whether the local end is connected, and the type of the connected network, which includes WiFi network, mobile data network, and optionally, the mobile data network includes 5G network. For example, the network management module of the first electronic device can be queried, and the query result is recorded, wherein the network management module is a module for managing the network of the first electronic device.

[0225] It should be noted that the embodiment takes the first state machine determining that the local end is not connected as an example for illustration. If it is determined that the local end is connected, the network sharing implementation process can refer to the embodiment shown in Figure 8

[0226] S703: In the initialization process of the first device attribute monitoring module, the state of the service switch is queried.

[0227] The first device attribute monitoring module can query whether the service switch is turned on in the initialization process, for example, querying whether the service switch is turned on from the setting application of the first electronic device.

[0228] S704: In the case where the service switch is turned on, the first device attribute monitoring module feeds back the query result to the first state machine.

[0229] In the case where the service switch is turned on, it indicates that the network sharing service has been started, and at this time, the first device attribute monitoring module can feed back the query result of the service switch to the first state machine to inform the first state machine that the network sharing service has been started.

[0230] As an example, in the case where the service switch is turned off, the first device attribute monitoring module can not feed back the query result to the first state machine, or can also feed back that the service switch is not turned on to the first state machine.

[0231] Optionally, the first device attribute monitoring module can register the listening of the service switch state to the setting application of the first electronic device, so that when the service switch is switched from the off state to the on state, the first device attribute monitoring module can listen that the service switch has been turned on, at this time, the first device attribute monitoring module informs the first state machine that the service switch has been turned on.

[0232] In the case where the service switch is turned on, the operation of S705 below is entered. Otherwise, in the case where the service switch is not turned on, the first state machine is stopped in the initial state.

[0233] It should be noted that the embodiment takes the setting of the service switch as an example for illustration. In another example, the electronic device can also not be provided with the service switch and is by default provided with the network sharing service, in which case, the operations of S703 and S704 are not performed, and the operation of S705 below can be directly entered.

[0234] S705: The first state machine is transferred to the client idle state.

[0235] The current state of the first electronic device is not connected and the service switch is turned on, in which case, the first state machine is transferred to the client idle state to wait for an input event to trigger the first electronic device to query whether the second electronic device has the network sharing capability.

[0236] ​S706: After the first device attribute monitoring module is initialized, the first data management module of the first electronic device is triggered to initialize.

[0237] S707: After the first data management module is initialized, the first client enabling module and the first data transceiver module of the first electronic device are triggered to initialize.

[0238] In one example, after the first data management module is initialized, the first network connection service of the first electronic device is triggered, the first listening module of the first electronic device is triggered to initialize, and the first server enabling module of the first electronic device is triggered to initialize.

[0239] It should be noted that the initialization of each module on the first electronic device side is introduced in this embodiment. For the second device side, each module related to network sharing is also initialized according to a similar process. After the initialization is completed, since the second electronic device is connected to the network and the network sharing service is started, the second state machine of the second electronic device is in the server idle state.

[0240] S708: After the first listening module detects that the first electronic device is online, the first device attribute monitoring module is sent an online notification.

[0241] For example, the first electronic device logs in a device account, the first listening module detects that the first electronic device is online, that is, joins the trust circle. In this case, the first listening module notifies the first device attribute monitoring module that the first electronic device is online. For example, the first device attribute monitoring module can be notified by sending an online notification to the first device attribute monitoring module.

[0242] S709: The first device attribute monitoring module sends an online event to the first state machine.

[0243] S710: The first state machine sends QUERY1 to the first data transceiver module.

[0244] QUERY1 is used to request to query whether there is an electronic device with network sharing capability in the trust circle.

[0245] It should be noted that this embodiment is described by taking the first electronic device online to trigger the first state machine to send QUERY1 to the first data transceiver module as an example. In another example, other online requirements events can also trigger the first state machine to send QUERY1 to the first data transceiver module. For example, when unlocking and brightening the screen, the first listening module detects an unlocking and brightening event, the first listening module sends the unlocking and brightening event to the first state machine, and correspondingly, the first state machine sends QUERY1 to the first data transceiver module.

[0246] S711: The first data transceiver module sends QUERY1 to the second data transceiver module of the second electronic device.

[0247] In one example, the first data transceiver module can learn which electronic devices exist in the trust circle, for example, can obtain the address information of each electronic device in the trust circle. In this way, after receiving QUERY1, QUERY1 is sent to each electronic device in the trust circle to request to query which electronic device in the trust circle has network sharing capability.

[0248] It should be noted that the first data transceiver module and the second data transceiver module can perform near field communication, for example, data transmission can be performed through Bluetooth.

[0249] S712: The second data transceiver module sends QUERY1 to the second service enable module of the second electronic device.

[0250] The second data transceiver module assigns QUERY1 to the second service enable module to request the second service enable module to query whether the second electronic device currently has network sharing capability.

[0251] S713: The second service enable module sends QUERY1 to the second state machine of the second electronic device.

[0252] S714: The second state machine feeds back REPLY1 to the second service enable module.

[0253] In one possible case, the second electronic device is in a networked state and has started the network sharing service, at this time the second state machine is in a service idle state. If QUERY1 is received, the second state machine triggers REPLY1, and REPLY1 is used to indicate that the second electronic device has network sharing capability.

[0254] In another possible case, the second electronic device is in a networked state, has started the network sharing service, and is sharing network with other electronic devices in the trust circle, at this time the second state machine is in a service connected state. As an example, after receiving QUERY1, the second state machine can query how many electronic devices are currently being shared with, that is, determine the number of devices, if the number of devices is less than or equal to a preset number, it means that the network can still be shared with the first electronic device, then the second state machine feeds back REPLY1 to the second service enable module. Otherwise, if the number of devices is greater than the preset number, it means that the network cannot be shared with the first electronic device, in this case, no REPLY1 can be replied to the second service enable module, or a REPLY message indicating that network sharing cannot be performed can also be replied, for example, REPLY2 is replied. The embodiments of the present application are described by taking the case that the second electronic device can share network with the first electronic device as an example.

[0255] It should be noted that the embodiments of the present application are described by limiting the number of electronic devices sharing the network. In another example, the number of devices sharing the network can also not be limited, and the embodiments of the present application do not limit this.

[0256] S715: The second service enabling module sends REPLY1 to the second data transceiver module.

[0257] S716: The second data transceiver module sends REPLY1 to the first data transceiver module.

[0258] S717: The first data transceiver module sends REPLY1 to the first state machine.

[0259] S718: In response to receiving REPLY1, the first state machine sends a service recommendation instruction to the first data management module.

[0260] According to the foregoing, when the first state machine is in the client idle state, it receives the REPLY message of the second electronic device, and the REPLY message indicates that the second electronic device currently has network sharing capability, it is determined that the network of the second electronic device can be shared, at this time, the first state machine can trigger service recommendation. In implementation, the first state machine can send a service recommendation instruction to the first data management module to trigger the first data management to perform UI display.

[0261] S719: The first data management module displays network sharing prompt information.

[0262] In one example, the first data management module can trigger the device service sharing center to make service recommendations to the user in the form of a side bar capsule. For example, see Figure 1 , the network sharing prompt information is displayed as shown in 10 in Figure 1 .

[0263] It should be noted that the embodiments of the present application are described by displaying network sharing prompt information. In another example, see Figure 2 , the network that the second electronic device can share can also be displayed in the network list of the network setting interface S1, or in yet another example, see Figure 3 , the device icon of the second electronic device can also be highlighted (such as displayed in blue) in the trust ring display interface S2 to indicate that the second electronic device can currently share the network.

[0264] S720: The first listening module listens to the confirmation sharing event and sends the confirmation sharing event to the first state machine.

[0265] The confirmation sharing event can be triggered by the user through the first operation.

[0266] For example, referring to Figure 1 After displaying the network sharing prompt information 10, the user clicks the "connect" control 101, triggering the first operation. In this case, the first monitoring module can monitor the confirmation sharing event corresponding to the first operation, and the first monitoring module sends the confirmation sharing event to the first state machine.

[0267] It should be noted that the above is an example of the first operation being a click operation on the "connect" control 101. For another example, referring to Figure 2 When the network list is displayed, the user can click the BST corresponding option 20, thereby triggering the first operation. For another example, referring to Figure 3 When the network sharing service card is displayed, the user can click the BST corresponding option 20, thereby triggering the first operation, which is not limited by the embodiments of the application.

[0268] S721: The first state machine sends a client connection instruction to the first client enabling module.

[0269] The client connection instruction is used to request to establish a P2P link with the second electronic device.

[0270] S722: The first client enabling module sends the client connection instruction to the first network connection service of the first electronic device.

[0271] As an example, before sending the client connection instruction to the first network connection service, the first client enabling module can first query the first network connection service whether it has the ability to establish a link, if it does, it can register the first network connection service to monitor whether the link is successfully established, and then send the client connection instruction to the first network connection service.

[0272] Exemplarily, the first client enabling module can query whether the first network connection service has the ability to establish a link by calling the initSynergyClient method, and the first network connection service can feed back to the first client enabling module whether it has the ability to establish a link by calling the onServiceConnected method. If it does, the first client enabling module can register the monitoring by calling the registerSynergyListener method, and then send the client connection instruction to the first network connection service by calling the startSynergyConnect method.

[0273] S723: The first network connection service requests to establish a P2P link with the second network connection service.

[0274] S724: The second network connection service sends a server connection message to the second server enabling module.

[0275] S725: The second service enabling module sends a service connection message to the second state machine.

[0276] S726: The second state machine sends a service connection instruction to the second service enabling module.

[0277] S727: The second service enabling module sends a service connection instruction to the second network connection service.

[0278] As an example, the second service enabling module can first query the second network connection service about whether it has the ability to establish a link before sending the service connection instruction to the second network connection service, and if so, can register the second network connection service to monitor whether the link is successfully established, and then send the service connection instruction to the second network connection service.

[0279] Illustratively, the second service enabling module can query the second network connection service about whether it has the ability to establish a link by calling the initSynergyServer method, and the second network connection service can feed back to the second service enabling module about whether it has the ability to establish a link by calling the onServiceConnected method. If so, the second service enabling module can register the monitoring by calling the registerSynergyListener method, and then issue the service connection instruction to the second network connection service by calling the startSynergyConnect method.

[0280] S728: The second network connection service establishes a P2P link with the first network connection service.

[0281] After the P2P link is established, the first electronic device can share the network of the second electronic device. For example, when the first electronic device needs to access the Internet, it can send the Internet access data to the second electronic device through the P2P link, and the second electronic device can send the Internet access data out through its own network, so that the first electronic device can access the Internet.

[0282] S729: After the P2P link is successfully established, the first network connection service sends a sharing success notification to the first client enabling module.

[0283] In an example, the first network connection service can send the sharing success notification to the first client enabling module by calling the OnEvent method.

[0284] S730: The first client enabling module sends a sharing success notification to the first state machine.

[0285] S731: The first state machine sends a sharing success display instruction to the first data management module.

[0286] The sharing success display instruction is used to instruct to display a sharing success prompt message, and the sharing success prompt message is used to indicate that the network sharing is successful.

[0287] S732: The first data management module displays the sharing success prompt message.

[0288] As an example, the first data management module can trigger the system UI to display the network sharing icon in the status bar.

[0289] Of course, the second electronic device side can also display the sharing success prompt message to the user in a similar process. For example, after the P2P link is successfully established, the second network connection service sends a sharing success notification to the second service enabling module by calling the OnEvent method, the second service enabling module sends a sharing success notification to the second state machine, and the second state machine sends a sharing success display instruction to the second data management module. The second data management module displays the sharing success prompt message.

[0290] In the case that the P2P link is successfully established between the first electronic device and the second electronic device, the first state machine is transferred to the client connection state. When the first state machine is in the client connection state, the following operations can be performed:

[0291] As an example, if the first electronic device is connected to a network by itself, and the connected network is a mobile data network, such as the user triggers the 5G network switch to turn on, the first electronic device is connected to the 5G network, and the first listening module listens to the networking event. In this case, the first listening module can notify the first state machine, and the first state machine instructs the first client enabling module to disconnect the P2P link after determining that the currently connected network is a mobile data network. The first client enabling module controls the first network connection service to disconnect the P2P link. The first electronic device enters the server idle state.

[0292] As an example, if the user triggers the first electronic device to share the network with other non-networked electronic devices, such as the user drags and drops the network sharing service card of the first electronic device to the device icon of the other networked electronic device based on the trust ring display interface, then releases it, the first listening module listens to the sharing network trigger event. In this case, the first listening module sends the sharing network trigger event to the first state machine. The first state machine triggers the first data management module to display the first prompt information, and the first prompt information is used to prompt that the current operation is not supported.

[0293] As an example, if the user triggers a disconnection operation, such as dragging the network sharing icon to a color that becomes white, the first listening module can listen to a shared network disconnection event, the first listening module notifies the first state machine, and the first state machine instructs the first client enabling module to disconnect the P2P link. The first client enabling module controls the first network connection service to disconnect the P2P link. The first state machine enters the client idle state.

[0294] As an example, if there is no data transmission between the first electronic device and the second electronic device through the P2P link for a long time, in this case, the first network connection service can trigger an interconnection service callback message to trigger a network disconnection event, thereby notifying the first state machine. Accordingly, the first state machine triggers the first client enabling module to control the first network connection service to disconnect the P2P link, and the first state machine shifts to the client idle state. Optionally, the first state machine instructs the first data management module to display a network sharing disconnection prompt, thereby prompting the user that the network sharing has been disconnected.

[0295] As an example, if the service switch is switched from the on state to the off state, since the first device attribute monitoring module registers the listening to the service switch, the first device attribute monitoring module can listen to the change of the service switch, at this time, the first device attribute monitoring module notifies the first state machine that the service switch is off, such as triggering a service switch disconnection event. The first state machine shifts from the client connection state to the initial state, and triggers the first client enabling module to disconnect the P2P link, and can also trigger the first data management module to display a network sharing disconnection prompt.

[0296] Of course, the above is an example of performing corresponding operations for different input events when the first state machine is in the client connection state. As an example, when the first state machine is in the client idle state, the following operations can be performed:

[0297] As an example, if the first electronic device is connected to a network by itself, the first listening module can listen to a networking event, the first listening module notifies the first state machine, the first state machine shifts to the server idle state, and then the first data transceiver module can be triggered to broadcast an UPDATE message, and the UPDATE message is used to indicate that the first electronic device has network sharing capability. The operations performed by the first state machine after entering the server idle state can be referred to the embodiment shown in Figure 8

[0298] As an example, if the service switch is switched from the on state to the off state, the first device attribute monitoring module can listen to the change of the service switch, at this time, the first device attribute monitoring module notifies the first state machine that the service switch is off, and the first state machine shifts to the initial state.

[0299] ​As an example, if the first data transceiving module receives an UPDATE message from the second electronic device and the UPDATE message is used to indicate that the second electronic device has the network sharing capability, it means that the second electronic device side can share the network, at this time, the first data transceiving module transmits the UPDATE message to the first state machine, and the first state machine triggers the first data management module to make service recommendation. In the case that the user determines to share the network, that is, confirms that the sharing event is triggered, the first state machine triggers the first client enabling module to establish a P2P link, and the specific implementation process can be referred to the above.

[0300] In the embodiment of the present application, when the first state machine of the first electronic device is in the client idle state, in response to the online requirement event of the first electronic device, the first state machine triggers the first electronic device to send a first query request to the second electronic device. After receiving the first query response of the second electronic device, the first state machine triggers the first electronic device to establish a P2P link with the second electronic device, so that the first electronic device shares the network of the second electronic device through the P2P link, and the first state machine shifts to the client connection state. In this way, the P2P link between electronic devices is established through the state machine control, so that the network sharing is realized without the need of sharing the password information, and any type of network sharing is supported.

[0301] It should be noted that the embodiment of the present application is described by taking the service receiver actively querying the service provider whether it has the network sharing capability as an example. In another example, the service provider can actively recommend the network sharing service to the service receiver, and the query operation of the service receiver and the active recommendation operation of the service receiver do not affect each other. Exemplarily, the first electronic device is networked, and the second electronic device is not networked, which is described by referring to Figure 8 , Figure 8 is a schematic diagram of a method flow of sharing a network according to another exemplary embodiment. The method is described by taking the first electronic device actively sharing the network to the second electronic device as an example, and can mainly include the following parts or all contents:

[0302] S801: After the first electronic device is powered on, the first network sharing module of the first electronic device triggers the first state machine of the first electronic device to initialize, and triggers the first device attribute monitoring module of the first electronic device to initialize.

[0303] S802: After the first state machine initialization is completed, it is determined that the local end is networked.

[0304] S803: In the initialization process of the first device attribute monitoring module, the state of the service switch is queried.

[0305] S804: In the case that the service switch is turned on, the first device attribute monitoring module feeds back the query result to the first state machine.

[0306] S805: The first state machine transfers to the service end idle state.

[0307] In the case that the first electronic device is connected to the network and the network sharing service is started, the first state machine transfers to the service end idle state.

[0308] S806: After the first device attribute monitoring module is initialized, the first service end enabling module of the first electronic device is initialized, and the first data transceiving module of the first electronic device is initialized.

[0309] After the first device attribute monitoring module is initialized, the first data management module of the first electronic device is initialized. After the first data management module is initialized, the first service end enabling module of the first electronic device is initialized, and the first data transceiving module of the first electronic device is initialized.

[0310] In one example, after the first data management module is initialized, the first listening module of the first electronic device is initialized, the first network connection service of the first electronic device is initialized, and the first client enabling module of the first electronic device is initialized.

[0311] S807: When the first listening module detects that the first electronic device is online, an online notification is sent to the first device attribute monitoring module.

[0312] S808: The first device attribute monitoring module sends an online event to the first state machine.

[0313] S809: The first state machine sends UPDATE1 to the first data transceiving module.

[0314] UPDATE1 is used to indicate that the current end has network sharing capability.

[0315] S810: The first data transceiving module sends UPDATE1 to the second data transceiving module of the second electronic device.

[0316] In one example, the first data transceiving module can know which electronic devices exist in the trust circle, for example, the address information of each electronic device in the trust circle can be obtained. Thus, after receiving UPDATE1, UPDATE1 is broadcasted to each electronic device in the trust circle.

[0317] S811: The second data transceiving module sends UPDATE1 to the second client enabling module of the second electronic device.

[0318] S812: The second client enabling module sends UPDATE1 to the second state machine of the second electronic device.

[0319] S813: The second state machine sends a service push display instruction to a second data management module of the second electronic device.

[0320] S814: The second data management module displays network sharing prompt information.

[0321] S815: The second listening module of the second electronic device listens to a confirmation sharing event and sends the confirmation sharing event to the second state machine.

[0322] S816: The second state machine sends a client connection instruction to a second client enabling module.

[0323] The client connection instruction is used to request to establish a P2P link with the first electronic device.

[0324] S817: The second client enabling module sends the client connection instruction to a second network connection service of the second electronic device.

[0325] S818: The second network connection service requests to establish a P2P link with the first network connection service.

[0326] S819: The first network connection service sends a server connection message to a first server enabling module.

[0327] S820: The first server enabling module sends the server connection message to the first state machine.

[0328] S821: The first state machine sends a server connection instruction to the first server enabling module.

[0329] S822: The first server enabling module sends the server connection instruction to the first network connection service.

[0330] S823: The first network connection service establishes a P2P link with the second network connection service.

[0331] Thus, the network sharing is realized.

[0332] Optionally, after the P2P link is successfully established, the first network connection service can send a sharing success notification to the first client enabling module. The first client enabling module sends the sharing success notification to the first state machine. The first state machine sends a sharing success display instruction to the first data management module. The first data management module displays a sharing success prompt message.

[0333] Similarly, after the P2P link is successfully established, on the second electronic device side, the second state machine can also trigger the second electronic device to display a sharing success prompt message. The specific implementation can be referred to the implementation process of the first state machine triggering the first electronic device to display the sharing success message.

[0334] In case that the P2P link is successfully established between the first electronic device and the second electronic device, the first state machine is transferred to the service connection state.

[0335] When the first state machine module is in the service connection state, the following operations can be performed:

[0336] As an example, if the network to which the first electronic device is connected is disconnected, for example, the user turns off the mobile data network, or the first electronic device moves and no longer connects to the WiFi network, the first listening module listens to the network disconnection event of the first electronic device, the first listening module notifies the first state machine, the first state machine can broadcast UPDATE2, for example, the first data transceiver module can be triggered to broadcast UPDATE2, UPDATE2 is used to indicate that the second electronic device does not have network sharing capability, in addition, the first state machine instructs the first service enabler module to disconnect the P2P link, and the first service enabler module controls the first network connection service to disconnect the P2P link. The first state machine is transferred from the service connection state to the service idle state.

[0337] As an example, when the temperature of the first electronic device is relatively high, the first listening module can listen to the device high temperature change event, the first listening module notifies the first state machine, the first state machine can trigger the first data transceiver module to broadcast UPDATE2, in addition, the first state machine triggers the first service enabler module to control the first network connection service to disconnect the P2P link. The first state machine is transferred from the service connection state to the service idle state.

[0338] As an example, if the first data transceiver module receives a QUERY message from the third electronic device, the first data transceiver module sends the QUERY message to the first service enabler module. The first service enabler module sends the QUERY message to the first state machine. The first state machine determines the number of electronic devices that are sharing the network of the local device, if the number of devices is less than or equal to a preset number, a REPLY message can be sent to the first service enabler module, the REPLY message is used to indicate that the first electronic device currently has network sharing capability, the first service enabler module feeds back the REPLY message to the second electronic device through the first data transceiver module in case that the REPLY message is received. Otherwise, if the number of devices is greater than the preset number, no REPLY message can be replied.

[0339] As an example, if the first electronic device and the second electronic device have not transmitted data through the P2P link for a long time, the first network connection service triggers an interconnection service callback message to trigger a network disconnection event, notify the first state machine, the first state machine triggers the first service enabler module to control the first network connection service to disconnect the P2P link, and is transferred to the service idle state.

[0340] As an example, if the user initiates to disconnect the network service connection at the first electronic device, the first monitoring module can monitor the network disconnection event, the first monitoring module informs the first state machine, the first state machine triggers the first service-side enabling module to control the first network connection service to disconnect the P2P link, and the first state machine is transferred to the service-side idle state.

[0341] As an example, if the service switch is switched from the on state to the off state, the first device attribute monitoring module can monitor the change of the service switch, at this time the first device attribute monitoring module informs the first state machine that the service switch is off, the first state machine triggers the first service-side enabling module to control the first network connection service to disconnect the P2P link, and is transferred to the initial state.

[0342] When the first state machine is in the service-side idle state, the following operations can also be performed:

[0343] As an example, when the temperature of the first electronic device decreases from high temperature, the first monitoring module can monitor the device low temperature change event, the first monitoring module informs the first state machine, and the first state machine can trigger the first data transceiver module to broadcast UPDATE2. At this time, the first state machine stays in the service-side idle state.

[0344] As an example, if the user drags the network sharing service card of other electronic device capable of sharing network to the device icon of the first electronic device and then releases it, the first monitoring module can monitor the network sharing event, the first monitoring module informs the first state machine, and if the network currently connected by the first electronic device is a WiFi network, the first state machine can trigger the first client-side enabling module to control the first network connection service to establish a P2P link with the other electronic device. Then, the first state machine is transferred to the client-side connection state.

[0345] As an example, when the service switch is switched from the on state to the off state, the first device attribute monitoring module can monitor the change of the service switch, at this time the first device attribute monitoring module informs the first state machine that the service switch is off, the first state machine is transferred from the service-side idle state to the initial state.

[0346] In the embodiment of the present application, when the first state machine of the first electronic device is in the service-side idle state, the first state machine can trigger the first electronic device to actively recommend network sharing service to the second electronic device. When the second electronic device requests to share network, the first state machine triggers the first electronic device to establish a P2P link with the second electronic device, so that the second electronic device shares the network of the first electronic device through the P2P link, and the first state machine is transferred to the service-side connection state. In this way, the P2P link between electronic devices is established through the state machine control, so that network sharing is realized without the need of sharing password information, and sharing of any type of network is supported.

[0347] It should be noted that the internal implementation logic of the second electronic device as a service provider sharing the network can refer to the internal implementation of the first electronic device in the embodiment shown in Figure 8

[0348] Figure 9 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. Referring to Figure 9 , the electronic device 100 can 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 loudspeaker 170A, a receiver 170B, a microphone 170C, a headset interface 170D, a sensor module 180, a key 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 can 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.

[0349] It can be understood that the structure shown 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 can include more or fewer components than shown, or combine certain components, or split certain components, or different component arrangements. The components shown can be implemented in hardware, software, or a combination of software and hardware.

[0350] ​The processor 110 can include one or more processing units such as: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (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. Among them, different processing units can be independent devices, or can be integrated in one or more processors.

[0351] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to instruction operation codes and timing signals, and complete the control of fetching instructions and executing instructions.

[0352] The memory in the processor 110 can also be provided for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can save instructions or data that the processor 110 has just used or repeatedly uses. If the processor 110 needs to use the instructions or data again, it can be directly called from the memory. Avoiding repeated access reduces the waiting time of the processor 110, thus improving the efficiency of the system.

[0353] The charging management module 140 is used to receive charging input from the charger. Among them, the charger can be a wireless charger, or a wired charger. The charging management module 140 can charge the battery 142, and at the same time, it can also supply power to the electronic device 100 through the power management module 141.

[0354] 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 the input of the battery 142 and / or the charging management module 140, and supplies 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, etc.

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

[0356] The mobile communication module 150 can provide a solution including 2G / 3G / 4G / 5G wireless communication applied to the electronic device 100.

[0357] The wireless communication module 160 can provide a solution for wireless communication, including wireless local area networks (WLAN) (e.g., wireless fidelity (Wi-Fi) network), Bluetooth (BT), and the like, applied to the electronic device 100.

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

[0359] The electronic device 100 can implement a photographing function through an ISP, a camera 193, a video codec, a GPU, a display 194, and an application processor, and the like.

[0360] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to implement an extension of 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. For example, files such as music, videos, and the like are saved in the external memory card.

[0361] The internal memory 121 can be used to store computer executable program code including instructions. The processor 110 performs various function applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program required for a function (e.g., a sound play function, an image play function, and the like), and the like. The data storage area can store data (e.g., audio data, a phonebook, and the like) created during use of the electronic device 100, and the like. In addition, the internal memory 121 can include a high-speed random access memory, and can further include a non-volatile memory such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), and the like.

[0362] The electronic device 100 can implement an audio function such as music play, recording, and the like, through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, and an application processor, and the like.

[0363] The temperature sensor 180J is configured to detect temperature. In some embodiments, the electronic device 100 performs a temperature handling strategy based on the temperature detected by the temperature sensor 180J. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of a processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In some other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 caused by low temperature. In some other embodiments, when the temperature is lower than yet another threshold, the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.

[0364] The indicator 192 can be an indicator light, which can be used to indicate the charging status, the change in power, and can also be used to indicate messages, missed calls, notifications, etc.

[0365] The embodiments of the present application also provide a chip system, which is applied to an electronic device and includes one or more processors configured to invoke computer instructions to cause the electronic device to perform the method described in the above embodiments.

[0366] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented 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, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable devices. The computer instructions can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer readable storage medium can be any available medium that can be accessed by a computer, or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be magnetic media (such as floppy disk, hard disk, magnetic tape), optical media (such as digital versatile disc (DVD)) or semiconductor media (such as solid state disk (SSD)) and the like.

[0367] The above describes optional embodiments provided by the present application, and is not used to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the technical scope disclosed by the present application should 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, the first electronic device including a state machine, the method includes: When the state machine is in the client idle state, in response to the internet access request event of the first electronic device, the state machine triggers the sending of a first query request to the second electronic device. When the state machine is in the client idle state, the first electronic device is in an offline state. Upon receiving the first query response from the second electronic device, the state machine triggers the establishment of a first P2P link with the second electronic device. The first P2P link is used for the first electronic device to share the first network of the second electronic device. The first query response indicates that the second electronic device currently has network sharing capability. After the first P2P link is successfully established, the state machine transitions from the client idle state to the client connected state.

2. The method as described in claim 1, characterized in that, Upon receiving the first query response from the second electronic device, the state machine triggers the establishment of a first P2P link with the second electronic device, including: Upon receiving the first query response, the state machine triggers the display of a network sharing prompt message; In response to a first operation on the network sharing prompt information, the state machine triggers the establishment of the first P2P link with the second electronic device.

3. The method as described in claim 1 or 2, characterized in that, The method further includes: When the state machine is in the client connected state, in response to a shared network disconnection event, the state machine transitions from the client connected state to the client idle state.

4. The method according to any one of claims 1-3, characterized in that, The method further includes: When the state machine is in the client connection state, in response to the shared network trigger event, the state machine triggers the display of a first prompt message. The shared network trigger event refers to a request to share the network with a third electronic device that is not connected to the network. The first prompt message is used to indicate that the current operation is not supported. The third electronic device and the first electronic device are able to communicate in the near field.

5. The method according to any one of claims 1-4, characterized in that, The method further includes: When the state machine is in the client idle state, if the first electronic device switches from an unconnected state to a connected state, the state machine transitions from the client idle state to the server idle state and triggers the broadcast of a first network change message. The first network change message is used to indicate that the first electronic device currently has network sharing capabilities.

6. The method according to any one of claims 1-4, characterized in that, The method further includes: When the state machine is in the client connected state, if the first electronic device is connected to the second network and the second network is a mobile data network, the state machine triggers the disconnection of the first P2P link, transitions from the client connected state to the server idle state, and triggers the broadcast of a first network change message. The first network change message is used to indicate that the first electronic device currently has network sharing capability and the second network is not a shared network.

7. The method as described in claim 5 or 6, characterized in that, The method further includes: When the state machine is in the server idle state, in response to the network disconnection event, the state machine triggers the broadcast of a second network change message. The second network change message is used to indicate that the first electronic device does not currently have network sharing capability. The network disconnection event refers to the first electronic device switching from a networked state to a non-networked state. The state machine transitions from the server-side idle state to the client-side idle state.

8. The method according to any one of claims 5-7, characterized in that, The method further includes: When the state machine is in the server idle state, in response to the network sharing event, if the network connected to the first electronic device is a WiFi network, the state machine triggers the establishment of a second P2P link with the fourth electronic device. The network sharing event means that the fourth electronic device shares the third network with the first electronic device, and the fourth electronic device and the first electronic device can communicate in the near field. After the second P2P link is successfully established, the state machine transitions from the server idle state to the client connected state.

9. The method as described in claim 5 or 6, characterized in that, The method further includes: When the state machine is in the server idle state, in response to the second query request, the state machine triggers the sending of a second query response to the fifth electronic device. The second query request is sent by the fifth electronic device and is used to query whether the first electronic device currently has network sharing capability. The fifth electronic device and the first electronic device can communicate in the near field. In response to a link establishment request, the state machine triggers the establishment of a third P2P link with the fifth electronic device; After the third P2P link is successfully established, the state machine transitions from the server idle state to the server connected state.

10. The method as described in claim 9, characterized in that, The method further includes: When the state machine is in the server-connected state, in response to the network disconnection event, the state machine triggers the broadcast of a second network change message and triggers the disconnection of the third P2P link. The second network change message is used to indicate that the first electronic device does not currently have network sharing capability. The network disconnection event refers to the first electronic device switching from a networked state to a non-networked state. The state machine transitions from the server-side connected state to the client-side idle state.

11. The method as described in claim 9, characterized in that, The method further includes: When the state machine is in the server connection state, in response to the device high temperature change event, the state machine triggers the broadcast of a second network change message and triggers the disconnection of the third P2P link. The second network change message is used to indicate that the first electronic device does not currently have network sharing capability. The state machine transitions from the server-connected state to the server-idle state.

12. The method as described in claim 11, characterized in that, The method further includes: When the state machine is in the server idle state, in response to a device low temperature change event, the state machine triggers the broadcast of the first network change message.

13. The method as described in claim 9, characterized in that, The method further includes: When the state machine is in the server connection state, in response to the third query request, the state machine determines the number of devices currently sharing the fourth network of the first electronic device. The third query request is sent by the sixth electronic device and is used to query whether the first electronic device currently has network sharing capability. The sixth electronic device and the first electronic device can communicate in the near field. If the number of devices is less than or equal to a preset number, the state machine triggers the sending of a third query response to the sixth electronic device. The third query response is used to indicate that the first electronic device currently has network sharing capability.

14. The method according to any one of claims 9-13, characterized in that, The method further includes: When the state machine is in the initial state, if the service switch is on and the first electronic device is not connected to the network, the state machine transitions from the initial state to the client idle state. The service switch is used to trigger the opening or closing of the network sharing service.

15. The method as described in claim 14, characterized in that, The method further includes: When the state machine is in the initial state, and the service switch is turned on and the first electronic device is connected to the network, the state machine transitions from the initial state to the server idle state.

16. The method as described in claim 14 or 15, characterized in that, The method further includes: When the state machine is in any of the multiple states, if the service switch switches from the on state to the off state, the state machine transitions from any of the states to the initial state. The multiple states include the client idle state, the client connected state, the server idle state, and the server connected state.

17. An electronic device, characterized in that, The electronic device includes: one or more processors, and a memory; the memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, and the one or more processors invoking the computer instructions to cause the electronic device to perform the method as described in any one of claims 1-16.

18. A chip system, characterized in that, The chip system is applied to an electronic device, the chip system including one or more processors, the one or more processors being configured to invoke computer instructions to cause the electronic device to perform the method as described in any one of claims 1-16.

19. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1-16.

20. A computer program product containing instructions, characterized in that, When it is run on a computer, it causes the computer to perform the method as described in any one of claims 1-16.