Android WIFI-系统连接WIFI显示网络连接受限

news/2025/2/13 23:15:37/

问题描述


使用Android设备打开设置,选择WIFI输入正确密码连接,会显示已连接,无网络,然后变成网络连接受限,实际可以使用此WIFI进行上网。

问题分析


异常Log

D NetworkMonitor/100: PROBE_DNS www.google.com 107ms OK 104.244.46.85
D NetworkMonitor/100: PROBE_DNS connectivitycheck.gstatic.com 118ms OK 203.208.50.66
D NetworkMonitor/100: PROBE_HTTP http://connectivitycheck.gstatic.com/generate_204 time=35ms ret=302 request={Connection=[close], User-Agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.32 Safari/537.36]} headers={null=[HTTP/1.0 302 Moved Temporarily], Allow=[GET,POST,HEAD], Location=[http://10.10.1.2:8080/cn/index.html], MIME-Version=[1.0], Pragma=[No-Cache], Server=[AP Server 1.0], X-Android-Received-Millis=[1615220820212], X-Android-Response-Source=[NETWORK 302], X-Android-Selected-Protocol=[http/1.0], X-Android-Sent-Millis=[1615220820196]}
D NetworkMonitor/100: PROBE_HTTPS https://www.google.com/generate_204 Probe failed with exception javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
D NetworkMonitor/100: isCaptivePortal: isSuccessful()=false isPortal()=true RedirectUrl=http://10.10.1.2:8080/cn/index.html isPartialConnectivity()=false Time=172ms



从Log中可以看出来,连接WIFI会进行网络的校验,从而判断是否可用,HTTP校验成功,但是HTTPS校验失败,因此会显示网络连接受限,其连接过程中会出现短暂的已连接,无网络是正常现象。HTTPS校验的网址https://www.google.com/generate_204,由于在国内无法访问,所以会校验失败,可采取的做法是替换此网址。

packages/modules/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java 

#校验源码部分
private CaptivePortalProbeResult sendDnsAndHttpProbes(ProxyInfo proxy, URL url, int probeType) {// Pre-resolve the captive portal server host so we can log it.// Only do this if HttpURLConnection is about to, to avoid any potentially// unnecessary resolution.final String host = (proxy != null) ? proxy.getHost() : url.getHost();// This method cannot safely report probe results because it might not be running on the// state machine thread. Reporting results here would cause races and potentially send// information to callers that does not make sense because the state machine has already// changed state.sendDnsProbe(host);return sendHttpProbe(url, probeType, null);
}# HTTPS网址相关源码
private final URL mCaptivePortalHttpsUrl;
mCaptivePortalHttpsUrl = makeURL(getCaptivePortalServerHttpsUrl());
public String getCaptivePortalServerHttpUrl() {return getSettingFromResource(mContext, R.string.config_captive_portal_http_url,R.string.default_captive_portal_http_url, CAPTIVE_PORTAL_HTTP_URL);
}



解决方案


packages/modules/NetworkStack/res/values/config.xml 

<!-- HTTP URL for network validation, to use for detecting captive portals. -->
<string name="default_captive_portal_http_url" translatable="false">http://connectivitycheck.gstatic.com/generate_204</string>
<!-- HTTPS URL for network validation, to use for confirming internet connectivity. -->
- <string name="default_captive_portal_https_url" translatable="false">https://www.google.com/generate_204</string>
+ <string name="default_captive_portal_https_url" translatable="false">https://developers.google.cn/generate_204</string>


网上还有另一种解法如下,就是关闭校验,此解法可以实现不显示网络连接受限的问题,但是在连接需要登陆的WIFI时,无法连接

frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java

loadSetting(stmt, Settings.Global.LID_BEHAVIOR, defaultLidBehavior);
loadStringSetting(stmt, Settings.Global.NTP_SERVER_2,R.string.def_ntp_server_2);
+ loadSetting(stmt, Global.CAPTIVE_PORTAL_MODE, Global.CAPTIVE_PORTAL_MODE_IGNORE);


关于captive_portal_mode的值
0:彻底禁用检测
1:检测到需要登录则弹窗提醒(默认值)
2:检测到需要登录则自动断开此热点并不再自动连接


http://www.ppmy.cn/news/1014163.html

相关文章

八年级编程代码必考题,八年级编程猫教学设计

大家好&#xff0c;小编来为大家解答以下问题&#xff0c;八年级编程哪个内容适合上公开课&#xff0c;八年级编程猫教学设计&#xff0c;现在让我们一起来看看吧&#xff01; 算术运算符与表达式 课题 算术运算符 与表达式 单元 Python程序设计基础 学科 信息 年级 八年级 主备…

国内大模型在局部能力上已超ChatGPT

中文大模型正在后来居上&#xff0c;也必须后来居上。 数科星球原创 作者丨苑晶 编辑丨大兔 从GPT3.5彻底出圈后&#xff0c;大模型的影响力开始蜚声国际。一段时间内&#xff0c;国内科技公司可谓被ChatGPT按在地上打&#xff0c;毫无还手之力。 彼时&#xff0c;很多企业…

rman常用命令

查看时间段需要恢复的归档 RMAN> list backup of archivelog time between "to_date(2023-08-02 00:10:00,yyyy-mm-dd,hh24:mi:ss)" and "to_date(2023-08-02 03:03:03,yyyy-mm-dd hh24:mi:ss)"; #加载不在控制文件记录中的归档&#xff0c;并删除6小时…

同芯同意创未来——赛意力量 SNP ·南京半导体高科专场

7月28日&#xff0c;“赛意力量全国行”将在南京组织以“同芯同意创未来”为主题的南京半导体高科专场沙龙活动。届时&#xff0c;“赛意力量”将携众优秀企业IT及财务领域嘉宾&#xff0c;开展深度交流&#xff0c;共同为推动科技创新与区域经济发展而出谋划策。 南京作为中国…

如何创建51单片机KEIL工程

如何创建51单片机KEIL工程步骤&#xff1a; &#xff08;1&#xff09;打开keil软件&#xff0c;点击工具栏-Project&#xff0c;选择创建新的工程&#xff1b; &#xff08;2&#xff09;然后给工程命名&#xff0c;文章以project为例&#xff0c;然后点击保存 &#xff08…

Vivado中SmartConnect和InterConnect的区别

前言&#xff1a;本文章为FPGA问答系列&#xff0c;我们会定期整理FPGA交流群&#xff08;包括其他FPGA博主的群&#xff09;里面有价值的问题&#xff0c;并汇总成文章&#xff0c;如果问题多的话就每周整理一期&#xff0c;如果问题少就每两周整理一期&#xff0c;一方面是希…

嵌入式Linux下LVGL的移植与配置

一.sdk源码下载路径 1.官方源码下载路径如下: ​​​​​​ https://github.com/lvgl/lvgl git下载方式 git clone https://github.com/lvgl/lvgl.git 2.个人移植好的源码8.2版本下载路径: 链接:https://pan.baidu.com/s/1jyqIennsQpv-RB4RyKvZyg?pwd=c68e 提取码:c68e…

模型训练技术指南

目录 引言 1. 模型训练的重要性 2. 数据预处理 3. 特征工程 4. 模型选择与评估 5. 参数调优 6. 模型集成 7. 过拟合与欠拟合 8. 模型保存与加载 9. 分布式训练与加速 10. 最佳实践与常见问题 引言 模型训练是机器学习领域中至关重要的一步&#xff0c;它决定了模型的…