Search in sources :

Example 6 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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

Example 7 with AccessPoint

use of com.android.settingslib.wifi.AccessPoint in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SavedAccessPointsWifiSettings method initPreferences.

private void initPreferences() {
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    final Context context = getPrefContext();
    final List<AccessPoint> accessPoints = WifiTracker.getCurrentAccessPoints(context, true, false, true);
    Collections.sort(accessPoints, new Comparator<AccessPoint>() {

        public int compare(AccessPoint ap1, AccessPoint ap2) {
            if (ap1.getConfigName() != null) {
                return ap1.getConfigName().compareTo(ap2.getConfigName());
            } else {
                return -1;
            }
        }
    });
    preferenceScreen.removeAll();
    final int accessPointsSize = accessPoints.size();
    for (int i = 0; i < accessPointsSize; ++i) {
        LongPressAccessPointPreference preference = new LongPressAccessPointPreference(accessPoints.get(i), context, mUserBadgeCache, true, this);
        preference.setIcon(null);
        preferenceScreen.addPreference(preference);
    }
    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) AccessPoint(com.android.settingslib.wifi.AccessPoint) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Aggregations

AccessPoint (com.android.settingslib.wifi.AccessPoint)7 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 WifiManager (android.net.wifi.WifiManager)2 Context (android.content.Context)1 NetworkInfo (android.net.NetworkInfo)1 WifiConfiguration (android.net.wifi.WifiConfiguration)1 Preference (android.support.v7.preference.Preference)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1 PreferenceViewHolder (android.support.v7.preference.PreferenceViewHolder)1 AccessPointPreference (com.android.settingslib.wifi.AccessPointPreference)1