Android 系统连接WIFI显示网络连接受限分析处理_安卓13类原生系统网络受限-CSDN博客
package\modules\NetworkStack\src\com\android\networkstack\util\NetworkStackUtils.java
public static final String CAPTIVE_PORTAL_MODE = "captive_portal_mode";
//0 不检测
public static final int CAPTIVE_PORTAL_MODE_IGNORE = 0;
//1默认弹框提示,默认
public static final int CAPTIVE_PORTAL_MODE_PROMPT = 1;
//2检测到需要登录则自动断开此热点并不再自动连接
public static final int CAPTIVE_PORTAL_MODE_AVOID = 2;
/vendor/mediatek/proprietary/packages/apps/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
//*/add wifi Not verified
loadSetting(stmt, Settings.Global.CAPTIVE_PORTAL_MODE, Settings.Global.CAPTIVE_PORTAL_MODE_IGNORE );//0
//*/
【以上是方法二】
国内访问或使用国外的网址失败,系统提示无法连接并访问网络,不可用或者网络受限
方案修改:一是替换了校验网络的url地址,二是去除整个校验网络过程。
【以下是方法一】
将该网址替换系统默认的校验网址
--- a/packages/modules/NetworkStack/res/values/config.xml
+++ b/packages/modules/NetworkStack/res/values/config.xml
@@ -11,7 +11,7 @@
<integer name="default_captive_portal_dns_probe_timeout">12500</integer>
<!-- 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>
- <string name="default_captive_portal_http_url" translatable="false">http://xxxxx/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://xxxx.xx.xx/generate_204\</string>
注意overlay地方:
vnd\vendor\mediatek\proprietary\packages\overlay\vendor\NetworkStackResOverlay\res\values\config.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="config_captive_portal_https_urls" translatable="false">
<item>https://connectivitycheck.gstatic.com/generate_204\</item>
<item>https://www.google.cn/generate_204\</item>
</string-array>
**+ <string-array name="config_captive_portal_https_urls" translatable="false">
- <item>https://xxx.xxx.xxx/generate_204\</item>
- <item>https://xxxx.xxx.xxx/generate_204\</item>
- </string-array>**
</resources>
如果没有特殊要求的话建议将网络评估机制的结果直接手动返回成功
添加变量:b/packages/modules/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java
@@ -1468,6 +1468,7 @@ public class NetworkMonitor extends StateMachine {
@VisibleForTesting
protected CaptivePortalProbeResult isCaptivePortal() {
- mIsCaptivePortalCheckEnabled = false;
if (!mIsCaptivePortalCheckEnabled) {
validationLog("Validation disabled.");
return CaptivePortalProbeResult.SUCCESS;
或者:构造方法里面://*/
mIsCaptivePortalCheckEnabled = false;
/*/
mIsCaptivePortalCheckEnabled = getIsCaptivePortalCheckEnabled();
//*/