diff options
author | Roshan Pius <rpius@google.com> | 2018-04-03 11:01:29 -0700 |
---|---|---|
committer | Sat K <satk@google.com> | 2018-04-06 19:22:31 +0000 |
commit | f210755c2ac34dc466bcab188b9716b2482bbfe1 (patch) | |
tree | 5c75c9902c0eb6a636c878cec4f1ba28f17b07fd /service | |
parent | dafc81f174519aa709e2ba4127360408d1644905 (diff) |
WifiConfigStorLegacy: Add null check during restore
One of our OEM's is running into a crash in the config store migration
logic added in O. See the below bug for more details. This issue is not
seen on Pixel devices, because the |configKey| can never be null there.
Also, added a wrapper for IpConfigStore to help in mocking static
method in IpConfigstore.
Note: This code is pretty much unused on Pixel devices & other OEM's
who have upgraded from N to O. Only will help OEM's who upgrade from N
to P directly.
Bug: 73877225
Test: Unit tests
Change-Id: I1b24c05bbb2bc488d77f3f93ec550517c1d1e5c3
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigStoreLegacy.java | 23 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiInjector.java | 2 |
2 files changed, 19 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java b/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java index 184ee2f67..ef6d82f31 100644 --- a/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java +++ b/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java @@ -81,16 +81,28 @@ public class WifiConfigStoreLegacy { */ private final WifiNetworkHistory mWifiNetworkHistory; private final WifiNative mWifiNative; - private final IpConfigStore mIpconfigStore; + private final IpConfigStoreWrapper mIpconfigStoreWrapper; private final LegacyPasspointConfigParser mPasspointConfigParser; + /** + * Used to help mocking the static methods of IpconfigStore. + */ + public static class IpConfigStoreWrapper { + /** + * Read IP configurations from Ip config store. + */ + public SparseArray<IpConfiguration> readIpAndProxyConfigurations(String filePath) { + return IpConfigStore.readIpAndProxyConfigurations(filePath); + } + } + WifiConfigStoreLegacy(WifiNetworkHistory wifiNetworkHistory, - WifiNative wifiNative, IpConfigStore ipConfigStore, + WifiNative wifiNative, IpConfigStoreWrapper ipConfigStore, LegacyPasspointConfigParser passpointConfigParser) { mWifiNetworkHistory = wifiNetworkHistory; mWifiNative = wifiNative; - mIpconfigStore = ipConfigStore; + mIpconfigStoreWrapper = ipConfigStore; mPasspointConfigParser = passpointConfigParser; } @@ -105,7 +117,7 @@ public class WifiConfigStoreLegacy { private static WifiConfiguration lookupWifiConfigurationUsingConfigKeyHash( Map<String, WifiConfiguration> configurationMap, int hashCode) { for (Map.Entry<String, WifiConfiguration> entry : configurationMap.entrySet()) { - if (entry.getKey().hashCode() == hashCode) { + if (entry.getKey() != null && entry.getKey().hashCode() == hashCode) { return entry.getValue(); } } @@ -122,7 +134,8 @@ public class WifiConfigStoreLegacy { // This is a map of the hash code of the network's configKey to the corresponding // IpConfiguration. SparseArray<IpConfiguration> ipConfigurations = - mIpconfigStore.readIpAndProxyConfigurations(IP_CONFIG_FILE.getAbsolutePath()); + mIpconfigStoreWrapper.readIpAndProxyConfigurations( + IP_CONFIG_FILE.getAbsolutePath()); if (ipConfigurations == null || ipConfigurations.size() == 0) { Log.w(TAG, "No ip configurations found in ipconfig store"); return; diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index 32bf1aed3..a1ecca2c7 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -214,7 +214,7 @@ public class WifiInjector { mWifiNetworkHistory = new WifiNetworkHistory(mContext, writer); mIpConfigStore = new IpConfigStore(writer); mWifiConfigStoreLegacy = new WifiConfigStoreLegacy( - mWifiNetworkHistory, mWifiNative, mIpConfigStore, + mWifiNetworkHistory, mWifiNative, new WifiConfigStoreLegacy.IpConfigStoreWrapper(), new LegacyPasspointConfigParser()); // Config Manager mWifiConfigManager = new WifiConfigManager(mContext, mClock, |