summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-03-16 10:55:16 -0700
committerRoshan Pius <rpius@google.com>2018-03-17 19:39:14 +0000
commite7df893234345aefd8efb25e45aa02c39644fcb2 (patch)
tree85d8391f01fb87a81a0eba61bbc73054bf4c5b82 /service
parent442372355e372b15bdab1bac0bec1d9cba1a6fa7 (diff)
WifiBackupRestore: Ignore unkown bitset values from backup
CL to clear out any invalid bits in the the various bitsets in the parsed WifiConfiguration from the received backup data. Bug: 73987207 Test: Unit tests Test: Restored backup data from another Pixel device. Change-Id: Ib936a08d9dafc487f485c5054df194b8815042f7
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiBackupDataV1Parser.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java b/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java
index 575732131..9a6cf36db 100644
--- a/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java
+++ b/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java
@@ -211,6 +211,54 @@ class WifiBackupDataV1Parser implements WifiBackupDataParser {
}
/**
+ * Helper method to mask out any invalid data in parsed WifiConfiguration.
+ *
+ * This is a compatibility layer added to the parsing logic to try and weed out any known
+ * issues in the backup data format from other OEM's.
+ */
+ private static void clearAnyKnownIssuesInParsedConfiguration(WifiConfiguration config) {
+ /**
+ * Fix for b/73987207. Clear any invalid bits in the bitsets.
+ */
+ // |allowedKeyManagement|
+ if (config.allowedKeyManagement.length()
+ > WifiConfiguration.KeyMgmt.strings.length) {
+ config.allowedKeyManagement.clear(
+ WifiConfiguration.KeyMgmt.strings.length,
+ config.allowedKeyManagement.length());
+ }
+ // |allowedProtocols|
+ if (config.allowedProtocols.length()
+ > WifiConfiguration.Protocol.strings.length) {
+ config.allowedProtocols.clear(
+ WifiConfiguration.Protocol.strings.length,
+ config.allowedProtocols.length());
+ }
+ // |allowedAuthAlgorithms|
+ if (config.allowedAuthAlgorithms.length()
+ > WifiConfiguration.AuthAlgorithm.strings.length) {
+ config.allowedAuthAlgorithms.clear(
+ WifiConfiguration.AuthAlgorithm.strings.length,
+ config.allowedAuthAlgorithms.length());
+ }
+ // |allowedGroupCiphers|
+ if (config.allowedGroupCiphers.length()
+ > WifiConfiguration.GroupCipher.strings.length) {
+ config.allowedGroupCiphers.clear(
+ WifiConfiguration.GroupCipher.strings.length,
+ config.allowedGroupCiphers.length());
+ }
+ // |allowedPairwiseCiphers|
+ if (config.allowedPairwiseCiphers.length()
+ > WifiConfiguration.PairwiseCipher.strings.length) {
+ config.allowedPairwiseCiphers.clear(
+ WifiConfiguration.PairwiseCipher.strings.length,
+ config.allowedPairwiseCiphers.length());
+ }
+ // Add any other fixable issues discovered from other OEM's here.
+ }
+
+ /**
* Parses the configuration data elements from the provided XML stream to a
* WifiConfiguration object.
* Looping through the tags makes it easy to add elements in the future minor versions if
@@ -300,6 +348,7 @@ class WifiBackupDataV1Parser implements WifiBackupDataParser {
"Unknown value name found: " + valueName[0]);
}
}
+ clearAnyKnownIssuesInParsedConfiguration(configuration);
return Pair.create(configKeyInData, configuration);
}