diff options
| author | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-31 19:49:51 +0000 |
|---|---|---|
| committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-31 19:49:51 +0000 |
| commit | adca86a0fa64a1cf1ec67438ceeea9a84750f8de (patch) | |
| tree | b61689f3194594bcf68130495a2c87eed817a6a1 | |
| parent | acae781862cb6146b629af2e192e27bbbafbcc38 (diff) | |
| parent | fcb9c7041f0d12e312384cf3894ec79604632b08 (diff) | |
| download | frameworks_opt_net_wifi-oreo-r2-release.tar.gz frameworks_opt_net_wifi-oreo-r2-release.tar.bz2 frameworks_opt_net_wifi-oreo-r2-release.zip | |
Merge cherrypicks of [2830107, 2830861, 2828443, 2830367, 2830108, 2830109, 2830110, 2830111, 2830592] into oc-r2-releaseandroid-8.0.0_r29oreo-r2-release
Change-Id: Ied9278164d85bf50963fc964e09d739ccad7b5e4
3 files changed, 27 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 25a5a20ad..460a9b775 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -2609,8 +2609,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. * @@ -2621,6 +2621,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!"); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 9fa67a000..6e8327da9 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -2487,6 +2487,7 @@ public class WifiConfigManagerTest { new WifiConfigStoreDataLegacy(networks, deletedEphermalSSIDs); when(mWifiConfigStoreLegacy.areStoresPresent()).thenReturn(true); + when(mWifiConfigStore.areStoresPresent()).thenReturn(false); when(mWifiConfigStoreLegacy.read()).thenReturn(storeData); // Now trigger the migration from legacy store. This should populate the in memory list with @@ -2520,6 +2521,24 @@ public class WifiConfigManagerTest { } /** + * Verifies the loading of networks using {@link WifiConfigManager#migrateFromLegacyStore()} ()} + * does not attempt to migrate data from legacy stores when the new store files are present + * (i.e migration was already done once). + */ + @Test + public void testNewStoreFilesPresentNoMigrationFromLegacyStore() throws Exception { + when(mWifiConfigStore.areStoresPresent()).thenReturn(true); + when(mWifiConfigStoreLegacy.areStoresPresent()).thenReturn(true); + + // Now trigger a migration from legacy store. + assertTrue(mWifiConfigManager.migrateFromLegacyStore()); + + verify(mWifiConfigStoreLegacy, never()).read(); + // Verify that we went ahead and deleted the old store files. + verify(mWifiConfigStoreLegacy).removeStores(); + } + + /** * Verifies the loading of networks using {@link WifiConfigManager#loadFromStore()} does * not attempt to read from any of the stores (new or legacy) when the store files are * not present. |
