summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaichi Ueura <daichi.ueura@sony.com>2018-09-20 17:49:59 +0900
committerDaichi Ueura <daichi.ueura@sony.com>2018-09-20 17:50:24 +0900
commitd2f873f0b74aef8da222c59e2081beaf2bbaf110 (patch)
treee30a13511a080df04b7b7d2143f2d9d0b109dfbb
parent8c414b5cc1f930424497bc26e51837070f5af9a8 (diff)
downloadwifi-d2f873f0b74aef8da222c59e2081beaf2bbaf110.tar.gz
Resetting SIM identity after store is read
Sometimes CMD_RESET_SIM_NETWORKS is received before CMD_BOOT_COMPLETED. And then identity is not reset because stored data is not loaded yet in this timing. Hence, framework requests connection with old identity. This patch calls the method resetSimNetworksresets after store is read to make sure identity is updated regardless of the order of events. Bug: 113547031 Test: Manual Test: run unit tests Change-Id: I601bc725ab102867dbb5441617d3f4d76321a95f
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java43
2 files changed, 45 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index bbffdc827..c8c4844cc 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -2733,6 +2733,8 @@ public class WifiConfigManager {
if (mConfiguredNetworks.sizeForAllUsers() == 0) {
Log.w(TAG, "No stored networks found.");
}
+ // resetSimNetworks may already have been called. Call it again to reset loaded SIM configs.
+ resetSimNetworks(mSimPresent);
sendConfiguredNetworksChangedBroadcast();
mPendingStoreRead = false;
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 4a7ad50d6..76068491d 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -3647,6 +3647,49 @@ public class WifiConfigManagerTest {
assertFalse(mWifiConfigManager.isSimPresent());
}
+ /**
+ * Verifies that SIM config is reset if store is read after the method resetSimNetworks
+ * is called.
+ */
+ @Test
+ public void testResetSimNetworksIsCalledAgainAfterLoadFromStore() {
+ String expectedIdentity = "13214561234567890@wlan.mnc456.mcc321.3gppnetwork.org";
+ when(mTelephonyManager.getSubscriberId()).thenReturn("3214561234567890");
+ when(mTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY);
+ when(mTelephonyManager.getSimOperator()).thenReturn("321456");
+ when(mTelephonyManager.getCarrierInfoForImsiEncryption(anyInt())).thenReturn(null);
+
+ WifiConfiguration simNetwork = WifiConfigurationTestUtil.createEapNetwork(
+ WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
+ simNetwork.enterpriseConfig.setIdentity("identity");
+ simNetwork.enterpriseConfig.setAnonymousIdentity("anonymous_identity");
+
+ // Set up the store data.
+ List<WifiConfiguration> sharedNetworks = new ArrayList<WifiConfiguration>() {
+ {
+ add(simNetwork);
+ }
+ };
+ setupStoreDataForRead(sharedNetworks, new ArrayList<WifiConfiguration>(),
+ new HashSet<String>());
+
+ // 1. Call resetSimNetworks with true(SIM is present).
+ mWifiConfigManager.resetSimNetworks(true);
+
+ // Verify SIM is present.
+ assertTrue(mWifiConfigManager.isSimPresent());
+
+ // 2. Read from store now.
+ assertTrue(mWifiConfigManager.loadFromStore());
+
+ // Verify SIM is present just in case and SIM config is reset.
+ assertTrue(mWifiConfigManager.isSimPresent());
+ WifiConfiguration retrievedSimNetwork =
+ mWifiConfigManager.getConfiguredNetwork(simNetwork.networkId);
+ assertEquals(expectedIdentity, retrievedSimNetwork.enterpriseConfig.getIdentity());
+ assertTrue(retrievedSimNetwork.enterpriseConfig.getAnonymousIdentity().isEmpty());
+ }
+
private NetworkUpdateResult verifyAddOrUpdateNetworkWithProxySettingsAndPermissions(
boolean withNetworkSettings,
boolean withProfileOwnerPolicy,