diff options
author | Roshan Pius <rpius@google.com> | 2017-08-15 09:03:03 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2017-08-15 09:13:01 -0700 |
commit | 347faef7fe3f5df209da431eb844bc026a1ba007 (patch) | |
tree | 94aec8bff7a0f16176abff5861a1b5e51d04bb77 /service | |
parent | 8f5c6f25e0b8266b3bae3540e854d67442bc60d2 (diff) |
WifiConfigManager: Skip data migration if new store is present
If the new config store files are present, skip data migration from the
older store file. The old store files may still be present in the device
if WifiConfigStoreLegacy.removeStores() failed for some reason during
the earlier migration.
Also, ensure that we attempt to delete all the store files in
WifiConfigStoreLegacy.removeStores(). Returning early on failure in that
method may leave the device in an incoherent state (some old store files
are deleted, while others are not).
Bug: 63376504
Test: Unit tests
Change-Id: If2e65a7e03677040dfccf88298887e21201aff92
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigManager.java | 10 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigStoreLegacy.java | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 981733d97..29c6d4fb5 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -2698,8 +2698,8 @@ public class WifiConfigManager { /** * Migrate data from legacy store files. The function performs the following operations: - * 1. Check if the legacy store files are present. - * 2. If yes, read all the data from the store files. + * 1. Check if the legacy store files are present and the new store files are absent on device. + * 2. Read all the data from the store files. * 3. Save it to the new store files. * 4. Delete the legacy store file. * @@ -2710,6 +2710,12 @@ public class WifiConfigManager { Log.d(TAG, "Legacy store files not found. No migration needed!"); return true; } + if (mWifiConfigStore.areStoresPresent()) { + Log.d(TAG, "New store files found. No migration needed!" + + " Remove legacy store files"); + mWifiConfigStoreLegacy.removeStores(); + return true; + } WifiConfigStoreDataLegacy storeData = mWifiConfigStoreLegacy.read(); Log.d(TAG, "Reading from legacy store completed"); loadInternalData(storeData.getConfigurations(), new ArrayList<WifiConfiguration>(), diff --git a/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java b/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java index 867775511..39e48a5cb 100644 --- a/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java +++ b/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java @@ -301,24 +301,20 @@ public class WifiConfigStoreLegacy { // First remove all networks from wpa_supplicant and save configuration. if (!mWifiNative.removeAllNetworks()) { Log.e(TAG, "Removing networks from wpa_supplicant failed"); - return false; } // Now remove the ipconfig.txt file. if (!IP_CONFIG_FILE.delete()) { Log.e(TAG, "Removing ipconfig.txt failed"); - return false; } // Now finally remove network history.txt if (!NETWORK_HISTORY_FILE.delete()) { Log.e(TAG, "Removing networkHistory.txt failed"); - return false; } if (!PPS_FILE.delete()) { Log.e(TAG, "Removing PerProviderSubscription.conf failed"); - return false; } Log.i(TAG, "All legacy stores removed!"); |