use of android.net.wifi.WifiManager in project android_packages_apps_Settings by omnirom.
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 crdroidandroid.
the class Utils method getWifiIpAddresses.
/**
* Returns the WIFI IP Addresses, if any, taking into account IPv4 and IPv6 style addresses.
* @param context the application context
* @return the formatted and newline-separated IP addresses, or null if none.
*/
public static String getWifiIpAddresses(Context context) {
WifiManager wifiManager = context.getSystemService(WifiManager.class);
Network currentNetwork = wifiManager.getCurrentNetwork();
if (currentNetwork != null) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
LinkProperties prop = cm.getLinkProperties(currentNetwork);
return formatIpAddresses(prop);
}
return null;
}
use of android.net.wifi.WifiManager in project android_packages_apps_Settings by crdroidandroid.
the class DataPlanUsageSummaryTest method testUpdateNetworkRestrictionSummary_shouldSetSummary.
@Test
public void testUpdateNetworkRestrictionSummary_shouldSetSummary() {
mDataUsageSummary = spy(new DataPlanUsageSummary());
NetworkRestrictionsPreference preference = mock(NetworkRestrictionsPreference.class);
mPolicyEditor = mock(NetworkPolicyEditor.class);
WifiManager wifiManager = mock(WifiManager.class);
ReflectionHelpers.setField(mDataUsageSummary, "mPolicyEditor", mPolicyEditor);
ReflectionHelpers.setField(mDataUsageSummary, "mWifiManager", wifiManager);
when(wifiManager.getConfiguredNetworks()).thenReturn(new ArrayList<>());
doReturn(mContext.getResources()).when(mDataUsageSummary).getResources();
mDataUsageSummary.updateNetworkRestrictionSummary(preference);
verify(preference).setSummary(mContext.getResources().getQuantityString(R.plurals.network_restrictions_summary, 0, 0));
}
use of android.net.wifi.WifiManager in project android_packages_apps_Settings by crdroidandroid.
the class DataUsageSummaryTest method testUpdateNetworkRestrictionSummary_shouldSetSummary.
@Test
public void testUpdateNetworkRestrictionSummary_shouldSetSummary() {
final DataUsageSummary dataUsageSummary = spy(new DataUsageSummary());
final NetworkRestrictionsPreference preference = mock(NetworkRestrictionsPreference.class);
final NetworkPolicyEditor policyEditor = mock(NetworkPolicyEditor.class);
final WifiManager wifiManager = mock(WifiManager.class);
ReflectionHelpers.setField(dataUsageSummary, "mPolicyEditor", policyEditor);
ReflectionHelpers.setField(dataUsageSummary, "mWifiManager", wifiManager);
when(wifiManager.getConfiguredNetworks()).thenReturn(new ArrayList<WifiConfiguration>());
doReturn(mContext.getResources()).when(dataUsageSummary).getResources();
dataUsageSummary.updateNetworkRestrictionSummary(preference);
verify(preference).setSummary(mContext.getResources().getQuantityString(R.plurals.network_restrictions_summary, 0, 0));
}
use of android.net.wifi.WifiManager in project android_packages_apps_Settings by SudaMod.
the class Utils method getWifiIpAddresses.
/**
* Returns the WIFI IP Addresses, if any, taking into account IPv4 and IPv6 style addresses.
* @param context the application context
* @return the formatted and newline-separated IP addresses, or null if none.
*/
public static String getWifiIpAddresses(Context context) {
WifiManager wifiManager = context.getSystemService(WifiManager.class);
Network currentNetwork = wifiManager.getCurrentNetwork();
if (currentNetwork != null) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
LinkProperties prop = cm.getLinkProperties(currentNetwork);
return formatIpAddresses(prop);
}
return null;
}
Aggregations