搜索
您的当前位置:首页正文

Android 11.0 禁止扫描2.4ghz WIFI

来源:吉趣旅游网

介绍

客户在连接wifi时不希望连接到2.4ghz的wifi,想要在打开wifi连接列表时只扫5ghz的wifi。

修改

在WificondScannerImpl.java中我们找到startSingleScan这里我们发现 freqs = allFreqs.getScanFreqs(); 是获取了所有的频段我们只需换成只有5g频段即可

代码如下:

import android.util.ArraySet;


freqs  此处获取wifi评率 从这里拦截入手
import android.util.ArraySet;
            int[] channels = null;
            int[] channelDfs = null;
            if (!allFreqs.isEmpty()) {
//*/soda water.20231007 disable 2.4ghz wifi
                //freqs = allFreqs.getScanFreqs();
        ArraySet<Integer> mChannels = new ArraySet<Integer>();
                channels = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ);
        channelDfs = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY);
            for (int chan : channels) {
                    mChannels.add(chan);
                }
                for (int chan : channelDfs) {
                        mChannels.add(chan);
                }
        freqs= new ArraySet<Integer>(mChannels);
         Log.d(TAG, "freqs=" + freqs);
//*/soda water.20231007

因篇幅问题不能全部显示,请点此查看更多更全内容

Top