Search in sources :

Example 86 with AccessPoint

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

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 87 with AccessPoint

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

the class SavedAccessPointsWifiSettings method onCreateDialog.

@Override
public Dialog onCreateDialog(int dialogId) {
    switch(dialogId) {
        case WifiSettings.WIFI_DIALOG_ID:
            if (mDlgAccessPoint == null && mAccessPointSavedState == null) {
                // Add new network
                mDialog = WifiDialog.createFullscreen(getActivity(), this, null, WifiConfigUiBase.MODE_CONNECT);
            } else {
                // Modify network
                if (mDlgAccessPoint == null) {
                    // Restore AP from save state
                    mDlgAccessPoint = new AccessPoint(getActivity(), mAccessPointSavedState);
                    // Reset the saved access point data
                    mAccessPointSavedState = null;
                }
                mDialog = WifiDialog.createModal(getActivity(), this, mDlgAccessPoint, WifiConfigUiBase.MODE_VIEW);
            }
            mSelectedAccessPoint = mDlgAccessPoint;
            return mDialog;
    }
    return super.onCreateDialog(dialogId);
}
Also used : AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 88 with AccessPoint

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

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 89 with AccessPoint

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

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 90 with AccessPoint

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

the class WifiSettings method updateAccessPointPreferences.

private void updateAccessPointPreferences() {
    // in case state has changed
    if (!mWifiManager.isWifiEnabled()) {
        return;
    }
    // AccessPoints are sorted by the WifiTracker
    final List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
    if (WifiTracker.sVerboseLogging) {
        Log.i(TAG, "updateAccessPoints called for: " + accessPoints);
    }
    boolean hasAvailableAccessPoints = false;
    mAccessPointsPreferenceCategory.removePreference(mStatusMessagePreference);
    cacheRemoveAllPrefs(mAccessPointsPreferenceCategory);
    int index = configureConnectedAccessPointPreferenceCategory(accessPoints) ? 1 : 0;
    int numAccessPoints = accessPoints.size();
    for (; index < numAccessPoints; index++) {
        AccessPoint accessPoint = accessPoints.get(index);
        // Ignore access points that are out of range.
        if (accessPoint.isReachable()) {
            String key = AccessPointPreference.generatePreferenceKey(accessPoint);
            hasAvailableAccessPoints = true;
            LongPressAccessPointPreference pref = (LongPressAccessPointPreference) getCachedPreference(key);
            if (pref != null) {
                pref.setOrder(index);
                continue;
            }
            LongPressAccessPointPreference preference = createLongPressActionPointPreference(accessPoint);
            preference.setKey(key);
            preference.setOrder(index);
            if (mOpenSsid != null && mOpenSsid.equals(accessPoint.getSsidStr()) && accessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
                if (!accessPoint.isSaved() || isDisabledByWrongPassword(accessPoint)) {
                    onPreferenceTreeClick(preference);
                    mOpenSsid = null;
                }
            }
            mAccessPointsPreferenceCategory.addPreference(preference);
            accessPoint.setListener(WifiSettings.this);
            preference.refresh();
        }
    }
    removeCachedPrefs(mAccessPointsPreferenceCategory);
    mAddPreference.setOrder(index);
    mAccessPointsPreferenceCategory.addPreference(mAddPreference);
    setAdditionalSettingsSummaries();
    if (!hasAvailableAccessPoints) {
        setProgressBarVisible(true);
        Preference pref = new Preference(getPrefContext());
        pref.setSelectable(false);
        pref.setSummary(R.string.wifi_empty_list_wifi_on);
        pref.setOrder(index++);
        pref.setKey(PREF_KEY_EMPTY_WIFI_LIST);
        mAccessPointsPreferenceCategory.addPreference(pref);
    } else {
        // Continuing showing progress bar for an additional delay to overlap with animation
        getView().postDelayed(mHideProgressBarRunnable, 1700);
    }
}
Also used : AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) Preference(android.support.v7.preference.Preference) AccessPoint(com.android.settingslib.wifi.AccessPoint) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Aggregations

AccessPoint (com.android.settingslib.wifi.AccessPoint)130 WifiConfiguration (android.net.wifi.WifiConfiguration)36 Bundle (android.os.Bundle)29 AccessPointPreference (com.android.settingslib.wifi.AccessPointPreference)27 Test (org.junit.Test)26 Intent (android.content.Intent)22 NetworkInfo (android.net.NetworkInfo)18 WifiManager (android.net.wifi.WifiManager)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 ArrayList (java.util.ArrayList)5 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)4 View (android.view.View)3 VisibleForTesting (androidx.annotation.VisibleForTesting)3 ScanResult (android.net.wifi.ScanResult)2 Spinner (android.widget.Spinner)2 AlertDialog (androidx.appcompat.app.AlertDialog)2