diff options
author | Roshan Pius <rpius@google.com> | 2020-02-26 20:55:40 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-02-26 20:55:40 +0000 |
commit | 30bb825c32f030aee393b7604c46a227f290a481 (patch) | |
tree | 8a671a69f247a0ff5c23bdb88669d67629bd02d1 | |
parent | b66edf6a39b0038c885b98134679d491ddfffd84 (diff) | |
parent | 3d972e6e27d470d0d9d9b5f6eb1fcc7e144af4b5 (diff) |
Merge changes from topics "remove_oem_configstore", "rename_oem_migration" into rvc-dev
* changes:
WifiConfigStore: Remove OEM's config store after read
wifi-service: Rename WifiOemMigrationHook class
32 files changed, 165 insertions, 119 deletions
diff --git a/service/java/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreData.java b/service/java/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreData.java index acfba80c5..065ccf1db 100644 --- a/service/java/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreData.java +++ b/service/java/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreData.java @@ -88,7 +88,8 @@ public class ImsiPrivacyProtectionExemptionStoreData implements WifiConfigStore. @Override public void deserializeData(XmlPullParser in, int outerTagDepth, int version, - WifiConfigStoreEncryptionUtil encryptionUtil) + WifiConfigStoreEncryptionUtil encryptionUtil, + WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { // Ignore empty reads. if (in == null) { diff --git a/service/java/com/android/server/wifi/NetworkListSharedStoreData.java b/service/java/com/android/server/wifi/NetworkListSharedStoreData.java index 77e14a6b9..1b0dc5366 100644 --- a/service/java/com/android/server/wifi/NetworkListSharedStoreData.java +++ b/service/java/com/android/server/wifi/NetworkListSharedStoreData.java @@ -23,9 +23,8 @@ import android.content.Context; */ public class NetworkListSharedStoreData extends NetworkListStoreData { - public NetworkListSharedStoreData(Context context, - WifiOemConfigStoreMigrationDataHolder wifiOemConfigStoreMigrationDataHolder) { - super(context, wifiOemConfigStoreMigrationDataHolder); + public NetworkListSharedStoreData(Context context) { + super(context); } @Override diff --git a/service/java/com/android/server/wifi/NetworkListStoreData.java b/service/java/com/android/server/wifi/NetworkListStoreData.java index 54b563413..5be8261e7 100644 --- a/service/java/com/android/server/wifi/NetworkListStoreData.java +++ b/service/java/com/android/server/wifi/NetworkListStoreData.java @@ -18,6 +18,7 @@ package com.android.server.wifi; import static com.android.server.wifi.WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION; +import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.net.IpConfiguration; @@ -59,17 +60,14 @@ public abstract class NetworkListStoreData implements WifiConfigStore.StoreData "WifiEnterpriseConfiguration"; private final Context mContext; - private final WifiOemConfigStoreMigrationDataHolder mWifiOemConfigStoreMigrationDataHolder; /** * List of saved shared networks visible to all the users to be stored in the store file. */ private List<WifiConfiguration> mConfigurations; - NetworkListStoreData(Context context, - WifiOemConfigStoreMigrationDataHolder wifiOemConfigStoreMigrationDataHolder) { + NetworkListStoreData(Context context) { mContext = context; - mWifiOemConfigStoreMigrationDataHolder = wifiOemConfigStoreMigrationDataHolder; } @Override @@ -82,11 +80,12 @@ public abstract class NetworkListStoreData implements WifiConfigStore.StoreData @Override public void deserializeData(XmlPullParser in, int outerTagDepth, @WifiConfigStore.Version int version, - @Nullable WifiConfigStoreEncryptionUtil encryptionUtil) + @Nullable WifiConfigStoreEncryptionUtil encryptionUtil, + @NonNull WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { // Check if we have data to migrate from OEM, if yes skip loading the section from the file. List<WifiConfiguration> oemMigratedConfigurations = - mWifiOemConfigStoreMigrationDataHolder.getUserSavedNetworks(); + storeMigrationDataHolder.getUserSavedNetworks(); if (oemMigratedConfigurations != null) { Log.i(TAG, "Loading data from OEM migration hook"); mConfigurations = oemMigratedConfigurations; diff --git a/service/java/com/android/server/wifi/NetworkListUserStoreData.java b/service/java/com/android/server/wifi/NetworkListUserStoreData.java index 6668a3def..c146c18f5 100644 --- a/service/java/com/android/server/wifi/NetworkListUserStoreData.java +++ b/service/java/com/android/server/wifi/NetworkListUserStoreData.java @@ -23,9 +23,8 @@ import android.content.Context; */ public class NetworkListUserStoreData extends NetworkListStoreData { - public NetworkListUserStoreData(Context context, - WifiOemConfigStoreMigrationDataHolder wifiOemConfigStoreMigrationDataHolder) { - super(context, wifiOemConfigStoreMigrationDataHolder); + public NetworkListUserStoreData(Context context) { + super(context); } @Override diff --git a/service/java/com/android/server/wifi/NetworkRequestStoreData.java b/service/java/com/android/server/wifi/NetworkRequestStoreData.java index 763f267b9..7d06a70e1 100644 --- a/service/java/com/android/server/wifi/NetworkRequestStoreData.java +++ b/service/java/com/android/server/wifi/NetworkRequestStoreData.java @@ -16,6 +16,7 @@ package com.android.server.wifi; +import android.annotation.NonNull; import android.annotation.Nullable; import android.net.MacAddress; import android.util.Log; @@ -98,7 +99,8 @@ public class NetworkRequestStoreData implements WifiConfigStore.StoreData { @Override public void deserializeData(XmlPullParser in, int outerTagDepth, @WifiConfigStore.Version int version, - @Nullable WifiConfigStoreEncryptionUtil encryptionUtil) + @Nullable WifiConfigStoreEncryptionUtil encryptionUtil, + @NonNull WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { // Ignore empty reads. if (in == null) { diff --git a/service/java/com/android/server/wifi/NetworkSuggestionStoreData.java b/service/java/com/android/server/wifi/NetworkSuggestionStoreData.java index 18e13b5fb..dd0d0d304 100644 --- a/service/java/com/android/server/wifi/NetworkSuggestionStoreData.java +++ b/service/java/com/android/server/wifi/NetworkSuggestionStoreData.java @@ -18,6 +18,7 @@ package com.android.server.wifi; import static com.android.server.wifi.WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION; +import android.annotation.NonNull; import android.annotation.Nullable; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiEnterpriseConfig; @@ -121,7 +122,8 @@ public class NetworkSuggestionStoreData implements WifiConfigStore.StoreData { @Override public void deserializeData(XmlPullParser in, int outerTagDepth, @WifiConfigStore.Version int version, - @Nullable WifiConfigStoreEncryptionUtil encryptionUtil) + @Nullable WifiConfigStoreEncryptionUtil encryptionUtil, + @NonNull WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { // Ignore empty reads. if (in == null) { diff --git a/service/java/com/android/server/wifi/RandomizedMacStoreData.java b/service/java/com/android/server/wifi/RandomizedMacStoreData.java index a03be6056..8c7c9bd83 100644 --- a/service/java/com/android/server/wifi/RandomizedMacStoreData.java +++ b/service/java/com/android/server/wifi/RandomizedMacStoreData.java @@ -16,6 +16,7 @@ package com.android.server.wifi; +import android.annotation.NonNull; import android.annotation.Nullable; import android.util.Log; @@ -56,7 +57,8 @@ public class RandomizedMacStoreData implements WifiConfigStore.StoreData { @Override public void deserializeData(XmlPullParser in, int outerTagDepth, @WifiConfigStore.Version int version, - @Nullable WifiConfigStoreEncryptionUtil encryptionUtil) + @Nullable WifiConfigStoreEncryptionUtil encryptionUtil, + @NonNull WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { // Ignore empty reads. if (in == null) { diff --git a/service/java/com/android/server/wifi/SoftApBackupRestore.java b/service/java/com/android/server/wifi/SoftApBackupRestore.java index 84d9e7564..1c1f5c413 100644 --- a/service/java/com/android/server/wifi/SoftApBackupRestore.java +++ b/service/java/com/android/server/wifi/SoftApBackupRestore.java @@ -20,7 +20,7 @@ import android.content.Context; import android.net.MacAddress; import android.net.wifi.SoftApConfiguration; import android.net.wifi.WifiConfiguration; -import android.net.wifi.WifiOemMigrationHook; +import android.net.wifi.WifiMigration; import android.util.BackupUtils; import android.util.Log; @@ -157,8 +157,8 @@ public class SoftApBackupRestore { configBuilder.setAutoShutdownEnabled(in.readBoolean()); } else { // Migrate data out of settings. - WifiOemMigrationHook.SettingsMigrationData migrationData = - WifiOemMigrationHook.loadFromSettings(mContext); + WifiMigration.SettingsMigrationData migrationData = + WifiMigration.loadFromSettings(mContext); if (migrationData == null) { Log.e(TAG, "No migration data present"); } else { diff --git a/service/java/com/android/server/wifi/SoftApStoreData.java b/service/java/com/android/server/wifi/SoftApStoreData.java index e4f874c23..deea15ae1 100644 --- a/service/java/com/android/server/wifi/SoftApStoreData.java +++ b/service/java/com/android/server/wifi/SoftApStoreData.java @@ -16,11 +16,12 @@ package com.android.server.wifi; +import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.net.MacAddress; import android.net.wifi.SoftApConfiguration; -import android.net.wifi.WifiOemMigrationHook; +import android.net.wifi.WifiMigration; import android.text.TextUtils; import android.util.Log; @@ -59,7 +60,6 @@ public class SoftApStoreData implements WifiConfigStore.StoreData { private final Context mContext; private final DataSource mDataSource; - private final WifiOemConfigStoreMigrationDataHolder mWifiOemConfigStoreMigrationDataHolder; /** * Interface define the data source for the notifier store data. @@ -95,12 +95,9 @@ public class SoftApStoreData implements WifiConfigStore.StoreData { * * @param dataSource The DataSource that implements the update and retrieval of the SSID set. */ - SoftApStoreData(Context context, - DataSource dataSource, - WifiOemConfigStoreMigrationDataHolder wifiOemConfigStoreMigrationDataHolder) { + SoftApStoreData(Context context, DataSource dataSource) { mContext = context; mDataSource = dataSource; - mWifiOemConfigStoreMigrationDataHolder = wifiOemConfigStoreMigrationDataHolder; } @Override @@ -142,11 +139,12 @@ public class SoftApStoreData implements WifiConfigStore.StoreData { @Override public void deserializeData(XmlPullParser in, int outerTagDepth, @WifiConfigStore.Version int version, - @Nullable WifiConfigStoreEncryptionUtil encryptionUtil) + @Nullable WifiConfigStoreEncryptionUtil encryptionUtil, + @NonNull WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { // Check if we have data to migrate from OEM, if yes skip loading the section from the file. SoftApConfiguration oemMigratedConfiguration = - mWifiOemConfigStoreMigrationDataHolder.getUserSoftApConfiguration(); + storeMigrationDataHolder.getUserSoftApConfiguration(); if (oemMigratedConfiguration != null) { Log.i(TAG, "Loading data from OEM migration hook"); mDataSource.fromDeserialized(oemMigratedConfiguration); @@ -262,8 +260,8 @@ public class SoftApStoreData implements WifiConfigStore.StoreData { } if (!autoShutdownEnabledTagPresent) { // Migrate data out of settings. - WifiOemMigrationHook.SettingsMigrationData migrationData = - WifiOemMigrationHook.loadFromSettings(mContext); + WifiMigration.SettingsMigrationData migrationData = + WifiMigration.loadFromSettings(mContext); if (migrationData == null) { Log.e(TAG, "No migration data present"); } else { diff --git a/service/java/com/android/server/wifi/SsidSetStoreData.java b/service/java/com/android/server/wifi/SsidSetStoreData.java index e3374ddbe..e5636f603 100644 --- a/service/java/com/android/server/wifi/SsidSetStoreData.java +++ b/service/java/com/android/server/wifi/SsidSetStoreData.java @@ -16,6 +16,7 @@ package com.android.server.wifi; +import android.annotation.NonNull; import android.annotation.Nullable; import android.text.TextUtils; import android.util.Log; @@ -90,7 +91,8 @@ public class SsidSetStoreData implements WifiConfigStore.StoreData { @Override public void deserializeData(XmlPullParser in, int outerTagDepth, @WifiConfigStore.Version int version, - @Nullable WifiConfigStoreEncryptionUtil encryptionUtil) + @Nullable WifiConfigStoreEncryptionUtil encryptionUtil, + @NonNull WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { // Ignore empty reads. if (in == null) { diff --git a/service/java/com/android/server/wifi/WakeupConfigStoreData.java b/service/java/com/android/server/wifi/WakeupConfigStoreData.java index 074393b81..f828930b6 100644 --- a/service/java/com/android/server/wifi/WakeupConfigStoreData.java +++ b/service/java/com/android/server/wifi/WakeupConfigStoreData.java @@ -16,6 +16,7 @@ package com.android.server.wifi; +import android.annotation.NonNull; import android.annotation.Nullable; import android.util.ArraySet; import android.util.Log; @@ -146,7 +147,8 @@ public class WakeupConfigStoreData implements StoreData { @Override public void deserializeData(XmlPullParser in, int outerTagDepth, @WifiConfigStore.Version int version, - @Nullable WifiConfigStoreEncryptionUtil encryptionUtil) + @Nullable WifiConfigStoreEncryptionUtil encryptionUtil, + @NonNull WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { if (!mHasBeenRead) { Log.d(TAG, "WifiWake user data has been read"); diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java index cd998d0e3..f2f48be1f 100644 --- a/service/java/com/android/server/wifi/WifiConfigStore.java +++ b/service/java/com/android/server/wifi/WifiConfigStore.java @@ -54,7 +54,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -191,6 +190,7 @@ public class WifiConfigStore { */ private final Clock mClock; private final WifiMetrics mWifiMetrics; + private final WifiConfigStoreMigrationDataHolder mStoreMigrationDataHolder; /** * Shared config store file instance. There are 2 shared store files: * {@link #STORE_FILE_NAME_SHARED_GENERAL} & {@link #STORE_FILE_NAME_SHARED_SOFTAP}. @@ -236,17 +236,20 @@ public class WifiConfigStore { * @param handler handler instance to post alarm timeouts to. * @param clock clock instance to retrieve timestamps for alarms. * @param wifiMetrics Metrics instance. + * @param storeMigrationDataHolder Needed for migration data out of OEM stores. * @param sharedStores List of {@link StoreFile} instances pointing to the shared store files. * This should be retrieved using {@link #createSharedFiles(boolean)} * method. */ public WifiConfigStore(Context context, Handler handler, Clock clock, WifiMetrics wifiMetrics, + WifiConfigStoreMigrationDataHolder storeMigrationDataHolder, List<StoreFile> sharedStores) { mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mEventHandler = handler; mClock = clock; mWifiMetrics = wifiMetrics; + mStoreMigrationDataHolder = storeMigrationDataHolder; mStoreDataList = new ArrayList<>(); // Initialize the store files. @@ -569,6 +572,8 @@ public class WifiConfigStore { } catch (ArithmeticException e) { // Silently ignore on any overflow errors. } + // Read is complete, go ahead and remove any OEM config stores. + mStoreMigrationDataHolder.removeStoreIfPresent(); Log.d(TAG, "Reading from all stores completed in " + readTime + " ms."); } @@ -617,7 +622,7 @@ public class WifiConfigStore { @Version int version, @NonNull WifiConfigStoreEncryptionUtil encryptionUtil) throws XmlPullParserException, IOException { for (StoreData storeData : storeDataSet) { - storeData.deserializeData(null, 0, version, encryptionUtil); + storeData.deserializeData(null, 0, version, encryptionUtil, mStoreMigrationDataHolder); } } @@ -672,7 +677,7 @@ public class WifiConfigStore { continue; } storeData.deserializeData(in, rootTagDepth + 1, version, - storeFile.getEncryptionUtil()); + storeFile.getEncryptionUtil(), mStoreMigrationDataHolder); storeDatasInvoked.add(storeData); } // Inform all the other registered store data clients that there is nothing in the store @@ -872,12 +877,14 @@ public class WifiConfigStore { * @param outerTagDepth The depth of the outer tag in the XML document * @param version Version of config store file. * @param encryptionUtil Utility to help decrypt any credential data. + * @param storeMigrationDataHolder Needed for migration data out of OEM stores. * * Note: This will be invoked every time a store file is read, even if there is nothing * in the store for them. */ void deserializeData(@Nullable XmlPullParser in, int outerTagDepth, @Version int version, - @Nullable WifiConfigStoreEncryptionUtil encryptionUtil) + @Nullable WifiConfigStoreEncryptionUtil encryptionUtil, + @NonNull WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException; /** diff --git a/service/java/com/android/server/wifi/WifiOemConfigStoreMigrationDataHolder.java b/service/java/com/android/server/wifi/WifiConfigStoreMigrationDataHolder.java index 930c8dfcb..7ecae0f1f 100644 --- a/service/java/com/android/server/wifi/WifiOemConfigStoreMigrationDataHolder.java +++ b/service/java/com/android/server/wifi/WifiConfigStoreMigrationDataHolder.java @@ -19,24 +19,24 @@ package com.android.server.wifi; import android.annotation.Nullable; import android.net.wifi.SoftApConfiguration; import android.net.wifi.WifiConfiguration; -import android.net.wifi.WifiOemMigrationHook; -import android.net.wifi.WifiOemMigrationHook.ConfigStoreMigrationData; +import android.net.wifi.WifiMigration; +import android.net.wifi.WifiMigration.ConfigStoreMigrationData; import java.util.List; /** * Caches the data migrated out of OEM config store. This class helps to avoid invoking the - * {@link WifiOemMigrationHook#loadFromConfigStore()} multiple times from different instances of + * {@link WifiMigration#loadFromConfigStore()} multiple times from different instances of * {@link WifiConfigStore.StoreData}. * */ -public class WifiOemConfigStoreMigrationDataHolder { +public class WifiConfigStoreMigrationDataHolder { private ConfigStoreMigrationData mData; private boolean mLoaded = false; - private void loadOemMigrationData() { + private void loadMigrationData() { if (!mLoaded) { - mData = WifiOemMigrationHook.loadFromConfigStore(); + mData = WifiMigration.loadFromConfigStore(); mLoaded = true; } } @@ -46,7 +46,7 @@ public class WifiOemConfigStoreMigrationDataHolder { */ @Nullable public List<WifiConfiguration> getUserSavedNetworks() { - loadOemMigrationData(); + loadMigrationData(); if (mData == null) return null; return mData.getUserSavedNetworkConfigurations(); } @@ -56,9 +56,18 @@ public class WifiOemConfigStoreMigrationDataHolder { */ @Nullable public SoftApConfiguration getUserSoftApConfiguration() { - loadOemMigrationData(); + loadMigrationData(); if (mData == null) return null; return mData.getUserSoftApConfiguration(); } + /** + * Check if there was any data to be migrated. If yes, then go ahead and invoke the API + * to remove the stores now. + */ + public void removeStoreIfPresent() { + if (mLoaded && mData != null) { + WifiMigration.removeConfigStore(); + } + } } diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index 2cc193028..14ab4ac51 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -157,7 +157,7 @@ public class WifiInjector { private final ThroughputPredictor mThroughputPredictor; private NetdWrapper mNetdWrapper; private final WifiHealthMonitor mWifiHealthMonitor; - private final WifiOemConfigStoreMigrationDataHolder mOemConfigStoreMigrationDataHolder; + private final WifiConfigStoreMigrationDataHolder mOemConfigStoreMigrationDataHolder; private final WifiSettingsConfigStore mSettingsConfigStore; private final WifiScanAlwaysAvailableSettingsCompatibility mWifiScanAlwaysAvailableSettingsCompatibility; @@ -248,13 +248,14 @@ public class WifiInjector { mKeyStore = keyStore; mWifiKeyStore = new WifiKeyStore(mKeyStore); // New config store + mOemConfigStoreMigrationDataHolder = new WifiConfigStoreMigrationDataHolder(); mWifiConfigStore = new WifiConfigStore(mContext, wifiHandler, mClock, mWifiMetrics, + mOemConfigStoreMigrationDataHolder, WifiConfigStore.createSharedFiles(mFrameworkFacade.isNiapModeOn(mContext))); SubscriptionManager subscriptionManager = mContext.getSystemService(SubscriptionManager.class); mTelephonyUtil = new TelephonyUtil(makeTelephonyManager(), subscriptionManager, mFrameworkFacade, mContext, wifiHandler); - mOemConfigStoreMigrationDataHolder = new WifiOemConfigStoreMigrationDataHolder(); String l2KeySeed = Secure.getString(mContext.getContentResolver(), Secure.ANDROID_ID); mWifiScoreCard = new WifiScoreCard(mClock, l2KeySeed, mDeviceConfigFacade); // Config Manager @@ -262,8 +263,8 @@ public class WifiInjector { mUserManager, mTelephonyUtil, mWifiKeyStore, mWifiConfigStore, mWifiPermissionsUtil, mWifiPermissionsWrapper, this, - new NetworkListSharedStoreData(mContext, mOemConfigStoreMigrationDataHolder), - new NetworkListUserStoreData(mContext, mOemConfigStoreMigrationDataHolder), + new NetworkListSharedStoreData(mContext), + new NetworkListUserStoreData(mContext), new RandomizedMacStoreData(), mFrameworkFacade, wifiHandler, mDeviceConfigFacade, mWifiScoreCard); mSettingsConfigStore = new WifiSettingsConfigStore(context, wifiHandler, mWifiConfigManager, @@ -680,7 +681,7 @@ public class WifiInjector { */ public SoftApStoreData makeSoftApStoreData( SoftApStoreData.DataSource dataSource) { - return new SoftApStoreData(mContext, dataSource, mOemConfigStoreMigrationDataHolder); + return new SoftApStoreData(mContext, dataSource); } public WifiPermissionsUtil getWifiPermissionsUtil() { diff --git a/service/java/com/android/server/wifi/WifiSettingsConfigStore.java b/service/java/com/android/server/wifi/WifiSettingsConfigStore.java index 7e072776c..4bb99a0b6 100644 --- a/service/java/com/android/server/wifi/WifiSettingsConfigStore.java +++ b/service/java/com/android/server/wifi/WifiSettingsConfigStore.java @@ -20,7 +20,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.StringDef; import android.content.Context; -import android.net.wifi.WifiOemMigrationHook; +import android.net.wifi.WifiMigration; import android.os.Handler; import android.text.TextUtils; import android.util.Log; @@ -175,8 +175,8 @@ public class WifiSettingsConfigStore { private void migrateFromSettingsIfNeeded() { if (!mSettings.isEmpty()) return; // already migrated. - WifiOemMigrationHook.SettingsMigrationData dataToMigrate = - WifiOemMigrationHook.loadFromSettings(mContext); + WifiMigration.SettingsMigrationData dataToMigrate = + WifiMigration.loadFromSettings(mContext); if (dataToMigrate == null) { Log.e(TAG, "Not settings data to migrate"); return; @@ -322,7 +322,8 @@ public class WifiSettingsConfigStore { @Override public void deserializeData(XmlPullParser in, int outerTagDepth, @WifiConfigStore.Version int version, - @Nullable WifiConfigStoreEncryptionUtil encryptionUtil) + @Nullable WifiConfigStoreEncryptionUtil encryptionUtil, + @NonNull WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { if (in == null) { // Empty read triggers the migration since it indicates that there is no settings diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointConfigSharedStoreData.java b/service/java/com/android/server/wifi/hotspot2/PasspointConfigSharedStoreData.java index b956983c4..fe69bcc27 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointConfigSharedStoreData.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointConfigSharedStoreData.java @@ -16,10 +16,12 @@ package com.android.server.wifi.hotspot2; +import android.annotation.NonNull; import android.annotation.Nullable; import android.util.Log; import com.android.server.wifi.WifiConfigStore; +import com.android.server.wifi.WifiConfigStoreMigrationDataHolder; import com.android.server.wifi.util.WifiConfigStoreEncryptionUtil; import com.android.server.wifi.util.XmlUtil; @@ -86,7 +88,8 @@ public class PasspointConfigSharedStoreData implements WifiConfigStore.StoreData @Override public void deserializeData(XmlPullParser in, int outerTagDepth, @WifiConfigStore.Version int version, - @Nullable WifiConfigStoreEncryptionUtil encryptionUtil) + @Nullable WifiConfigStoreEncryptionUtil encryptionUtil, + @NonNull WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { // Ignore empty reads. if (in == null) { diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointConfigUserStoreData.java b/service/java/com/android/server/wifi/hotspot2/PasspointConfigUserStoreData.java index e7de22f55..84c8be706 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointConfigUserStoreData.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointConfigUserStoreData.java @@ -16,12 +16,14 @@ package com.android.server.wifi.hotspot2; +import android.annotation.NonNull; import android.annotation.Nullable; import android.net.wifi.hotspot2.PasspointConfiguration; import android.text.TextUtils; import android.util.Log; import com.android.server.wifi.WifiConfigStore; +import com.android.server.wifi.WifiConfigStoreMigrationDataHolder; import com.android.server.wifi.WifiKeyStore; import com.android.server.wifi.util.TelephonyUtil; import com.android.server.wifi.util.WifiConfigStoreEncryptionUtil; @@ -116,7 +118,8 @@ public class PasspointConfigUserStoreData implements WifiConfigStore.StoreData { @Override public void deserializeData(XmlPullParser in, int outerTagDepth, @WifiConfigStore.Version int version, - @Nullable WifiConfigStoreEncryptionUtil encryptionUtil) + @Nullable WifiConfigStoreEncryptionUtil encryptionUtil, + @NonNull WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { // Ignore empty reads. if (in == null) { diff --git a/tests/wifitests/src/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreDataTest.java index f9e05cb32..e75fd2736 100644 --- a/tests/wifitests/src/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreDataTest.java @@ -17,6 +17,7 @@ package com.android.server.wifi; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -71,7 +72,8 @@ public class ImsiPrivacyProtectionExemptionStoreDataTest { final ByteArrayInputStream inputStream = new ByteArrayInputStream(data); in.setInput(inputStream, StandardCharsets.UTF_8.name()); mImsiPrivacyProtectionExemptionStoreData.deserializeData(in, in.getDepth(), - WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, null); + WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, null, + mock(WifiConfigStoreMigrationDataHolder.class)); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java index 805eefb9c..702476317 100644 --- a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java @@ -252,16 +252,15 @@ public class NetworkListStoreDataTest extends WifiBaseTest { private NetworkListSharedStoreData mNetworkListSharedStoreData; @Mock private Context mContext; @Mock private PackageManager mPackageManager; - @Mock WifiOemConfigStoreMigrationDataHolder mWifiOemConfigStoreMigrationDataHolder; + @Mock WifiConfigStoreMigrationDataHolder mWifiConfigStoreMigrationDataHolder; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(mContext.getPackageManager()).thenReturn(mPackageManager); when(mPackageManager.getNameForUid(anyInt())).thenReturn(TEST_CREATOR_NAME); - when(mWifiOemConfigStoreMigrationDataHolder.getUserSavedNetworks()).thenReturn(null); - mNetworkListSharedStoreData = - new NetworkListSharedStoreData(mContext, mWifiOemConfigStoreMigrationDataHolder); + when(mWifiConfigStoreMigrationDataHolder.getUserSavedNetworks()).thenReturn(null); + mNetworkListSharedStoreData = new NetworkListSharedStoreData(mContext); } /** @@ -292,7 +291,8 @@ public class NetworkListStoreDataTest extends WifiBaseTest { in.setInput(inputStream, StandardCharsets.UTF_8.name()); mNetworkListSharedStoreData.deserializeData(in, in.getDepth(), WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, - mock(WifiConfigStoreEncryptionUtil.class)); + mock(WifiConfigStoreEncryptionUtil.class), + mWifiConfigStoreMigrationDataHolder); return mNetworkListSharedStoreData.getConfigurations(); } @@ -397,8 +397,7 @@ public class NetworkListStoreDataTest extends WifiBaseTest { assertEquals(WifiConfigStore.STORE_FILE_SHARED_GENERAL, mNetworkListSharedStoreData.getStoreFileId()); assertEquals(WifiConfigStore.STORE_FILE_USER_GENERAL, - new NetworkListUserStoreData(mContext, mWifiOemConfigStoreMigrationDataHolder) - .getStoreFileId()); + new NetworkListUserStoreData(mContext).getStoreFileId()); } /** @@ -693,7 +692,7 @@ public class NetworkListStoreDataTest extends WifiBaseTest { @Test public void deserializeSharedConfigurationsFromOemConfigStoreMigration() throws Exception { List<WifiConfiguration> oemUserSavedNetworks = getTestNetworksConfig(true /* shared */); - when(mWifiOemConfigStoreMigrationDataHolder.getUserSavedNetworks()) + when(mWifiConfigStoreMigrationDataHolder.getUserSavedNetworks()) .thenReturn(oemUserSavedNetworks); // File contents are ignored. diff --git a/tests/wifitests/src/com/android/server/wifi/NetworkRequestStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/NetworkRequestStoreDataTest.java index 7f7c770f2..1b5373e01 100644 --- a/tests/wifitests/src/com/android/server/wifi/NetworkRequestStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/NetworkRequestStoreDataTest.java @@ -95,7 +95,8 @@ public class NetworkRequestStoreDataTest extends WifiBaseTest { in.setInput(inputStream, StandardCharsets.UTF_8.name()); mNetworkRequestStoreData.deserializeData(in, in.getDepth(), WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, - mock(WifiConfigStoreEncryptionUtil.class)); + mock(WifiConfigStoreEncryptionUtil.class), + mock(WifiConfigStoreMigrationDataHolder.class)); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java index 6567362e2..86d594045 100644 --- a/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java @@ -259,7 +259,8 @@ public class NetworkSuggestionStoreDataTest extends WifiBaseTest { final ByteArrayInputStream inputStream = new ByteArrayInputStream(data); in.setInput(inputStream, StandardCharsets.UTF_8.name()); mNetworkSuggestionStoreData.deserializeData(in, in.getDepth(), - WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, null); + WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, null, + mock(WifiConfigStoreMigrationDataHolder.class)); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/RandomizedMacStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/RandomizedMacStoreDataTest.java index ad27814a0..948d2ae92 100644 --- a/tests/wifitests/src/com/android/server/wifi/RandomizedMacStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/RandomizedMacStoreDataTest.java @@ -81,7 +81,8 @@ public class RandomizedMacStoreDataTest extends WifiBaseTest { in.setInput(inputStream, StandardCharsets.UTF_8.name()); mRandomizedMacStoreData.deserializeData(in, in.getDepth(), WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, - mock(WifiConfigStoreEncryptionUtil.class)); + mock(WifiConfigStoreEncryptionUtil.class), + mock(WifiConfigStoreMigrationDataHolder.class)); return mRandomizedMacStoreData.getMacMapping(); } diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApBackupRestoreTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApBackupRestoreTest.java index c7565c6ca..3b3c0671a 100644 --- a/tests/wifitests/src/com/android/server/wifi/SoftApBackupRestoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SoftApBackupRestoreTest.java @@ -25,7 +25,7 @@ import android.content.Context; import android.net.MacAddress; import android.net.wifi.SoftApConfiguration; import android.net.wifi.WifiConfiguration; -import android.net.wifi.WifiOemMigrationHook; +import android.net.wifi.WifiMigration; import android.util.BackupUtils; import androidx.test.filters.SmallTest; @@ -55,7 +55,7 @@ import java.util.List; public class SoftApBackupRestoreTest extends WifiBaseTest { @Mock private Context mContext; - @Mock private WifiOemMigrationHook.SettingsMigrationData mOemMigrationData; + @Mock private WifiMigration.SettingsMigrationData mOemMigrationData; private SoftApBackupRestore mSoftApBackupRestore; private final ArrayList<MacAddress> mTestBlockedList = new ArrayList<>(); private final ArrayList<MacAddress> mTestAllowedList = new ArrayList<>(); @@ -101,10 +101,10 @@ public class SoftApBackupRestoreTest extends WifiBaseTest { MockitoAnnotations.initMocks(this); mSession = ExtendedMockito.mockitoSession() - .mockStatic(WifiOemMigrationHook.class, withSettings().lenient()) + .mockStatic(WifiMigration.class, withSettings().lenient()) .strictness(Strictness.LENIENT) .startMocking(); - when(WifiOemMigrationHook.loadFromSettings(any(Context.class))) + when(WifiMigration.loadFromSettings(any(Context.class))) .thenReturn(mOemMigrationData); when(mOemMigrationData.isSoftApTimeoutEnabled()).thenReturn(true); @@ -263,7 +263,7 @@ public class SoftApBackupRestoreTest extends WifiBaseTest { /** * Verifies that the restore of version 5 backup data will read the auto shutdown enable/disable - * tag from {@link WifiOemMigrationHook#loadFromSettings(Context)} + * tag from {@link WifiMigration#loadFromSettings(Context)} */ @Test public void testSoftApConfigRestoreFromVersion5() throws Exception { diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java index f3317fdd6..9726882ee 100644 --- a/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java @@ -32,7 +32,7 @@ import android.content.Context; import android.net.MacAddress; import android.net.wifi.SoftApConfiguration; import android.net.wifi.WifiConfiguration; -import android.net.wifi.WifiOemMigrationHook; +import android.net.wifi.WifiMigration; import android.util.Xml; import androidx.test.filters.SmallTest; @@ -140,8 +140,8 @@ public class SoftApStoreDataTest extends WifiBaseTest { @Mock private Context mContext; @Mock SoftApStoreData.DataSource mDataSource; - @Mock WifiOemConfigStoreMigrationDataHolder mWifiOemConfigStoreMigrationDataHolder; - @Mock private WifiOemMigrationHook.SettingsMigrationData mOemMigrationData; + @Mock WifiConfigStoreMigrationDataHolder mWifiConfigStoreMigrationDataHolder; + @Mock private WifiMigration.SettingsMigrationData mOemMigrationData; MockitoSession mSession; SoftApStoreData mSoftApStoreData; @@ -149,15 +149,14 @@ public class SoftApStoreDataTest extends WifiBaseTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mSession = ExtendedMockito.mockitoSession() - .mockStatic(WifiOemMigrationHook.class, withSettings().lenient()) + .mockStatic(WifiMigration.class, withSettings().lenient()) .strictness(Strictness.LENIENT) .startMocking(); - when(WifiOemMigrationHook.loadFromSettings(any(Context.class))) + when(WifiMigration.loadFromSettings(any(Context.class))) .thenReturn(mOemMigrationData); when(mOemMigrationData.isSoftApTimeoutEnabled()).thenReturn(true); - mSoftApStoreData = - new SoftApStoreData(mContext, mDataSource, mWifiOemConfigStoreMigrationDataHolder); + mSoftApStoreData = new SoftApStoreData(mContext, mDataSource); TEST_BLOCKEDLIST.add(MacAddress.fromString(TEST_BLOCKED_CLIENT)); TEST_ALLOWEDLIST.add(MacAddress.fromString(TEST_ALLOWED_CLIENT)); } @@ -214,7 +213,8 @@ public class SoftApStoreDataTest extends WifiBaseTest { in.setInput(inputStream, StandardCharsets.UTF_8.name()); mSoftApStoreData.deserializeData(in, in.getDepth(), WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, - mock(WifiConfigStoreEncryptionUtil.class)); + mock(WifiConfigStoreEncryptionUtil.class), + mWifiConfigStoreMigrationDataHolder); } /** @@ -443,7 +443,7 @@ public class SoftApStoreDataTest extends WifiBaseTest { @Test public void deserializeSoftApFromOemConfigStoreMigration() throws Exception { SoftApConfiguration oemSoftApConfig = createDefaultTestSoftApConfiguration(); - when(mWifiOemConfigStoreMigrationDataHolder.getUserSoftApConfiguration()) + when(mWifiConfigStoreMigrationDataHolder.getUserSoftApConfiguration()) .thenReturn(oemSoftApConfig); // File contents are ignored. @@ -469,7 +469,7 @@ public class SoftApStoreDataTest extends WifiBaseTest { /** * Verify that the store data is deserialized correctly using the predefined test XML data * when the auto shutdown tag is retrieved from - * {@link WifiOemMigrationHook.loadFromSettings(Context)}. + * {@link WifiMigration.loadFromSettings(Context)}. * * @throws Exception */ diff --git a/tests/wifitests/src/com/android/server/wifi/SsidSetStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/SsidSetStoreDataTest.java index b3b8439f4..66afa8271 100644 --- a/tests/wifitests/src/com/android/server/wifi/SsidSetStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SsidSetStoreDataTest.java @@ -99,7 +99,8 @@ public class SsidSetStoreDataTest extends WifiBaseTest { in.setInput(inputStream, StandardCharsets.UTF_8.name()); mSsidSetStoreData.deserializeData(in, in.getDepth(), WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, - mock(WifiConfigStoreEncryptionUtil.class)); + mock(WifiConfigStoreEncryptionUtil.class), + mock(WifiConfigStoreMigrationDataHolder.class)); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WakeupConfigStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/WakeupConfigStoreDataTest.java index cc7587a36..baf43f5a7 100644 --- a/tests/wifitests/src/com/android/server/wifi/WakeupConfigStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WakeupConfigStoreDataTest.java @@ -92,7 +92,8 @@ public class WakeupConfigStoreDataTest extends WifiBaseTest { in.setInput(inputStream, StandardCharsets.UTF_8.name()); mWakeupConfigData.deserializeData(in, in.getDepth(), WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, - mock(WifiConfigStoreEncryptionUtil.class)); + mock(WifiConfigStoreEncryptionUtil.class), + mock(WifiConfigStoreMigrationDataHolder.class)); } /** @@ -183,7 +184,8 @@ public class WakeupConfigStoreDataTest extends WifiBaseTest { public void hasBeenReadIsTrueWhenUserStoreIsLoaded() throws Exception { mWakeupConfigData.deserializeData(null /* in */, 0 /* outerTagDepth */, WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, - mock(WifiConfigStoreEncryptionUtil.class)); + mock(WifiConfigStoreEncryptionUtil.class), + mock(WifiConfigStoreMigrationDataHolder.class)); assertTrue(mWakeupConfigData.hasBeenRead()); } diff --git a/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java b/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java index 6ca9c30af..cdacea91e 100644 --- a/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java @@ -154,7 +154,8 @@ public class WakeupControllerTest extends WifiBaseTest { try { mWakeupConfigStoreData.deserializeData(null, 0, WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, - mock(WifiConfigStoreEncryptionUtil.class)); + mock(WifiConfigStoreEncryptionUtil.class), + mock(WifiConfigStoreMigrationDataHolder.class)); } catch (XmlPullParserException | IOException e) { // unreachable } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java index 44f2b1ad0..8b783cbc3 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java @@ -157,7 +157,7 @@ public class WifiConfigStoreTest extends WifiBaseTest { @Mock private Clock mClock; @Mock private WifiMetrics mWifiMetrics; @Mock private WifiConfigStoreEncryptionUtil mEncryptionUtil; - @Mock WifiOemConfigStoreMigrationDataHolder mWifiOemConfigStoreMigrationDataHolder; + @Mock WifiConfigStoreMigrationDataHolder mWifiConfigStoreMigrationDataHolder; private MockStoreFile mSharedStore; private MockStoreFile mUserStore; private MockStoreFile mUserNetworkSuggestionsStore; @@ -185,7 +185,7 @@ public class WifiConfigStoreTest extends WifiBaseTest { .thenReturn(new EncryptedData(new byte[0], new byte[0])); when(mEncryptionUtil.decrypt(any(EncryptedData.class))) .thenReturn(new byte[0]); - when(mWifiOemConfigStoreMigrationDataHolder.getUserSavedNetworks()).thenReturn(null); + when(mWifiConfigStoreMigrationDataHolder.getUserSavedNetworks()).thenReturn(null); mSharedStore = new MockStoreFile(WifiConfigStore.STORE_FILE_SHARED_GENERAL); mUserStore = new MockStoreFile(WifiConfigStore.STORE_FILE_USER_GENERAL); mUserNetworkSuggestionsStore = @@ -205,7 +205,7 @@ public class WifiConfigStoreTest extends WifiBaseTest { setupMocks(); mWifiConfigStore = new WifiConfigStore(mContext, new Handler(mLooper.getLooper()), mClock, - mWifiMetrics, Arrays.asList(mSharedStore)); + mWifiMetrics, mWifiConfigStoreMigrationDataHolder, Arrays.asList(mSharedStore)); // Enable verbose logging before tests. mWifiConfigStore.enableVerboseLogging(true); } @@ -323,6 +323,7 @@ public class WifiConfigStoreTest extends WifiBaseTest { mWifiConfigStore.read(); assertEquals(TEST_USER_DATA, mUserStoreData.getData()); assertEquals(TEST_SHARE_DATA, mSharedStoreData.getData()); + verify(mWifiConfigStoreMigrationDataHolder).removeStoreIfPresent(); } /** @@ -360,6 +361,7 @@ public class WifiConfigStoreTest extends WifiBaseTest { mWifiConfigStore.read(); assertEquals("abcds", mSharedStoreData.getData()); assertEquals("asdfa", mUserStoreData.getData()); + verify(mWifiConfigStoreMigrationDataHolder).removeStoreIfPresent(); } @@ -389,6 +391,7 @@ public class WifiConfigStoreTest extends WifiBaseTest { mWifiConfigStore.read(); assertEquals(TEST_USER_DATA, mUserStoreData.getData()); assertEquals(TEST_SHARE_DATA, mSharedStoreData.getData()); + verify(mWifiConfigStoreMigrationDataHolder).removeStoreIfPresent(); verify(mWifiMetrics, times(2)).noteWifiConfigStoreReadDuration(anyInt()); verify(mWifiMetrics).noteWifiConfigStoreWriteDuration(anyInt()); @@ -417,9 +420,9 @@ public class WifiConfigStoreTest extends WifiBaseTest { // Ensure that we got the call to deserialize empty shared data, but no user data. verify(sharedStoreData).resetData(); - verify(sharedStoreData).deserializeData(eq(null), anyInt(), anyInt(), any()); + verify(sharedStoreData).deserializeData(eq(null), anyInt(), anyInt(), any(), any()); verify(userStoreData, never()).resetData(); - verify(userStoreData, never()).deserializeData(any(), anyInt(), anyInt(), any()); + verify(userStoreData, never()).deserializeData(any(), anyInt(), anyInt(), any(), any()); } /** @@ -446,9 +449,9 @@ public class WifiConfigStoreTest extends WifiBaseTest { // Ensure that we got the call to deserialize empty shared & user data. verify(userStoreData).resetData(); - verify(userStoreData).deserializeData(eq(null), anyInt(), anyInt(), any()); + verify(userStoreData).deserializeData(eq(null), anyInt(), anyInt(), any(), any()); verify(sharedStoreData).resetData(); - verify(sharedStoreData).deserializeData(eq(null), anyInt(), anyInt(), any()); + verify(sharedStoreData).deserializeData(eq(null), anyInt(), anyInt(), any(), any()); } /** @@ -506,8 +509,7 @@ public class WifiConfigStoreTest extends WifiBaseTest { @Test public void testReadWifiConfigStoreData() throws Exception { // Setup network list. - NetworkListStoreData networkList = - new NetworkListUserStoreData(mContext, mWifiOemConfigStoreMigrationDataHolder); + NetworkListStoreData networkList = new NetworkListUserStoreData(mContext); mWifiConfigStore.registerStoreData(networkList); WifiConfiguration openNetwork = WifiConfigurationTestUtil.createOpenNetwork(); openNetwork.creatorName = TEST_CREATOR_NAME; @@ -543,8 +545,7 @@ public class WifiConfigStoreTest extends WifiBaseTest { mWifiConfigStore.switchUserStoresAndRead(mUserStores); // Setup network list store data. - NetworkListStoreData networkList = - new NetworkListUserStoreData(mContext, mWifiOemConfigStoreMigrationDataHolder); + NetworkListStoreData networkList = new NetworkListUserStoreData(mContext); mWifiConfigStore.registerStoreData(networkList); WifiConfiguration openNetwork = WifiConfigurationTestUtil.createOpenNetwork(); openNetwork.creatorName = TEST_CREATOR_NAME; @@ -607,9 +608,9 @@ public class WifiConfigStoreTest extends WifiBaseTest { mUserStore.storeRawDataToWrite(null); mWifiConfigStore.read(); - verify(storeData1).deserializeData(notNull(), anyInt(), anyInt(), any()); - verify(storeData1, never()).deserializeData(eq(null), anyInt(), anyInt(), any()); - verify(storeData2).deserializeData(eq(null), anyInt(), anyInt(), any()); + verify(storeData1).deserializeData(notNull(), anyInt(), anyInt(), any(), any()); + verify(storeData1, never()).deserializeData(eq(null), anyInt(), anyInt(), any(), any()); + verify(storeData2).deserializeData(eq(null), anyInt(), anyInt(), any(), any()); reset(storeData1, storeData2); // Scenario 2: StoreData2 in user store file. @@ -623,9 +624,9 @@ public class WifiConfigStoreTest extends WifiBaseTest { mUserStore.storeRawDataToWrite(fileContentsXmlStringWithOnlyStoreData2.getBytes()); mWifiConfigStore.read(); - verify(storeData1).deserializeData(eq(null), anyInt(), anyInt(), any()); - verify(storeData2).deserializeData(notNull(), anyInt(), anyInt(), any()); - verify(storeData2, never()).deserializeData(eq(null), anyInt(), anyInt(), any()); + verify(storeData1).deserializeData(eq(null), anyInt(), anyInt(), any(), any()); + verify(storeData2).deserializeData(notNull(), anyInt(), anyInt(), any(), any()); + verify(storeData2, never()).deserializeData(eq(null), anyInt(), anyInt(), any(), any()); reset(storeData1, storeData2); // Scenario 3: StoreData1 in shared store file & StoreData2 in user store file. @@ -639,10 +640,10 @@ public class WifiConfigStoreTest extends WifiBaseTest { mUserStore.storeRawDataToWrite(fileContentsXmlStringWithOnlyStoreData2.getBytes()); mWifiConfigStore.read(); - verify(storeData1).deserializeData(notNull(), anyInt(), anyInt(), any()); - verify(storeData1, never()).deserializeData(eq(null), anyInt(), anyInt(), any()); - verify(storeData2).deserializeData(notNull(), anyInt(), anyInt(), any()); - verify(storeData2, never()).deserializeData(eq(null), anyInt(), anyInt(), any()); + verify(storeData1).deserializeData(notNull(), anyInt(), anyInt(), any(), any()); + verify(storeData1, never()).deserializeData(eq(null), anyInt(), anyInt(), any(), any()); + verify(storeData2).deserializeData(notNull(), anyInt(), anyInt(), any(), any()); + verify(storeData2, never()).deserializeData(eq(null), anyInt(), anyInt(), any(), any()); reset(storeData1, storeData2); // Scenario 4: StoreData1 & StoreData2 in shared store file. @@ -657,10 +658,10 @@ public class WifiConfigStoreTest extends WifiBaseTest { mUserStore.storeRawDataToWrite(null); mWifiConfigStore.read(); - verify(storeData1).deserializeData(notNull(), anyInt(), anyInt(), any()); - verify(storeData1, never()).deserializeData(eq(null), anyInt(), anyInt(), any()); - verify(storeData2).deserializeData(notNull(), anyInt(), anyInt(), any()); - verify(storeData2, never()).deserializeData(eq(null), anyInt(), anyInt(), any()); + verify(storeData1).deserializeData(notNull(), anyInt(), anyInt(), any(), any()); + verify(storeData1, never()).deserializeData(eq(null), anyInt(), anyInt(), any(), any()); + verify(storeData2).deserializeData(notNull(), anyInt(), anyInt(), any(), any()); + verify(storeData2, never()).deserializeData(eq(null), anyInt(), anyInt(), any(), any()); reset(storeData1, storeData2); } @@ -779,10 +780,10 @@ public class WifiConfigStoreTest extends WifiBaseTest { mWifiConfigStore.read(); verify(sharedStoreData, times(1)).deserializeData( any(XmlPullParser.class), anyInt(), - eq(WifiConfigStore.INITIAL_CONFIG_STORE_DATA_VERSION), any()); + eq(WifiConfigStore.INITIAL_CONFIG_STORE_DATA_VERSION), any(), any()); verify(userStoreData, times(1)).deserializeData( any(XmlPullParser.class), anyInt(), - eq(WifiConfigStore.INITIAL_CONFIG_STORE_DATA_VERSION), any()); + eq(WifiConfigStore.INITIAL_CONFIG_STORE_DATA_VERSION), any(), any()); } /** @@ -830,10 +831,10 @@ public class WifiConfigStoreTest extends WifiBaseTest { mWifiConfigStore.read(); verify(sharedStoreData, times(1)) .deserializeData(any(XmlPullParser.class), anyInt(), - eq(WifiConfigStore.INTEGRITY_CONFIG_STORE_DATA_VERSION), any()); + eq(WifiConfigStore.INTEGRITY_CONFIG_STORE_DATA_VERSION), any(), any()); verify(userStoreData, times(1)) .deserializeData(any(XmlPullParser.class), anyInt(), - eq(WifiConfigStore.INTEGRITY_CONFIG_STORE_DATA_VERSION), any()); + eq(WifiConfigStore.INTEGRITY_CONFIG_STORE_DATA_VERSION), any(), any()); } /** @@ -898,7 +899,8 @@ public class WifiConfigStoreTest extends WifiBaseTest { @Override public void deserializeData(XmlPullParser in, int outerTagDepth, int version, - WifiConfigStoreEncryptionUtil encryptionUtil) + WifiConfigStoreEncryptionUtil encryptionUtil, + WifiConfigStoreMigrationDataHolder storeMigrationDataHolder) throws XmlPullParserException, IOException { if (in == null) { return; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java index 2fa4b0ea9..52c43ce7a 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java @@ -2971,6 +2971,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest { in.setInput(inputStream, StandardCharsets.UTF_8.name()); mNetworkRequestStoreData.deserializeData(in, in.getDepth(), WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, - mock(WifiConfigStoreEncryptionUtil.class)); + mock(WifiConfigStoreEncryptionUtil.class), + mock(WifiConfigStoreMigrationDataHolder.class)); } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiSettingsConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiSettingsConfigStoreTest.java index 22cb7f435..3537ae760 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiSettingsConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiSettingsConfigStoreTest.java @@ -116,7 +116,8 @@ public class WifiSettingsConfigStoreTest extends WifiBaseTest { XmlPullParser in = createSettingsTestXmlForParsing(WIFI_VERBOSE_LOGGING_ENABLED, true); storeDataCaptor.getValue().resetData(); - storeDataCaptor.getValue().deserializeData(in, in.getDepth(), -1, null); + storeDataCaptor.getValue().deserializeData(in, in.getDepth(), -1, null, + mock(WifiConfigStoreMigrationDataHolder.class)); assertTrue(mWifiSettingsConfigStore.getBoolean(WIFI_VERBOSE_LOGGING_ENABLED, false)); } diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigSharedStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigSharedStoreDataTest.java index 3ee3c15f6..64b2460a2 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigSharedStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigSharedStoreDataTest.java @@ -26,6 +26,7 @@ import androidx.test.filters.SmallTest; import com.android.internal.util.FastXmlSerializer; import com.android.server.wifi.WifiBaseTest; import com.android.server.wifi.WifiConfigStore; +import com.android.server.wifi.WifiConfigStoreMigrationDataHolder; import com.android.server.wifi.util.WifiConfigStoreEncryptionUtil; import org.junit.Before; @@ -81,7 +82,8 @@ public class PasspointConfigSharedStoreDataTest extends WifiBaseTest { in.setInput(inputStream, StandardCharsets.UTF_8.name()); mConfigStoreData.deserializeData(in, in.getDepth(), WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, - mock(WifiConfigStoreEncryptionUtil.class)); + mock(WifiConfigStoreEncryptionUtil.class), + mock(WifiConfigStoreMigrationDataHolder.class)); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigUserStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigUserStoreDataTest.java index cfa6044f6..0c00875b0 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigUserStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigUserStoreDataTest.java @@ -37,6 +37,7 @@ import androidx.test.filters.SmallTest; import com.android.internal.util.FastXmlSerializer; import com.android.server.wifi.WifiBaseTest; import com.android.server.wifi.WifiConfigStore; +import com.android.server.wifi.WifiConfigStoreMigrationDataHolder; import com.android.server.wifi.WifiKeyStore; import com.android.server.wifi.util.TelephonyUtil; import com.android.server.wifi.util.WifiConfigStoreEncryptionUtil; @@ -237,7 +238,8 @@ public class PasspointConfigUserStoreDataTest extends WifiBaseTest { in.setInput(inputStream, StandardCharsets.UTF_8.name()); mConfigStoreData.deserializeData(in, in.getDepth(), WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION, - mock(WifiConfigStoreEncryptionUtil.class)); + mock(WifiConfigStoreEncryptionUtil.class), + mock(WifiConfigStoreMigrationDataHolder.class)); } /** |