summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/SoftApBackupRestore.java3
-rw-r--r--service/java/com/android/server/wifi/SoftApStoreData.java102
-rw-r--r--service/java/com/android/server/wifi/WifiApConfigStore.java12
3 files changed, 68 insertions, 49 deletions
diff --git a/service/java/com/android/server/wifi/SoftApBackupRestore.java b/service/java/com/android/server/wifi/SoftApBackupRestore.java
index 477c1a06d..790a5cb69 100644
--- a/service/java/com/android/server/wifi/SoftApBackupRestore.java
+++ b/service/java/com/android/server/wifi/SoftApBackupRestore.java
@@ -129,6 +129,9 @@ public class SoftApBackupRestore {
} catch (BackupUtils.BadVersionException badVersion) {
Log.e(TAG, "Invalid backup data received, BadVersionException: " + badVersion);
return null;
+ } catch (IllegalArgumentException ie) {
+ Log.e(TAG, "Invalid backup data received, IllegalArgumentException " + ie);
+ return null;
}
return configBuilder.build();
}
diff --git a/service/java/com/android/server/wifi/SoftApStoreData.java b/service/java/com/android/server/wifi/SoftApStoreData.java
index be8dcd891..e48ce94a7 100644
--- a/service/java/com/android/server/wifi/SoftApStoreData.java
+++ b/service/java/com/android/server/wifi/SoftApStoreData.java
@@ -21,6 +21,7 @@ import android.net.wifi.SoftApConfiguration;
import android.text.TextUtils;
import android.util.Log;
+import com.android.server.wifi.util.ApConfigUtil;
import com.android.server.wifi.util.WifiConfigStoreEncryptionUtil;
import com.android.server.wifi.util.XmlUtil;
@@ -42,6 +43,7 @@ public class SoftApStoreData implements WifiConfigStore.StoreData {
private static final String XML_TAG_HIDDEN_SSID = "HiddenSSID";
private static final String XML_TAG_SECURITY_TYPE = "SecurityType";
private static final String XML_TAG_WPA2_PASSPHRASE = "Wpa2Passphrase";
+ private static final String XML_TAG_AP_BAND = "ApBand";
private final DataSource mDataSource;
@@ -90,7 +92,7 @@ public class SoftApStoreData implements WifiConfigStore.StoreData {
SoftApConfiguration softApConfig = mDataSource.toSerialize();
if (softApConfig != null) {
XmlUtil.writeNextValue(out, XML_TAG_SSID, softApConfig.getSsid());
- XmlUtil.writeNextValue(out, XML_TAG_BAND, softApConfig.getBand());
+ XmlUtil.writeNextValue(out, XML_TAG_AP_BAND, softApConfig.getBand());
XmlUtil.writeNextValue(out, XML_TAG_CHANNEL, softApConfig.getChannel());
XmlUtil.writeNextValue(out, XML_TAG_HIDDEN_SSID, softApConfig.isHiddenSsid());
XmlUtil.writeNextValue(out, XML_TAG_SECURITY_TYPE, softApConfig.getSecurityType());
@@ -114,58 +116,66 @@ public class SoftApStoreData implements WifiConfigStore.StoreData {
int securityType = SoftApConfiguration.SECURITY_TYPE_OPEN;
String wpa2Passphrase = null;
String ssid = null;
- int band = -1;
+ // Note that, during deserializaion, we may read the old band encoding (XML_TAG_BAND)
+ // or the new band encoding (XML_TAG_AP_BAND) that is used after the introduction of the
+ // 6GHz band. If the old encoding is found, a conversion is done.
int channel = -1;
- while (!XmlUtil.isNextSectionEnd(in, outerTagDepth)) {
- String[] valueName = new String[1];
- Object value = XmlUtil.readCurrentValue(in, valueName);
- if (TextUtils.isEmpty(valueName[0])) {
- throw new XmlPullParserException("Missing value name");
+ int apBand = -1;
+ try {
+ while (!XmlUtil.isNextSectionEnd(in, outerTagDepth)) {
+ String[] valueName = new String[1];
+ Object value = XmlUtil.readCurrentValue(in, valueName);
+ if (TextUtils.isEmpty(valueName[0])) {
+ throw new XmlPullParserException("Missing value name");
+ }
+ switch (valueName[0]) {
+ case XML_TAG_SSID:
+ ssid = (String) value;
+ softApConfigBuilder.setSsid((String) value);
+ break;
+ case XML_TAG_BAND:
+ apBand = ApConfigUtil.convertWifiConfigBandToSoftApConfigBand((int) value);
+ break;
+ case XML_TAG_AP_BAND:
+ apBand = (int) value;
+ break;
+ case XML_TAG_CHANNEL:
+ channel = (int) value;
+ break;
+ case XML_TAG_HIDDEN_SSID:
+ softApConfigBuilder.setHiddenSsid((boolean) value);
+ break;
+ case XML_TAG_SECURITY_TYPE:
+ securityType = (int) value;
+ break;
+ case XML_TAG_WPA2_PASSPHRASE:
+ wpa2Passphrase = (String) value;
+ break;
+ default:
+ Log.w(TAG, "Ignoring unknown value name " + valueName[0]);
+ break;
+ }
}
- switch (valueName[0]) {
- case XML_TAG_SSID:
- ssid = (String) value;
- softApConfigBuilder.setSsid((String) value);
- break;
- case XML_TAG_BAND:
- band = (int) value;
- break;
- case XML_TAG_CHANNEL:
- channel = (int) value;
- break;
- case XML_TAG_HIDDEN_SSID:
- softApConfigBuilder.setHiddenSsid((boolean) value);
- break;
- case XML_TAG_SECURITY_TYPE:
- securityType = (int) value;
- break;
- case XML_TAG_WPA2_PASSPHRASE:
- wpa2Passphrase = (String) value;
- break;
- default:
- Log.w(TAG, "Ignoring unknown value name " + valueName[0]);
- break;
- }
- }
- // Set channel and band
- if (channel == 0) {
- if (band != -1) {
- softApConfigBuilder.setBand(band);
+ // Set channel and band
+ if (channel == 0) {
+ softApConfigBuilder.setBand(apBand);
+ } else {
+ softApConfigBuilder.setChannel(channel, apBand);
}
- } else if ((channel != -1) && (band != -1)) {
- softApConfigBuilder.setChannel(channel, band);
- }
- // We should at-least have SSID restored from store.
- if (ssid == null) {
- Log.e(TAG, "Failed to parse SSID");
+ // We should at-least have SSID restored from store.
+ if (ssid == null) {
+ Log.e(TAG, "Failed to parse SSID");
+ return;
+ }
+ if (securityType == SoftApConfiguration.SECURITY_TYPE_WPA2_PSK) {
+ softApConfigBuilder.setWpa2Passphrase(wpa2Passphrase);
+ }
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Failed to parse configuration" + e);
return;
}
- if (securityType == SoftApConfiguration.SECURITY_TYPE_WPA2_PSK) {
- softApConfigBuilder.setWpa2Passphrase(wpa2Passphrase);
- }
-
mDataSource.fromDeserialized(softApConfigBuilder.setSsid(ssid).build());
}
diff --git a/service/java/com/android/server/wifi/WifiApConfigStore.java b/service/java/com/android/server/wifi/WifiApConfigStore.java
index 8b7d94697..a42dbebd7 100644
--- a/service/java/com/android/server/wifi/WifiApConfigStore.java
+++ b/service/java/com/android/server/wifi/WifiApConfigStore.java
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.IntentFilter;
import android.net.MacAddress;
import android.net.wifi.SoftApConfiguration;
+import android.net.wifi.WifiConfiguration;
import android.os.Environment;
import android.os.Handler;
import android.os.Process;
@@ -293,9 +294,11 @@ public class WifiApConfigStore {
int channel = in.readInt();
if (channel == 0) {
- configBuilder.setBand(band);
+ configBuilder.setBand(
+ ApConfigUtil.convertWifiConfigBandToSoftApConfigBand(band));
} else {
- configBuilder.setChannel(channel, band);
+ configBuilder.setChannel(channel,
+ ApConfigUtil.convertWifiConfigBandToSoftApConfigBand(band));
}
}
@@ -304,13 +307,16 @@ public class WifiApConfigStore {
}
int authType = in.readInt();
- if (authType == SoftApConfiguration.SECURITY_TYPE_WPA2_PSK) {
+ if (authType == WifiConfiguration.KeyMgmt.WPA2_PSK) {
configBuilder.setWpa2Passphrase(in.readUTF());
}
config = configBuilder.build();
} catch (IOException e) {
Log.e(TAG, "Error reading hotspot configuration " + e);
config = null;
+ } catch (IllegalArgumentException ie) {
+ Log.e(TAG, "Invalid hotspot configuration " + ie);
+ config = null;
} finally {
if (in != null) {
try {