Search in sources :

Example 36 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project platform_packages_apps_Settings by BlissRoms.

the class WifiDialogActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    final Intent intent = getIntent();
    if (WizardManagerHelper.isSetupWizardIntent(intent)) {
        setTheme(SetupWizardUtils.getTransparentTheme(intent));
    }
    super.onCreate(savedInstanceState);
    final Bundle accessPointState = intent.getBundleExtra(KEY_ACCESS_POINT_STATE);
    AccessPoint accessPoint = null;
    if (accessPointState != null) {
        accessPoint = new AccessPoint(this, accessPointState);
    }
    WifiDialog dialog = WifiDialog.createModal(this, this, accessPoint, WifiConfigUiBase.MODE_CONNECT);
    dialog.show();
    dialog.setOnDismissListener(this);
}
Also used : Bundle(android.os.Bundle) AccessPoint(com.android.settingslib.wifi.AccessPoint) Intent(android.content.Intent)

Example 37 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project platform_packages_apps_Settings by BlissRoms.

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();
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiConfiguration(android.net.wifi.WifiConfiguration) NetworkInfo(android.net.NetworkInfo) Bundle(android.os.Bundle) AccessPoint(com.android.settingslib.wifi.AccessPoint) Intent(android.content.Intent)

Example 38 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project platform_packages_apps_Settings by BlissRoms.

the class WifiNetworkDetailsFragment method onAttach.

@Override
public void onAttach(Context context) {
    mWifiDetailActionBarObserver = new WifiDetailActionBarObserver(context, this);
    getLifecycle().addObserver(mWifiDetailActionBarObserver);
    mAccessPoint = new AccessPoint(context, getArguments());
    super.onAttach(context);
}
Also used : AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 39 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project platform_packages_apps_Settings by BlissRoms.

the class SavedAccessPointsWifiSettings method initPreferences.

private void initPreferences() {
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    final Context context = getPrefContext();
    final List<AccessPoint> accessPoints = WifiSavedConfigUtils.getAllConfigs(context, mWifiManager);
    Collections.sort(accessPoints, SAVED_NETWORK_COMPARATOR);
    cacheRemoveAllPrefs(preferenceScreen);
    final int accessPointsSize = accessPoints.size();
    for (int i = 0; i < accessPointsSize; ++i) {
        AccessPoint ap = accessPoints.get(i);
        String key = AccessPointPreference.generatePreferenceKey(ap);
        LongPressAccessPointPreference preference = (LongPressAccessPointPreference) getCachedPreference(key);
        if (preference == null) {
            preference = new LongPressAccessPointPreference(ap, context, mUserBadgeCache, true, this);
            preference.setKey(key);
            preference.setIcon(null);
            preferenceScreen.addPreference(preference);
        }
        preference.setOrder(i);
    }
    removeCachedPrefs(preferenceScreen);
    if (mAddNetworkPreference == null) {
        mAddNetworkPreference = new Preference(getPrefContext());
        mAddNetworkPreference.setIcon(R.drawable.ic_menu_add_inset);
        mAddNetworkPreference.setTitle(R.string.wifi_add_network);
    }
    mAddNetworkPreference.setOrder(accessPointsSize);
    preferenceScreen.addPreference(mAddNetworkPreference);
    if (getPreferenceScreen().getPreferenceCount() < 1) {
        Log.w(TAG, "Saved networks activity loaded, but there are no saved networks!");
    }
}
Also used : Context(android.content.Context) PreferenceScreen(android.support.v7.preference.PreferenceScreen) AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) Preference(android.support.v7.preference.Preference) AccessPoint(com.android.settingslib.wifi.AccessPoint) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 40 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project android_packages_apps_Settings by omnirom.

the class WifiSettingsUiTest method changingSecurityStateOnApShouldNotCauseMultipleListItems.

@Test
public void changingSecurityStateOnApShouldNotCauseMultipleListItems() {
    setWifiState(WifiManager.WIFI_STATE_ENABLED);
    TestAccessPointBuilder builder = new TestAccessPointBuilder(mContext).setSsid(TEST_SSID).setSecurity(AccessPoint.SECURITY_NONE).setRssi(TEST_RSSI);
    AccessPoint open = builder.build();
    builder.setSecurity(AccessPoint.SECURITY_EAP);
    AccessPoint eap = builder.build();
    builder.setSecurity(AccessPoint.SECURITY_WEP);
    AccessPoint wep = builder.build();
    // Return a different security state each time getAccessPoints is invoked
    when(mWifiTracker.getAccessPoints()).thenReturn(Lists.newArrayList(open)).thenReturn(Lists.newArrayList(eap)).thenReturn(Lists.newArrayList(wep));
    launchActivity();
    onView(withText(TEST_SSID)).check(matches(isDisplayed()));
    mWifiListener.onAccessPointsChanged();
    onView(withText(TEST_SSID)).check(matches(isDisplayed()));
    mWifiListener.onAccessPointsChanged();
    onView(withText(TEST_SSID)).check(matches(isDisplayed()));
}
Also used : AccessPoint(com.android.settingslib.wifi.AccessPoint) TestAccessPointBuilder(com.android.settingslib.wifi.TestAccessPointBuilder) Test(org.junit.Test)

Aggregations

AccessPoint (com.android.settingslib.wifi.AccessPoint)132 WifiConfiguration (android.net.wifi.WifiConfiguration)36 Bundle (android.os.Bundle)29 AccessPointPreference (com.android.settingslib.wifi.AccessPointPreference)27 Test (org.junit.Test)27 Intent (android.content.Intent)21 WifiManager (android.net.wifi.WifiManager)20 NetworkInfo (android.net.NetworkInfo)18 WifiInfo (android.net.wifi.WifiInfo)16 Context (android.content.Context)13 Preference (android.support.v7.preference.Preference)13 PreferenceScreen (android.support.v7.preference.PreferenceScreen)7 TestAccessPointBuilder (com.android.settingslib.wifi.TestAccessPointBuilder)7 Spinner (android.widget.Spinner)4 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)4 ArrayList (java.util.ArrayList)4 View (android.view.View)3 VisibleForTesting (androidx.annotation.VisibleForTesting)3 ScanResult (android.net.wifi.ScanResult)2 ArrayAdapter (android.widget.ArrayAdapter)2