android 网络连接受限解决

问题log

07-21 11:12:12.623  2802 15955 D NetworkMonitor/109: PROBE_HTTPS https://www.google.com/generate_204 Probe failed with exception javax.net.ssl.SSLHandshakeException: Chain validation failed
07-21 11:12:12.702  2802 15956 D NetworkMonitor/109: PROBE_HTTP http://connectivitycheck.gstatic.com/generate_204 time=870ms ret=204 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.1 204 No Content], Connection=[close], Content-Length=[0], Cross-Origin-Resource-Policy=[cross-origin], Date=[Wed, 23 Aug 2023 09:06:01 GMT], X-Android-Received-Millis=[1689909132701], X-Android-Response-Source=[NETWORK 204], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1689909131931]}
07-21 11:12:13.068  2802 15954 D NetworkMonitor/109: PROBE_FALLBACK http://www.google.com/gen_204 time=362ms ret=204 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.1 204 No Content], Connection=[close], Content-Length=[0], Content-Security-Policy=[object-src 'none';base-uri 'self';script-src 'nonce-Nx4YkFMXBPZjNT5UaF_eew' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other], Content-Type=[text/html; charset=UTF-8], Date=[Wed, 23 Aug 2023 09:06:02 GMT], Origin-Trial=[Ap+qNlnLzJDKSmEHjzM5ilaa908GuehlLqGb6ezME5lkhelj20qVzfv06zPmQ3LodoeujZuphAolrnhnPA8w4AIAAABfeyJvcmlnaW4iOiJodHRwczovL3d3dy5nb29nbGUuY29tOjQ0MyIsImZlYXR1cmUiOiJQZXJtaXNzaW9uc1BvbGljeVVubG9hZCIsImV4cGlyeSI6MTY4NTY2Mzk5OX0=, AvudrjMZqL7335p1KLV2lHo1kxdMeIN0dUI15d0CPz9dovVLCcXk8OAqjho1DX4s6NbHbA/AGobuGvcZv0drGgQAAAB9eyJvcmlnaW4iOiJodHRwczovL3d3dy5nb29nbGUuY29tOjQ0MyIsImZlYXR1cmUiOiJCYWNrRm9yd2FyZENhY2hlTm90UmVzdG9yZWRSZWFzb25zIiwiZXhwaXJ5IjoxNjkxNTM5MTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZX0=], Permissions-Policy=[unload=()], Server=[gws], Set-Cookie=[1P_JAR=2023-08-23-09; expires=Fri, 22-Sep-2023 09:06:02 GMT; path=/; domain=.google.com; Secure], X-Android-Received-Millis=[1689909133066], X-Android-Response-Source=[NETWORK 204], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1689909132839], X-Frame-Options=[SAMEORIGIN], X-XSS-Protection=[0]}
07-21 11:12:13.071  2802 15954 D NetworkMonitor/109: isCaptivePortal: isSuccessful()=false isPortal()=false RedirectUrl=null isPartialConnectivity()=true Time=1264ms

可以看到是访问https://www.google.com/generate_204  时失败

失败的原因:

1.连接的是国内的网络,是无法访问国外的网站的,自然会失败。

2.如果连接的国外的网络的话,并且发现可以正确访问国外的某些网站。但是还算提示网络受限,那这个时候 请排查  手机的系统时间是否正确,访问这个网站需要时间误差大概不能超过一个月(没有具体实验过)。

解决方案:

1.  临时更换检验网站。(临时解决方案)

adb shell settings put global captive_portal_https_url https://connect.rom.miui.com/generate_204

2. 更改代码。

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

http://connectivitycheck.gstatic.com/generate_204

- https://www.google.com/generate_204
+ https://developers.google.cn/generate_204

3.将手机的时间 设置为自动设置时间

参考文章:Android系统连接WIFI显示网络连接受限_android 网络连接受限_阿炎-阿景的博客-CSDN博客

你可能感兴趣的:(android)