public static void connectToAP(ProxyConfiguration conf) throws Exception { if (APL.getWifiManager() != null && APL.getWifiManager().isWifiEnabled()) { if (conf != null && conf.ap != null && conf.ap.getLevel() > -1) { // Connect to AP only if it's available ReflectionUtils.connectToWifi(APL.getWifiManager(), conf.ap.networkId); APL.getWifiManager().enableNetwork(conf.ap.networkId, true); } } }
protected static ProxyStatusItem isWifiEnabled(ProxyConfiguration conf) { ProxyStatusItem result = null; if (APL.getWifiManager().isWifiEnabled()) { NetworkInfo ni = APL.getConnectivityManager().getActiveNetworkInfo(); if (ni != null && ni.isConnected() && ni.getType() == ConnectivityManager.TYPE_WIFI) { String status = APL.getContext().getString(R.string.status_wifi_enabled); result = new ProxyStatusItem( ProxyStatusProperties.WIFI_ENABLED, CheckStatusValues.CHECKED, true, true, status); } else { result = new ProxyStatusItem( ProxyStatusProperties.WIFI_ENABLED, CheckStatusValues.CHECKED, false, true, APL.getContext().getString(R.string.status_wifi_enabled_disconnected)); } } else { result = new ProxyStatusItem( ProxyStatusProperties.WIFI_ENABLED, CheckStatusValues.CHECKED, false, true, APL.getContext().getString(R.string.status_wifi_not_enabled)); } return result; }
public static void startWifiScan() { if (APL.getWifiManager() != null && APL.getWifiManager().isWifiEnabled()) { APL.getWifiManager().startScan(); } }