判断wifi是2.4G还是5G

1.WifiInfo 源码:

 

int mFrequency=wifiInfo.getFrequency();

如果

mFrequency 大于 2400 且 小于 2500  为2.4G

mFrequency 大于4900 且小于 5900 为 5G

 

  

 

 

    /**
     * @hide
     * TODO: makes real freq boundaries
     */
    public boolean is24GHz() {
        return ScanResult.is24GHz(mFrequency);
    }

    /**
     * @hide
     * TODO: makes real freq boundaries
     */
    public boolean is5GHz() {
        return ScanResult.is5GHz(mFrequency);
    }

 2.  ScanResult 代码

  public static boolean is24GHz(int freq) {
        return freq > 2400 && freq < 2500;
    }

 

    /**
     * @hide
     * TODO: makes real freq boundaries
     */
    public static boolean is5GHz(int freq) {
        return freq > 4900 && freq < 5900;
    }

  

posted @ 2018-09-29 11:04  咖喱不见不散啊  阅读(2863)  评论(0编辑  收藏  举报