• 配置WifiConfiguration


    1. public WifiConfiguration CreateWifiInfo(String SSID, String Password, int Type)     
    2.    {     
    3.          WifiConfiguration config = new WifiConfiguration();       
    4.           config.allowedAuthAlgorithms.clear();     
    5.           config.allowedGroupCiphers.clear();     
    6.           config.allowedKeyManagement.clear();     
    7.           config.allowedPairwiseCiphers.clear();     
    8.           config.allowedProtocols.clear();     
    9.          config.SSID = """ + SSID + """;       
    10.              
    11.          WifiConfiguration tempConfig = this.IsExsits(SSID);               
    12.          if(tempConfig != null) {      
    13.              mWifiManager.removeNetwork(tempConfig.networkId);      
    14.          }    
    15.              
    16.          if(Type == 1) //WIFICIPHER_NOPASS    
    17.          {     
    18.               config.wepKeys[0] = "";     
    19.               config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);     
    20.               config.wepTxKeyIndex = 0;     
    21.          }     
    22.          if(Type == 2) //WIFICIPHER_WEP    
    23.          {     
    24.              config.hiddenSSID = true;    
    25.              config.wepKeys[0]= """+Password+""";     
    26.              config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);     
    27.              config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);     
    28.              config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);     
    29.              config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);     
    30.              config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);     
    31.              config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);     
    32.              config.wepTxKeyIndex = 0;     
    33.          }     
    34.          if(Type == 3) //WIFICIPHER_WPA    
    35.          {     
    36.          config.preSharedKey = """+Password+""";     
    37.          config.hiddenSSID = true;       
    38.          config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);       
    39.          config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);                             
    40.          config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);                             
    41.          config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);                        
    42.          //config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);      
    43.          config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);    
    44.          config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);    
    45.          config.status = WifiConfiguration.Status.ENABLED;       
    46.          }    
    47.           return config;     
    48.    }     
  • 相关阅读:
    检查点(Checkpoint)过程如何处理未提交的事务
    SQL Server代理(4/12):配置数据库邮件
    SQL Server代理(3/12):代理警报和操作员
    hash_multimap
    hash_map
    hash_multiset
    hash_set
    hash 函数
    pair
    multimap
  • 原文地址:https://www.cnblogs.com/dongweiq/p/4795201.html
Copyright © 2020-2023  润新知