Limite de conexão de rede de conexão do telefone Andriod (limite de conexão)

Fenômeno:
você pode navegar na Internet depois de se conectar ao wi-fi, mas o status da rede mostra que a rede está indisponível e há um pequeno × no ícone do wi-fi. Isso ocorre porque o sistema detectará automaticamente o endereço do servidor do portal cativo após conectar-se a wifi. O endereço de código padrão da Qualcomm é google. Alguns usuários domésticos não podem acessar o site do google, mesmo que possam ficar online, o status da rede mostra que não está disponível.
Modifique o URL: No
framework, podemos encontrar o endereço do servidor :

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);
    }

O endereço padrão do banco de dados pode ser alterado por meio do comando:

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

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

Mude para a URL desejada pelo fornecedor.
Você também pode bloquear o monitoramento:
Método 1:

adb shell settings put global captive_portal_mode 0

Caminho dois:

adb shell settings put global captive_portal_detection_enabled 0

Nos frameworks de código-fonte / 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);
        }

Altere o valor padrão de Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT

Acho que você gosta

Origin blog.csdn.net/weixin_42271802/article/details/113204426
Recomendado
Clasificación