use of android.net.wifi.WifiManager in project AisenWeiBo by wangdan.
the class SystemUtils method getUDPIP.
public static String getUDPIP(Context context) {
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
DhcpInfo dhcpInfo = wifi.getDhcpInfo();
int IpAddress = dhcpInfo.ipAddress;
int subMask = dhcpInfo.netmask;
return transformIp((~subMask) | IpAddress);
}
use of android.net.wifi.WifiManager in project AisenWeiBo by wangdan.
the class SystemUtils method getMacAddress.
/**
* mac地址
*
* @return
*/
public static String getMacAddress(Context context) {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo != null && wifiInfo.getMacAddress() != null)
return wifiInfo.getMacAddress().replace(":", "");
else
// 00117f29d23a
return "0022f420d03f";
}
use of android.net.wifi.WifiManager in project android_packages_apps_Settings by LineageOS.
the class ConfigureWifiSettings method getPreferenceControllers.
@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
final NetworkScoreManagerWrapper networkScoreManagerWrapper = new NetworkScoreManagerWrapper(context.getSystemService(NetworkScoreManager.class));
mWifiWakeupPreferenceController = new WifiWakeupPreferenceController(context, getLifecycle());
mUseOpenWifiPreferenceController = new UseOpenWifiPreferenceController(context, this, networkScoreManagerWrapper, getLifecycle());
final WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(mWifiWakeupPreferenceController);
controllers.add(new NetworkScorerPickerPreferenceController(context, networkScoreManagerWrapper));
controllers.add(new NotifyOpenNetworksPreferenceController(context, getLifecycle()));
controllers.add(mUseOpenWifiPreferenceController);
controllers.add(new WifiInfoPreferenceController(context, getLifecycle(), wifiManager));
controllers.add(new CellularFallbackPreferenceController(context));
controllers.add(new WifiP2pPreferenceController(context, getLifecycle(), wifiManager));
controllers.add(new WifiCallingPreferenceController(context));
controllers.add(new WpsPreferenceController(context, getLifecycle(), wifiManager, getFragmentManager()));
return controllers;
}
use of android.net.wifi.WifiManager in project android_packages_apps_Settings by LineageOS.
the class WifiDialogActivity method onForget.
@Override
public void onForget(WifiDialog dialog) {
final WifiManager wifiManager = getSystemService(WifiManager.class);
final AccessPoint accessPoint = dialog.getController().getAccessPoint();
if (accessPoint != null) {
if (!accessPoint.isSaved()) {
if (accessPoint.getNetworkInfo() != null && accessPoint.getNetworkInfo().getState() != NetworkInfo.State.DISCONNECTED) {
// Network is active but has no network ID - must be ephemeral.
wifiManager.disableEphemeralNetwork(AccessPoint.convertToQuotedString(accessPoint.getSsidStr()));
} else {
// Should not happen, but a monkey seems to trigger it
Log.e(TAG, "Failed to forget invalid network " + accessPoint.getConfig());
}
} else {
wifiManager.forget(accessPoint.getConfig().networkId, null);
}
}
Intent resultData = new Intent();
if (accessPoint != null) {
Bundle accessPointState = new Bundle();
accessPoint.saveWifiState(accessPointState);
resultData.putExtra(KEY_ACCESS_POINT_STATE, accessPointState);
}
setResult(RESULT_FORGET);
finish();
}
use of android.net.wifi.WifiManager in project android_packages_apps_Settings by LineageOS.
the class WifiDialogActivity method onSubmit.
@Override
public void onSubmit(WifiDialog dialog) {
final WifiConfiguration config = dialog.getController().getConfig();
final AccessPoint accessPoint = dialog.getController().getAccessPoint();
final WifiManager wifiManager = getSystemService(WifiManager.class);
if (config == null) {
if (accessPoint != null && accessPoint.isSaved()) {
wifiManager.connect(accessPoint.getConfig(), null);
}
} else {
wifiManager.save(config, null);
if (accessPoint != null) {
// accessPoint is null for "Add network"
NetworkInfo networkInfo = accessPoint.getNetworkInfo();
if (networkInfo == null || !networkInfo.isConnected()) {
wifiManager.connect(config, null);
}
}
}
Intent resultData = new Intent();
if (accessPoint != null) {
Bundle accessPointState = new Bundle();
accessPoint.saveWifiState(accessPointState);
resultData.putExtra(KEY_ACCESS_POINT_STATE, accessPointState);
}
if (config != null) {
resultData.putExtra(KEY_WIFI_CONFIGURATION, config);
}
setResult(RESULT_CONNECTED, resultData);
finish();
}
Aggregations