Andriod phone connection network connection limit (connect limit)

Phenomenon: After
connecting to wifi, you can surf the Internet, but the network status shows that the network is unavailable, and there is a small × on the wifi icon. This is because the system will automatically detect the captive portal server address after connecting to wifi. The default code address of Qualcomm is google. Some domestic users can’t access the google website, even if they can go online, the network status is unavailable.
Modify the URL: In the
framework, we can find the server address:

private static final String DEFAULT_HTTPS_URL     = "https://www.google.com/generate_204";
private static final String DEFAULT_HTTP_URL      =
            "http://connectivitycheck.gstatic.com/generate_204";
private static String getCaptivePortalServerHttpsUrl(Context context) {
    
    
        return getSetting(context, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, DEFAULT_HTTPS_URL);                                                                                                                  
    }
    public static String getCaptivePortalServerHttpUrl(Context context) {
    
    
        return getSetting(context, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, DEFAULT_HTTP_URL);
    }

The default address of the database can be changed through the command:

adb shell "settings put global captive_portal_http_url http://**************"

adb shell "settings put global captive_portal_https_url https://**************"

Change to the URL that the vendor wants.
You can also block monitoring:
Method 1:

adb shell settings put global captive_portal_mode 0

Way two:

adb shell settings put global captive_portal_detection_enabled 0

In the source code frameworks/base/services/core/java/com/android/server/ConnectivityService.java

case NetworkMonitor.EVENT_PROVISIONING_NOTIFICATION: {
    
    
                    final int netId = msg.arg2;
                    final boolean visible = (msg.arg1 != 0);
                    final NetworkAgentInfo nai;
                    synchronized (mNetworkForNetId) {
    
    
                        nai = mNetworkForNetId.get(netId);
                    }
                    // If captive portal status has changed, update capabilities or disconnect.
                    if (nai != null && (visible != nai.lastCaptivePortalDetected)) {
    
    
                        final int oldScore = nai.getCurrentScore();
                        nai.lastCaptivePortalDetected = visible;
                        nai.everCaptivePortalDetected |= visible;
                        if (nai.lastCaptivePortalDetected &&
                            Settings.Global.CAPTIVE_PORTAL_MODE_AVOID == getCaptivePortalMode()) {
    
    
                            if (DBG) log("Avoiding captive portal network: " + nai.name());
                            nai.asyncChannel.sendMessage(
                                    NetworkAgent.CMD_PREVENT_AUTOMATIC_RECONNECT);
                            teardownUnneededNetwork(nai);
                            break;
                        }
                        updateCapabilities(oldScore, nai, nai.networkCapabilities);
                    }
                    if (!visible) {
    
    
                        mNotifier.clearNotification(netId);
                    } else {
    
    
                        if (nai == null) {
    
    
                            loge("EVENT_PROVISIONING_NOTIFICATION from unknown NetworkMonitor");
                            break;
                        }
                        if (!nai.networkMisc.provisioningNotificationDisabled) {
    
    
                            mNotifier.showNotification(netId, NotificationType.SIGN_IN, nai, null,
                                    (PendingIntent) msg.obj, nai.networkMisc.explicitlySelected);
                        }
                    }

        private int getCaptivePortalMode() {
    
    
            return Settings.Global.getInt(mContext.getContentResolver(),
                    Settings.Global.CAPTIVE_PORTAL_MODE,
                    Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT);
        }

Change the default value of Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT

Guess you like

Origin blog.csdn.net/weixin_42271802/article/details/113204426