use of android.net.wifi.WifiConfiguration in project android by cSploit.
the class NetworkManager method shiftPriorityAndSave.
public 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 zxingfragmentlib by mitoyarzun.
the class WifiConfigManager method changeNetworkWPA.
// Adding a WPA or WPA2 network
private static void changeNetworkWPA(WifiManager wifiManager, WifiParsedResult wifiResult) {
WifiConfiguration config = changeNetworkCommon(wifiResult);
// Hex passwords that are 64 bits long are not to be quoted.
config.preSharedKey = quoteNonHex(wifiResult.getPassword(), 64);
config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
// For WPA
config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
// For WPA2
config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
updateNetwork(wifiManager, config);
}
use of android.net.wifi.WifiConfiguration in project zxingfragmentlib by mitoyarzun.
the class WifiConfigManager method changeNetworkWEP.
// Adding a WEP network
private static void changeNetworkWEP(WifiManager wifiManager, WifiParsedResult wifiResult) {
WifiConfiguration config = changeNetworkCommon(wifiResult);
config.wepKeys[0] = quoteNonHex(wifiResult.getPassword(), 10, 26, 58);
config.wepTxKeyIndex = 0;
config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
updateNetwork(wifiManager, config);
}
use of android.net.wifi.WifiConfiguration in project zxingfragmentlib by mitoyarzun.
the class WifiConfigManager method changeNetworkUnEncrypted.
// Adding an open, unsecured network
private static void changeNetworkUnEncrypted(WifiManager wifiManager, WifiParsedResult wifiResult) {
WifiConfiguration config = changeNetworkCommon(wifiResult);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
updateNetwork(wifiManager, config);
}
use of android.net.wifi.WifiConfiguration in project XPrivacy by M66B.
the class XWifiManager method after.
@Override
@SuppressWarnings("rawtypes")
protected void after(XParam param) throws Throwable {
switch(mMethod) {
case Srv_getBatchedScanResults:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(new ArrayList());
break;
case getConfiguredNetworks:
case Srv_getConfiguredNetworks:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(new ArrayList<WifiConfiguration>());
break;
case getConnectionInfo:
case Srv_getConnectionInfo:
if (param.getResult() != null)
if (isRestricted(param)) {
WifiInfo result = (WifiInfo) param.getResult();
WifiInfo wInfo = WifiInfo.class.getConstructor(WifiInfo.class).newInstance(result);
if (getRestrictionName().equals(PrivacyManager.cInternet)) {
// Supplicant state
try {
Field fieldState = WifiInfo.class.getDeclaredField("mSupplicantState");
fieldState.setAccessible(true);
fieldState.set(wInfo, SupplicantState.DISCONNECTED);
} catch (Throwable ex) {
Util.bug(this, ex);
}
} else {
// BSSID
try {
Field fieldBSSID = WifiInfo.class.getDeclaredField("mBSSID");
fieldBSSID.setAccessible(true);
fieldBSSID.set(wInfo, PrivacyManager.getDefacedProp(Binder.getCallingUid(), "MAC"));
} catch (Throwable ex) {
Util.bug(this, ex);
}
// IP address
try {
Field fieldIp = WifiInfo.class.getDeclaredField("mIpAddress");
fieldIp.setAccessible(true);
fieldIp.set(wInfo, PrivacyManager.getDefacedProp(Binder.getCallingUid(), "InetAddress"));
} catch (Throwable ex) {
Util.bug(this, ex);
}
// MAC address
try {
Field fieldMAC = WifiInfo.class.getDeclaredField("mMacAddress");
fieldMAC.setAccessible(true);
fieldMAC.set(wInfo, PrivacyManager.getDefacedProp(Binder.getCallingUid(), "MAC"));
} catch (Throwable ex) {
Util.bug(this, ex);
}
// SSID
String ssid = (String) PrivacyManager.getDefacedProp(Binder.getCallingUid(), "SSID");
try {
Field fieldSSID = WifiInfo.class.getDeclaredField("mSSID");
fieldSSID.setAccessible(true);
fieldSSID.set(wInfo, ssid);
} catch (Throwable ex) {
try {
Field fieldWifiSsid = WifiInfo.class.getDeclaredField("mWifiSsid");
fieldWifiSsid.setAccessible(true);
Object mWifiSsid = fieldWifiSsid.get(wInfo);
if (mWifiSsid != null) {
// public static WifiSsid
// createFromAsciiEncoded(String
// asciiEncoded)
Method methodCreateFromAsciiEncoded = mWifiSsid.getClass().getDeclaredMethod("createFromAsciiEncoded", String.class);
fieldWifiSsid.set(wInfo, methodCreateFromAsciiEncoded.invoke(null, ssid));
}
} catch (Throwable exex) {
Util.bug(this, exex);
}
}
}
param.setResult(wInfo);
}
break;
case getDhcpInfo:
case Srv_getDhcpInfo:
if (param.getResult() != null)
if (isRestricted(param)) {
DhcpInfo result = (DhcpInfo) param.getResult();
DhcpInfo dInfo = DhcpInfo.class.getConstructor(DhcpInfo.class).newInstance(result);
dInfo.ipAddress = (Integer) PrivacyManager.getDefacedProp(Binder.getCallingUid(), "IPInt");
dInfo.gateway = dInfo.ipAddress;
dInfo.dns1 = dInfo.ipAddress;
dInfo.dns2 = dInfo.ipAddress;
dInfo.serverAddress = dInfo.ipAddress;
param.setResult(dInfo);
}
break;
case getScanResults:
case Srv_getScanResults:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(new ArrayList<ScanResult>());
break;
case getWifiApConfiguration:
case Srv_getWifiApConfiguration:
if (param.getResult() != null)
if (isRestricted(param))
param.setResult(null);
break;
}
}
Aggregations