Method for automatically enabling access point function and relay function, and electronic device
Embodiments of this application relate to the field of terminal technologies and disclose a method for automatically enabling an access point function and a relay function, and an electronic device. After an electronic device is powered on, if the electronic device is connected to a wired network and does not use the network within preset duration, an AP mode is enabled; or if the electronic device is connected to a wireless network and does not use the network within preset duration, a repeater mode is enabled. The AP function and the relay function can be automatically enabled on the electronic device such as a personal computer or a smart screen, and an existing device of a consumer can be set as an AP or a repeater. The consumer does not need to buy a dedicated AP or repeater. This improves Wi-Fi use experience of the consumer.
1 . A method for automatically enabling an access point function and a relay function, comprising:
determining that an electronic device is powered on;
determining if the electronic device does not use a network within a preset duration;
in response to determining that the electronic device does not use the network within the preset duration, displaying a prompt information used to prompt a user to confirm to set the electronic device as an access point (AP) or a repeater based on a network access mode; and
setting, based on the confirmation, the electronic device as the AP or the repeater based on the network access mode.
2 . The method according to claim 1 , wherein the setting the electronic device as the AP or the repeater based on the network access mode comprises:
if the electronic device is connected to a wired network, setting the electronic device as the AP.
3 . The method according to claim 2 , further comprising:
obtaining AP configuration information of the electronic device; wherein
the setting the electronic device as the AP comprises:
setting the electronic device to an AP mode based on the AP configuration information.
4 . The method according to claim 3 , wherein the obtaining AP configuration information of the electronic device comprises:
obtaining, by the electronic device, AP configuration information of a wireless fidelity Wi-Fi network to which the electronic device has connected; or
receiving, by the electronic device, AP configuration information input by the user.
5 . The method according to claim 3 , wherein the obtaining AP configuration information of the electronic device comprises:
when access to the wired network is detected, obtaining, by the electronic device, the AP configuration information.
6 . The method according to claim 3 , wherein the AP configuration information comprises at least one or more of:
a service set identifier (SSID), an access password, or an encryption type.
7 . The method according to claim 1 , wherein the setting the electronic device as the AP or the repeater based on the network access mode comprises:
if the electronic device is connected to a wireless network, setting the electronic device as the repeater.
8 . The method according to claim 7 , further comprising:
obtaining AP configuration information of a wireless fidelity (Wi-Fi) network accessed by the electronic device; wherein
the setting the electronic device as the repeater comprises:
setting the electronic device to a repeater mode based on the AP configuration information of the Wi-Fi network.
9 . The method according to claim 1 , wherein that the electronic device does not use the network within the preset duration includes:
the electronic device is in a standby mode, or the electronic device does not upload or download data within the preset duration.
10 . An electronic device, comprising:
a processor, and
a memory coupled to the processor to store instructions, which when executed by the processor, cause the electronic device to:
determine that the electronic device is powered on; and
determine if the processor does not communicate with a network within a preset duration;
in response to determining that the electronic device does not communicate with the network within the preset duration, display a prompt information used to prompt a user to confirm to set the electronic device as an access point (AP) or a repeater based on a network access mode; and
set, based on the confirmation, the electronic device as the AP or the repeater based on the network access mode.
11 . The electronic device according to claim 10 , wherein
if the electronic device is connected to a wired network, the processor sets the electronic device as the AP.
12 . The electronic device according to claim 11 , wherein the processor is further configured to:
obtain AP configuration information of the electronic device; and
set the electronic device to an AP mode based on the AP configuration information.
13 . The electronic device according to claim 12 , wherein
the processor obtains the AP configuration information of a wireless fidelity (Wi-Fi) network to which the electronic device has connected; or
the processor receives AP configuration information input by the user.
14 . The electronic device according to claim 12 , wherein
the instructions further cause the electronic device to:
detect whether the electronic device accesses the wired network; and
the processor is configured to:
obtain the AP configuration information if the electronic device detects that the electronic device accesses the wired network.
15 . The electronic device according to claim 12 , wherein the AP configuration information comprises at least one of:
a service set identifier SSID, an access password, or an encryption type.
16 . The electronic device according to claim 10 , wherein
if the electronic device is connected to a wireless network, the processor sets the electronic device as the repeater.
17 . The electronic device according to claim 16 , wherein the processor is further configured to:
obtain AP configuration information of a wireless fidelity (Wi-Fi) network accessed by the electronic device; and
set the electronic device to a repeater mode based on the AP configuration information of the Wi-Fi network.
18 . The electronic device according to claim 10 , wherein when the processor does not use the network within the preset duration,
the electronic device is in a standby mode, or the electronic device does not upload or download data within the preset duration.