summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-07-13 07:50:56 -0700
committerRoshan Pius <rpius@google.com>2018-08-08 10:03:54 -0700
commit72182eb1654c78c0492e55c2479f49ab78a5530b (patch)
treec2c6446e3ef5b5eadd2ca2d153b5c4cd8028ef21 /service
parent553438e468dbfe74b7efa03b6551c42d72497d09 (diff)
WifiBackupRestore: Backup network's metered status
Uprev the backup format to 1.1 and add the backup of network's metered status (WifiConfiguration.meteredOverride) Test: Unit tests Test: 'bmgr backup com.android.provider.settings' Test: 'bmgr restore <sha> com.android.provider.settings' Bug: 109870734 Change-Id: Ie6da5fb3a2f1371fcd7dc54e3d0eb1b9663b7825
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiBackupDataV1Parser.java25
-rw-r--r--service/java/com/android/server/wifi/WifiBackupRestore.java4
-rw-r--r--service/java/com/android/server/wifi/util/XmlUtil.java1
3 files changed, 23 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java b/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java
index 9a6cf36db..e090cc0cf 100644
--- a/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java
+++ b/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java
@@ -90,7 +90,7 @@ class WifiBackupDataV1Parser implements WifiBackupDataParser {
private static final String TAG = "WifiBackupDataV1Parser";
- private static final int HIGHEST_SUPPORTED_MINOR_VERSION = 0;
+ private static final int HIGHEST_SUPPORTED_MINOR_VERSION = 1;
// List of tags supported for <WifiConfiguration> section in minor version 0
private static final Set<String> WIFI_CONFIGURATION_MINOR_V0_SUPPORTED_TAGS =
@@ -111,8 +111,15 @@ class WifiBackupDataV1Parser implements WifiBackupDataParser {
WifiConfigurationXmlUtil.XML_TAG_SHARED,
}));
- // List of tags supported for <IpConfiguration> section in minor version 0
- private static final Set<String> IP_CONFIGURATION_MINOR_V0_SUPPORTED_TAGS =
+ // List of tags supported for <WifiConfiguration> section in minor version 1
+ private static final Set<String> WIFI_CONFIGURATION_MINOR_V1_SUPPORTED_TAGS =
+ new HashSet<String>() {{
+ addAll(WIFI_CONFIGURATION_MINOR_V0_SUPPORTED_TAGS);
+ add(WifiConfigurationXmlUtil.XML_TAG_METERED_OVERRIDE);
+ }};
+
+ // List of tags supported for <IpConfiguration> section in minor version 0 & 1
+ private static final Set<String> IP_CONFIGURATION_MINOR_V0_V1_SUPPORTED_TAGS =
new HashSet<String>(Arrays.asList(new String[] {
IpConfigurationXmlUtil.XML_TAG_IP_ASSIGNMENT,
IpConfigurationXmlUtil.XML_TAG_LINK_ADDRESS,
@@ -342,6 +349,9 @@ class WifiBackupDataV1Parser implements WifiBackupDataParser {
case WifiConfigurationXmlUtil.XML_TAG_SHARED:
configuration.shared = (boolean) value;
break;
+ case WifiConfigurationXmlUtil.XML_TAG_METERED_OVERRIDE:
+ configuration.meteredOverride = (int) value;
+ break;
default:
// should never happen, since other tags are filtered out earlier
throw new XmlPullParserException(
@@ -362,7 +372,10 @@ class WifiBackupDataV1Parser implements WifiBackupDataParser {
*/
private static Set<String> getSupportedWifiConfigurationTags(int minorVersion) {
switch (minorVersion) {
- case 0: return WIFI_CONFIGURATION_MINOR_V0_SUPPORTED_TAGS;
+ case 0:
+ return WIFI_CONFIGURATION_MINOR_V0_SUPPORTED_TAGS;
+ case 1:
+ return WIFI_CONFIGURATION_MINOR_V1_SUPPORTED_TAGS;
default:
Log.e(TAG, "Invalid minorVersion: " + minorVersion);
return Collections.<String>emptySet();
@@ -573,7 +586,9 @@ class WifiBackupDataV1Parser implements WifiBackupDataParser {
*/
private static Set<String> getSupportedIpConfigurationTags(int minorVersion) {
switch (minorVersion) {
- case 0: return IP_CONFIGURATION_MINOR_V0_SUPPORTED_TAGS;
+ case 0:
+ case 1:
+ return IP_CONFIGURATION_MINOR_V0_V1_SUPPORTED_TAGS;
default:
Log.e(TAG, "Invalid minorVersion: " + minorVersion);
return Collections.<String>emptySet();
diff --git a/service/java/com/android/server/wifi/WifiBackupRestore.java b/service/java/com/android/server/wifi/WifiBackupRestore.java
index 2d95570fc..9dae5c9b9 100644
--- a/service/java/com/android/server/wifi/WifiBackupRestore.java
+++ b/service/java/com/android/server/wifi/WifiBackupRestore.java
@@ -71,7 +71,7 @@ public class WifiBackupRestore {
* MajorVersion will be incremented for modifications of the XML schema, excluding additive
* modifications in <WifiConfiguration> and/or <IpConfiguration> tags.
* Should the major version be bumped up, a new {@link WifiBackupDataParser} parser needs to
- * be added and returned from {@link getWifiBackupDataParser()}.
+ * be added and returned from {@link #getWifiBackupDataParser(int)} ()}.
* Note that bumping up the major version will result in inability to restore the backup
* set to those lower versions of SDK_INT that don't support the version.
*
@@ -81,7 +81,7 @@ public class WifiBackupRestore {
* Note that bumping up only the minor version will still allow restoring the backup set to
* lower versions of SDK_INT.
*/
- private static final float CURRENT_BACKUP_DATA_VERSION = 1.0f;
+ private static final float CURRENT_BACKUP_DATA_VERSION = 1.1f;
/** This list of older versions will be used to restore data from older backups. */
/**
diff --git a/service/java/com/android/server/wifi/util/XmlUtil.java b/service/java/com/android/server/wifi/util/XmlUtil.java
index 34aa04edc..4e1d3b3a3 100644
--- a/service/java/com/android/server/wifi/util/XmlUtil.java
+++ b/service/java/com/android/server/wifi/util/XmlUtil.java
@@ -420,6 +420,7 @@ public class XmlUtil {
public static void writeToXmlForBackup(XmlSerializer out, WifiConfiguration configuration)
throws XmlPullParserException, IOException {
writeCommonElementsToXml(out, configuration);
+ XmlUtil.writeNextValue(out, XML_TAG_METERED_OVERRIDE, configuration.meteredOverride);
}
/**