adb如何刷新Captive Portal地址

什么是 Captive Portal?

Captive Portal 是一种网络机制,常见于公共 Wi-Fi(如机场、咖啡馆、酒店等)。当你连接这类 Wi-Fi 后,通常会被重定向到一个登录或认证页面(比如需要点击“同意条款”或输入账号密码),才能访问互联网。

Android 需要自动判断当前网络是否处于这种受限状态,以便在状态栏显示“需要登录”提示,并引导用户打开浏览器完成认证。


http://captive.v2ex.co/generate_204 是一个国内可用、返回标准 HTTP 204 响应的网络检测地址,由V2EX 提供,常用于替代 Google 默认地址,解决 Android 在中国大陆等地区误报“无网络”的问题。

  • 删除默认的地址

    1
    2
    adb shell settings delete global captive_portal_https_url
    adb shell settings delete global captive_portal_http_url
  • 修改新的地址

    1
    2
    adb shell settings put global captive_portal_http_url http://captive.v2ex.co/generate_204
    adb shell settings put global captive_portal_https_url https://captive.v2ex.co/generate_204

改完同样把手机切换飞行模式,再切换回来就可以了。如果需要其它服务器地址,自行修改。
http://www.qualcomm.cn/generate_204(高通中国)
http://connect.rom.miui.com/generate_204(小米)