前面三篇文章基本上已经把zxing的核心源码看的差不多了,现在我们在分析它所包含的功能的部分,其实history也是属于这一部分的,但是放在第三篇说了
核心类:
        com.google.zxing.client.android.wifi.WifiConfigManager wifi管理类,通过它用解析后的结果进行管理
        com.google.zxing.client.android.wifi.NetworkType 网络类型分类 
        com.google.zxing.client.result.WifiResultParser core中的方法,对扫描结果是wifi进行的解析
        com.google.zxing.client.result.WifiParsedResult  core中的方法,用来存储解析后的结果
 
WifiConfigManager 包含了以下几个方法
changeNetworkCommon 用来处理没有密码的 wifi连接
changeNetworkWEP  用来处理WEP的 wifi连接
changeNetworkWPA 用来处理WPA的 wifi连接
本身它继承了AsyncTask方法,doInBackground()处理了连接那一个类型了wifi,会根据解析的结果得到wifi的类型,然后去连接,代码如下:

 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(); 就是得到wifi的类型的,这个方法的获取是通过核心包Core中WifiResultParser的parser解析后返回WifiParsedResult类中包含的

 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);
}
到此,便完成了wifi的解析
上面所说是内部解析wifi的数据,那页面上是怎么展示的呢,这还要回到CaptureActivity的handleDecode方法,因为这个就是对所有类型的数据的结果进行展示的
handleDecode会调用handleDecodeInternally进行处理,画个图大家可以参考

二维码zxing源码分析(四)wifi部分的更多相关文章

  1. 二维码zxing源码分析(五)精简代码

    由于工作的需要,我并不是需要二维码扫描的所有的功能,我只是需要扫一扫,并显示出来图片和url就行,于是我们就要精简代码了,源码已经分析完了,精简起来就方便多了,源码分析请看 二维码zxing源码分析( ...

  2. 二维码zxing源码分析(二)decode部分

           在上一篇博客中分析了zxing怎么打开摄像头,并且扫描结果,那么扫描之后的数据呢,是不是就要解析了呢,那我们看一下zxing怎么解析这个数据的.       上一篇博客地址ZXING源码 ...

  3. 二维码zxing源码分析(一)camera部分

    首先,我们先把zxing的源代码给下载下来,这个网上有很多,我下载的是2.3的,不得不说这个谷歌提供的包包含的功能还是很全面的.     我把下载的包解压后,找到android文件夹,导入到ecpli ...

  4. 二维码扫描 zxing源码分析(三)result、history部分

    前两个部分的地址是:ZXING源码分析(一)CAMERA部分  . zxing源码分析(二)decode部分 下面我们来看第三部分 result包下面有很多的类,其中的核心类是 com.google. ...

  5. zxing源码分析——QR码部分

    Android应用横竖屏切换 zxing源码分析——DataMatrix码部分 zxing源码分析——QR码部分 2013-07-10 17:16:03|  分类: 默认分类 |  标签: |字号大中 ...

  6. 一步步实现windows版ijkplayer系列文章之二——Ijkplayer播放器源码分析之音视频输出——视频篇

    一步步实现windows版ijkplayer系列文章之一--Windows10平台编译ffmpeg 4.0.2,生成ffplay 一步步实现windows版ijkplayer系列文章之二--Ijkpl ...

  7. Alink漫谈(二十) :卡方检验源码解析

    Alink漫谈(二十) :卡方检验源码解析 目录 Alink漫谈(二十) :卡方检验源码解析 0x00 摘要 0x01 背景概念 1.1 假设检验 1.2 H0和H1是什么? 1.3 P值 (P-va ...

  8. 方维 o2o app源码出售

    方维 o2o app源码出售 方维o2oapp源码出售 1.本人官方5万购买,现把方维o2o app 源码低价出售: 2.包括网站源码本地搭建包成功提供指导 3.包括网站说明文档,不包含app说明文档 ...

  9. Ubuntu12.04下zxing源码编译

    1.下载zxing源码 git clone https://github.com/15903016222/zxing-cpp.git 2.安装依赖工具cmake sudo apt-get instal ...

随机推荐

  1. NHibernate分页

    转载:http://www.cnblogs.com/tenghoo/archive/2011/02/14/1954393.html NHibernate专题:http://kb.cnblogs.com ...

  2. Parallel.ForEach , ThreadPool.QueueUserWorkItem

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  3. Python-面向对象 (二 继承)

    一 继承   基类定义例如以下: class people:     #define attribute     name = ''     age  = 0     #define private ...

  4. JavaScript创建Map对象(转)

    JavaScript 里面本身没有map对象,用JavaScript的Array来实现Map的数据结构. /* * MAP对象,实现MAP功能 * * 接口: * size()     获取MAP元素 ...

  5. 【PAT】1029. Median (25)

    Given an increasing sequence S of N integers, the median is the number at the middle position. For e ...

  6. CF B. Kolya and Tandem Repeat

    Kolya got string s for his birthday, the string consists of small English letters. He immediately ad ...

  7. 使用Underscore.js的template将Backbone.js的js代码和html代码分离

    这段时间在学习Require.js和Backbone.js的过程中,发现有些项目里的HTML代码都是写在View的js代码里面的,渲染的时候需要对Collection进行循环,再将HTML代码拼接上去 ...

  8. 【JavaScript】JS中没有代码块的概念

    <script> var m = "roboce"; if(m === "roboce"){ var k = "haha"; } ...

  9. 实现顶部轮播,下部listview经典布局的两种方式

    开头: 在做android开发的时候,我们经常会遇到这样的布局,上面是一个图片轮播图,下面是一些列表的项目.很多新闻app,视频类app都采用这样的布局.起初的时候 由于没有很多参考,我自己想到了一种 ...

  10. angularJs项目实战!02:前端的页面分解与组装

    自从上一篇文章到现在已经有将近一个月的时间,我将精力放在了前端页面分解与组装,和angularjs如何与jquery.bootstrap.D3等一系列其他类库结合使用的经验总结上.由于公司新招了一些员 ...