public Security getWifiSecurity(String ssid) {
   List<ScanResult> scanResults = mWifiManager.getScanResults();
   for (ScanResult scanResult : scanResults) {
     if (scanResult.SSID.equals(ssid)) {
       if (scanResult.capabilities.contains(Security.WPA.type)) {
         return Security.WPA;
       } else if (scanResult.capabilities.contains(Security.WEP.type)) {
         return Security.WEP;
       } else {
         return Security.NONE;
       }
     }
   }
   return Security.NONE;
 }
예제 #2
0
  private void getWifiList() {
    boolean isCanConnect = false;
    List<String> wifiSSIDList = new ArrayList<>();
    final List<ScanResult> scanResults = admin.getWifiList();
    if (newSacn != null) {
      newSacn.clear();
    } else {
      newSacn = new ArrayList<>();
    }
    for (ScanResult scanResult : scanResults) {
      if (WifiAdmin.isConnectCamera(getActivity(), scanResult.SSID, scanResult.BSSID)) {
        newSacn.add(scanResult);
        wifiSSIDList.add(scanResult.SSID.replace("\"", ""));
      }
    }

    wifiName =
        SpUtils.getInstance(mActivity)
            .getStringValue(com.leautolink.leautocamera.config.Constant.WIFI_SSID);
    String wifiPassword = "******";
    if (!TextUtils.isEmpty(wifiName)) {
      wifiPassword =
          SpUtils.getInstance(mActivity)
              .getStringValue(com.leautolink.leautocamera.config.Constant.WIFI_PWD);
    }

    Logger.d(
        TAG,
        "wifiName -->| "
            + wifiName
            + " wifipwd -->| "
            + wifiPassword
            + " isContains -->| "
            + wifiSSIDList.contains(wifiName));

    if (wifiSSIDList.contains(wifiName)) {
      isCanConnect = connectWifi(wifiName, wifiPassword);
      tempSSID = wifiName;
    } else if (newSacn.size() == 1) {
      inputWifiPassword(newSacn.get(0));
      return;
    }
    Logger.e(TAG, wifiName + " isCanConnect  -->| " + isCanConnect);
    if (!isCanConnect) {
      // TODO 显示wifi列表
      showWifiList(true);
    }
  }