[go: up one dir, main page]

CN109327916B - Method and device for automatically connecting WLAN of mobile terminal to WiFi - Google Patents

Method and device for automatically connecting WLAN of mobile terminal to WiFi Download PDF

Info

Publication number
CN109327916B
CN109327916B CN201811256923.8A CN201811256923A CN109327916B CN 109327916 B CN109327916 B CN 109327916B CN 201811256923 A CN201811256923 A CN 201811256923A CN 109327916 B CN109327916 B CN 109327916B
Authority
CN
China
Prior art keywords
wlan
state
wifi
mobile terminal
current mobile
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811256923.8A
Other languages
Chinese (zh)
Other versions
CN109327916A (en
Inventor
曾攀文
陈小君
杨益军
令狐克严
彭银波
昝燕能
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Cvhealth Science And Technology Co ltd
Original Assignee
Chengdu Cvhealth Science And Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chengdu Cvhealth Science And Technology Co ltd filed Critical Chengdu Cvhealth Science And Technology Co ltd
Priority to CN201811256923.8A priority Critical patent/CN109327916B/en
Publication of CN109327916A publication Critical patent/CN109327916A/en
Application granted granted Critical
Publication of CN109327916B publication Critical patent/CN109327916B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/724User interfaces specially adapted for cordless or mobile telephones
    • H04M1/72403User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W24/00Supervisory, monitoring or testing arrangements
    • H04W24/08Testing, supervising or monitoring using real traffic
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W84/00Network topologies
    • H04W84/02Hierarchically pre-organised networks, e.g. paging networks, cellular networks, WLAN [Wireless Local Area Network] or WLL [Wireless Local Loop]
    • H04W84/10Small scale networks; Flat hierarchical networks
    • H04W84/12WLAN [Wireless Local Area Networks]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Human Computer Interaction (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Telephone Function (AREA)

Abstract

The invention discloses a method and a device for automatically connecting a WLAN (wireless local area network) of a mobile terminal to WiFi (wireless fidelity). The method for automatically connecting the WLAN of the mobile terminal to the WiFi comprises the following steps: checking the WLAN state of the current mobile terminal; starting a corresponding thread according to the state of the WLAN of the current mobile terminal, circularly detecting, and directly entering WiFi connection flow processing to connect designated WiFi if the WLAN of the current mobile terminal is in the started state; if the WLAN of the current mobile terminal is not in the started state, sequentially entering the next state, starting a corresponding thread, and circularly detecting until the WLAN of the current mobile terminal is in the started state; and entering WiFi connection flow processing to connect the designated WiFi. According to the scheme, the WiFi can be fully automatically connected to any android mobile phone of any domestic manufacturer, and the method is good in compatibility, high in success rate and good in continuity.

Description

Method and device for automatically connecting WLAN of mobile terminal to WiFi
Technical Field
The invention relates to the field of rubberizing, in particular to a method and a device for automatically connecting a Wireless Local Area Network (WLAN) with a wireless fidelity (WiFi) of a mobile terminal.
Background
The android api belongs to an open source method provided by a system, belongs to the prior art, and in the existing mobile terminal, because the system has a security protection mechanism, when the WLAN api is called to be opened, a user needs to give an application program the authority to open the WLAN. When an application program needs to open a WLAN authority, a system pops up a WLAN authority opening application frame and blocks the operation of the application, and the application program can continue to operate after a user can operate and approve or reject the application program.
Disclosure of Invention
The invention aims to solve the technical problems of improving the compatibility of the android mobile phone in China and realizing the full-automatic WiFi connection designation in the real sense, and aims to provide a method and a device for the WLAN of a mobile terminal to automatically connect the WiFi.
The invention is realized by the following technical scheme:
in a first aspect, the present invention provides a method for automatically connecting a WLAN of a mobile terminal to a WiFi, comprising the following steps:
sequentially setting a closing state, an opening state and an opening state according to the WLAN state advancing sequence of the mobile terminal, and checking the state of the WLAN of the current mobile terminal; starting a corresponding thread according to the state of the WLAN of the current mobile terminal, circularly detecting, and directly entering WiFi connection flow processing to connect designated WiFi if the WLAN of the current mobile terminal is in the started state; and if the WLAN of the current mobile terminal is not in the started state, sequentially entering the next state, starting a corresponding thread, circularly detecting until the WLAN of the current mobile terminal is in the started state, entering WiFi connection flow processing, and connecting the specified WiFi.
Corresponding to the first aspect, the invention starts the corresponding thread according to the state of the WLAN of the current mobile terminal, performs cycle detection, and directly enters the WiFi connection flow process if the WLAN of the current mobile terminal is in the started state; if the WLAN of the current mobile terminal is not in the started state, entering the next state in sequence, starting a corresponding thread, circularly detecting until the WLAN of the current mobile terminal is in the started state, and entering WiFi connection flow processing, wherein the specific implementation steps are as follows: if the WLAN state of the current mobile terminal is in the closing state, starting a thread, circularly detecting whether the WLAN state is in the closing state, and if the WLAN enters the closing state, exiting the circulation; if the WLAN state of the current mobile terminal is closed, starting a thread, calling android api to open the WLAN, circularly detecting whether the WLAN enters the open state, and if the WLAN enters the open state, exiting the circulation; if the WLAN state of the current mobile terminal is in the opening state, starting a thread, circularly detecting whether the WLAN state is in the opening state, and if the WLAN enters the opening state, exiting the circulation; and if the WLAN state of the current mobile terminal is started, entering WiFi connection flow processing to connect the appointed WiFi.
Corresponding to the first aspect, the WiFi connection process of the present invention, the specific steps of connecting the designated WiFi are as follows:
if the WLAN of the current mobile terminal is connected to the designated WiFi, starting a loop detection thread and keeping the loop detection thread without entering subsequent operation; if the WiFi of the WLAN connection of the current mobile terminal is different from the designated WiFi, checking whether the WLAN state of the mobile terminal is in a closed state, starting a thread, and entering loop detection until the WLAN state enters the closed state; recording the current time t1, calling android api to open the WLAN, returning to the state, recording the time t2 at the moment, if t2-t1 is less than fixed time and the returned state is failure, sending a message to inform a user of timely processing authority, entering a starting thread, circularly checking, separating fixed time, detecting the state of the WLAN, if the state of the WLAN is changed into the open state, checking whether WiFi information configuration to be connected exists in the system, if the WiFi information configuration exists, directly reading configuration for use, connecting appointed WiFi, otherwise, establishing appointed WiFi information configuration, reading establishment configuration information again, and connecting appointed WiFi; if the WLAN state is not the opening state, accumulating the fixed interval time, and if the accumulated fixed interval time is larger than a set value, returning to the connection failure and stopping all threads.
Corresponding to the first aspect, if the WLAN status of the current mobile terminal is in the off state, timeout detection is required, and if the WLAN status has not been changed to the on state within a fixed time, an error is returned, and the WLAN on operation is terminated.
Corresponding to the first aspect, after the WLAN activation operation is terminated, the user is also prompted for the reason for the failure according to the status.
In a second aspect, the present invention discloses a device for automatically connecting a WLAN of a mobile terminal to a WiFi, comprising:
a connection opportunity triggering module: stopping the current WLAN connection WiFi action and all threads of the mobile terminal until an application program on the mobile terminal needs to connect WiFi operation at any time, and sending an instruction to trigger a detection module to work; a detection module: sequentially setting a closing state, an opening state and an opening state according to the WLAN state advancing sequence of the mobile terminal, and checking the state of the WLAN of the current mobile terminal; WiFi connects the judgement module: starting a corresponding thread according to the state of the WLAN of the current mobile terminal, circularly detecting, and directly entering WiFi connection flow processing to connect designated WiFi if the WLAN of the current mobile terminal is in the started state; and if the WLAN of the current mobile terminal is not in the started state, sequentially entering the next state, starting a corresponding thread, circularly detecting until the WLAN of the current mobile terminal is in the started state, entering WiFi connection flow processing, and connecting the specified WiFi.
Compared with the prior art, the invention has the following advantages and beneficial effects:
1. according to the invention, the states of the WLAN are divided into four types, corresponding threads are set for each state, circulating detection is carried out, each thread works independently and does not influence each other, only when the WLAN is in an opened state, the application program APP on the same mobile terminal or different mobile terminals continues to run, WiFi connection is carried out, and the situation that a user repeatedly opens the android system WLAN through manual operation is avoided, so that WiFi full-automatic connection can be realized; the method can realize full-automatic connection of designated WiFi for android mobile phones of any domestic manufacturer, and is good in compatibility, high in success rate and good in continuity.
2. The method and the device eliminate the situation that the WLAN cannot be automatically connected to the designated WiFi due to the fact that the mobile terminals of some manufacturers are provided with the WLAN permission selection application frames but actually do not block the continuous operation of the application program APP on the same mobile terminal or different mobile terminals.
Drawings
The accompanying drawings, which are included to provide a further understanding of the embodiments of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the principles of the invention. In the drawings:
FIG. 1 is a flow chart of the present invention;
fig. 2 is a schematic block diagram.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail below with reference to examples and accompanying drawings, and the exemplary embodiments and descriptions thereof are only used for explaining the present invention and are not meant to limit the present invention.
Indicated in the examples below:
connection opportunity triggering: refers to the time when the application needs to connect with WiFi at any time;
WiFi: representing wireless communication 2.4G or 5G hot spot broadcasting;
WLAN state: the switching process of the state is fixed as the following two conditions:
open- > close;
closed- > open-medium- > closed.
Example 1:
as shown in fig. 1-2, the present invention includes a method for WLAN automatic WiFi connection of a mobile terminal, comprising the steps of:
s1: sequentially setting a closing state, an opening state and an opening state according to the WLAN state advancing sequence of the mobile terminal, and checking the state of the WLAN of the current mobile terminal;
s2: starting a corresponding thread according to the state of the WLAN of the current mobile terminal, circularly detecting, and directly entering WiFi connection flow processing to connect designated WiFi if the WLAN of the current mobile terminal is in the started state; and if the WLAN of the current mobile terminal is not in the started state, sequentially entering the next state, starting a corresponding thread, circularly detecting until the WLAN of the current mobile terminal is in the started state, entering WiFi connection flow processing, and connecting the specified WiFi. The corresponding threads and the loop detection of each state of the WLAN work independently without mutual influence. One or more state threads and loop detection work may be performed simultaneously.
The reasons for the failure of the WLAN to connect to the WiFi are various, and may be errors occurring in the process of opening the WLAN or in the process of connecting to the WiFi, and there is no feasible method for solving the errors occurring in the process of opening the WLAN at present. In the prior art, when a WLAN api is called to be opened, a user is required to give an application program an authority to open the WLAN due to a system security protection mechanism. For mobile phone manufacturers of different brands, mobile phone systems are different, the permission application frame for opening the WLAN is also set to be different, although the WLAN permission selection application frame is set on the mobile terminals of some manufacturers, the continuous operation of the application program APP on the same mobile terminal or different mobile terminals is not actually blocked, under the condition that a user does not operate the WLAN permission selection application frame, the continuous operation of the application program APP opens the WiFi connection WLAN, the WLAN is not opened at the moment, connection errors can occur, WiFi connection is stopped, the state is failed to return, and therefore the WiFi network cannot be connected to the designated and existing WiFi network automatically, the android system WLAN needs to be manually operated by the user repeatedly to be opened at the moment to be connected to the designated WiFi, the steps are complex, the success rate and the duration rate are not ideal. Because no matter what kind of brand's cell-phone, four kinds of states that WLAN locates are fixed unchangeable, this scheme is based on this principle, divide into four kinds with the state that WLAN locates, all set up corresponding thread to every state, carry out the cycle detection, and each thread independent work, each is not mutually influenced, only after WLAN has been opened the state, just continue to operate application APP on same mobile terminal or different mobile terminals, carry out wiFi and connect, avoid user's manual operation to open android system WLAN repeatedly, can realize the full automatic connection of wiFi. The method can realize full-automatic connection of designated WiFi for android mobile phones of any domestic manufacturer, and is good in compatibility, high in success rate and good in continuity.
Starting a corresponding thread according to the state of the WLAN of the current mobile terminal, circularly detecting, and directly entering WiFi connection flow processing if the WLAN of the current mobile terminal is in the started state; if the WLAN of the current mobile terminal is not in the started state, entering the next state in sequence, starting a corresponding thread, circularly detecting until the WLAN of the current mobile terminal is in the started state, and entering WiFi connection flow processing, wherein the specific implementation steps are as follows:
s21: if the WLAN state of the current mobile terminal is in the closing state, starting a thread, circularly detecting whether the WLAN state is in the closing state, and if the WLAN enters the closing state, exiting the circulation;
s22: if the WLAN state of the current mobile terminal is closed, starting a thread, calling android api to open the WLAN, circularly detecting whether the WLAN enters the open state, and if the WLAN enters the open state, exiting the circulation;
s23: if the WLAN state of the current mobile terminal is in the opening state, starting a thread, circularly detecting whether the WLAN state is in the opening state, and if the WLAN enters the opening state, exiting the circulation;
s24: and if the WLAN state of the current mobile terminal is started, entering WiFi connection flow processing to connect the appointed WiFi.
In the WLAN connection process, it may also occur that the WLAN is just opened, the system may actively connect to the last time or WiFi with high priority, so that at this time, when we go to connect to the designated WiFi, the system is switched by the system connection logic, at this time, the processing mode is to let the system connect to the WiFi with high priority, and when it is detected that the system is connected, a command is invoked to disconnect the WiFi that the system is connecting or has connected, and the designated WiFi is reconnected.
Therefore, the WiFi connection flow process, connecting the designated WiFi, adopts the following processing steps:
s241: if the WLAN of the current mobile terminal is connected to the designated WiFi, starting a loop detection thread and keeping the loop detection thread without entering subsequent operation;
s242: if the WiFi of the WLAN connection of the current mobile terminal is different from the designated WiFi, in order to detect whether the WLAN in the thread is closed by the user, checking whether the WLAN state of the mobile terminal is a closed state, starting the thread, and entering circular detection until the WLAN state is the closed state;
due to the fact that the WiFi connection is failed to be opened by calling the android api, the user may not agree with the request of the WLAN permission box, the WLAN permission selection application box is set on the mobile terminal of part of manufacturers, the continuous operation of the application program APP on the same mobile terminal or different mobile terminals is not blocked, and the state failure can be returned under the condition that the user does not operate the WLAN permission selection application box, so that the WiFi connection failure is caused. In order to eliminate the reason that the WiFi connection failure is not caused by setting a WLAN permission selection application box on a mobile terminal of a part of manufacturers but does not block the continuous operation of the application APP on the same mobile terminal or a different mobile terminal, the following operations are performed:
recording the current time t1, calling android api to open the WLAN, returning to the state, recording the time t2 at the moment, if t2-t1 is less than a fixed time (such as 1 second) and the returned state is WiFi connection failure, sending a message to inform a user of timely processing authority, agreeing to WLAN connection, entering a starting thread, circularly checking, detecting the WLAN state at an interval of a fixed time (which can be 100 milliseconds), if the WLAN state is changed into the opening state, checking whether WiFi information configuration to be connected exists in the system, if the WiFi information configuration exists, directly reading the configuration for use, connecting the designated WiFi, otherwise, creating the designated WiFi information configuration, reading the created configuration information again, if the content of the configuration information is wrong, starting the thread to circularly re-read the configuration, recording the time, and if the content of the configuration information is more than a certain time, indicating that the system has an unknown problem, exiting the connection and returning to the. If the content of the read configuration file is correct, connecting the designated WiFi; if the WLAN state is not the opening state, accumulating the fixed interval time, if the accumulated fixed interval time is larger than a set value (such as 15 seconds), returning to the connection failure and stopping all threads. Each cycle of each thread detects whether the WLAN state is abnormally switched and exits the stop if abnormally switched.
By monitoring the opening time of the WLAN of the android api, when the time interval is less than a fixed time such as 1 second, the WLAN connection WiFi failure is considered to be abnormal, because if the user does not agree to connect the WLAN and returns to the state to connect the WiFi failure, the opening time of the WLAN of the android api is necessarily greater than the fixed time such as 1 second. Therefore, when the WLAN status is not in the on state, the fixed interval time needs to be accumulated, when the fixed interval time exceeds a limit value (e.g. 15 seconds), no WLAN connection is performed, which means that the user does not approve the WLAN connection operation, and the connection failure returned at this time is the correct value, all threads can be stopped, and the user is waited to trigger the operation next time. By monitoring the opening time of the WLAN by the android api, the abnormal condition of connection failure caused by setting a WLAN permission selection application frame on the mobile terminals of part manufacturers but not blocking the continuous operation of the application program APP on the same mobile terminal or different mobile terminals is further eliminated, and the success rate and the continuity of full-automatic WiFi connection are further improved. In order to connect the designated WiFi, the designated WiFi configuration information is judged, WiFi information configuration is not carried out, connection is carried out, the fact that the connected designated WiFi is a network in existence is guaranteed, and reliability of automatic connection of the designated WiFi is further improved.
When the designated WiFi information configuration is created, a special thread is needed to be started, whether the ID attribute in the configuration information which is just created has a value (-1 represents no value) or not is checked, if the ID attribute does not have the value, the circulation detection is carried out, the WLAN state is detected, if the WLAN state is not started, a connection failure message is sent, and all threads are stopped; and if the WLAN state is started, reestablishing the WiFi information configuration file, waiting for 1 second, accumulating the establishing times after a system processes a response task, if the establishing times are equal to 5 times, indicating that the system has an unknown problem, sending a connection failure message, and stopping all threads.
If the ID has a value (not equal to-1), indicating that the creation is successful, exiting the cycle, re-detecting whether the WLAN state is started, if not, sending a connection failure message, and stopping all threads; if the WLAN is in an opened state, circularly detecting whether the WiFi automatically connected by the current system is successfully connected, if the connection is successful, disconnecting the connection, calling an android system command to connect the WiFi, sending a delay notice, controlling the total WiFi connection time not to be more than 20 seconds (or other interval time), if the total WiFi connection time is more than 20 seconds, directly returning to the connection failure, and stopping all threads; and if the connection fails, accumulating the time, entering the next cycle, if the accumulated time is equal to 5 seconds, directly jumping out of the cycle, calling an android system to connect WiFi, sending a delay notice, controlling the total WiFi connection time not to be more than 20 seconds (or other interval time), and if the total WiFi connection time is more than 20 seconds, directly returning to the connection failure and stopping all threads.
In order to detect whether WiFi is switched by a user in a thread, when the WLAN is in an opened state, delaying for 0.1 second, checking whether the current WiFi is connected completely in a logic way, and if not, entering the next cycle; and if so, sending a connection success message, starting an error detection thread and keeping continuing to circularly detect whether the WiFi is switched by the user in the thread.
Preferably, if the WLAN status of the current mobile terminal is in the off state, timeout detection is required, and if the WLAN status is not changed to the on state within a fixed time, an error is returned to terminate the WLAN on operation.
The arrangement further eliminates the situation of connection failure in the full-automatic WiFi connection, and further improves the accuracy of the full-automatic WiFi connection.
In order to facilitate the user to find the problem, follow-up operation is carried out, and after the WLAN starting operation is terminated, the user is prompted to the reason of the failure according to the state.
Example 2:
referring to fig. 2, the device for automatically connecting WiFi to WLAN of mobile terminal of the present invention is shown, which comprises a processor and a memory connected to each other, and further comprises a device connected to the processor
A connection opportunity triggering module: stopping the current WLAN connection WiFi action and all threads of the mobile terminal until an application program on the mobile terminal needs to connect WiFi operation at any time, and sending an instruction to trigger a detection module to work;
a detection module: sequentially setting a closing state, an opening state and an opening state according to the WLAN state advancing sequence of the mobile terminal, and checking the state of the WLAN of the current mobile terminal;
WiFi connects the judgement module: starting a corresponding thread according to the state of the WLAN of the current mobile terminal, circularly detecting, and directly entering WiFi connection flow processing to connect designated WiFi if the WLAN of the current mobile terminal is in the started state; and if the WLAN of the current mobile terminal is not in the started state, sequentially entering the next state, starting a corresponding thread, circularly detecting until the WLAN of the current mobile terminal is in the started state, entering WiFi connection flow processing, and connecting the specified WiFi.
The WiFi connection judging module comprises the following specific processing steps:
if the WLAN state of the current mobile terminal is in the closing state, starting a thread, circularly detecting whether the WLAN state is in the closing state, and if the WLAN enters the closing state, exiting the circulation;
if the WLAN state of the current mobile terminal is closed, starting a thread, calling android api to open the WLAN, circularly detecting whether the WLAN enters the open state, and if the WLAN enters the open state, exiting the circulation;
if the WLAN state of the current mobile terminal is in the opening state, starting a thread, circularly detecting whether the WLAN state is in the opening state, and if the WLAN enters the opening state, exiting the circulation;
and if the WLAN state of the current mobile terminal is started, entering WiFi connection flow processing to connect the appointed WiFi.
On the basis of the above step, the following is preferred; WiFi connection flow processing, wherein the specific steps of connecting the designated WiFi are as follows:
if the WLAN connection of the current mobile terminal designates WiFi, starting a loop detection thread and keeping the loop detection thread without entering subsequent operation;
if the WiFi of the WLAN connection of the current mobile terminal is different from the designated WiFi, checking whether the WLAN state of the mobile terminal is in a closed state, starting a thread, and entering loop detection until the WLAN state enters the closed state;
recording the current time t1, calling android api to open the WLAN, returning to the state, recording the time t2 at the moment, if t2-t1 is less than a fixed time (such as 1 second) and the returned state is failure, sending a message to inform a user of processing, entering a starting thread, circularly checking, separating the fixed time, detecting the WLAN state, if the WLAN state is changed into the open state, checking whether WiFi to be connected exists in the system, if the WLAN state is the open state, directly reading configuration for use, connecting the designated WiFi, otherwise, creating designated WiFi information configuration, reading the created configuration information again, and connecting the designated WiFi; if the WLAN state is not the opening state, accumulating the fixed interval time, and if the accumulated fixed interval time is larger than a set value, returning to the connection failure and stopping all threads.
If the current WLAN state of the mobile terminal is off, timeout detection is required, and if the WLAN state is not changed to on within a fixed time, an error is returned, and the WLAN on operation is terminated.
And after the WLAN starting operation is terminated, prompting the user of the reason of the failure according to the state.
It will be understood by those of ordinary skill in the art that the WLAN and WLAN are referred to by the same meaning, and the WiFi and WiFi are referred to by the same meaning in implementing the methods and apparatus of the above embodiments.
It will be understood by those skilled in the art that all or part of the steps in the method for implementing the above embodiments may be implemented by hardware, or may be implemented by a program to instruct relevant hardware, where the program may be stored in a computer-readable storage medium, and when executed, may include the procedures of the embodiments of the methods as described above. The storage medium may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc.
In summary, the present invention provides a method and an apparatus for automatically connecting a WLAN of a mobile terminal to a WiFi, where the states of the WLAN are divided into four types, each state is provided with a corresponding thread, and loop detection is performed, and each thread works independently without affecting each other, and only after the WLAN is in an activated state, an application APP on the same mobile terminal or different mobile terminals continues to run for WiFi connection, so as to avoid that a user manually operates to repeatedly open a WLAN of an android system, and thus, WiFi full-automatic connection can be achieved. The method can realize full-automatic connection of designated WiFi for android mobile phones of any domestic manufacturer, and is good in compatibility, high in success rate and good in continuity. The scheme eliminates the situation that the WLAN cannot be automatically connected to the designated WiFi due to the fact that the mobile terminals of some manufacturers are provided with the WLAN permission selection application frames but actually do not block the continuous operation of the application program APP on the same mobile terminal or different mobile terminals, and detects the situation that the WLAN cannot be automatically connected to the designated WiFi due to various factors such as whether the WLAN is closed by a user in a thread, whether the WiFi is switched by the user in the thread, whether the designated WiFi configuration information exists and the like, and achieves the purpose of truly and automatically connecting the designated WiFi.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are merely exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (6)

1. The method for automatically connecting the WLAN of the mobile terminal to the WiFi is characterized by comprising the following steps:
sequentially setting a closing state, an opening state and an opening state according to the WLAN state advancing sequence of the mobile terminal, and checking the state of the WLAN of the current mobile terminal;
starting a corresponding thread according to the state of the WLAN of the current mobile terminal, circularly detecting, and directly entering WiFi connection flow processing to connect designated WiFi if the WLAN of the current mobile terminal is in the started state; if the WLAN of the current mobile terminal is not in the started state, sequentially entering the next state, starting a corresponding thread, and circularly detecting until the WLAN of the current mobile terminal is in the started state; then entering WiFi connection flow processing to connect the designated WiFi;
the specific implementation steps of entering the WiFi connection flow processing until the WLAN of the current mobile terminal is in the on state are as follows:
if the WLAN state of the current mobile terminal is in the closing state, starting a thread, circularly detecting whether the WLAN state is in the closing state, and if the WLAN enters the closing state, exiting the circulation;
if the WLAN state of the current mobile terminal is closed, starting a thread, calling android api to open the WLAN, circularly detecting whether the WLAN enters the open state, and if the WLAN enters the open state, exiting the circulation;
if the WLAN state of the current mobile terminal is in the opening state, starting a thread, circularly detecting whether the WLAN state is in the opening state, and if the WLAN enters the opening state, exiting the circulation;
and if the WLAN state of the current mobile terminal is started, entering WiFi connection flow processing to connect the appointed WiFi.
2. The method of claim 1, wherein the WiFi connection process is performed to connect the designated WiFi by the following specific steps:
if the WLAN of the current mobile terminal is connected to the designated WiFi, starting a loop detection thread and keeping the loop detection thread without entering subsequent operation;
if the WiFi of the WLAN connection of the current mobile terminal is different from the designated WiFi, checking whether the WLAN state of the mobile terminal is in a closed state, starting a thread, and entering loop detection until the WLAN state enters the closed state;
recording the current time t1, calling android api to open the WLAN, returning to the state, recording the time t2 at the moment, if t2-t1 is less than fixed time and the returned state is failure, sending a message to inform a user of timely processing authority, entering a starting thread, circularly checking, separating fixed time, detecting the state of the WLAN, if the state of the WLAN is changed into the open state, checking whether WiFi information configuration to be connected exists in the system, if the WiFi information configuration exists, directly reading configuration for use, connecting appointed WiFi, otherwise, establishing appointed WiFi information configuration, reading establishment configuration information again, and connecting appointed WiFi; if the WLAN state is not the opening state, accumulating the fixed interval time, and if the accumulated fixed interval time is larger than a set value, returning to the connection failure and stopping all threads.
3. The method as claimed in claim 1, wherein if the current WLAN status of the mobile terminal is off, timeout detection is required, and if the WLAN status has not been changed to on within a fixed time, an error is returned to terminate the WLAN on operation.
4. The method as claimed in claim 3, wherein the user is further prompted for the reason of the failure according to the status after the WLAN activation operation is terminated.
5. Device for automatically connecting a WLAN of a mobile terminal to a WiFi, comprising:
a connection opportunity triggering module: stopping the current WLAN connection WiFi action and all threads of the mobile terminal until an application program on the mobile terminal needs to connect WiFi operation at any time, and sending an instruction to trigger a detection module to work;
a detection module: sequentially setting a closing state, an opening state and an opening state according to the WLAN state advancing sequence of the mobile terminal, and checking the state of the WLAN of the current mobile terminal;
WiFi connects the judgement module: starting a corresponding thread according to the state of the WLAN of the current mobile terminal, circularly detecting, and directly entering WiFi connection flow processing to connect designated WiFi if the WLAN of the current mobile terminal is in the started state; if the WLAN of the current mobile terminal is not in the started state, sequentially entering the next state, starting a corresponding thread, circularly detecting until the WLAN of the current mobile terminal is in the started state, entering WiFi connection flow processing, and connecting appointed WiFi;
the specific processing steps in the WiFi link determination module are as follows:
if the WLAN state of the current mobile terminal is in the closing state, starting a thread, circularly detecting whether the WLAN state is in the closing state, and if the WLAN enters the closing state, exiting the circulation;
if the WLAN state of the current mobile terminal is closed, starting a thread, calling android api to open the WLAN, circularly detecting whether the WLAN enters the open state, and if the WLAN enters the open state, exiting the circulation;
if the WLAN state of the current mobile terminal is in the opening state, starting a thread, circularly detecting whether the WLAN state is in the opening state, and if the WLAN enters the opening state, exiting the circulation;
and if the WLAN state of the current mobile terminal is started, entering WiFi connection flow processing to connect the appointed WiFi.
6. The apparatus of claim 5, wherein if the current WLAN status of the mobile terminal is off, a timeout detection is required, and if the WLAN status has not been changed to on within a fixed time, an error is returned to terminate the WLAN on operation.
CN201811256923.8A 2018-10-26 2018-10-26 Method and device for automatically connecting WLAN of mobile terminal to WiFi Active CN109327916B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811256923.8A CN109327916B (en) 2018-10-26 2018-10-26 Method and device for automatically connecting WLAN of mobile terminal to WiFi

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811256923.8A CN109327916B (en) 2018-10-26 2018-10-26 Method and device for automatically connecting WLAN of mobile terminal to WiFi

Publications (2)

Publication Number Publication Date
CN109327916A CN109327916A (en) 2019-02-12
CN109327916B true CN109327916B (en) 2021-05-18

Family

ID=65261886

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811256923.8A Active CN109327916B (en) 2018-10-26 2018-10-26 Method and device for automatically connecting WLAN of mobile terminal to WiFi

Country Status (1)

Country Link
CN (1) CN109327916B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112235849A (en) * 2020-10-19 2021-01-15 展讯半导体(成都)有限公司 Method, system, electronic device, and medium for identifying Wi-Fi hotspot type

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103024929A (en) * 2012-12-20 2013-04-03 惠州Tcl移动通信有限公司 Mobile terminal and method for connecting wireless network based on mobile terminal
CN106060897A (en) * 2016-05-31 2016-10-26 合肥联宝信息技术有限公司 Method for automatically starting WiFi and electronic device using same
CN106603436A (en) * 2016-12-01 2017-04-26 美的智慧家居科技有限公司 Method and system for intelligent device connecting to network

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8570993B2 (en) * 2010-05-20 2013-10-29 At&T Mobility Ii Llc Wi-Fi intelligent selection engine

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103024929A (en) * 2012-12-20 2013-04-03 惠州Tcl移动通信有限公司 Mobile terminal and method for connecting wireless network based on mobile terminal
CN106060897A (en) * 2016-05-31 2016-10-26 合肥联宝信息技术有限公司 Method for automatically starting WiFi and electronic device using same
CN106603436A (en) * 2016-12-01 2017-04-26 美的智慧家居科技有限公司 Method and system for intelligent device connecting to network

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于Android平台的WiFi管理软件的设计与实现;刘瑾;刘一玮;李玥;《计算机光盘软件与应用》;20140901;正文第76页至第77页 *

Also Published As

Publication number Publication date
CN109327916A (en) 2019-02-12

Similar Documents

Publication Publication Date Title
CN101110663A (en) Method, system and device for realizing link fault handling
US20240244462A1 (en) Information processing method and apparatus
CN101547082A (en) Active/standby link switching method and network device
WO2016045190A1 (en) Switching method, switching system and terminal for system and/or application program
CN107547368B (en) BFD session switching method, device and storage medium
CN109327916B (en) Method and device for automatically connecting WLAN of mobile terminal to WiFi
JP2010541442A (en) System and method for detecting signal failure in a ring bus system
US20220100607A1 (en) Method and system for managing fault recovery in system-on-chips
CN110072244B (en) Control method and device of radio link failure timer
CN105376785A (en) Processing method for network communication function abnormity, application processor and mobile terminal
CN101163059B (en) Network node detection method and apparatus
CN102970700A (en) Method and system for performing dual-homing automatic switching judgment according to number of registered gateways
CN105517030A (en) Processing method for network communication function abnormity, modem, and mobile terminal
CN112787886A (en) Processing method, device driver, readable storage medium and computer for real-time system network device auto-negotiation
CN112367179B (en) Link switching method and device
CN103037443A (en) Method and device for coordinating cell outage compensation and capacity and coverage optimization
US20240008122A1 (en) Method performed by user equipment, and user equipment
WO2023273088A1 (en) Control method for ring node, and network device and storage medium
CN115883339A (en) Method, device, storage medium and electronic equipment for dual-computer hot standby switching
CN113991839B (en) Device and method for improving remote control opening reliability
WO2016131187A1 (en) Network switching method and apparatus, and terminal
CN112769667B (en) Loop protection control method and device for multi-device cascade communication network
CN105245840A (en) A data forwarding method, device and camera
CN105376787A (en) Method for processing network communication function abnormity and application processor
CN112653596B (en) Method and device for routing information issuing and gateway equipment switching

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant