Andriod電話接続ネットワーク接続制限(接続制限)

現象:
wifiに接続した後、インターネットを閲覧できますが、ネットワークステータスにネットワークが利用できないことが示され、wifiアイコンに小さな×が表示されます。これは、に接続した後、システムがキャプティブポータルサーバーのアドレスを自動的に検出するためです。 Wi-Fi。Qualcommのデフォルトのコードアドレスはgoogleです。一部の国内ユーザーは、オンラインになってもgoogle Webサイトにアクセスできませんが、ネットワークステータスにアクセスできないことが示されて
います。URLを変更します
フレームワークで、サーバーアドレスを見つけることができます。 :

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

データベースのデフォルトアドレスは、次のコマンドで変更できます。

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

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

ベンダーが必要とするURLに変更します。
監視をブロックすることもできます。
方法1:

adb shell settings put global captive_portal_mode 0

方法2:

adb shell settings put global captive_portal_detection_enabled 0

ソースコード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);
        }

Settings.Global.CAPTIVE_PORTAL_MODE_PROMPTのデフォルト値を変更します

おすすめ

転載: blog.csdn.net/weixin_42271802/article/details/113204426