use of com.android.settingslib.wifi.AccessPoint in project android_packages_apps_Settings by omnirom.
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();
}
use of com.android.settingslib.wifi.AccessPoint in project android_packages_apps_Settings by DirtyUnicorns.
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);
}
use of com.android.settingslib.wifi.AccessPoint in project android_packages_apps_Settings by DirtyUnicorns.
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[] {}));
}
use of com.android.settingslib.wifi.AccessPoint in project android_packages_apps_Settings by DirtyUnicorns.
the class WifiSettingsUiTest method wrongPasswordSavedNetwork.
@Test
public void wrongPasswordSavedNetwork() {
setWifiState(WifiManager.WIFI_STATE_ENABLED);
// Set up an AccessPoint that is disabled due to incorrect password.
WifiConfiguration config = new WifiConfiguration();
config.SSID = TEST_SSID;
config.BSSID = TEST_BSSID;
config.networkId = TEST_NETWORK_ID;
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
WifiConfiguration.NetworkSelectionStatus selectionStatus = new WifiConfiguration.NetworkSelectionStatus();
selectionStatus.setNetworkSelectionDisableReason(WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);
selectionStatus.setNetworkSelectionStatus(WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_TEMPORARY_DISABLED);
config.setNetworkSelectionStatus(selectionStatus);
WifiInfo wifiInfo = new WifiInfo();
wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(TEST_UNQUOTED_SSID));
wifiInfo.setBSSID(TEST_BSSID);
wifiInfo.setRssi(TEST_RSSI);
wifiInfo.setNetworkId(TEST_NETWORK_ID);
AccessPoint accessPoint = new AccessPoint(mContext, config);
accessPoint.update(config, wifiInfo, null);
// Make sure we've set up our access point correctly.
assertThat(accessPoint.getSsidStr()).isEqualTo(TEST_UNQUOTED_SSID);
assertThat(accessPoint.getBssid()).isEqualTo(TEST_BSSID);
assertThat(accessPoint.isActive()).isFalse();
assertThat(accessPoint.getConfig()).isNotNull();
WifiConfiguration.NetworkSelectionStatus networkStatus = accessPoint.getConfig().getNetworkSelectionStatus();
assertThat(networkStatus).isNotNull();
assertThat(networkStatus.isNetworkEnabled()).isFalse();
assertThat(networkStatus.getNetworkSelectionDisableReason()).isEqualTo(WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);
when(mWifiTracker.getAccessPoints()).thenReturn(Lists.newArrayList(accessPoint));
launchActivity(WifiSettings.EXTRA_START_CONNECT_SSID, accessPoint.getSsidStr());
// Make sure that the password dialog is visible.
onView(withText(resourceId(STRING, WIFI_PASSWORD))).check(matches(isDisplayed()));
onView(withText(resourceId(STRING, WIFI_SHOW_PASSWORD))).check(matches(isDisplayed()));
onView(withId(resourceId(ID, PASSWORD_LAYOUT))).check(matches(isDisplayed()));
onView(withId(resourceId(ID, PASSWORD))).check(matches(isDisplayed()));
}
use of com.android.settingslib.wifi.AccessPoint in project android_packages_apps_Settings by DirtyUnicorns.
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);
}
Aggregations