先直接上结论,在电脑上连接好adb后输入这两行命令之一即可。直接关闭检测,简单粗暴,副作用是连接需要登录的公共WiFi不会自动弹出登录页面
adb shell settings put global captive_portal_detection_enabled 0 (7.1.1及以下版本)
adb shell settings put global captive_portal_mode 0 (7.1.2及以上版本)
或者也可以通过更换Captive Portal服务器来解决,详见下文

为什么要去掉?这个叉不仅是一个图标,而是真正会影响到系统的运行。在打叉状态时系统会默认网络不通,于是原生浏览器,系统下载等等都会直接罢工……
以下为网络上找到的资料,转自 https://android.stackexchange.com/questions/186993/captive-portal-parameters

Configuring captive portal behaviour

captive_portal_detection_enabled (<= Android 7.1.1)
0: Don’t attempt to detect captive portals
1: Prompt the user to sign in
2: Immediately disconnect from the network and do not reconnect to that network in the future

captive_portal_mode (>= Android 7.1.2)
0: Completely disable captive portal checks
1: Enable it (default)

Setting captive portal URL(s)

captive_portal_server (<= Android 6.0.1)
The server that holds a generate_204 page, used to internally craft a URL for captive portal detection (new URL("http", mServer, "/generate_204"); – obsolete as of Android 7.0, see below)

captive_portal_use_https (>= Android 7.0)
0: Don’t use HTTPS for network validation
1: Use HTTPS (default)

captive_portal_http_url (>= Android 7.0)
The URL used for HTTP captive portal detection - use in pair with captive_portal_use_https (set to 0)
>= Android 7.1.1: OS no longer appends generate_204 to URL automatically, giving input URL some flexibility

captive_portal_https_url (>= Android 7.0)
The URL used for HTTPS captive portal detection - use in pair with captive_portal_use_https (set to 1)
>= Android 7.1.1: OS no longer appends generate_204 to URL automatically

Requirement for the URL to be used

A HTTP 204 response code (“no content”) from the server is used for validation, no extra content needed: take the default detection URL for example, curl clients3.google.com/generate_204 returns empty, and inspecting HTTP response by adding –write-out %{http_code} returns 204.’

A small list of usable captive portal server URLs in mainland China (personally tested)

https://captive.v2ex.co/generate_204 (hosted by v2ex.com)
https://connect.rom.miui.com/generate_204 (hosted by Xiaomi, used by default on MIUI)
https://noisyfox.cn/generate_204 (hosted by noisyfox.cn)
https://www.google.cn/generate_204 & https://developers.google.cn/generate_204 (hosted by Google)
https://www.qualcomm.cn/generate_204 (hosted by Qualcomm)

Further notes

The source also mentions parameters captive_portal_user_agent, captive_portal_fallback_url and captive_portal_other_fallback_urls:

captive_portal_fallback_url (>= Android 7.1.1) obviously is supposed
to hold a single URL, while captive_portal_other_fallback_urls holds
multiple further URLs (comma separated list, so the URLs might not
contain any comma).

But I personally conducted tests on Android 8.0.0, and both fallback parameters don’t work. Assuming they’re declarations without an implementation for now.

Some examples of captive portal settings of Android in China show the use of some of the above settings:

1
2
3
4
adb shell settings put global captive_portal_http_url http://www.google.cn/generate_204
adb shell settings put global captive_portal_https_url https://www.google.cn/generate_204
adb shell settings put global captive_portal_fallback_url http://www.google.cn/generate_204
adb shell settings put global captive_portal_other_fallback_urls http://www.qualcomm.cn/generate_204

Knowing that, “tin foils” even could set up their own verification service. With Apache:

1
2
3
RewriteEngine On
RewriteCond %{REQUEST_URI} /generate_204$
RewriteRule $ / [R=204,L]

or with Nginx:

1
location / generate_204 { return 204 ; }