Fix misc problems happening in SetupWizard XL
Change-Id: I6ba0813f36625de3d86543953972869657be50be
This commit is contained in:
@@ -90,6 +90,9 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
private TextView mDns2View;
|
private TextView mDns2View;
|
||||||
|
|
||||||
static boolean requireKeyStore(WifiConfiguration config) {
|
static boolean requireKeyStore(WifiConfiguration config) {
|
||||||
|
if (config == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
String values[] = {config.ca_cert.value(), config.client_cert.value(),
|
String values[] = {config.ca_cert.value(), config.client_cert.value(),
|
||||||
config.private_key.value()};
|
config.private_key.value()};
|
||||||
for (String value : values) {
|
for (String value : values) {
|
||||||
|
@@ -22,7 +22,7 @@ import android.widget.Button;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Foundation interface glues between Activities and UIs like
|
* Foundation interface glues between Activities and UIs like
|
||||||
* {@link WifiDialog} or {@link WifiConfigController}.
|
* {@link WifiDialog} or {@link WifiPreference}.
|
||||||
*/
|
*/
|
||||||
public interface WifiConfigUiBase {
|
public interface WifiConfigUiBase {
|
||||||
public Context getContext();
|
public Context getContext();
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.wifi;
|
package com.android.settings.wifi;
|
||||||
|
|
||||||
|
import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
|
||||||
|
|
||||||
import com.android.settings.ProgressCategoryBase;
|
import com.android.settings.ProgressCategoryBase;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
@@ -33,7 +35,6 @@ import android.net.wifi.ScanResult;
|
|||||||
import android.net.wifi.SupplicantState;
|
import android.net.wifi.SupplicantState;
|
||||||
import android.net.wifi.WifiConfiguration;
|
import android.net.wifi.WifiConfiguration;
|
||||||
import android.net.wifi.WifiConfiguration.KeyMgmt;
|
import android.net.wifi.WifiConfiguration.KeyMgmt;
|
||||||
import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
|
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -45,6 +46,7 @@ import android.preference.PreferenceScreen;
|
|||||||
import android.provider.Settings.Secure;
|
import android.provider.Settings.Secure;
|
||||||
import android.security.Credentials;
|
import android.security.Credentials;
|
||||||
import android.security.KeyStore;
|
import android.security.KeyStore;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -547,6 +549,10 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
if (activity instanceof WifiSettingsForSetupWizardXL) {
|
if (activity instanceof WifiSettingsForSetupWizardXL) {
|
||||||
|
if (mLastState == DetailedState.FAILED) {
|
||||||
|
// We clean up the status and let users select another network if they want.
|
||||||
|
refreshAccessPoints();
|
||||||
|
}
|
||||||
((WifiSettingsForSetupWizardXL)activity).updateConnectionState(mLastState);
|
((WifiSettingsForSetupWizardXL)activity).updateConnectionState(mLastState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -625,6 +631,7 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
final WifiConfigUiBase uiBase = (mDialog != null ? mDialog : mConfigPreference);
|
final WifiConfigUiBase uiBase = (mDialog != null ? mDialog : mConfigPreference);
|
||||||
final WifiConfigController configController = uiBase.getController();
|
final WifiConfigController configController = uiBase.getController();
|
||||||
|
|
||||||
|
boolean successful = true;
|
||||||
switch(configController.chosenNetworkSetupMethod()) {
|
switch(configController.chosenNetworkSetupMethod()) {
|
||||||
case WifiConfigController.WPS_PBC:
|
case WifiConfigController.WPS_PBC:
|
||||||
mWifiManager.startWpsPbc(mSelectedAccessPoint.bssid);
|
mWifiManager.startWpsPbc(mSelectedAccessPoint.bssid);
|
||||||
@@ -638,8 +645,11 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
if (mSelectedAccessPoint != null
|
if (mSelectedAccessPoint != null
|
||||||
&& !requireKeyStore(mSelectedAccessPoint.getConfig())) {
|
&& !requireKeyStore(mSelectedAccessPoint.getConfig())
|
||||||
|
&& mSelectedAccessPoint.networkId != INVALID_NETWORK_ID) {
|
||||||
mWifiManager.connectNetwork(mSelectedAccessPoint.networkId);
|
mWifiManager.connectNetwork(mSelectedAccessPoint.networkId);
|
||||||
|
} else {
|
||||||
|
successful = false;
|
||||||
}
|
}
|
||||||
} else if (config.networkId != INVALID_NETWORK_ID) {
|
} else if (config.networkId != INVALID_NETWORK_ID) {
|
||||||
if (mSelectedAccessPoint != null) {
|
if (mSelectedAccessPoint != null) {
|
||||||
@@ -655,7 +665,8 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mInXlSetupWizard && mConfigPreference != null) {
|
if (mInXlSetupWizard && successful && mConfigPreference != null) {
|
||||||
|
// Now connecting to the AccessPoint.
|
||||||
mConnectingAccessPoint = mSelectedAccessPoint;
|
mConnectingAccessPoint = mSelectedAccessPoint;
|
||||||
mConnectingAccessPoint.setSelectable(false);
|
mConnectingAccessPoint.setSelectable(false);
|
||||||
}
|
}
|
||||||
@@ -685,9 +696,8 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
mConnectingAccessPoint = null;
|
mConnectingAccessPoint = null;
|
||||||
mAccessPoints.removeAll();
|
mAccessPoints.removeAll();
|
||||||
|
|
||||||
final Activity activity = getActivity();
|
if (mInXlSetupWizard) {
|
||||||
if (activity instanceof WifiSettingsForSetupWizardXL) {
|
((WifiSettingsForSetupWizardXL)getActivity()).onRefreshAccessPoints();
|
||||||
((WifiSettingsForSetupWizardXL)activity).onRefreshAccessPoints();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@ import android.util.Log;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -52,7 +53,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
stateMap.put(DetailedState.SUSPENDED, DetailedState.SUSPENDED); // ?
|
stateMap.put(DetailedState.SUSPENDED, DetailedState.SUSPENDED); // ?
|
||||||
stateMap.put(DetailedState.DISCONNECTING, DetailedState.DISCONNECTED);
|
stateMap.put(DetailedState.DISCONNECTING, DetailedState.DISCONNECTED);
|
||||||
stateMap.put(DetailedState.DISCONNECTED, DetailedState.DISCONNECTED);
|
stateMap.put(DetailedState.DISCONNECTED, DetailedState.DISCONNECTED);
|
||||||
stateMap.put(DetailedState.FAILED, DetailedState.DISCONNECTED);
|
stateMap.put(DetailedState.FAILED, DetailedState.FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextView mProgressText;
|
private TextView mProgressText;
|
||||||
@@ -61,6 +62,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
private TextView mStatusText;
|
private TextView mStatusText;
|
||||||
|
|
||||||
private StatusBarManager mStatusBarManager;
|
private StatusBarManager mStatusBarManager;
|
||||||
|
private InputMethodManager mInputMethodManager;
|
||||||
|
|
||||||
// This count reduces every time when there's a notification about WiFi status change.
|
// This count reduces every time when there's a notification about WiFi status change.
|
||||||
// During the term this is >0, The system shows the message "connecting", regardless
|
// During the term this is >0, The system shows the message "connecting", regardless
|
||||||
@@ -76,6 +78,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
setContentView(R.layout.wifi_settings_for_setup_wizard_xl);
|
setContentView(R.layout.wifi_settings_for_setup_wizard_xl);
|
||||||
mWifiSettings =
|
mWifiSettings =
|
||||||
(WifiSettings)getFragmentManager().findFragmentById(R.id.wifi_setup_fragment);
|
(WifiSettings)getFragmentManager().findFragmentById(R.id.wifi_setup_fragment);
|
||||||
|
mInputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
setup();
|
setup();
|
||||||
// XXX: should we use method?
|
// XXX: should we use method?
|
||||||
getIntent().putExtra(WifiSettings.IN_XL_SETUP_WIZARD, true);
|
getIntent().putExtra(WifiSettings.IN_XL_SETUP_WIZARD, true);
|
||||||
@@ -141,10 +144,19 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
mWifiSettings.detachConfigPreference();
|
mWifiSettings.detachConfigPreference();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
hideSoftwareKeyboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hideSoftwareKeyboard() {
|
||||||
|
final View focusedView = getCurrentFocus();
|
||||||
|
if (focusedView != null) {
|
||||||
|
mInputMethodManager.hideSoftInputFromWindow(focusedView.getWindowToken(), 0);
|
||||||
|
focusedView.clearFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called from WifiSettings
|
// Called from WifiSettings
|
||||||
public void updateConnectionState(DetailedState originalState) {
|
/* package */ void updateConnectionState(DetailedState originalState) {
|
||||||
final DetailedState state = stateMap.get(originalState);
|
final DetailedState state = stateMap.get(originalState);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SCANNING: {
|
case SCANNING: {
|
||||||
@@ -175,6 +187,13 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case FAILED: {
|
||||||
|
mProgressBar.setIndeterminate(false);
|
||||||
|
mProgressBar.setProgress(0);
|
||||||
|
mStatusText.setText(R.string.wifi_setup_status_select_network);
|
||||||
|
mProgressText.setText(Summary.get(this, state));
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: // Not connected.
|
default: // Not connected.
|
||||||
if (mWifiSettings.getAccessPointsCount() == 0 &&
|
if (mWifiSettings.getAccessPointsCount() == 0 &&
|
||||||
mIgnoringWifiNotificationCount > 0) {
|
mIgnoringWifiNotificationCount > 0) {
|
||||||
@@ -205,5 +224,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
public void onRefreshAccessPoints() {
|
public void onRefreshAccessPoints() {
|
||||||
mProgressBar.setIndeterminate(true);
|
mProgressBar.setIndeterminate(true);
|
||||||
mProgressText.setText(Summary.get(this, DetailedState.SCANNING));
|
mProgressText.setText(Summary.get(this, DetailedState.SCANNING));
|
||||||
|
mStatusText.setText(Summary.get(this, DetailedState.SCANNING));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user