QR code zxing source code analysis (4) wifi, zxing source code wifi

Source: Internet
Author: User

QR code zxing source code analysis (4) wifi, zxing source code wifi
The addresses of the first three parts are: ZXING source code analysis (1) CAMERA, zxing source code analysis (2) decode and zxing source code analysis (3) result and history: the core source code of zxing has basically been read in the first three articles. Now we are analyzing the functions of zxing, in fact, history also belongs to this part, but in the third article, it describes the core class: com. google. zxing. client. android. wifi. wifiConfigManager wifi management class, which uses the parsed results to manage com. google. zxing. client. android. wifi. networkType network type classification com. google. zxing. client. result. in the WifiResultParser core, the scan result is parsed by wifi com. google. zxing. client. result. methods In WifiParsedResult core, used to store the parsed result WifiConfigManager contains the following methods: changeNetworkCommon is used to process Wi-Fi connections without a password changeNetworkWEP is used to process Wi-Fi connections of WEP changeNetworkWPA is used to process Wi-Fi connections of WPA. It inherits the AsyncTask Method, doInBackground () processes the connection type wifi, and gets the wifi type based on the resolution result, and then connects. The Code is as follows:

 String networkTypeString = theWifiResult.getNetworkEncryption();    NetworkType networkType;    try {      networkType = NetworkType.forIntentValue(networkTypeString);    } catch (IllegalArgumentException ignored) {      Log.w(TAG, "Bad network type; see NetworkType values: " + networkTypeString);      return null;    }    if (networkType == NetworkType.NO_PASSWORD) {      changeNetworkUnEncrypted(wifiManager, theWifiResult);    } else {      String password = theWifiResult.getPassword();      if (password != null && !password.isEmpty()) {        if (networkType == NetworkType.WEP) {          changeNetworkWEP(wifiManager, theWifiResult);        } else if (networkType == NetworkType.WPA) {          changeNetworkWPA(wifiManager, theWifiResult);        }      }    }

TheWifiResult. getNetworkEncryption (); gets the wifi type. This method is obtained by parsing the parser of the WifiResultParser in the Core package and returning the data contained in the WifiParsedResult class

 public WifiParsedResult parse(Result result) {    String rawText = getMassagedText(result);    if (!rawText.startsWith("WIFI:")) {      return null;    }    String ssid = matchSinglePrefixedField("S:", rawText, ';', false);    if (ssid == null || ssid.isEmpty()) {      return null;    }    String pass = matchSinglePrefixedField("P:", rawText, ';', false);    String type = matchSinglePrefixedField("T:", rawText, ';', false);    if (type == null) {      type = "nopass";    }    boolean hidden = Boolean.parseBoolean(matchSinglePrefixedField("H:", rawText, ';', false));    return new WifiParsedResult(type, ssid, pass, hidden);  }
At this point, the Wi-Fi resolution is completed. The above is the internal resolution of wifi data. How is the data displayed on the page? This will return to the handleDecode method of CaptureActivity, this is because handleDecode that displays the results of all types of data calls handleDecodeInternally for processing. if you draw a picture, you can refer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.