use of android.net.wifi.WifiConfiguration in project android_frameworks_base by AOSPA.
the class OSUManager method wnmRemediate.
// !!! Consistently check passpoint match.
// !!! Convert to a one-thread thread-pool
public void wnmRemediate(long bssid, String url, PasspointMatch match) throws IOException, SAXException {
WifiConfiguration config = mWifiNetworkAdapter.getActiveWifiConfig();
HomeSP homeSP = MOManager.buildSP(config.getMoTree());
if (homeSP == null) {
throw new IOException("Remediation request for unidentified Passpoint network " + config.networkId);
}
Network network = mWifiNetworkAdapter.getCurrentNetwork();
if (network == null) {
throw new IOException("Failed to determine current network");
}
WifiInfo wifiInfo = mWifiNetworkAdapter.getConnectionInfo();
if (wifiInfo == null || Utils.parseMac(wifiInfo.getBSSID()) != bssid) {
throw new IOException("Mismatching BSSID");
}
Log.d(TAG, "WNM Remediation on " + network.netId + " FQDN " + homeSP.getFQDN());
doRemediate(url, network, homeSP, false);
}
use of android.net.wifi.WifiConfiguration in project android_frameworks_base by AOSPA.
the class OSUManager method setOSUSelection.
public void setOSUSelection(int osuID) {
OSUInfo selection = null;
for (OSUInfo osuInfo : mOSUMap.values()) {
Log.d("ZXZ", "In select: " + osuInfo + ", id " + osuInfo.getOsuID());
if (osuInfo.getOsuID() == osuID && osuInfo.getIconStatus() == OSUInfo.IconStatus.Available) {
selection = osuInfo;
break;
}
}
Log.d(TAG, "Selected OSU ID " + osuID + ", matches " + selection);
if (selection == null) {
mPendingOSU = null;
return;
}
mPendingOSU = selection;
WifiConfiguration config = mWifiNetworkAdapter.getActiveWifiConfig();
if (config != null && bssidMatch(selection) && Utils.unquote(config.SSID).equals(selection.getSSID())) {
try {
// Go straight to provisioning if the network is already selected.
// Also note that mOSUNwkID is left unset to leave the network around after
// flow completion since it was not added by the OSU flow.
initiateProvisioning(mPendingOSU, mWifiNetworkAdapter.getCurrentNetwork());
} catch (IOException ioe) {
notifyUser(OSUOperationStatus.ProvisioningFailure, ioe.getMessage(), mPendingOSU.getName(LOCALE));
} finally {
mPendingOSU = null;
}
} else {
try {
mOSUNwkID = mWifiNetworkAdapter.connect(selection, mPendingOSU.getName(LOCALE));
} catch (IOException ioe) {
notifyUser(OSUOperationStatus.ProvisioningFailure, ioe.getMessage(), selection.getName(LOCALE));
}
}
}
use of android.net.wifi.WifiConfiguration in project android_frameworks_base by AOSPA.
the class NetworkPolicyManagerShellCommand method getWifiPolicies.
private List<NetworkPolicy> getWifiPolicies() throws RemoteException {
// First gets a list of saved wi-fi networks.
final List<WifiConfiguration> configs = mWifiManager.getConfiguredNetworks();
final int size = configs != null ? configs.size() : 0;
final Set<String> ssids = new HashSet<>(size);
if (configs != null) {
for (WifiConfiguration config : configs) {
ssids.add(removeDoubleQuotes(config.SSID));
}
}
// Then gets the saved policies.
final NetworkPolicy[] policies = mInterface.getNetworkPolicies(null);
final List<NetworkPolicy> wifiPolicies = new ArrayList<NetworkPolicy>(policies.length);
for (NetworkPolicy policy : policies) {
if (!policy.template.isMatchRuleMobile()) {
wifiPolicies.add(policy);
final String netId = getNetworkId(policy);
ssids.remove(netId);
}
}
// Finally, creates new default policies for saved WI-FIs not policied yet.
for (String ssid : ssids) {
final NetworkPolicy policy = newPolicy(ssid);
wifiPolicies.add(policy);
}
return wifiPolicies;
}
use of android.net.wifi.WifiConfiguration in project routerkeygenAndroid by routerkeygen.
the class Wifi method shiftPriorityAndSave.
private static int shiftPriorityAndSave(final WifiManager wifiMgr) {
final List<WifiConfiguration> configurations = wifiMgr.getConfiguredNetworks();
sortByPriority(configurations);
final int size = configurations.size();
for (int i = 0; i < size; i++) {
final WifiConfiguration config = configurations.get(i);
config.priority = i;
wifiMgr.updateNetwork(config);
}
wifiMgr.saveConfiguration();
return size;
}
use of android.net.wifi.WifiConfiguration in project routerkeygenAndroid by routerkeygen.
the class Wifi method checkForExcessOpenNetworkAndSave.
/**
* Ensure no more than numOpenNetworksKept open networks in configuration list.
*
* @param wifiMgr
* @param numOpenNetworksKept
* @return Operation succeed or not.
*/
private static boolean checkForExcessOpenNetworkAndSave(final WifiManager wifiMgr, final int numOpenNetworksKept) {
final List<WifiConfiguration> configurations = wifiMgr.getConfiguredNetworks();
sortByPriority(configurations);
boolean modified = false;
int tempCount = 0;
for (int i = configurations.size() - 1; i >= 0; i--) {
final WifiConfiguration config = configurations.get(i);
if (ConfigSec.isOpenNetwork(ConfigSec.getWifiConfigurationSecurity(config))) {
tempCount++;
if (tempCount >= numOpenNetworksKept) {
modified = true;
wifiMgr.removeNetwork(config.networkId);
}
}
}
return !modified || wifiMgr.saveConfiguration();
}
Aggregations