This application pertains to the field of electronic technologies, and in particular, relates to a network connection method, an electronic device and a non-transitory readable storage medium.
With development of mobile Internet technologies, a small intelligent terminal such as a watch or a wristband also has a cellular network capability to facilitate network communication of users because a modem is integrated. The intelligent terminal gradually becomes a portable thing for people to live, work, and travel. However, continuous working of the modem for a relatively long time may lead to high power consumption of the intelligent terminal, which affects an endurance capability of the small intelligent terminal.
According to a first aspect, an embodiment of this application provides a network connection method. The method is applied to a first electronic device and includes:
According to a second aspect, an embodiment of this application provides a network connection method. The method is applied to a second electronic device and includes:
According to a third aspect, an embodiment of this application provides a network connection apparatus. The apparatus is applied to a first electronic device and includes:
According to a fourth aspect, an embodiment of this application provides a network connection apparatus. The apparatus is applied to a second electronic device and includes:
According to a fifth aspect, an embodiment of this application provides an electronic device. The electronic device includes a processor, a memory, and a program or an instruction stored in the memory and executable on the processor, and when the program or the instruction is executed by the processor, steps of the method according to any one of the first aspect or the second aspect are implemented.
According to a sixth aspect, an embodiment of this application provides a non-transitory readable storage medium. The non-transitory readable storage medium stores a program or an instruction, and when the program or the instruction is executed by a processor, steps of the method according to any one of the first aspect or the second aspect are implemented.
According to a seventh aspect, an embodiment of this application provides a chip. The chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is configured to run a program or an instruction to implement the method according to any one of the first aspect or the second aspect.
The following clearly describes the technical solutions in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Apparently, the described embodiments are some but not all of the embodiments of this application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of this application shall fall within the protection scope of this application.
In the specification and claims of this application, the terms “first”, “second”, and the like are intended to distinguish between similar objects but do not describe an order or sequence. It should be understood that the terms used in such a way are interchangeable in proper circumstances so that the embodiments of this application can be implemented in orders other than the order illustrated or described herein. Objects classified by “first” and “second” are usually of a same type, and the number of objects is not limited. For example, there may be one or more first objects. In addition, in the specification and claims, “and/or” represents at least one of connected objects, and a character “/” generally represents an “or” relationship between associated objects.
With reference to the accompanying drawings, the following describes in detail the network connection method provided in the embodiments of this application by using embodiments and application scenes thereof.
Referring to
In the following embodiments of this application, Bluetooth communication between the first electronic device and the second electronic device is used as an example for description. Optionally, the first electronic device and/or the second electronic device may have a Bluetooth low energy (BLE) component and a classic Bluetooth (BT) module. The first electronic device and the second electronic device may be connected to each other through the Bluetooth low energy component and/or the classic Bluetooth module, to implement a BLE connection or a BT connection between the first electronic device and the second electronic device.
A remote procedure call (RPC) component may run in the first electronic device and the second electronic device, so that the first electronic device has a function of remotely calling the second electronic device. The first electronic device may send an RPC operation request to the second electronic device through the Bluetooth connection between the first electronic device and the second electronic device, where the RPC operation request includes a network interface function call number. After receiving the RPC operation request, the second electronic device may call a network interface call function indicated by the network interface function call number, so as to call a network interface corresponding to the network interface call function by using the network interface call function. Response information of the network interface is sent to the first electronic device, so that the first electronic device implements proxy calling on the network interface of the second electronic device, where the network interface of the second electronic device is a network communication capability provided by the first electronic device. In this case, the first electronic device may be used as a network proxy client, and the second electronic device may be used as a network proxy server to provide a network communication capability for the first electronic device. For example, the first electronic device and the second electronic device may be a mobile phone, a computer, a wearable device, or the like.
Optionally, a Bluetooth-based connection between the first electronic device and the second electronic device may be used as an example. Referring to
Both the network proxy client layer 1013 of the first electronic device 101 and the network proxy server layer 1023 of the second electronic device 102 include a network interface. The RPC component layer 1012 of the first electronic device 101 is configured to generate the RPC operation request including the network interface function call number according to an RPC protocol, and transmit the RPC operation request to the Bluetooth physical link layer 1011. The Bluetooth physical link layer 1011 of the first electronic device 101 transmits the RPC operation request to the Bluetooth physical link layer 1021 of the second electronic device 102. The Bluetooth physical link layer 1021 transmits the received RPC operation request to the RPC component layer 1022. The RPC component layer 1022 parses the RPC operation request to obtain the network interface function call number for calling. The second electronic device 102 calls the network interface call function indicated by the network interface function call number, and calls the network interface in the network proxy server layer 1023 by using the network interface call function.
Referring to
Step 301: When meeting a remote networking condition, a first electronic device sends an RPC operation request including a network interface function call number to a second electronic device.
In this embodiment of this application, the first electronic device may detect running data of the first electronic device periodically or in real time, and determine whether the first electronic device meets the remote networking condition, to determine whether the first electronic device needs to perform proxy calling on a network interface of the second electronic device.
When the first electronic device does not meet the remote networking condition, the first electronic device may call a local network interface to implement network communication. When the first electronic device meets the remote networking condition, the first electronic device may obtain a network interface function call number of a network interface function. The network interface function is used to call the network interface, and the network interface function call number is used to identify the network interface function. The RPC operation request is generated by encapsulating the network interface function call number of the network interface function according to an RPC protocol. The first electronic device may send the RPC operation request to the second electronic device through a Bluetooth-based connection established between the first electronic device and the second electronic device. It should be noted that the RPC operation request may further include information such as a network parameter and a network address of the second electronic device. The network interface is configured to provide a network communication function. For example, the network interface may be a socket interface, and the socket interface is also referred to as a bsd socket interface.
The remote networking condition may be a condition in which the first electronic device may perform proxy calling on a network interface of another electronic device. Optionally, the remote networking condition may include: the first electronic device is connected to the second electronic device; or the first electronic device is connected to the second electronic device, and power consumption of the first electronic device is greater than a specified power consumption threshold; or the first electronic device is connected to the second electronic device, and electrical energy of the first electronic device is less than a specified electrical energy threshold.
For example, in a case that the remote networking condition is that the first electronic device is connected to the second electronic device, the first electronic device may obtain a Bluetooth connection state between the first electronic device and the second electronic device in real time. When it is detected that the Bluetooth connection state between the first electronic device and the second electronic device is that a Bluetooth connection between the first electronic device and the second electronic device is successfully established, it is determined that the first electronic device meets the remote networking condition.
Step 302: The second electronic device calls a network interface call function indicated by the network interface function call number.
In this embodiment of this application, after receiving the RPC operation request sent by the first electronic device, the second electronic device may parse the RPC operation request according to the RPC protocol, to obtain the network interface function call number included in the RPC operation request. The second electronic device calls the network interface call function indicated by the network interface function call number, to call a local network interface of the second electronic device by using the network interface call function.
For example, the RPC operation request includes a socket interface parameter and the network interface function call number of the network interface call function used to call the socket interface. After parsing the RPC operation request, the second electronic device obtains the socket interface parameter and the network interface function call number. The second electronic device calls the network interface function indicated by the network interface function call number, and imports the socket interface parameter to the network interface function.
Step 303: The second electronic device generates an RPC operation response according to response information of a network interface called by the network interface call function.
In this embodiment of this application, the second electronic device calls the network interface call function to call the network interface by using the network interface call function, and obtains the response information returned by the network interface. The second electronic device generates the RPC operation response by encapsulating the response information according to the RPC protocol.
Step 304: The second electronic device sends the RPC operation response to the first electronic device.
In this embodiment of this application, the second electronic device sends the RPC operation response to the first electronic device through a Bluetooth-based connection established between the second electronic device and the first electronic device.
Step 305: The first electronic device parses the RPC operation response to obtain the response information of the network interface.
In this embodiment of this application, after receiving the RPC operation response sent by the second electronic device, the first electronic device parses the RPC operation response to obtain the response information of the network interface, so as to implement a network communication function of the first electronic device.
In conclusion, in the network connection method provided in this embodiment of this application, when the first electronic device meets the remote networking condition, the first electronic device sends the RPC operation request including the network interface function call number to the second electronic device, so that the second electronic device calls the network interface call function indicated by the network interface function call number, generates the RPC operation response according to the response information of the network interface called by the network interface call function, and sends the RPC operation response to the first electronic device. After receiving the RPC operation response sent by the second electronic device, the first electronic device may parse the RPC operation response to obtain the response information of the network interface. In this technical solution, the first electronic device may send the RPC operation request to the second electronic device, so that the second electronic device calls the local network interface, and returns the response information of the network interface to the first electronic device. The first electronic device implements proxy calling on the network interface of the second electronic device, and therefore the network interface of the second electronic device is a network communication capability provided by the first electronic device. Compared with current technology, the first electronic device is prevented from using a network component such as a modem to provide a network communication capability. On the basis of ensuring that the first electronic device has a network communication capability, working duration of the network component in the first electronic device is reduced, thereby reducing impact of high running power consumption of the network component on an endurance capability of the first electronic device, and improving the endurance capability of the first electronic device.
Referring to
Step 401: When meeting a remote networking condition, a first electronic device sends an RPC operation request including a network interface function call number to a second electronic device.
For an explanation and implementation of this step, refer to the explanation and implementation of the foregoing step 301. Details are not described in this embodiment of this application.
Step 402: The second electronic device calls a network interface call function indicated by the network interface function call number.
For an explanation and implementation of this step, refer to the explanation and implementation of the foregoing step 302. Details are not described in this embodiment of this application.
It should be noted that in an optional application scene, both the first electronic device and the second electronic device may perform an operation in a multiplexing manner. In this embodiment of this application, an example in which both the first electronic device and the second electronic device may perform an operation in a multiplexing manner is used for description. For example, the second electronic device may call the network interface call function by using a multiplex monitoring function. The second electronic device may create a handle of the network interface called by the network interface call function, and content of the handle is second information. The second electronic device stores the handle of the network interface in a second storage space. A process in which the second electronic device calls the network interface call function indicated by the network interface function call number includes: when it is monitored, by using the multiplex monitoring function, that the handle that is of the network interface and that includes the second information exists in the second storage space, calling the network interface call function indicated by the network interface function call number.
The handle is also referred to as a handle number, and is monitored by the multiplex monitoring function. Optionally, the second storage space may store the handle of the network interface. The multiplex monitoring function is used to monitor the handle of the network interface. When the second electronic device detects, by using the multiplex monitoring function, that the handle that is of the network interface and that includes the second information exists in the second storage space, a process of calling the network interface call function indicated by the network interface function call number may include: when it is monitored, by using the multiplex monitoring function, that the handle of the network interface is the second information, calling the network interface call function indicated by the network interface function call number. Optionally, the multiplex monitoring function may be a select function or a poll function.
For example, the second electronic device establishes the handle of the network interface in response to the networking instruction, and content of the handle is the second information. The handle of the network interface is stored in the second storage space. When the select function detects that the handle of the network interface is the second information, the network interface call function indicated by the network interface function call number is called. The networking instruction may be generated by the second electronic device when a user to whom the second electronic device belongs wants to use a network communication function by using the second electronic device. For example, the user clicks a networking identifier, so that when receiving the click operation for the networking identifier, the second electronic device generates the networking instruction in response to the click operation.
Step 403: The second electronic device generates an RPC operation response according to response information of a network interface called by the network interface call function.
In this embodiment of this application, the second electronic device calls the network interface call function to call the network interface by using the network interface call function, and obtains the response information returned by the network interface. The second electronic device generates the RPC operation response by encapsulating the response information according to the RPC protocol.
Step 404: The second electronic device sends the RPC operation response to the first electronic device.
In this embodiment of this application, the second electronic device sends the RPC operation response to the first electronic device through a Bluetooth-based connection established between the second electronic device and the first electronic device.
Step 405: The first electronic device parses the RPC operation response to obtain the response information of the network interface.
In this embodiment of this application, after receiving the RPC operation response sent by the second electronic device, the first electronic device parses the RPC operation response to obtain the response information of the network interface, so as to implement a network communication function of the first electronic device.
Step 406: The second electronic device updates a handle of the network interface from second information to first information, where the first information is used to indicate that the network interface is called through the RPC operation request.
Optionally, the first information may be specified information, or the first information may be information generated by using a setting rule according to the second information. In a case that the first information may be the information generated by using the setting rule according to the second information, a process in which the second electronic device updates the handle of the network interface from the second information to the first information may include: the second electronic device generates the first information by using the setting rule according to the second information, and updates the handle of the network interface from the second information to the first information.
For example, the content of the handle may be a value, and the handle may be a fixed value greater than 100,000. The setting rule may be that the first information is a sum of the second information and 100,000. If the handle that is of the network interface and that is created by the second electronic device is 26, that is, the second information is 26, the first information generated by the second electronic device by using the setting rule according to the second information is 100,026. The handle of the network interface is updated to 100,026.
Step 407: The second electronic device sends the handle to the first electronic device.
In this embodiment of this application, the second electronic device may send the handle of the network interface to the first electronic device through the Bluetooth-based connection established between the second electronic device and the first electronic device. It should be noted that step 406 may be performed before step 403. In this case, that the second electronic device generates the RPC operation response according to the response information of the network interface called by the network interface call function may be replaced with that the second electronic device generates the RPC operation response according to the response information of the network interface called by the network interface call function and the handle of the network interface. That is, the RPC operation response may include the response information of the network interface and the handle of the network interface.
Step 408: The first electronic device stores the handle in a first storage space, where the handle is monitored by a multiplex monitoring function.
In this embodiment of this application, after receiving the handle that is of the network interface and that is sent by the second electronic device, the first electronic device may store the handle of the network interface in the first storage space. For example, the first electronic device may include a virtual file system layer, and the first storage space may be a storage space corresponding to the virtual file system layer. The first electronic device may monitor, by using the multiplex function, the handle stored in the first storage space.
Step 409: The first electronic device responds to a networking instruction, and sends the RPC operation request to the second electronic device when it is monitored, by using the multiplex monitoring function, that the handle including the first information exists in the first storage space, where the RPC operation request further includes the handle.
In this embodiment of this application, when the user wants to use the network communication function, a target input used to trigger the network communication function may be performed on the first electronic device, and the networking instruction is generated in response to the target input. The networking instruction is used to reflect that the first electronic device needs to call the network interface. In response to the networking instruction, the first electronic device may locally call the network interface call function, to call the network interface by using the network interface call function, and obtain the response information of the network interface. Alternatively, the first electronic device may send the RPC operation request to the second electronic device, so that the first electronic device performs proxy calling on the network interface of the second electronic device, to obtain the response information of the network interface of the second electronic device.
The first electronic device responds to the networking instruction and determines whether it is monitored, by using the multiplex monitoring function, that the handle including the first information exists in the first storage space, to determine whether the first electronic device can perform proxy calling on the network interface of the second electronic device by sending the RPC request to the second electronic device.
When it is monitored, by using the multiplex monitoring function, that the handle including the first information exists in the first storage space, it indicates that the first electronic device may perform proxy calling on the network interface of the second electronic device. In this case, the first electronic device sends the RPC operation request to the second electronic device. The RPC operation request includes the network interface function call number and the handle that is of the network interface and that includes the first information. When it is not monitored, by using the multiplex monitoring function, that the handle including the first information exists in the first storage space, it indicates that the first electronic device cannot perform proxy calling on the network interface of the second electronic device. In this case, the first electronic device may call the network interface call function to obtain the response information of the network interface called by the network interface call function. In other words, the first electronic device may call the local network interface to receive the response information of the network interface, so as to implement network communication.
Optionally, the first storage space may store the handle of the network interface. When the handle that includes the first information and that is sent by the second electronic device is not received, the handle stored in the first storage space may be the handle that is of the network interface and that is created by the first electronic device, and the handle includes third information. After the first electronic device receives the handle that includes the first information and that is sent by the second electronic device, a process in which the first electronic device stores the handle in the first storage space may include: the first electronic device updates the handle that is of the network interface and that includes the third information in the first storage space to the handle including the first information.
The first electronic device may respond to the networking instruction, and determines whether it is monitored, by using the multiplex monitoring function, that the handle of the network interface in the first storage space is the first information. When it is monitored, by using the multiplex monitoring function, that the handle of the network interface in the first storage space is the first information, it is determined that the handle including the first information exists in the first storage space. When it is monitored, by using the multiplex monitoring function, that the handle of the network interface in the first storage space is not the first information, it is determined that the handle including the first information does not exist in the first storage space.
For example, the example in step 406 is still used as an example. The first electronic device determines whether it is monitored, by using the multiplex monitoring function, that the handle of the network interface in the first storage space is 100,026. When it is monitored that the handle of the network interface in the first storage space is 100,026, the RPC operation request is sent to the second electronic device, so that the second electronic device calls the local network interface in response to the RPC request, and returns the response information of the network interface to the first electronic device. When it is monitored that the handle of the network interface in the first storage space is not 100,026, the first electronic device may call the local network interface to obtain the response information of the network interface.
Step 410: The second electronic device updates the received handle from the first information to the second information, and perform step 402.
In this embodiment of this application, after receiving the RPC operation request that includes the handle of the network interface and that is sent by the first electronic device, the second electronic device updates the received handle from the first information to the second information, and stores the updated handle in the second storage space. Therefore, the second electronic device performs step 402 and when it is monitored, by using the multiplex monitoring function, that the handle that is of the network interface and that includes the second information exists in the second storage space, calls the network interface call function indicated by the network interface function call number.
Optionally, in a case that the first information may be the information generated by using the setting rule according to the second information, a process in which the second electronic device updates the received handle from the first information to the second information may include: the second electronic device restores and generates the second information by using the setting rule according to the first information, and updates the handle of the network interface from the first information to the second information.
For example, the setting rule may be that the first information is a sum of the second information and 100,000. If the handle in the RPC operation request received by the second electronic device is 100,026, the second information generated by the second electronic device by using the setting rule according to the first information is 26. The handle of the network interface in the first storage space is updated to 26.
In this embodiment of this application, after the second electronic device calls the network interface call function indicated by the network interface function call number, the second electronic device updates the handle of the network interface to the first information used to indicate that the network interface is called by using the RPC operation request, and sends the updated handle of the network interface to the first electronic device. Therefore, when performing an operation in a multiplexing manner, the first electronic device may determine, according to whether the handle that is of the network interface and that includes the first information is detected by using the multiplex monitoring function, that the first electronic device performs proxy calling on the network interface of the second electronic device, or performs calling on the local network interface of the first electronic device. In other words, the first electronic device may distinguish, according to whether the handle that is of the network interface and that includes the first information is detected by using the multiplex monitoring function, whether the first electronic device uses the network interface of the second electronic device to provide the network communication capability for the first electronic device, or the first electronic device uses the local network interface of the first electronic device to provide the network communication capability for the first electronic device, so that the first electronic device can be compatible with calling of the local network interface and calling of the network interface of the second electronic device, thereby resolving a problem of calling compatibility in multiplexing.
In conclusion, in the network connection method provided in this embodiment of this application, when the first electronic device meets the remote networking condition, the first electronic device sends the RPC operation request including the network interface function call number to the second electronic device, so that the second electronic device calls the network interface call function indicated by the network interface function call number, generates the RPC operation response according to the response information of the network interface called by the network interface call function, and sends the RPC operation response to the first electronic device. After receiving the RPC operation response sent by the second electronic device, the first electronic device may parse the RPC operation response to obtain the response information of the network interface. In this technical solution, the first electronic device may send the RPC operation request to the second electronic device, so that the second electronic device calls the local network interface, and returns the response information of the network interface to the first electronic device. The first electronic device implements proxy calling on the network interface of the second electronic device, and therefore the network interface of the second electronic device is a network communication capability provided by the first electronic device. Compared with current technology, the first electronic device is prevented from using a network component such as a modem to provide a network communication capability. On the basis of ensuring that the first electronic device has a network communication capability, working duration of the network component in the first electronic device is reduced, thereby reducing impact of high running power consumption of the network component on an endurance capability of the first electronic device, and improving the endurance capability of the first electronic device.
Referring to
Step 501: When a remote networking condition is met, send an RPC operation request including a network interface function call number to a second electronic device, so that the second electronic device calls a network interface call function indicated by the network interface function call number, generates an RPC operation response according to response information of a network interface called by the network interface call function, and sends the RPC operation response to the first electronic device.
Step 502: Receive the RPC operation response sent by the second electronic device.
Step 503: Parse the RPC operation response to obtain the response information of the network interface.
In this embodiment of this application, when the first electronic device meets the remote networking condition, the first electronic device sends the RPC operation request including the network interface function call number to the second electronic device, so that the second electronic device calls the network interface call function indicated by the network interface function call number, generates the RPC operation response according to the response information of the network interface called by the network interface call function, and sends the RPC operation response to the first electronic device. After receiving the RPC operation response sent by the second electronic device, the first electronic device may parse the RPC operation response to obtain the response information of the network interface. In this technical solution, the first electronic device may send the RPC operation request to the second electronic device, so that the second electronic device calls the local network interface, and returns the response information of the network interface to the first electronic device. The first electronic device implements proxy calling on the network interface of the second electronic device, and therefore the network interface of the second electronic device is a network communication capability provided by the first electronic device. Compared with current technology, the first electronic device is prevented from using a network component such as a modem to provide a network communication capability. On the basis of ensuring that the first electronic device has a network communication capability, working duration of the network component in the first electronic device is reduced, thereby reducing impact of high running power consumption of the network component on an endurance capability of the first electronic device, and improving the endurance capability of the first electronic device.
Optionally, after the sending a remote procedure call RPC operation request including a network interface function call number to a second electronic device, the method further includes:
Optionally, the method further includes:
Optionally, the remote networking condition includes:
In the network connection method provided in this embodiment of this application, for an explanation and implementation of each step, refer to the foregoing explanation and implementation of the related step in the network connection method shown in
Referring to
Step 601: Receive an RPC operation request that includes a network interface function call number and that is sent by a first electronic device.
Step 602: Call a network interface call function indicated by the network interface function call number.
Step 603: Generate an RPC operation response according to response information of a network interface called by the network interface call function.
Step 604: Send the RPC operation response to the first electronic device.
In this embodiment of this application, when the first electronic device meets the remote networking condition, the first electronic device sends the remote procedure call RPC operation request including the network interface function call number to the second electronic device, so that the second electronic device calls the network interface call function indicated by the network interface function call number, generates the RPC operation response according to the response information of the network interface called by the network interface call function, and sends the RPC operation response to the first electronic device. After receiving the RPC operation response sent by the second electronic device, the first electronic device may parse the RPC operation response to obtain the response information of the network interface. In this technical solution, the first electronic device may send the RPC operation request to the second electronic device, so that the second electronic device calls the local network interface, and returns the response information of the network interface to the first electronic device. The first electronic device implements proxy calling on the network interface of the second electronic device, and therefore the network interface of the second electronic device is a network communication capability provided by the first electronic device. Compared with current technology, the first electronic device is prevented from using a network component such as a modem to provide a network communication capability. On the basis of ensuring that the first electronic device has a network communication capability, working duration of the network component in the first electronic device is reduced, thereby reducing impact of high running power consumption of the network component on an endurance capability of the first electronic device, and improving the endurance capability of the first electronic device.
Optionally, a handle of the network interface is second information, and after the calling a network interface call function indicated by the network interface function call number, the method further includes:
Optionally, the calling a network interface call function indicated by the network interface function call number includes: when it is monitored, by using a multiplex monitoring function, that the handle that is of the network interface and that includes the second information exists in a second storage space, calling the network interface call function indicated by the network interface function call number; and
In the network connection method provided in this embodiment of this application, for an explanation and implementation of each step, refer to the foregoing explanation and implementation of the related step in the network connection method shown in
It should be noted that, the network connection method provided in the embodiments of this application may be performed by a network connection apparatus, or a control module that is in the network connection apparatus and that is configured to perform the network connection method. In the embodiments of this application, an example in which the network connection apparatus performs the network connection method is used to describe the network connection apparatus provided in the embodiments of this application.
Referring to
Optionally, the receiving module 702 is further configured to receive a handle that is of the network interface and that is sent by the second electronic device, where the handle includes first information, the handle is sent by the second electronic device to the first electronic device after the second electronic device calls the network interface and updates the handle of the network interface to the first information, and the first information is used to indicate that the network interface is called through the RPC operation request;
Optionally, the apparatus 700 also includes:
Optionally, the remote networking condition includes:
In this embodiment of this application, when the first electronic device meets the remote networking condition, the first electronic device sends the remote procedure call RPC operation request including the network interface function call number to the second electronic device, so that the second electronic device calls the network interface call function indicated by the network interface function call number, generates the RPC operation response according to the response information of the network interface called by the network interface call function, and sends the RPC operation response to the first electronic device. After receiving the RPC operation response sent by the second electronic device, the first electronic device may parse the RPC operation response to obtain the response information of the network interface. In this technical solution, the first electronic device may send the RPC operation request to the second electronic device, so that the second electronic device calls the local network interface, and returns the response information of the network interface to the first electronic device. The first electronic device implements proxy calling on the network interface of the second electronic device, and therefore the network interface of the second electronic device is a network communication capability provided by the first electronic device. Compared with current technology, the first electronic device is prevented from using a network component such as a modem to provide a network communication capability. On the basis of ensuring that the first electronic device has a network communication capability, working duration of the network component in the first electronic device is reduced, thereby reducing impact of high running power consumption of the network component on an endurance capability of the first electronic device, and improving the endurance capability of the first electronic device.
Referring to
Optionally, a handle of the network interface is second information, and the apparatus 800 further includes:
Optionally, the calling module 802 is further configured to: when it is monitored, by using a multiplex monitoring function, that the handle that is of the network interface and that includes the second information exists in a second storage space, call the network interface call function indicated by the network interface function call number;
In this embodiment of this application, when the first electronic device meets the remote networking condition, the first electronic device sends the remote procedure call RPC operation request including the network interface function call number to the second electronic device, so that the second electronic device calls the network interface call function indicated by the network interface function call number, generates the RPC operation response according to the response information of the network interface called by the network interface call function, and sends the RPC operation response to the first electronic device. After receiving the RPC operation response sent by the second electronic device, the first electronic device may parse the RPC operation response to obtain the response information of the network interface. In this technical solution, the first electronic device may send the RPC operation request to the second electronic device, so that the second electronic device calls the local network interface, and returns the response information of the network interface to the first electronic device. The first electronic device implements proxy calling on the network interface of the second electronic device, and therefore the network interface of the second electronic device is a network communication capability provided by the first electronic device. Compared with current technology, the first electronic device is prevented from using a network component such as a modem to provide a network communication capability. On the basis of ensuring that the first electronic device has a network communication capability, working duration of the network component in the first electronic device is reduced, thereby reducing impact of high running power consumption of the network component on an endurance capability of the first electronic device, and improving the endurance capability of the first electronic device.
The network connection apparatus in this embodiment of this application may be an apparatus, or may be a component, an integrated circuit, or a chip in a terminal. The apparatus may be a mobile electronic device, or may be a non-mobile electronic device. For example, the mobile electronic device may be a mobile phone, a tablet computer, a notebook computer, a palmtop computer, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA). The non-mobile electronic device may, be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine. This is not limited in this embodiment of this application.
The network connection apparatus in this embodiment of this application may be an apparatus with an operating system. The operating system may be an Android operating system, an iOS operating system, or another possible operating system This is not limited in this embodiment of this application.
The network connection apparatus provided in this embodiment of this application can implement the processes implemented in the method embodiments shown in
Optionally, as shown in
It should be noted that the electronic device in this embodiment of this application includes the mobile electronic device and the non-mobile electronic device.
A person skilled in the art can understand that the electronic device 1000 may further include the power supply (for example, a battery) that supplies power to each component. The power supply may be logically connected to the processor 1010 by using a power supply management system, so as to manage functions such as charging, discharging, and power consumption by using the power supply management system. The structure of the electronic device shown in
In a case that the electronic device is a first electronic device, the processor 1010 is configured to: when a remote networking condition is met, send a remote procedure call RPC operation request including a network interface function call number to a second electronic device, so that the second electronic device calls a network interface call function indicated by the network interface function call number, generates an RPC operation response according to response information of a network interface called by the network interface call function, and sends the RPC operation response to the first electronic device.
The processor 1010 is further configured to receive the RPC operation response sent by the second electronic device.
The processor 1010 is further configured to parse the RPC operation response to obtain the response information of the network interface.
In this embodiment of this application, when the first electronic device meets the remote networking condition, the first electronic device sends the RPC operation request including the network interface function call number to the second electronic device, so that the second electronic device calls the network interface call function indicated by the network interface function call number, generates the RPC operation response according to the response information of the network interface called by the network interface call function, and sends the RPC operation response to the first electronic device. After receiving the RPC operation response sent by the second electronic device, the first electronic device may parse the RPC operation response to obtain the response information of the network interface. In this technical solution, the first electronic device may send the RPC operation request to the second electronic device, so that the second electronic device calls the local network interface, and returns the response information of the network interface to the first electronic device. The first electronic device implements proxy calling on the network interface of the second electronic device, and therefore the network interface of the second electronic device is a network communication capability provided by the first electronic device. Compared with current technology, the first electronic device is prevented from using a network component such as a modem to provide a network communication capability. On the basis of ensuring that the first electronic device has a network communication capability, working duration of the network component in the first electronic device is reduced, thereby reducing impact of high running power consumption of the network component on an endurance capability of the first electronic device, and improving the endurance capability of the first electronic device.
Optionally, the processor 1010 is further configured to:
Optionally, the processor 1010 is further configured to: respond to the networking instruction, and when it is not monitored, by using the multiplex monitoring function, that the handle including the first information exists in the first storage space, call the network interface call function, and obtain the response information of the network interface called by the network interface call function.
Optionally, the remote networking condition includes:
In a case that the electronic device is a second electronic device, the processor 1010 is configured to receive a remote procedure call RPC operation request that includes a network interface function call number and that is sent by a first electronic device.
The processor 1010 is further configured to call a network interface call function indicated by the network interface function call number; and is further configured to generate an RPC operation response according to response information of a network interface called by the network interface call function; and send the RPC operation response to the first electronic device.
Optionally, handle of the network interface is second information, and the processor 1010 is further configured to:
Optionally, the processor 1010 is further configured to: when it is monitored, by using a multiplex monitoring function, that the handle that is of the network interface and that includes the second information exists in a second storage space, call the network interface call function indicated by the network interface function call number;
It should be understood that, in this embodiment of this application, the input unit 1004 may include a graphics processing unit (GPU) 10041 and a microphone 10042, and the graphics processing unit 10041 processes image data of a still image or a video that is obtained by an image capturing apparatus (for example, a camera) in a video capturing mode or an image capturing mode. The display unit 1006 may include a display panel 10061. The display panel 10061 may be configured in a form such as a liquid crystal display or an organic light-emitting diode. The user input unit 1007 may include a touch panel 10071 and another input device 10072. The touch panel 10071 is also referred to as a touchscreen. The touch panel 10071 may include two parts: a touch detection apparatus and a touch controller. The another input device 10072 may include but is not limited to a physical keyboard, a functional button (such as a volume control button or a power on/off button), a trackball, a mouse, and a joystick. Details are not described herein. The memory 1009 may be configured to store a software program and various data, including but not limited to an application and an operating system. An application processor and a modem processor may be integrated into the processor 1010, the application processor mainly processes an operating system, a user interface, an application program, and the like, and the modem processor mainly processes wireless communication. It can be understood that, alternatively, the modem processor may not be integrated into the processor 1010.
An embodiment of this application further provides a non-transitory readable storage medium. The non-transitory readable storage medium stores a program or an instruction, and when the program or the instruction is executed by a processor, the processes in the foregoing network connection method embodiment are implemented, and a same technical effect can be achieved. To avoid repetition, details are not described herein again.
The processor is a processor in the electronic device in the foregoing embodiment. The non-transitory readable storage medium includes a non-transitory computer readable storage medium, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc.
An embodiment of this application further provides a chip. The chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is configured to run a program or an instruction to implement the processes of the foregoing network connection method embodiment, and a same technical effect can be achieved. To avoid repetition, details are not described herein again.
It should be understood that the chip mentioned in this embodiment of this application may also be referred to as a system-level chip, a system chip, a chip system, or an on-chip system chip.
It should be noted that, in this specification, the terms “include”, “comprise”, or their any other variant is intended to cover a non-exclusive inclusion, so that a process, a method, an article, or an apparatus that includes a list of elements not only includes those elements but also includes other elements which are not expressly listed, or further includes elements inherent to such process, method, article, or apparatus. An element preceded by “includes a . . . ” does not, without more constraints, preclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element. In addition, it should be noted that the scope of the method and the apparatus in the embodiments of this application is not limited to performing functions in an illustrated or discussed sequence, and may further include performing functions in a basically simultaneous manner or in a reverse sequence according to the functions concerned. For example, the described method may be performed in an order different from that described, and the steps may be added, omitted, or combined. In addition, features described with reference to some examples may be combined in other examples.
Based on the foregoing descriptions of the embodiments, a person skilled in the art may clearly understand that the foregoing method embodiment may be implemented by software in addition to a necessary general hardware platform or by hardware. Whether these functions of the method and the unit in the example of each embodiment are executed in a hardware or software manner depends on an application and design constraint condition of the technical solution. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of the present disclosure. In many cases, the foregoing method embodiments may be implemented by software in addition to a necessary general hardware platform. Based on such an understanding, the technical solutions of this application essentially or the part contributing to the prior art may be implemented in a form of a software product. The computer software product is stored in a storage medium (for example, a ROM/RAM, a floppy disk, or an optical disc), and includes several instructions for instructing a terminal (which may be a mobile phone, a computer, a server, an air conditioner, a network device, or the like) to perform the methods described in the embodiments of this application.
The embodiments of this application are described above with reference to the accompanying drawings, but this application is not limited to the above implementations, and the above implementations are merely illustrative but not restrictive. Under the enlightenment of this application, a person of ordinary skill in the art can make many forms without departing from the purpose of this application and the protection scope of the claims, all of which fall within the protection of this application.
Number | Date | Country | Kind |
---|---|---|---|
202111366049.5 | Nov 2021 | CN | national |
This application is a Bypass Continuation Application of International Patent Application No. PCT/CN2022/131596, filed Nov. 14, 2022, and claims priority to Chinese Patent Application No. 202111366049.5, filed Nov. 17, 2021, the disclosures of which are hereby incorporated by reference in their entireties.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2022/131596 | Nov 2022 | WO |
Child | 18665367 | US |