summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHai Shalom <haishalom@google.com>2020-02-18 14:01:31 -0800
committerHai Shalom <haishalom@google.com>2020-02-19 12:16:24 -0800
commit3ec3e900e8f0eaf7c816672dac9e59c14b208cd1 (patch)
treedf5af3d6d5a208b6e4d4aee95cf7518862602247
parentbeb9fe4d1848ada5fe2de19b99af747404cc800a (diff)
[Passpoint] Fix provider removal for factory reset and multiple providers with same FQDN
Fix Passpoint provider removal for factory reset and multiple providers with same FQDN. Bug: 149776782 Test: atest PasspointManagerTest WifiServiceImplTest Test: Manually run Wi-Fi factory reset from Settings Change-Id: I4518bf2c9f7af6790a223d06126e1ed7d9063096
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java19
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointManager.java22
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java133
4 files changed, 127 insertions, 51 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 9f3532312..c7313da4b 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -2709,16 +2709,29 @@ public class WifiServiceImpl extends BaseWifiService {
*/
@Override
public boolean removePasspointConfiguration(String fqdn, String packageName) {
+ return removePasspointConfigurationInternal(fqdn, null);
+ }
+
+ /**
+ * Remove a Passpoint profile based on either FQDN (multiple matching profiles) or a unique
+ * identifier (one matching profile).
+ *
+ * @param fqdn The FQDN of the Passpoint configuration to be removed
+ * @param uniqueId The unique identifier of the Passpoint configuration to be removed
+ * @return true on success or false on failure
+ */
+ private boolean removePasspointConfigurationInternal(String fqdn, String uniqueId) {
final int uid = Binder.getCallingUid();
boolean privileged = false;
if (mWifiPermissionsUtil.checkNetworkSettingsPermission(uid)
|| mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(uid)) {
privileged = true;
}
- mLog.info("removePasspointConfiguration uid=%").c(Binder.getCallingUid()).flush();
+ mLog.info("removePasspointConfigurationInternal uid=%").c(Binder.getCallingUid()).flush();
final boolean privilegedFinal = privileged;
return mWifiThreadRunner.call(
- () -> mPasspointManager.removeProvider(uid, privilegedFinal, null, fqdn), false);
+ () -> mPasspointManager.removeProvider(uid, privilegedFinal, uniqueId, fqdn),
+ false);
}
/**
@@ -3335,7 +3348,7 @@ public class WifiServiceImpl extends BaseWifiService {
() -> mPasspointManager.getProviderConfigs(Process.WIFI_UID /* ignored */, true),
Collections.emptyList());
for (PasspointConfiguration config : configs) {
- removePasspointConfiguration(config.getUniqueId(), packageName);
+ removePasspointConfigurationInternal(null, config.getUniqueId());
}
mWifiThreadRunner.post(() -> {
mWifiConfigManager.clearDeletedEphemeralNetworks();
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
index 2a8a86eca..0c80a9721 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
@@ -486,14 +486,14 @@ public class PasspointManager {
public boolean removeProvider(int callingUid, boolean privileged, String uniqueId,
String fqdn) {
if (uniqueId == null && fqdn == null) {
+ mWifiMetrics.incrementNumPasspointProviderUninstallation();
Log.e(TAG, "Cannot remove provider, both FQDN and unique ID are null");
return false;
}
- mWifiMetrics.incrementNumPasspointProviderUninstallation();
-
if (uniqueId != null) {
// Unique identifier provided
+ mWifiMetrics.incrementNumPasspointProviderUninstallation();
PasspointProvider provider = mProviders.get(uniqueId);
if (provider == null) {
Log.e(TAG, "Config doesn't exist");
@@ -504,16 +504,26 @@ public class PasspointManager {
// FQDN provided, loop through all profiles with matching FQDN
ArrayList<PasspointProvider> passpointProviders = new ArrayList<>(mProviders.values());
- boolean removed = false;
-
+ int removedProviders = 0;
+ int numOfUninstallations = 0;
for (PasspointProvider provider : passpointProviders) {
if (!TextUtils.equals(provider.getConfig().getHomeSp().getFqdn(), fqdn)) {
continue;
}
- removed = removed || removeProviderInternal(provider, callingUid, privileged);
+ mWifiMetrics.incrementNumPasspointProviderUninstallation();
+ numOfUninstallations++;
+ if (removeProviderInternal(provider, callingUid, privileged)) {
+ removedProviders++;
+ }
+ }
+
+ if (numOfUninstallations == 0) {
+ // Update uninstallation requests metrics here to cover the corner case of trying to
+ // uninstall a non-existent provider.
+ mWifiMetrics.incrementNumPasspointProviderUninstallation();
}
- return removed;
+ return removedProviders > 0;
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index a289171b4..5cd51be30 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -4008,8 +4008,8 @@ public class WifiServiceImplTest extends WifiBaseTest {
verify(mWifiConfigManager).removeNetwork(
network.networkId, Binder.getCallingUid(), TEST_PACKAGE_NAME);
- verify(mPasspointManager).removeProvider(anyInt(), anyBoolean(), isNull(),
- eq(config.getUniqueId()));
+ verify(mPasspointManager).removeProvider(anyInt(), anyBoolean(), eq(config.getUniqueId()),
+ isNull());
verify(mWifiConfigManager).clearDeletedEphemeralNetworks();
verify(mClientModeImpl).clearNetworkRequestUserApprovedAccessPoints();
verify(mWifiNetworkSuggestionsManager).clear();
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
index ea1ef1782..98dbcb97a 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
@@ -141,6 +141,8 @@ public class PasspointManagerTest extends WifiBaseTest {
private static final String TEST_FRIENDLY_NAME = "friendly name";
private static final String TEST_FRIENDLY_NAME2 = "second friendly name";
private static final String TEST_REALM = "realm.test.com";
+ private static final String TEST_REALM2 = "realm.test2.com";
+ private static final String TEST_REALM3 = "realm.test3.com";
private static final String TEST_IMSI = "123456*";
private static final String FULL_IMSI = "123456789123456";
private static final int TEST_CARRIER_ID = 10;
@@ -316,6 +318,17 @@ public class PasspointManagerTest extends WifiBaseTest {
*/
private PasspointConfiguration createTestConfigWithUserCredential(String fqdn,
String friendlyName) {
+ return createTestConfigWithUserCredentialAndRealm(fqdn, friendlyName, TEST_REALM);
+ }
+
+ /**
+ * Helper function for creating a test configuration with user credential
+ * and a unique realm.
+ *
+ * @return {@link PasspointConfiguration}
+ */
+ private PasspointConfiguration createTestConfigWithUserCredentialAndRealm(String fqdn,
+ String friendlyName, String realm) {
PasspointConfiguration config = new PasspointConfiguration();
HomeSp homeSp = new HomeSp();
homeSp.setFqdn(fqdn);
@@ -327,7 +340,7 @@ public class PasspointManagerTest extends WifiBaseTest {
friendlyNames.put("jp", friendlyName + 2);
config.setServiceFriendlyNames(friendlyNames);
Credential credential = new Credential();
- credential.setRealm(TEST_REALM);
+ credential.setRealm(realm != null ? realm : TEST_REALM);
credential.setCaCertificate(FakeKeys.CA_CERT0);
Credential.UserCredential userCredential = new Credential.UserCredential();
userCredential.setUsername("username");
@@ -362,12 +375,12 @@ public class PasspointManagerTest extends WifiBaseTest {
}
private PasspointProvider addTestProvider(String fqdn, String friendlyName,
- String packageName, boolean isSuggestion) {
+ String packageName, boolean isSuggestion, String realm) {
WifiConfiguration wifiConfig = WifiConfigurationTestUtil.generateWifiConfig(-1, TEST_UID,
"\"PasspointTestSSID\"", true, true,
fqdn, friendlyName, SECURITY_EAP);
- return addTestProvider(fqdn, friendlyName, packageName, wifiConfig, isSuggestion);
+ return addTestProvider(fqdn, friendlyName, packageName, wifiConfig, isSuggestion, realm);
}
/**
@@ -377,8 +390,9 @@ public class PasspointManagerTest extends WifiBaseTest {
* @return {@link PasspointProvider}
*/
private PasspointProvider addTestProvider(String fqdn, String friendlyName,
- String packageName, WifiConfiguration wifiConfig, boolean isSuggestion) {
- PasspointConfiguration config = createTestConfigWithUserCredential(fqdn, friendlyName);
+ String packageName, WifiConfiguration wifiConfig, boolean isSuggestion, String realm) {
+ PasspointConfiguration config =
+ createTestConfigWithUserCredentialAndRealm(fqdn, friendlyName, realm);
wifiConfig.setPasspointUniqueId(config.getUniqueId());
PasspointProvider provider = createMockProvider(config, wifiConfig, isSuggestion);
when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
@@ -999,7 +1013,7 @@ public class PasspointManagerTest extends WifiBaseTest {
com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession().mockStatic(
InformationElementUtil.class).startMocking();
try {
- addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(null);
InformationElementUtil.Vsa vsa = new InformationElementUtil.Vsa();
@@ -1028,7 +1042,7 @@ public class PasspointManagerTest extends WifiBaseTest {
@Test
public void matchProviderAsHomeProvider() throws Exception {
PasspointProvider provider =
- addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
ANQPData entry = new ANQPData(mClock, null);
when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry);
@@ -1049,7 +1063,7 @@ public class PasspointManagerTest extends WifiBaseTest {
@Test
public void matchProviderAsRoamingProvider() throws Exception {
PasspointProvider provider =
- addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
ANQPData entry = new ANQPData(mClock, null);
when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry);
@@ -1070,9 +1084,9 @@ public class PasspointManagerTest extends WifiBaseTest {
public void matchScanResultWithMultipleProviderAsHomeAndRoaming() {
// Only add roaming providers.
PasspointProvider roamingProvider1 =
- addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
PasspointProvider roamingProvider2 =
- addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME2, TEST_PACKAGE1, false);
+ addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME2, TEST_PACKAGE1, false, null);
ANQPData entry = new ANQPData(mClock, null);
when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry);
when(roamingProvider1.match(anyMap(), any(RoamingConsortium.class)))
@@ -1088,9 +1102,9 @@ public class PasspointManagerTest extends WifiBaseTest {
}
// Add home providers.
PasspointProvider homeProvider1 =
- addTestProvider(TEST_FQDN + "home", TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
- PasspointProvider homeProvider2 =
- addTestProvider(TEST_FQDN2 + "home", TEST_FRIENDLY_NAME2, TEST_PACKAGE1, false);
+ addTestProvider(TEST_FQDN + "home", TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+ PasspointProvider homeProvider2 = addTestProvider(TEST_FQDN2 + "home", TEST_FRIENDLY_NAME2,
+ TEST_PACKAGE1, false, null);
when(homeProvider1.match(anyMap(), any(RoamingConsortium.class)))
.thenReturn(PasspointMatch.HomeProvider);
when(homeProvider2.match(anyMap(), any(RoamingConsortium.class)))
@@ -1111,7 +1125,7 @@ public class PasspointManagerTest extends WifiBaseTest {
@Test
public void matchProviderWithNoMatch() throws Exception {
PasspointProvider provider =
- addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
ANQPData entry = new ANQPData(mClock, null);
when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry);
@@ -1170,7 +1184,7 @@ public class PasspointManagerTest extends WifiBaseTest {
InformationElementUtil.class).startMocking();
try {
PasspointProvider provider = addTestProvider(TEST_FQDN + 0, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
when(provider.tryUpdateCarrierId()).thenReturn(true);
reset(mWifiConfigManager);
@@ -1204,15 +1218,15 @@ public class PasspointManagerTest extends WifiBaseTest {
InformationElementUtil.class).startMocking();
try {
PasspointProvider providerHome = addTestProvider(TEST_FQDN + 0, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
providerHome.getWifiConfig().isHomeProviderNetwork = true;
PasspointProvider providerRoaming = addTestProvider(TEST_FQDN + 1, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
WifiConfiguration wifiConfiguration = WifiConfigurationTestUtil.generateWifiConfig(-1,
TEST_UID, "\"PasspointTestSSID\"", true, true,
TEST_FQDN + 2, TEST_FRIENDLY_NAME, SECURITY_EAP);
PasspointProvider providerNone = addTestProvider(TEST_FQDN + 2, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, wifiConfiguration, false);
+ TEST_PACKAGE, wifiConfiguration, false, null);
ANQPData entry = new ANQPData(mClock, null);
InformationElementUtil.Vsa vsa = new InformationElementUtil.Vsa();
vsa.anqpDomainID = TEST_ANQP_DOMAIN_ID2;
@@ -1255,18 +1269,18 @@ public class PasspointManagerTest extends WifiBaseTest {
@Test
public void getWifiConfigsForPasspointProfiles() {
PasspointProvider provider1 = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
PasspointProvider provider2 = addTestProvider(TEST_FQDN + 1, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
PasspointProvider provider3 = addTestProvider(TEST_FQDN + 2, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
assertEquals(3, mManager.getWifiConfigsForPasspointProfiles(
Arrays.asList(provider1.getConfig().getUniqueId(),
provider2.getConfig().getUniqueId(), provider3.getConfig().getUniqueId(),
TEST_FQDN + "_353ab8c93", TEST_FQDN + "_83765319aca")).size());
PasspointProvider provider4 = addTestProvider(TEST_FQDN + 3, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, true);
+ TEST_PACKAGE, true, null);
when(mWifiNetworkSuggestionsManager
.isPasspointSuggestionSharedWithUser(provider4.getWifiConfig())).thenReturn(false);
assertEquals(3, mManager.getWifiConfigsForPasspointProfiles(
@@ -1274,7 +1288,7 @@ public class PasspointManagerTest extends WifiBaseTest {
provider2.getConfig().getUniqueId(), provider3.getConfig().getUniqueId(),
provider4.getConfig().getUniqueId(), TEST_FQDN + "_83765319aca")).size());
PasspointProvider provider5 = addTestProvider(TEST_FQDN + 4, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, true);
+ TEST_PACKAGE, true, null);
when(mWifiNetworkSuggestionsManager
.isPasspointSuggestionSharedWithUser(provider5.getWifiConfig())).thenReturn(true);
assertEquals(4, mManager.getWifiConfigsForPasspointProfiles(
@@ -1478,9 +1492,9 @@ public class PasspointManagerTest extends WifiBaseTest {
@Test
public void getMatchingPasspointConfigsForOsuProvidersWithMatch() {
PasspointProvider provider1 =
- addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
PasspointProvider provider2 =
- addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME2, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME2, TEST_PACKAGE, false, null);
List<OsuProvider> osuProviders = new ArrayList<>();
Map<String, String> friendlyNames = new HashMap<>();
@@ -1507,8 +1521,8 @@ public class PasspointManagerTest extends WifiBaseTest {
*/
@Test
public void getMatchingPasspointConfigsForOsuProvidersWitNoMatch() {
- addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
- addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME2, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+ addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME2, TEST_PACKAGE, false, null);
List<OsuProvider> osuProviders = new ArrayList<>();
@@ -1809,7 +1823,7 @@ public class PasspointManagerTest extends WifiBaseTest {
@Test
public void providerNetworkConnectedFirstTime() throws Exception {
PasspointProvider provider =
- addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
when(provider.getHasEverConnected()).thenReturn(false);
mManager.onPasspointNetworkConnected(provider.getConfig().getUniqueId());
verify(provider).setHasEverConnected(eq(true));
@@ -1825,7 +1839,7 @@ public class PasspointManagerTest extends WifiBaseTest {
@Test
public void providerNetworkConnectedNotFirstTime() throws Exception {
PasspointProvider provider =
- addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
when(provider.getHasEverConnected()).thenReturn(true);
mManager.onPasspointNetworkConnected(TEST_FQDN);
verify(provider, never()).setHasEverConnected(anyBoolean());
@@ -1840,7 +1854,7 @@ public class PasspointManagerTest extends WifiBaseTest {
@Test
public void updateMetrics() {
PasspointProvider provider =
- addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
ArgumentCaptor<Map<String, PasspointProvider>> argCaptor = ArgumentCaptor.forClass(
Map.class);
// Provider have not provided a successful network connection.
@@ -1888,7 +1902,7 @@ public class PasspointManagerTest extends WifiBaseTest {
currentConfiguration.FQDN = TEST_FQDN;
when(mClientModeImpl.getCurrentWifiConfiguration()).thenReturn(currentConfiguration);
PasspointProvider passpointProvider =
- addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false);
+ addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
currentConfiguration.setPasspointUniqueId(passpointProvider.getConfig().getUniqueId());
verify(mAppOpsManager).startWatchingMode(eq(OPSTR_CHANGE_WIFI_STATE), eq(TEST_PACKAGE),
mAppOpChangedListenerCaptor.capture());
@@ -2211,17 +2225,17 @@ public class PasspointManagerTest extends WifiBaseTest {
InformationElementUtil.class).startMocking();
try {
PasspointProvider providerHome = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
providerHome.getConfig().setSubscriptionExpirationTimeInMillis(
System.currentTimeMillis() + 100000);
providerHome.getWifiConfig().isHomeProviderNetwork = true;
PasspointProvider providerRoaming = addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
WifiConfiguration wifiConfiguration = WifiConfigurationTestUtil.generateWifiConfig(-1,
TEST_UID, "\"PasspointTestSSID\"", true, true,
TEST_FQDN + 2, TEST_FRIENDLY_NAME, SECURITY_EAP);
PasspointProvider providerNone = addTestProvider(TEST_FQDN + 2, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, wifiConfiguration, false);
+ TEST_PACKAGE, wifiConfiguration, false, null);
ANQPData entry = new ANQPData(mClock, null);
InformationElementUtil.Vsa vsa = new InformationElementUtil.Vsa();
vsa.anqpDomainID = TEST_ANQP_DOMAIN_ID;
@@ -2261,17 +2275,17 @@ public class PasspointManagerTest extends WifiBaseTest {
InformationElementUtil.class).startMocking();
try {
PasspointProvider providerHome = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
providerHome.getConfig().setSubscriptionExpirationTimeInMillis(
System.currentTimeMillis() - 10000);
providerHome.getWifiConfig().isHomeProviderNetwork = true;
PasspointProvider providerRoaming = addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
WifiConfiguration wifiConfiguration = WifiConfigurationTestUtil.generateWifiConfig(-1,
TEST_UID, "\"PasspointTestSSID\"", true, true,
TEST_FQDN + 2, TEST_FRIENDLY_NAME, SECURITY_EAP);
PasspointProvider providerNone = addTestProvider(TEST_FQDN + 2, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, wifiConfiguration, false);
+ TEST_PACKAGE, wifiConfiguration, false, null);
ANQPData entry = new ANQPData(mClock, null);
InformationElementUtil.Vsa vsa = new InformationElementUtil.Vsa();
vsa.anqpDomainID = TEST_ANQP_DOMAIN_ID;
@@ -2311,19 +2325,19 @@ public class PasspointManagerTest extends WifiBaseTest {
InformationElementUtil.class).startMocking();
try {
PasspointProvider providerHome = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
providerHome.getConfig().setSubscriptionExpirationTimeInMillis(
System.currentTimeMillis() - 10000);
providerHome.getWifiConfig().isHomeProviderNetwork = true;
PasspointProvider providerRoaming = addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, false);
+ TEST_PACKAGE, false, null);
providerRoaming.getConfig().setSubscriptionExpirationTimeInMillis(
System.currentTimeMillis() + 100000);
WifiConfiguration wifiConfiguration = WifiConfigurationTestUtil.generateWifiConfig(-1,
TEST_UID, "\"PasspointTestSSID\"", true, true,
TEST_FQDN + 2, TEST_FRIENDLY_NAME, SECURITY_EAP);
PasspointProvider providerNone = addTestProvider(TEST_FQDN + 2, TEST_FRIENDLY_NAME,
- TEST_PACKAGE, wifiConfiguration, false);
+ TEST_PACKAGE, wifiConfiguration, false, null);
ANQPData entry = new ANQPData(mClock, null);
InformationElementUtil.Vsa vsa = new InformationElementUtil.Vsa();
vsa.anqpDomainID = TEST_ANQP_DOMAIN_ID;
@@ -2467,4 +2481,43 @@ public class PasspointManagerTest extends WifiBaseTest {
verify(mAnqpRequestManager, never()).requestANQPElements(any(long.class),
any(ANQPNetworkKey.class), any(boolean.class), any(NetworkDetail.HSRelease.class));
}
+
+ /**
+ * Verify that removing of multiple providers with the same FQDN is done correctly.
+ */
+ @Test
+ public void removeAllProvidersWithSameFqdn() {
+ PasspointProvider provider1 = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
+ TEST_PACKAGE, false, TEST_REALM);
+ PasspointProvider provider2 = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
+ TEST_PACKAGE, false, TEST_REALM2);
+ PasspointProvider provider3 = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
+ TEST_PACKAGE, false, TEST_REALM3);
+
+ List<PasspointProvider> providers = mUserDataSource.getProviders();
+ assertEquals(3, providers.size());
+ verify(mWifiMetrics, times(3)).incrementNumPasspointProviderInstallation();
+ verify(mWifiMetrics, times(3)).incrementNumPasspointProviderInstallSuccess();
+
+ // Remove the provider as the creator app.
+ assertTrue(mManager.removeProvider(TEST_CREATOR_UID, false, null, TEST_FQDN));
+
+ verify(provider1).uninstallCertsAndKeys();
+ verify(mWifiConfigManager, times(1)).removePasspointConfiguredNetwork(
+ provider1.getWifiConfig().getKey());
+ verify(provider2).uninstallCertsAndKeys();
+ verify(mWifiConfigManager, times(1)).removePasspointConfiguredNetwork(
+ provider2.getWifiConfig().getKey());
+ verify(provider3).uninstallCertsAndKeys();
+ verify(mWifiConfigManager, times(1)).removePasspointConfiguredNetwork(
+ provider3.getWifiConfig().getKey());
+
+ verify(mWifiMetrics, times(3)).incrementNumPasspointProviderUninstallation();
+ verify(mWifiMetrics, times(3)).incrementNumPasspointProviderUninstallSuccess();
+ verify(mAppOpsManager).stopWatchingMode(any(AppOpsManager.OnOpChangedListener.class));
+ assertTrue(mManager.getProviderConfigs(TEST_CREATOR_UID, false).isEmpty());
+
+ // Verify content in the data source.
+ assertTrue(mUserDataSource.getProviders().isEmpty());
+ }
}