[WifiSetup] Mechanism for suspending auto finish
We have been using forget() to prevent auto-reconnection when the user hits back to Wifi setup. This has the side effect of forgetting networks, which is undesirable especially for password protected APs. The new mechanism keeps a flag on whether the user has selected a connection. Only auto-advance if the user has picked a network and there is a valid WiFi connection. The new EXTRA_REQUIRE_USER_SELECTION can specify whether a user selection is required initially. That is, whether to auto finish if the system connected to a network without user input. The default is false so WiFi can be skipped if the user started setup wizard with a valid WiFi connection (e.g. after System Update). Note that a user selection is always required when the user goes back from the next screen. Since the new AP dialog does not have a connect button, the SKIP button in the navigation bar also changes to NEXT when there is a valid WiFi connection, so the user can hit NEXT if they decided not to change the network. Bug: 15333554 Bug: 15999487 Change-Id: I98e935b8e09e470a0c49c44bc299bb2eced98634
This commit is contained in:
@@ -560,13 +560,11 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
switch (item.getItemId()) {
|
||||
case MENU_ID_CONNECT: {
|
||||
if (mSelectedAccessPoint.networkId != INVALID_NETWORK_ID) {
|
||||
mWifiManager.connect(mSelectedAccessPoint.networkId,
|
||||
mConnectListener);
|
||||
connect(mSelectedAccessPoint.networkId);
|
||||
} else if (mSelectedAccessPoint.security == AccessPoint.SECURITY_NONE) {
|
||||
/** Bypass dialog for unsecured networks */
|
||||
mSelectedAccessPoint.generateOpenNetworkConfig();
|
||||
mWifiManager.connect(mSelectedAccessPoint.getConfig(),
|
||||
mConnectListener);
|
||||
connect(mSelectedAccessPoint.getConfig());
|
||||
} else {
|
||||
showDialog(mSelectedAccessPoint, true);
|
||||
}
|
||||
@@ -600,7 +598,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
savedNetworksExist = true;
|
||||
getActivity().invalidateOptionsMenu();
|
||||
}
|
||||
mWifiManager.connect(mSelectedAccessPoint.getConfig(), mConnectListener);
|
||||
connect(mSelectedAccessPoint.getConfig());
|
||||
} else {
|
||||
showDialog(mSelectedAccessPoint, false);
|
||||
}
|
||||
@@ -930,8 +928,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
if (config == null) {
|
||||
if (mSelectedAccessPoint != null
|
||||
&& mSelectedAccessPoint.networkId != INVALID_NETWORK_ID) {
|
||||
mWifiManager.connect(mSelectedAccessPoint.networkId,
|
||||
mConnectListener);
|
||||
connect(mSelectedAccessPoint.networkId);
|
||||
}
|
||||
} else if (config.networkId != INVALID_NETWORK_ID) {
|
||||
if (mSelectedAccessPoint != null) {
|
||||
@@ -941,7 +938,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
if (configController.isEdit()) {
|
||||
mWifiManager.save(config, mSaveListener);
|
||||
} else {
|
||||
mWifiManager.connect(config, mConnectListener);
|
||||
connect(config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -969,6 +966,14 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
changeNextButtonState(false);
|
||||
}
|
||||
|
||||
protected void connect(final WifiConfiguration config) {
|
||||
mWifiManager.connect(config, mConnectListener);
|
||||
}
|
||||
|
||||
protected void connect(final int networkId) {
|
||||
mWifiManager.connect(networkId, mConnectListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes acccess points and ask Wifi module to scan networks again.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user