Android SoftAp支持 (二)
来源:互联网 发布:centos7 git 源码安装 编辑:程序博客网 时间:2024/05/19 18:39
SoftAp界面开启流程(让你的手机支持SoftAp功能)
市面上大多数手机支持SoftAp功能,有少数手机没有打开SoftAp的界面设置,所以无法开启此功能(当然有些山寨手机平板打开了此设置功能也不一定能使用SoftAP,因为此功能需要WIFI芯片与WIFI驱动的支持才能真正意义上实现)。
深入代码介绍一下手机 PortableWi-Fi hostpot 界面开启条件
上文《Android SoftAp支持 (一)》提到当勾选Portable Wi-Fihostpot,系统的Setting程序TetherSettings.java将响应此动作。tether这个词意思是拴绳,拴住的意思,理解起来有点晦涩,这里我的理解是分享的意思,比如WIFI_TETHERING(用WIFI分享网路),
那么这些网络分享如何满足什么条件才开启呢?
从WirelessSettings开始说
在packages/apps/Settings/src/com/android/settings/WirelessSettings.java的onCreate方法中会去检测系统是否Tether
1)调用获取ConnectivityManager实例对象,并调用isTetheringSupported方法来检测是否支持Tether
2)调用getTetheringLabel查看支持哪些网络共享方式,并显示到界面
先看isTetheringSupported方法
它调用了frameworks/base/services/java/com/android/server/ConnectivityService.java的isTetheringSupported 方法
之后会检测是否有配置文件配置了tether,有则使用设置的值,没有查询到配置这使用查询ro.tether.denied属性的默认值。
这里我们假设得到的tetherEnableInSettings为ture,也不意味着就能正确打开Portable Wi-Fihostpot 界面。因为还需要检测是否支持WIFI网络共享配置
mTethering.getTetherableWifiRegexs().length!=0检测是否支持网络共享配置,这里Android4.4 与之前的版本有一定区别,但总体不变,大家可以参考其他代码做一些变通
getTetherableWifiRegexs()方法
updateConfiguration()方法中赋值
这里的config_tether_wifi_regexs数组由配置文件生成
配置文件config.xml
frameworks/base/core/res/res/values/config.xml
- Android SoftAp支持 (二)
- Android SoftAp支持 (二)
- Android SoftAp支持 (二)
- Android SoftAp支持 (一)
- Android SoftAp支持 (一)
- Android SoftAp支持 (一)
- Android SoftAp支持
- Android dialog用法(二)
- Spring 事务管理(二)
- nand flash读写 (二) (转)
- ArcGIS for javascript 学习(二)
- android 四舍五入
- android o…
- android …
- android scoket
- Android - LayoutInflater
- Android - LayoutInflater
- DB LUW 与 SAP LUW(二)
- 启动softAP过程:
- 启动softAP过程:
- Android 4.1 Netd详细分…
- Android 4.1 Netd详细分…
- Android SoftAp支持 (二)
- Android SoftAp支持 (二)
- Android 4.1 Netd详细分…
- Android 4.1 Netd详细分…
- Android 4.1 Netd详细分…
- Android 4.1 Netd详细分…
- android USB绑定功能实现(fr…
- android USB绑定功能实现(fr…
- linux bring up串口何时初始化
- Linux __setup解析