Android8.1原生系统网络感叹号消除

原生系统Android8.1上,WiFi上出现感叹号,此时WiFi可正常访问。

这里写图片描述

原因

这是Android 5.0引入的网络评估机制:就是当你连上网络后,会给目标产生204响应的服务器发送给一个请求,如果服务器返回的是状态码为204的响应,那么就被认为网络可以访问;否则,如返回的是其他状态码,那么将被视为网络访问需要登录操作等;没有响应的话,就被认为是网络不可访问。这里的情况就是,目标服务器不能正常访问

产生204响应的服务器

加粗网址亲测可行,其余未测试,但可作为一个参考

修改&恢复默认

测试系统:Android 8.1默认使用https来验证,如要使用http,需要先写入关闭https验证的配置,再填写http服务器。然后开启飞行模式,再打开感叹号即可消失。其中,xxxxx即服务器的URL。

# 查看所有配置
adb shell settings list global
# 使用https
adb shell settings put global captive_portal_https_url xxxxx
# 使用http
adb shell settings put global captive_portal_use_https 0
adb shell settings put global captive_portal_http_url xxxxx
# 使用默认,即删除配置
adb shell settings delete global captive_portal_http_url
adb shell settings delete global captive_portal_https_url

禁用此功能

按照上述方法,设置captive_portal_mode的值如下:

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

Android8.0相关源码代码:

这里写图片描述
源代码链接,无需梯子可直达。

参考

https://www.noisyfox.io/android-captive-portal.html
http://www.pixcn.cn/article-2990-1.html
http://blog.sina.com.cn/s/blog_5fdac4c90102wv27.html

猜你喜欢

转载自blog.csdn.net/asahinokawa/article/details/80722178