summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2013-02-02 11:10:13 +0000
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-03-24 16:12:09 -0700
commit0f8d436d69860dca49cf71ea4d501699e41c8386 (patch)
tree4ebbd2890358126c9cefac8807a31ce14fefc9b6 /src
parent1805134df9e33632c33e3ad70500d88b5842d318 (diff)
downloadpackages_apps_settings-0f8d436d69860dca49cf71ea4d501699e41c8386.zip
packages_apps_settings-0f8d436d69860dca49cf71ea4d501699e41c8386.tar.gz
packages_apps_settings-0f8d436d69860dca49cf71ea4d501699e41c8386.tar.bz2
Wifi: Allow configuration of Ad-Hoc (IBSS) networks
Show Ad-Hoc (IBSS) networks in the list of available Wi-Fi networks and allow to connect to or create new Ad-Hoc (IBSS) networks. This requires the IBSS changes in frameworks/base and external/wpa_supplicant_8 Change-Id: Ie44c47753100bbf8e691446e69b8d31659f64e3b
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/wifi/AccessPoint.java24
-rw-r--r--src/com/android/settings/wifi/WifiConfigController.java26
-rw-r--r--src/com/android/settings/wifi/WifiSettings.java8
3 files changed, 43 insertions, 15 deletions
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index f6581a5..e69e900 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -62,6 +62,8 @@ class AccessPoint extends Preference {
int security;
int networkId;
boolean wpsAvailable = false;
+ boolean isIBSS = false;
+ int frequency;
PskType pskType = PskType.UNKNOWN;
@@ -188,6 +190,8 @@ class AccessPoint extends Preference {
security = getSecurity(config);
networkId = config.networkId;
mRssi = Integer.MAX_VALUE;
+ isIBSS = config.isIBSS;
+ frequency = config.frequency;
mConfig = config;
}
@@ -196,6 +200,8 @@ class AccessPoint extends Preference {
bssid = result.BSSID;
security = getSecurity(result);
wpsAvailable = security != SECURITY_EAP && result.capabilities.contains("WPS");
+ isIBSS = result.capabilities.contains("[IBSS]");
+ frequency = result.frequency;
if (security == SECURITY_PSK)
pskType = getPskType(result);
networkId = -1;
@@ -338,24 +344,28 @@ class AccessPoint extends Preference {
setTitle(ssid);
Context context = getContext();
+ StringBuilder summary = new StringBuilder();
+
+ if (isIBSS)
+ summary.append(context.getString(R.string.wifi_mode_ibss_short)).append(" ");
+
if (mState != null) { // This is the active connection
- setSummary(Summary.get(context, mState));
+ summary.append(Summary.get(context, mState));
} else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range
- setSummary(context.getString(R.string.wifi_not_in_range));
+ summary.append(context.getString(R.string.wifi_not_in_range));
} else if (mConfig != null && mConfig.status == WifiConfiguration.Status.DISABLED) {
switch (mConfig.disableReason) {
case WifiConfiguration.DISABLED_AUTH_FAILURE:
- setSummary(context.getString(R.string.wifi_disabled_password_failure));
+ summary.append(context.getString(R.string.wifi_disabled_password_failure));
break;
case WifiConfiguration.DISABLED_DHCP_FAILURE:
case WifiConfiguration.DISABLED_DNS_FAILURE:
- setSummary(context.getString(R.string.wifi_disabled_network_failure));
+ summary.append(context.getString(R.string.wifi_disabled_network_failure));
break;
case WifiConfiguration.DISABLED_UNKNOWN_REASON:
- setSummary(context.getString(R.string.wifi_disabled_generic));
+ summary.append(context.getString(R.string.wifi_disabled_generic));
}
} else { // In range, not disabled.
- StringBuilder summary = new StringBuilder();
if (mConfig != null) { // Is saved network
summary.append(context.getString(R.string.wifi_remembered));
}
@@ -377,8 +387,8 @@ class AccessPoint extends Preference {
summary.append(context.getString(R.string.wifi_wps_available_second_item));
}
}
- setSummary(summary.toString());
}
+ setSummary(summary.toString());
}
/**
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 2598a0e..bde8008 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -74,6 +74,7 @@ public class WifiConfigController implements TextWatcher,
private boolean mEdit;
private TextView mSsidView;
+ private CheckBox mIbssView;
// e.g. AccessPoint.SECURITY_NONE
private int mAccessPointSecurity;
@@ -159,6 +160,7 @@ public class WifiConfigController implements TextWatcher,
mIpSettingsSpinner.setOnItemSelectedListener(this);
mProxySettingsSpinner = (Spinner) mView.findViewById(R.id.proxy_settings);
mProxySettingsSpinner.setOnItemSelectedListener(this);
+ mIbssView = (CheckBox) mView.findViewById(R.id.wifi_ibss_checkbox);
if (mAccessPoint == null) { // new network
mConfigUi.setTitle(R.string.wifi_add_network);
@@ -184,6 +186,7 @@ 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);
mConfigUi.setSubmitButton(context.getString(R.string.wifi_save));
} else {
@@ -191,6 +194,10 @@ public class WifiConfigController implements TextWatcher,
ViewGroup group = (ViewGroup) mView.findViewById(R.id.info);
+ if (mAccessPoint.isIBSS) {
+ addRow(group, R.string.wifi_mode, context.getString(R.string.wifi_mode_ibss));
+ }
+
DetailedState state = mAccessPoint.getState();
if (state != null) {
addRow(group, R.string.wifi_status, Summary.get(mConfigUi.getContext(), state));
@@ -209,7 +216,8 @@ public class WifiConfigController implements TextWatcher,
addRow(group, R.string.wifi_security, mAccessPoint.getSecurityString(false));
- boolean showAdvancedFields = false;
+ // always show advanced fields for IBSS, because we usually need a static IP
+ boolean showAdvancedFields = mAccessPoint.isIBSS;
if (mAccessPoint.networkId != INVALID_NETWORK_ID) {
WifiConfiguration config = mAccessPoint.getConfig();
if (config.ipAssignment == IpAssignment.STATIC) {
@@ -247,7 +255,7 @@ public class WifiConfigController implements TextWatcher,
if (mEdit) {
mConfigUi.setSubmitButton(context.getString(R.string.wifi_save));
} else {
- if (state == null && level != -1) {
+ if (state == null && (level != -1 || mAccessPoint.isIBSS)) {
mConfigUi.setSubmitButton(context.getString(R.string.wifi_connect));
} else {
mView.findViewById(R.id.ip_fields).setVisibility(View.GONE);
@@ -310,13 +318,23 @@ public class WifiConfigController implements TextWatcher,
if (mAccessPoint == null) {
config.SSID = AccessPoint.convertToQuotedString(
mSsidView.getText().toString());
- // If the user adds a network manually, assume that it is hidden.
- config.hiddenSSID = true;
+
+ if (mIbssView.isChecked()) {
+ config.isIBSS = true;
+ config.frequency = 2412; //TODO: select from UI
+ } else {
+ // If the user adds a network manually, assume that it is hidden.
+ config.hiddenSSID = true;
+ }
} else if (mAccessPoint.networkId == INVALID_NETWORK_ID) {
config.SSID = AccessPoint.convertToQuotedString(
mAccessPoint.ssid);
+ config.isIBSS = mAccessPoint.isIBSS;
+ config.frequency = mAccessPoint.frequency;
} else {
config.networkId = mAccessPoint.networkId;
+ config.isIBSS = mAccessPoint.isIBSS;
+ config.frequency = mAccessPoint.frequency;
}
switch (mAccessPointSecurity) {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index a481b08..85c0afa 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -592,7 +592,8 @@ public class WifiSettings extends SettingsPreferenceFragment
mSelectedAccessPoint = (AccessPoint) preference;
/** Bypass dialog for unsecured, unsaved networks */
if (mSelectedAccessPoint.security == AccessPoint.SECURITY_NONE &&
- mSelectedAccessPoint.networkId == INVALID_NETWORK_ID) {
+ mSelectedAccessPoint.networkId == INVALID_NETWORK_ID &&
+ !mSelectedAccessPoint.isIBSS) {
mSelectedAccessPoint.generateOpenNetworkConfig();
mWifiManager.connect(mSelectedAccessPoint.getConfig(), mConnectListener);
} else {
@@ -772,9 +773,8 @@ public class WifiSettings extends SettingsPreferenceFragment
final List<ScanResult> results = mWifiManager.getScanResults();
if (results != null) {
for (ScanResult result : results) {
- // Ignore hidden and ad-hoc networks.
- if (result.SSID == null || result.SSID.length() == 0 ||
- result.capabilities.contains("[IBSS]")) {
+ // Ignore hidden networks.
+ if (result.SSID == null || result.SSID.length() == 0) {
continue;
}