Search in sources :

Example 66 with WifiManager

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;
}
Also used : WifiManager(android.net.wifi.WifiManager) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) NetworkScorerPickerPreferenceController(com.android.settings.network.NetworkScorerPickerPreferenceController) WifiP2pPreferenceController(com.android.settings.wifi.p2p.WifiP2pPreferenceController) ArrayList(java.util.ArrayList) WifiCallingPreferenceController(com.android.settings.network.WifiCallingPreferenceController) NetworkScoreManager(android.net.NetworkScoreManager) NetworkScoreManagerWrapper(com.android.settings.network.NetworkScoreManagerWrapper)

Example 67 with WifiManager

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;
}
Also used : WifiManager(android.net.wifi.WifiManager) ConnectivityManager(android.net.ConnectivityManager) Network(android.net.Network) LinkProperties(android.net.LinkProperties)

Example 68 with WifiManager

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));
}
Also used : WifiManager(android.net.wifi.WifiManager) NetworkPolicyEditor(com.android.settingslib.NetworkPolicyEditor) Test(org.junit.Test)

Example 69 with WifiManager

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));
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiConfiguration(android.net.wifi.WifiConfiguration) NetworkPolicyEditor(com.android.settingslib.NetworkPolicyEditor) Test(org.junit.Test)

Example 70 with WifiManager

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;
}
Also used : WifiManager(android.net.wifi.WifiManager) ConnectivityManager(android.net.ConnectivityManager) Network(android.net.Network) LinkProperties(android.net.LinkProperties)

Aggregations

WifiManager (android.net.wifi.WifiManager)329 WifiInfo (android.net.wifi.WifiInfo)80 WifiConfiguration (android.net.wifi.WifiConfiguration)76 IOException (java.io.IOException)38 Intent (android.content.Intent)27 SuppressLint (android.annotation.SuppressLint)26 ConnectivityManager (android.net.ConnectivityManager)23 Context (android.content.Context)22 NetworkInfo (android.net.NetworkInfo)21 Test (org.junit.Test)20 AccessPoint (com.android.settingslib.wifi.AccessPoint)17 IntentFilter (android.content.IntentFilter)16 Bundle (android.os.Bundle)16 ArrayList (java.util.ArrayList)16 NetworkPolicyEditor (com.android.settingslib.NetworkPolicyEditor)12 PowerManager (android.os.PowerManager)11 WifiEnterpriseConfig (android.net.wifi.WifiEnterpriseConfig)10 SocketException (java.net.SocketException)10 SharedPreferences (android.content.SharedPreferences)9 Method (java.lang.reflect.Method)9