From f89adbf3e7b2d56b8806ce2bd797dc9b2aec3526 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Tue, 18 Sep 2018 14:34:05 -0700 Subject: WifiBackupRestore: Ignore configKey mismatch in backup data WifiConfiguration.configKey() is not part of the SDK. So, we can't enforce that all Android devices return the same config key for a given WifiConfiguration. The configKey validation in the parser for backup data was just meant to be a failsafe. So, it should be safe to ignore the check. Bug: 115441410 Test: Unit tests Change-Id: Ibe50e9525abc4f7a3e5a440ba2760a166246e91d (cherry-picked from 234096a8f72046630787a7936fca161243b68edd) --- .../server/wifi/WifiBackupDataV1Parser.java | 29 ++++++++-------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java b/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java index 9a6cf36db..9b27cf434 100644 --- a/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java +++ b/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java @@ -167,8 +167,7 @@ class WifiBackupDataV1Parser implements WifiBackupDataParser { in, WifiBackupRestore.XML_TAG_SECTION_HEADER_WIFI_CONFIGURATION, networkTagDepth); int configTagDepth = networkTagDepth + 1; - configuration = parseWifiConfigurationFromXmlAndValidateConfigKey(in, configTagDepth, - minorVersion); + configuration = parseWifiConfigurationFromXml(in, configTagDepth, minorVersion); if (configuration == null) { return null; } @@ -182,12 +181,12 @@ class WifiBackupDataV1Parser implements WifiBackupDataParser { } /** - * Helper method to parse the WifiConfiguration object and validate the configKey parsed. + * Helper method to parse the WifiConfiguration object. */ - private WifiConfiguration parseWifiConfigurationFromXmlAndValidateConfigKey(XmlPullParser in, + private WifiConfiguration parseWifiConfigurationFromXml(XmlPullParser in, int outerTagDepth, int minorVersion) throws XmlPullParserException, IOException { Pair parsedConfig = - parseWifiConfigurationFromXml(in, outerTagDepth, minorVersion); + parseWifiConfigurationFromXmlInternal(in, outerTagDepth, minorVersion); if (parsedConfig == null || parsedConfig.first == null || parsedConfig.second == null) { return null; } @@ -195,17 +194,10 @@ class WifiBackupDataV1Parser implements WifiBackupDataParser { WifiConfiguration configuration = parsedConfig.second; String configKeyCalculated = configuration.configKey(); if (!configKeyParsed.equals(configKeyCalculated)) { - String configKeyMismatchLog = - "Configuration key does not match. Retrieved: " + configKeyParsed - + ", Calculated: " + configKeyCalculated; - if (configuration.shared) { - Log.e(TAG, configKeyMismatchLog); - return null; - } else { - // ConfigKey mismatches are expected for private networks because the - // UID is not preserved across backup/restore. - Log.w(TAG, configKeyMismatchLog); - } + // configKey is not part of the SDK. So, we can't expect this to be the same + // across OEM's. Just log a warning & continue. + Log.w(TAG, "Configuration key does not match. Retrieved: " + configKeyParsed + + ", Calculated: " + configKeyCalculated); } return configuration; } @@ -269,8 +261,9 @@ class WifiBackupDataV1Parser implements WifiBackupDataParser { * @param minorVersion minor version number parsed from incoming data. * @return Pair if parsing is successful, null otherwise. */ - private static Pair parseWifiConfigurationFromXml(XmlPullParser in, - int outerTagDepth, int minorVersion) throws XmlPullParserException, IOException { + private static Pair parseWifiConfigurationFromXmlInternal( + XmlPullParser in, int outerTagDepth, int minorVersion) + throws XmlPullParserException, IOException { WifiConfiguration configuration = new WifiConfiguration(); String configKeyInData = null; Set supportedTags = getSupportedWifiConfigurationTags(minorVersion); -- cgit v1.2.3