示例#1
0
std::string CNetworkInterfaceAndroid::GetCurrentWirelessEssId()
{
  std::string ret;

  if (m_ni.getType() == CJNIConnectivityManager::TYPE_WIFI)
  {
    CJNIWifiManager wm = CXBMCApp::getSystemService("wifi");
    if (wm.isWifiEnabled())
    {
      CJNIWifiInfo wi = wm.getConnectionInfo();
      ret = wi.getSSID();
    }
  }
  return ret;
}
void CAndroidNetworkManager::GetCurrentWifiConnection()
{
  CJNIWifiManager wifiManager(CJNIContext::getSystemService("wifi"));
  if(!wifiManager || !wifiManager.isWifiEnabled())
    return;

  CJNIWifiInfo wifiInfo = wifiManager.getConnectionInfo();
  if (!wifiInfo)
  {
    m_currentWifi.reset();
    return;
  }

  std::string bssid = wifiInfo.getBSSID();
  for(CAndroidConnectionList::iterator i = m_wifiAccessPoints.begin(); i < m_wifiAccessPoints.end(); i++)
  {
    std::string accessPointBSSID = (*i)->GetBSSID();
    if(bssid == accessPointBSSID)
    {
      m_currentWifi = *i;
      break;
    }
  }

  if (!m_currentWifi.get())
    m_currentWifi = CAndroidConnectionPtr(new CAndroidConnection(wifiInfo, &m_wifiConnectionEvent));
  else
    m_currentWifi->Update(wifiInfo);

  CJNIConnectivityManager connectivityManager(CJNIContext::getSystemService("connectivity"));
  if (connectivityManager)
  {
    CJNINetworkInfo networkInfo = connectivityManager.getNetworkInfo(CJNIConnectivityManager::TYPE_WIFI);
    if (networkInfo)
      m_currentWifi->Update(networkInfo);
    else
    {
      m_currentWifi.reset();
      return;
    }
  }
  m_currentWifi->GetDHCPInfo();
//  if (m_currentWifi->GetState() == NETWORK_CONNECTION_STATE_DISCONNECTED)
//    m_currentWifi.reset();
}
示例#3
0
std::string CNetworkInterfaceAndroid::GetCurrentWirelessEssId()
{
  std::string ret;

  CJNIConnectivityManager connman(CXBMCApp::getSystemService(CJNIContext::CONNECTIVITY_SERVICE));
  CJNINetworkInfo ni = connman.getNetworkInfo(m_network);
  if (!ni)
    return "";

  if (ni.getType() == CJNIConnectivityManager::TYPE_WIFI)
  {
    CJNIWifiManager wm = CXBMCApp::getSystemService("wifi");
    if (wm.isWifiEnabled())
    {
      CJNIWifiInfo wi = wm.getConnectionInfo();
      ret = wi.getSSID();
    }
  }
  return ret;
}