Search in sources :

Example 16 with AccessPoint

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

the class WifiSettingsUiTest method setupConnectedAccessPoint.

private void setupConnectedAccessPoint() {
    WifiConfiguration config = new WifiConfiguration();
    config.SSID = TEST_SSID;
    config.BSSID = TEST_BSSID;
    config.networkId = TEST_NETWORK_ID;
    WifiInfo wifiInfo = new WifiInfo();
    wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(TEST_UNQUOTED_SSID));
    wifiInfo.setBSSID(TEST_BSSID);
    wifiInfo.setRssi(TEST_RSSI);
    wifiInfo.setNetworkId(TEST_NETWORK_ID);
    NetworkInfo networkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, null, null);
    networkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null);
    AccessPoint accessPoint = new AccessPoint(mContext, config);
    accessPoint.update(config, wifiInfo, networkInfo);
    assertThat(accessPoint.getSsidStr()).isEqualTo(TEST_UNQUOTED_SSID);
    assertThat(accessPoint.getBssid()).isEqualTo(TEST_BSSID);
    assertThat(accessPoint.getNetworkInfo()).isNotNull();
    assertThat(accessPoint.isActive()).isTrue();
    assertThat(accessPoint.getSettingsSummary()).isEqualTo(resourceString(WIFI_DISPLAY_STATUS_CONNECTED));
    when(mWifiTracker.getAccessPoints()).thenReturn(Lists.asList(accessPoint, new AccessPoint[] {}));
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) NetworkInfo(android.net.NetworkInfo) AccessPoint(com.android.settingslib.wifi.AccessPoint) WifiInfo(android.net.wifi.WifiInfo)

Example 17 with AccessPoint

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

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

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

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

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

the class WifiSettings method onCreateDialog.

@Override
public Dialog onCreateDialog(int dialogId) {
    switch(dialogId) {
        case WIFI_DIALOG_ID:
            if (mDlgAccessPoint == null && mAccessPointSavedState == null) {
                // add new network
                mDialog = WifiDialog.createFullscreen(getActivity(), this, mDlgAccessPoint, mDialogMode);
            } 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, mDialogMode);
            }
            mSelectedAccessPoint = mDlgAccessPoint;
            return mDialog;
        case WPS_PBC_DIALOG_ID:
            return new WpsDialog(getActivity(), WpsInfo.PBC);
        case WPS_PIN_DIALOG_ID:
            return new WpsDialog(getActivity(), WpsInfo.DISPLAY);
        case WRITE_NFC_DIALOG_ID:
            if (mSelectedAccessPoint != null) {
                mWifiToNfcDialog = new WriteWifiConfigToNfcDialog(getActivity(), mSelectedAccessPoint.getSecurity(), new WifiManagerWrapper(mWifiManager));
            } else if (mWifiNfcDialogSavedState != null) {
                mWifiToNfcDialog = new WriteWifiConfigToNfcDialog(getActivity(), mWifiNfcDialogSavedState, new WifiManagerWrapper(mWifiManager));
            }
            return mWifiToNfcDialog;
    }
    return super.onCreateDialog(dialogId);
}
Also used : AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 20 with AccessPoint

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

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)

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