summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2013-02-28 23:19:58 +0000
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-03-24 16:12:29 -0700
commit5814f08554e053081e76e7dcf6e8ff804ae5d713 (patch)
tree42432253e40a07621c004dc88154c09cdc7ae3a4 /src
parent0f8d436d69860dca49cf71ea4d501699e41c8386 (diff)
downloadpackages_apps_settings-5814f08554e053081e76e7dcf6e8ff804ae5d713.zip
packages_apps_settings-5814f08554e053081e76e7dcf6e8ff804ae5d713.tar.gz
packages_apps_settings-5814f08554e053081e76e7dcf6e8ff804ae5d713.tar.bz2
Wifi: Enable IBSS options only if IBSS is supported
Show IBSS network options only if IBSS mode is supported by the Wifi driver. This makes use of the new API isIbssSupported() of WifiManager. We have to be careful to make the query only after we reached WIFI_STATE_ENABLED. WifiSettingsForSetupWizardXL is left out because it does not handle these states. Change-Id: I072c5cc6ed36305806b469cf05c4786d22bfd418
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/wifi/WifiConfigController.java9
-rw-r--r--src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java2
-rw-r--r--src/com/android/settings/wifi/WifiDialog.java6
-rw-r--r--src/com/android/settings/wifi/WifiSettings.java12
4 files changed, 22 insertions, 7 deletions
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index bde8008..c194575 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -72,6 +72,7 @@ public class WifiConfigController implements TextWatcher,
private final AccessPoint mAccessPoint;
private boolean mEdit;
+ private boolean mIbssSupported;
private TextView mSsidView;
private CheckBox mIbssView;
@@ -142,7 +143,8 @@ public class WifiConfigController implements TextWatcher,
}
public WifiConfigController(
- WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit) {
+ WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit,
+ boolean ibssSupported) {
mConfigUi = parent;
mInXlSetupWizard = (parent instanceof WifiConfigUiForSetupWizardXL);
@@ -151,6 +153,7 @@ public class WifiConfigController implements TextWatcher,
mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE :
accessPoint.security;
mEdit = edit;
+ mIbssSupported = ibssSupported;
mTextViewChangedHandler = new Handler();
final Context context = mConfigUi.getContext();
@@ -186,7 +189,9 @@ public class WifiConfigController implements TextWatcher,
showProxyFields();
mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
mView.findViewById(R.id.wifi_advanced_togglebox).setOnClickListener(this);
- mView.findViewById(R.id.wifi_ibss_toggle).setVisibility(View.VISIBLE);
+
+ if (mIbssSupported)
+ mView.findViewById(R.id.wifi_ibss_toggle).setVisibility(View.VISIBLE);
mConfigUi.setSubmitButton(context.getString(R.string.wifi_save));
} else {
diff --git a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java b/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
index 440e694..e11e857 100644
--- a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
+++ b/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
@@ -68,7 +68,7 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh
mInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mView = mInflater.inflate(R.layout.wifi_config_ui_for_setup_wizard, parent, true);
- mController = new WifiConfigController(this, mView, mAccessPoint, edit);
+ mController = new WifiConfigController(this, mView, mAccessPoint, edit, false);
mInputMethodManager = (InputMethodManager)
activity.getSystemService(Context.INPUT_METHOD_SERVICE);
diff --git a/src/com/android/settings/wifi/WifiDialog.java b/src/com/android/settings/wifi/WifiDialog.java
index 82b0cc6..a46755b 100644
--- a/src/com/android/settings/wifi/WifiDialog.java
+++ b/src/com/android/settings/wifi/WifiDialog.java
@@ -30,6 +30,7 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase {
static final int BUTTON_FORGET = DialogInterface.BUTTON_NEUTRAL;
private final boolean mEdit;
+ private final boolean mIbssSupported;
private final DialogInterface.OnClickListener mListener;
private final AccessPoint mAccessPoint;
@@ -37,9 +38,10 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase {
private WifiConfigController mController;
public WifiDialog(Context context, DialogInterface.OnClickListener listener,
- AccessPoint accessPoint, boolean edit) {
+ AccessPoint accessPoint, boolean edit, boolean ibssSupported) {
super(context, R.style.Theme_WifiDialog);
mEdit = edit;
+ mIbssSupported = ibssSupported;
mListener = listener;
mAccessPoint = accessPoint;
}
@@ -54,7 +56,7 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase {
mView = getLayoutInflater().inflate(R.layout.wifi_dialog, null);
setView(mView);
setInverseBackgroundForced(true);
- mController = new WifiConfigController(this, mView, mAccessPoint, mEdit);
+ mController = new WifiConfigController(this, mView, mAccessPoint, mEdit, mIbssSupported);
super.onCreate(savedInstanceState);
/* During creation, the submit button can be unavailable to determine
* visibility. Right after creation, update button visibility */
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 85c0afa..84623d4 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -124,7 +124,7 @@ public class WifiSettings extends SettingsPreferenceFragment
private WifiManager.ActionListener mSaveListener;
private WifiManager.ActionListener mForgetListener;
private boolean mP2pSupported;
-
+ private boolean mIbssSupported;
private WifiEnabler mWifiEnabler;
// An access point being editted is stored here.
@@ -632,7 +632,7 @@ public class WifiSettings extends SettingsPreferenceFragment
}
// If it's still null, fine, it's for Add Network
mSelectedAccessPoint = ap;
- mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit);
+ mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit, mIbssSupported);
return mDialog;
case WPS_PBC_DIALOG_ID:
return new WpsDialog(getActivity(), WpsInfo.PBC);
@@ -778,6 +778,11 @@ public class WifiSettings extends SettingsPreferenceFragment
continue;
}
+ // Ignore IBSS if chipset does not support them
+ if (!mIbssSupported && result.capabilities.contains("[IBSS]")) {
+ continue;
+ }
+
boolean found = false;
for (AccessPoint accessPoint : apMap.getAll(result.SSID)) {
if (accessPoint.update(result))
@@ -892,6 +897,9 @@ public class WifiSettings extends SettingsPreferenceFragment
switch (state) {
case WifiManager.WIFI_STATE_ENABLED:
+ // this function only returns valid results in enabled state
+ mIbssSupported = mWifiManager.isIbssSupported();
+
mScanner.resume();
return; // not break, to avoid the call to pause() below