Search

US-12621885-B2 - File sharing method and terminal device

US12621885B2US 12621885 B2US12621885 B2US 12621885B2US-12621885-B2

Abstract

Embodiments of this application provide a file sharing method and a terminal device. The method includes: After receiving a file sharing request of a transmitter device, if a receiver device is currently connected to a 2.4 GHz Wi-Fi network and does not support dual band dual concurrent DBDC, the receiver device establishes a peer-to-peer P2P connection in a target frequency band with the transmitter device, where the target frequency band includes frequency bands of 5 GHz and above; and the receiver device receives, by using the P2P connection, a file sent by the transmitter device. In this way, the transmitter device establishes the P2P connection in a higher wireless frequency band with the receiver device, to prevent another wireless signal in a frequency band of less than 5 GHz from causing interference to the P2P connection between the transmitter device and the receiver device.

Inventors

  • Yayun SUO

Assignees

  • HONOR DEVICE CO., LTD.

Dates

Publication Date
20260505
Application Date
20221213
Priority Date
20220210

Claims (19)

  1. 1 . A file sharing method, applied to a receiver device, wherein the method comprises: receiving a first broadcast message sent by a transmitter device, wherein the first broadcast message comprises a file sharing request; sending a second broadcast message to the transmitter device in response to the first broadcast message, wherein the second broadcast message comprises receiver device information; receiving a P2P connection request of the transmitter device, wherein the P2P connection request is generated by the transmitter device based on the receiver device information; when the receiver device is currently connected to a 2.4 GHz Wi-Fi network and does not support dual band dual concurrent (DBDC), starting a network preferential selection procedure in response to the P2P connection request, wherein the network preferential selection procedure is used for the receiver device to switch from the 2.4 GHz Wi-Fi network to a Wi-Fi network in a target frequency band, wherein the target frequency band comprises frequency bands of 5 GHz and above, wherein the network preferential selection procedure comprises determining whether the receiver device is currently connected to a Wi-Fi hotspot in the target frequency band, when the receiver device is not currently connected to the Wi-Fi hotspot in the target frequency band, selecting a target hotspot from surrounding Wi-Fi hotspots in the target frequency band based on a signal strength and/or a protocol standard of the Wi-Fi hotspot, when the target hotspot is selected, determining whether a condition for connecting to the target hotspot is met, and when the condition for connecting to the target hotspot is met, connecting to the target hotspot; establishing a Wi-Fi P2P connection in the target frequency band with the transmitter device; and receiving a file sent by the transmitter device by using the Wi-Fi P2P connection.
  2. 2 . The method according to claim 1 , wherein the selecting the target hotspot from surrounding Wi-Fi hotspots in the target frequency band based on a signal strength and/or a protocol standard of the Wi-Fi hotspot comprises: selecting, from the Wi-Fi hotspots in the target frequency band, a Wi-Fi hotspot that belongs to a same access point device as a Wi-Fi hotspot to which the receiver device is currently connected and that has a received signal strength indicator RSSI value greater than a first preset threshold as the target hotspot; and/or selecting, from the Wi-Fi hotspots in the target frequency band, a Wi-Fi hotspot that has a largest quantity of signal bars as the target hotspot; and/or selecting, from the Wi-Fi hotspots in the target frequency band, a Wi-Fi hotspot that has a highest protocol standard as the target hotspot.
  3. 3 . The method according to claim 1 , wherein the determining whether the condition for connecting to the target hotspot is met further comprises: determining, based on a score and/or a signal strength of the target hotspot, whether the condition for connecting to the target hotspot is met, wherein the score of the target hotspot is determined based on at least one or more of the following information: a quantity of times of success of historical connections between the receiver device and the target hotspot, a historical transmission rate, a historical signal strength, and a quantity of times of historical freeze.
  4. 4 . The method according to claim 1 , wherein meeting the condition for connecting to the target hotspot comprises any one of the following: a score of the target hotspot is greater than or equal to a second preset threshold, and an RSSI value of the target hotspot is greater than or equal to a third preset threshold; the score of the target hotspot is greater than a sum of a score of a Wi-Fi hotspot to which the receiver device is currently connected and a preset compensation value, and the RSSI value of the target hotspot is greater than or equal to a fourth preset threshold; or the target hotspot and the Wi-Fi hotspot to which the receiver device is currently connected belong to a same access point device, and designated bits in a media access control address MAC address are the same, and the RSSI value of the target hotspot is greater than or equal to a fifth preset threshold.
  5. 5 . The method according to claim 1 , further comprising: ending the network preferential selection procedure when the receiver device is currently connected to the Wi-Fi hotspot in the target frequency band.
  6. 6 . The method according to claim 1 , further comprising: when the target hotspot is not selected, or when the condition for connecting to the target hotspot is not met, starting a network multiplex procedure.
  7. 7 . The method according to claim 6 , wherein the network multiplex procedure comprises: sending a first indication message to the transmitter device, wherein the first indication message is used to indicate the transmitter device to create a personal hotspot in the target frequency band; receiving connection information of the personal hotspot from the transmitter device; and connecting to the personal hotspot based on the connection information.
  8. 8 . The method according to claim 6 , wherein the network multiplex procedure comprises: sending a remote network configuration request to the transmitter device, wherein the remote network configuration request is used to indicate the transmitter device to configure a P2P agent server network in the target frequency band; receiving a configuration result of the P2P agent server network from the transmitter device; and configuring a local P2P agent client network based on the configuration result, to switch from the 2.4 GHz Wi-Fi network to the P2P agent server network.
  9. 9 . The method according to claim 1 , wherein the first broadcast message and the second broadcast message are Bluetooth low energy (BLE) broadcast messages, and the P2P connection request is sent by the transmitter device by using a BLE connection; and before the receiving, by the receiver device, the P2P connection request from the transmitter device, the method further comprises: establishing the BLE connection with the transmitter device.
  10. 10 . The method according to claim 1 , wherein before the establishing the Wi-Fi P2P connection in the target frequency band with the transmitter device, the method further comprises: disconnecting a Bluetooth low energy (BLE) connection from the transmitter device.
  11. 11 . A terminal device operating as a receiver device, comprising: a processor; a memory coupled to the processor and configured to store program instructions, wherein the processor is configured to execute the program instructions to cause the terminal device to: receive a first broadcast message sent by a transmitter device, wherein the first broadcast message comprises a file sharing request; send a second broadcast message to the transmitter device in response to the first broadcast message, wherein the second broadcast message comprises receiver device information; receive a P2P connection request of the transmitter device, wherein the P2P connection request is generated by the transmitter device based on the receiver device information; when the receiver device is currently connected to a 2.4 GHz Wi-Fi network and does not support dual band dual concurrent (DBDC), start a network preferential selection procedure in response to the P2P connection request, wherein the network preferential selection procedure is used for the receiver device to switch from the 2.4 GHz Wi-Fi network to a Wi-Fi network in a target frequency band, wherein the target frequency band comprises frequency bands of 5 GHz and above; establish a Wi-Fi P2P connection in the target frequency band with the transmitter device; receive a file sent by the transmitter device by using the Wi-Fi P2P connection; when a target hotspot is not selected, or when a condition for connecting to the target hotspot is not met, start a network multiplex procedure, which when performed, is configured to: send a first indication message to the transmitter device, wherein the first indication message is used to indicate the transmitter device to create a personal hotspot in the target frequency band; receive connection information of the personal hotspot from the transmitter device; and connect to the personal hotspot based on the connection information.
  12. 12 . The terminal device according to claim 11 , wherein the network preferential selection procedure comprises to: determine whether the receiver device is currently connected to a Wi-Fi hotspot in the target frequency band; when the receiver device is not currently connected to the Wi-Fi hotspot in the target frequency band, select a target hotspot from surrounding Wi-Fi hotspots in the target frequency band based on a signal strength and/or a protocol standard of the Wi-Fi hotspot; when the target hotspot is selected, determine whether a condition for connecting to the target hotspot is met; and when the condition for connecting to the target hotspot is met, connect to the target hotspot.
  13. 13 . The terminal device according to claim 12 , wherein to select the target hotspot from surrounding Wi-Fi hotspots in the target frequency band based on the signal strength and/or the protocol standard of the Wi-Fi hotspot comprises to: select, from the Wi-Fi hotspots in the target frequency band, a Wi-Fi hotspot that belongs to a same access point device as a Wi-Fi hotspot to which the receiver device is currently connected and that has a received signal strength indicator RSSI value greater than a first preset threshold as the target hotspot; and/or select, from the Wi-Fi hotspots in the target frequency band, a Wi-Fi hotspot that has a largest quantity of signal bars as the target hotspot; and/or select, from the Wi-Fi hotspots in the target frequency band, a Wi-Fi hotspot that has a highest protocol standard as the target hotspot.
  14. 14 . The terminal device according to claim 12 , wherein to determine whether the condition for connecting to the target hotspot is met comprises to: determine, based on a score and/or a signal strength of the target hotspot, whether the condition for connecting to the target hotspot is met, wherein the score of the target hotspot is determined based on at least one or more of the following information: a quantity of times of success of historical connections between the receiver device and the target hotspot, a historical transmission rate, a historical signal strength, and a quantity of times of historical freeze.
  15. 15 . The terminal device according to claim 12 , wherein meeting the condition for connecting to the target hotspot comprises any one of the following: a score of the target hotspot is greater than or equal to a second preset threshold, and an RSSI value of the target hotspot is greater than or equal to a third preset threshold; the score of the target hotspot is greater than a sum of a score of a Wi-Fi hotspot to which the receiver device is currently connected and a preset compensation value, and the RSSI value of the target hotspot is greater than or equal to a fourth preset threshold; or the target hotspot and the Wi-Fi hotspot to which the receiver device is currently connected belong to a same access point device, and designated bits in a media access control address MAC address are the same, and the RSSI value of the target hotspot is greater than or equal to a fifth preset threshold.
  16. 16 . The terminal device according to claim 12 , the program instructions further cause the terminal device to: end the network preferential selection procedure when the receiver device is currently connected to the Wi-Fi hotspot in the target frequency band.
  17. 17 . The terminal device according to claim 12 , the program instructions further cause the terminal device to: when the target hotspot is not selected, or when the condition for connecting to the target hotspot is not met, start a network multiplex procedure.
  18. 18 . The terminal device according to claim 17 , wherein the network multiplex procedure comprises to: send a first indication message to the transmitter device, wherein the first indication message is used to indicate the transmitter device to create a personal hotspot in the target frequency band; receive connection information of the personal hotspot from the transmitter device; and connect to the personal hotspot based on the connection information.
  19. 19 . A non-transitory computer storage medium, wherein the computer-readable storage medium stores program instructions, and when the program instructions are run on a computer operating as a receiver device, the computer is enabled to: receive a first broadcast message sent by a transmitter device, wherein the first broadcast message comprises a file sharing request; send a second broadcast message to the transmitter device in response to the first broadcast message, wherein the second broadcast message comprises receiver device information; receive a P2P connection request of the transmitter device, wherein the P2P connection request is generated by the transmitter device based on the receiver device information; when the receiver device is currently connected to a 2.4 GHz Wi-Fi network and does not support dual band dual concurrent (DBDC), start a network preferential selection procedure in response to the P2P connection request, wherein the network preferential selection procedure is used for the receiver device to switch from the 2.4 GHz Wi-Fi network to a Wi-Fi network in a target frequency band, wherein the target frequency band comprises frequency bands of 5 GHz and above; establish a Wi-Fi P2P connection in the target frequency band with the transmitter device; receive a file sent by the transmitter device by using the Wi-Fi P2P connection; and when a target hotspot is not selected, or when a condition for connecting to the target hotspot is not met, start a network multiplex procedure, which when performed, is configured to: send a remote network configuration request to the transmitter device, wherein the remote network configuration request is used to indicate the transmitter device to configure a P2P agent server network in the target frequency band; receive a configuration result of the P2P agent server network from the transmitter device; and configure a local P2P agent client network based on the configuration result, to switch from the 2.4 GHz Wi-Fi network to the P2P agent server network.

Description

CROSS-REFERENCE TO RELATED APPLICATIONS This application is a National Stage of International Application No. PCT/CN2022/138817, filed on Dec. 13, 2022, which claims priority to Chinese Patent Application No. 202210123103.1, filed on Feb. 10, 2022, both of which are hereby incorporated by reference in their entireties. TECHNICAL FIELD Embodiments of this application relate to the field of terminal technologies, and in particular, to a file sharing method and a terminal device. BACKGROUND Data may be transmitted between terminal devices based on wireless fidelity (wireless fidelity, Wi-Fi) peer-to-peer (peer-to-peer, P2P) connections. This function is usually used for scenarios in which a user shares photos, files, and the like between different terminal devices. For example, when the user needs to share photos in a mobile phone to a tablet computer, the mobile phone and the tablet computer may establish a Wi-Fi P2P connection with each other in response to an operation of the user, so that the photos in the mobile phone can be sent to the tablet computer by using the Wi-Fi P2P connection. Currently, a Wi-Fi technology is mainly implemented in high frequency bands such as 2.4 GHz and 5 GHz frequency bands. When any terminal device is connected to a Wi-Fi hotspot in the 2.4 GHz frequency band and does not support dual band dual concurrent (dual band dual concurrent, DBDC), the Wi-Fi P2P connection between the two terminal devices is negotiated to be established in the 2.4 GHz frequency band. Compared with a high frequency band such as the 5 GHz frequency band, a transmission rate of the 2.4 GHz frequency band is lower, and is also susceptible to interference from Bluetooth or other Wi-Fi signals in the same frequency band. Therefore, when two terminal devices share files based on a Wi-Fi P2P connection in the 2.4 GHz frequency band, a file transmission speed is usually quite low, resulting in a long file transmission time. For example, on the Wi-Fi P2P connection in the 2.4 GHz frequency band, it takes 3 minutes to transmit a 60 MB video file. This greatly wastes user time and reduces use experience of the user. SUMMARY Embodiments of this application provide a file sharing method and a terminal device, to improve a speed of file transmission between terminal devices. According to a first aspect, embodiments of this application provide a file sharing method, applied to a receiver device. The method includes: receiving a first broadcast message sent by a transmitter device, where the first broadcast message includes a file sharing request; sending a second broadcast message to the transmitter device in response to the first broadcast message, where the second broadcast message includes receiver device information; receiving a P2P connection request of the transmitter device, where the P2P connection request is generated by the transmitter device based on the receiver device information; if the receiver device is currently connected to a 2.4 GHz Wi-Fi network and does not support dual band dual concurrent DBDC, starting a network preferential selection procedure in response to the P2P connection request, where the network preferential selection procedure is used for the receiver device to switch from the 2.4 GHz Wi-Fi network to a Wi-Fi network in a target frequency band, where the target frequency band includes frequency bands of 5 GHz and above; establishing a Wi-Fi P2P connection in the target frequency band with the transmitter device; and receiving a file sent by the transmitter device by using the Wi-Fi P2P connection. According to the method provided in this embodiment of this application, the transmitter device establishes the Wi-Fi P2P connection in a frequency band of 5 GHz or above with the receiver device, to prevent another wireless signal in a frequency band of less than 5 GHz from causing interference to the Wi-Fi P2P connection between the transmitter device and the receiver device, so as to help improve a speed of file transmission between the transmitter device and the receiver device, improve stability of the Wi-Fi P2P connection between the transmitter device and the receiver device, and shorten a file transmission time, thereby improving use experience of sharing, by a user, a file between two terminal devices. In an implementation, the network preferential selection procedure includes: determining whether the receiver device is currently connected to a Wi-Fi hotspot in the target frequency band; if the receiver device is not currently connected to the Wi-Fi hotspot in the target frequency band, selecting a target hotspot from surrounding Wi-Fi hotspots in the target frequency band based on a signal strength and/or a protocol standard of the Wi-Fi hotspot; if the target hotspot is selected, determining whether a condition for connecting to the target hotspot is met; and if the condition for connecting to the target hotspot is met, connecting to the target hotspot. In this way, after receivi