android13 系统强制wifi连接到内网,假装具有互联网能力

packages\modules\Wifi\service\java\com\android\server\wifi\WifiNetworkSelector.java

cpp 复制代码
    /**
     * Check if current network has internet or is expected to not have internet
     */
    public boolean hasInternetOrExpectNoInternet(WifiInfo wifiInfo) {
        WifiConfiguration network =
                mWifiConfigManager.getConfiguredNetwork(wifiInfo.getNetworkId());
        if (network == null) {
            return false;
        }
        //return !network.hasNoInternetAccess() || network.isNoInternetAccessExpected();
		return true;
    }

强制返回true,前面的几篇都不要看了,没用

packages\modules\NetworkStack\src\com\android\server\connectivity\NetworkMonitor.java

cpp 复制代码
private CaptivePortalProbeResult isCaptivePortal(ValidationProperties properties,
            URL[] httpsUrls, URL[] httpUrls, URL fallbackUrl) {
    // 内网专属修改:强制返回检测成功,彻底跳过所有外网探针/门户检测
    validationLog("Internal network: skip all captive portal and internet probe check");
    return CaptivePortalProbeResult.success(CaptivePortalProbeResult.PROBE_UNKNOWN);

    // 以下原代码全部保留,无需做任何修改
    if (!mIsCaptivePortalCheckEnabled) {
        validationLog("Validation disabled.");
        return CaptivePortalProbeResult.success(CaptivePortalProbeResult.PROBE_UNKNOWN);
    }

    URL pacUrl = null;

    // On networks with a PAC instead of fetching a URL that should result in a 204
    // response, we instead simply fetch the PAC script.  This is done for a few reasons:
    // 1. At present our PAC code does not yet handle multiple PACs on multiple networks
    //    until something like https://android-review.googlesource.com/#/c/115180/ lands.
    //    Network.openConnection() will ignore network-specific PACs and instead fetch
    //    using NO_PROXY.  If a PAC is in place, the only fetch we know will succeed with
    //    NO_PROXY is the fetch of the PAC itself.
    // 2. To proxy the generate_204 fetch through a PAC would require a number of things
    //    happen before the fetch can commence, namely:
    //        a) the PAC script be fetched
    //        b) a PAC script resolver service be fired up and resolve the captive portal
    //           server.
    //    Network validation could be delayed until these prerequisities are satisifed or
    //    could simply be left to race them.  Neither is an optimal solution.
    // 3. PAC scripts are sometimes used to block or restrict Internet access and may in
    //    fact block fetching of the generate_204 URL which would lead to false negative
    //    results for network validation.
    final ProxyInfo proxyInfo = mLinkProperties.getHttpProxy();
    if (proxyInfo != null && !Uri.EMPTY.equals(proxyInfo.getPacFileUrl())) {
        pacUrl = makeURL(proxyInfo.getPacFileUrl().toString());
        if (pacUrl == null) {
            return CaptivePortalProbeResult.failed(CaptivePortalProbeResult.PROBE_UNKNOWN);
        }
    }

    if ((pacUrl == null) && (httpUrls.length == 0 || httpsUrls.length == 0
            || httpUrls[0] == null || httpsUrls[0] == null)) {
        return CaptivePortalProbeResult.failed(CaptivePortalProbeResult.PROBE_UNKNOWN);
    }

    long startTime = SystemClock.elapsedRealtime();

    final CaptivePortalProbeResult result;
    if (pacUrl != null) {
        result = sendDnsAndHttpProbes(null, pacUrl, ValidationProbeEvent.PROBE_PAC);
        reportHttpProbeResult(NETWORK_VALIDATION_PROBE_HTTP, result);
    } else if (mUseHttps && httpsUrls.length == 1 && httpUrls.length == 1) {
        // Probe results are reported inside sendHttpAndHttpsParallelWithFallbackProbes.
        result = sendHttpAndHttpsParallelWithFallbackProbes(properties, proxyInfo,
                httpsUrls[0], httpUrls[0], fallbackUrl);
    } else if (mUseHttps) {
        // Support result aggregation from multiple Urls.
        result = sendMultiParallelHttpAndHttpsProbes(properties, proxyInfo, httpsUrls,
                httpUrls);
    } else {
        result = sendDnsAndHttpProbes(proxyInfo, httpUrls[0], ValidationProbeEvent.PROBE_HTTP);
        reportHttpProbeResult(NETWORK_VALIDATION_PROBE_HTTP, result);
    }

    long endTime = SystemClock.elapsedRealtime();

    log("isCaptivePortal: isSuccessful()=" + result.isSuccessful()
            + " isPortal()=" + result.isPortal()
            + " RedirectUrl=" + result.redirectUrl
            + " isPartialConnectivity()=" + result.isPartialConnectivity()
            + " Time=" + (endTime - startTime) + "ms");

    return result;
}
相关推荐
Georgewu17 分钟前
如何判断应用在鸿蒙卓易通或者出境易环境下?
android·harmonyos
localbob1 小时前
Pico 4XVR 1.10.13安装包下载与安装教程 ico 4XVR最新版下载、4XVR 1.10.13 APK安装包、Pico VR看电影软件、4XVR完整版安装教程、Pico 4播放器推荐、V
android·vr·vr播放器·vr眼镜播放器下载·pico 4xvr·4xvr下载·pico 4xvr最新版安装包
峥嵘life1 小时前
Android16 EDLA【CTS】CtsConnectivityMultiDevicesTestCases存在fail项
android·学习
大傻^2 小时前
SpringAI2.0 Null Safety 实战:JSpecify 注解体系与 Kotlin 互操作
android·开发语言·人工智能·kotlin·springai
游戏开发爱好者82 小时前
React Native iOS 代码如何加密,JS 打包 和 IPA 混淆
android·javascript·react native·ios·小程序·uni-app·iphone
kcuwu.2 小时前
Python判断及循环
android·java·python
轩情吖2 小时前
MySQL之索引
android·数据库·mysql·b+树·索引·page·
2501_915918412 小时前
iOS mobileprovision 描述文件管理,新建、下载和内容查看
android·ios·小程序·https·uni-app·iphone·webview
00后程序员张3 小时前
iOS 应用程序使用历史记录和耗能记录怎么查?
android·ios·小程序·https·uni-app·iphone·webview
用户69371750013843 小时前
OS级AI Agent:手机操作系统的下一个战场
android·前端·人工智能