diff --git a/framework/java/android/net/wifi/hotspot2/PasspointConfiguration.java b/framework/java/android/net/wifi/hotspot2/PasspointConfiguration.java
index 60c8133..f9ebd2b 100644
--- a/framework/java/android/net/wifi/hotspot2/PasspointConfiguration.java
+++ b/framework/java/android/net/wifi/hotspot2/PasspointConfiguration.java
@@ -996,12 +996,12 @@
             }
             String[] decoratedIdentityPrefixArray = mDecoratedIdentityPrefix.split("!");
             if (decoratedIdentityPrefixArray.length > MAX_NUMBER_OF_ENTRIES) {
-                Log.d(TAG, "too many decoratedIdentityPrefix");
+                Log.e(TAG, "too many decoratedIdentityPrefix");
                 return false;
             }
             for (String prefix : decoratedIdentityPrefixArray) {
                 if (prefix.length() > MAX_STRING_LENGTH) {
-                    Log.d(TAG, "The decoratedIdentityPrefix is too long: " + prefix);
+                    Log.e(TAG, "The decoratedIdentityPrefix is too long: " + prefix);
                     return false;
                 }
             }
@@ -1009,52 +1009,70 @@
 
         if (mAaaServerTrustedNames != null) {
             if (mAaaServerTrustedNames.length > MAX_NUMBER_OF_ENTRIES) {
-                Log.d(TAG, "Too many AaaServerTrustedNames");
+                Log.e(TAG, "Too many AaaServerTrustedNames");
                 return false;
             }
             for (String fqdn : mAaaServerTrustedNames) {
                 if (fqdn.getBytes(StandardCharsets.UTF_8).length > MAX_STRING_LENGTH) {
-                    Log.d(TAG, "AaaServerTrustedNames is too long");
+                    Log.e(TAG, "AaaServerTrustedNames is too long");
                     return false;
                 }
             }
         }
         if (mSubscriptionType != null) {
             if (mSubscriptionType.getBytes(StandardCharsets.UTF_8).length > MAX_STRING_LENGTH) {
-                Log.d(TAG, "SubscriptionType is too long");
+                Log.e(TAG, "SubscriptionType is too long");
                 return false;
             }
         }
 
         if (mTrustRootCertList != null) {
             if (mTrustRootCertList.size() > MAX_NUMBER_OF_ENTRIES) {
-                Log.d(TAG, "Too many TrustRootCert");
+                Log.e(TAG, "Too many TrustRootCert");
                 return false;
             }
             for (Map.Entry<String, byte[]> entry : mTrustRootCertList.entrySet()) {
                 String url = entry.getKey();
                 byte[] certFingerprint = entry.getValue();
                 if (TextUtils.isEmpty(url)) {
-                    Log.d(TAG, "Empty URL");
+                    Log.e(TAG, "Empty URL");
                     return false;
                 }
                 if (url.getBytes(StandardCharsets.UTF_8).length > MAX_URL_BYTES) {
-                    Log.d(TAG, "URL bytes exceeded the max: "
+                    Log.e(TAG, "URL bytes exceeded the max: "
                             + url.getBytes(StandardCharsets.UTF_8).length);
                     return false;
                 }
 
                 if (certFingerprint == null) {
-                    Log.d(TAG, "Fingerprint not specified");
+                    Log.e(TAG, "Fingerprint not specified");
                     return false;
                 }
                 if (certFingerprint.length != CERTIFICATE_SHA256_BYTES) {
-                    Log.d(TAG, "Incorrect size of trust root certificate SHA-256 fingerprint: "
+                    Log.e(TAG, "Incorrect size of trust root certificate SHA-256 fingerprint: "
                             + certFingerprint.length);
                     return false;
                 }
             }
         }
+
+        if (mServiceFriendlyNames != null) {
+            if (mServiceFriendlyNames.size() > MAX_NUMBER_OF_ENTRIES) {
+                Log.e(TAG, "ServiceFriendlyNames exceed the max!");
+                return false;
+            }
+            for (Map.Entry<String, String> names : mServiceFriendlyNames.entrySet()) {
+                if (names.getKey() == null || names.getValue() == null) {
+                    Log.e(TAG, "Service friendly name entry should not be null");
+                    return false;
+                }
+                if (names.getKey().length() > MAX_STRING_LENGTH
+                        || names.getValue().length() > MAX_STRING_LENGTH) {
+                    Log.e(TAG, "Service friendly name is to long");
+                    return false;
+                }
+            }
+        }
         return true;
     }
 
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
index 2422194..d255e50 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
@@ -24,6 +24,7 @@
 
 import android.annotation.NonNull;
 import android.annotation.Nullable;
+import android.app.ActivityManager;
 import android.app.AppOpsManager;
 import android.content.Context;
 import android.net.MacAddress;
@@ -136,6 +137,7 @@
     private final Clock mClock;
     private final WifiPermissionsUtil mWifiPermissionsUtil;
     private final WifiSettingsStore mSettingsStore;
+    private final boolean mIsLowMemory;
 
     /**
      * Map of package name of an app to the app ops changed listener for the app.
@@ -145,7 +147,8 @@
     // Counter used for assigning unique identifier to each provider.
     private long mProviderIndex;
     private boolean mVerboseLoggingEnabled = false;
-    private boolean mEnabled;
+    // Set default value to false before receiving boot completed event.
+    private boolean mEnabled = false;
 
     private class CallbackHandler implements PasspointEventHandler.Callbacks {
         private final Context mContext;
@@ -379,6 +382,8 @@
                 new SharedDataSourceHandler()));
         mPasspointProvisioner = objectFactory.makePasspointProvisioner(context, wifiNative,
                 this, wifiMetrics);
+        ActivityManager activityManager = context.getSystemService(ActivityManager.class);
+        mIsLowMemory = activityManager.isLowRamDevice();
         mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
         sPasspointManager = this;
         mMacAddressUtil = macAddressUtil;
@@ -477,10 +482,20 @@
             Log.e(TAG, "Set isTrusted to false on a non suggestion passpoint is not allowed");
             return false;
         }
+        if (config.getServiceFriendlyNames() != null && isFromSuggestion) {
+            Log.e(TAG, "Passpoint from suggestion should not have ServiceFriendlyNames");
+            return false;
+        }
         if (!mWifiPermissionsUtil.doesUidBelongToCurrentUserOrDeviceOwner(uid)) {
             Log.e(TAG, "UID " + uid + " not visible to the current user");
             return false;
         }
+        if (getPasspointProviderWithPackage(packageName).size()
+                >= WifiManager.getMaxNumberOfNetworkSuggestionsPerApp(mIsLowMemory)) {
+            Log.e(TAG, "packageName " + packageName + " has too many passpoint with exceed the "
+                    + "limitation");
+            return false;
+        }
 
         mWifiCarrierInfoManager.tryUpdateCarrierIdForPasspoint(config);
         // Create a provider and install the necessary certificates and keys.
diff --git a/service/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java b/service/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java
index de777a1..a201086 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionStoreDataTest.java
@@ -525,11 +525,6 @@
         homeSp.setFqdn(fqdn);
         homeSp.setFriendlyName(friendlyName);
         config.setHomeSp(homeSp);
-        Map<String, String> friendlyNames = new HashMap<>();
-        friendlyNames.put("en", friendlyName);
-        friendlyNames.put("kr", friendlyName + 1);
-        friendlyNames.put("jp", friendlyName + 2);
-        config.setServiceFriendlyNames(friendlyNames);
         Credential credential = new Credential();
         credential.setRealm(TEST_REALM);
         credential.setCaCertificate(FakeKeys.CA_CERT0);
diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index 901c75d..1859b10 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -4921,11 +4921,6 @@
         homeSp.setFqdn(fqdn);
         homeSp.setFriendlyName(friendlyName);
         config.setHomeSp(homeSp);
-        Map<String, String> friendlyNames = new HashMap<>();
-        friendlyNames.put("en", friendlyName);
-        friendlyNames.put("kr", friendlyName + 1);
-        friendlyNames.put("jp", friendlyName + 2);
-        config.setServiceFriendlyNames(friendlyNames);
         Credential credential = new Credential();
         credential.setRealm(TEST_REALM);
         credential.setCaCertificate(FakeKeys.CA_CERT0);
diff --git a/service/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
index 8cafc9f..2acd185 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
@@ -51,6 +51,7 @@
 import static org.mockito.Mockito.when;
 import static org.mockito.MockitoAnnotations.initMocks;
 
+import android.app.ActivityManager;
 import android.app.AppOpsManager;
 import android.content.Context;
 import android.content.Intent;
@@ -219,6 +220,7 @@
     @Mock WifiNetworkSuggestionsManager mWifiNetworkSuggestionsManager;
     @Mock MacAddressUtil mMacAddressUtil;
     @Mock WifiPermissionsUtil mWifiPermissionsUtil;
+    @Mock ActivityManager mActivityManager;
 
     Handler mHandler;
     TestLooper mLooper;
@@ -257,6 +259,7 @@
                 any(PasspointManager.class), any(WifiMetrics.class)))
                 .thenReturn(mPasspointProvisioner);
         when(mContext.getSystemService(Context.APP_OPS_SERVICE)).thenReturn(mAppOpsManager);
+        when(mContext.getSystemService(ActivityManager.class)).thenReturn(mActivityManager);
         when(mWifiInjector.getWifiNetworkSuggestionsManager())
                 .thenReturn(mWifiNetworkSuggestionsManager);
         when(mWifiPermissionsUtil.doesUidBelongToCurrentUserOrDeviceOwner(anyInt()))
@@ -369,11 +372,6 @@
         homeSp.setFqdn(fqdn);
         homeSp.setFriendlyName(friendlyName);
         config.setHomeSp(homeSp);
-        Map<String, String> friendlyNames = new HashMap<>();
-        friendlyNames.put("en", friendlyName);
-        friendlyNames.put("kr", friendlyName + 1);
-        friendlyNames.put("jp", friendlyName + 2);
-        config.setServiceFriendlyNames(friendlyNames);
         Credential credential = new Credential();
         credential.setRealm(realm != null ? realm : TEST_REALM);
         credential.setCaCertificate(FakeKeys.CA_CERT0);
@@ -410,12 +408,14 @@
     }
 
     private PasspointProvider addTestProvider(String fqdn, String friendlyName,
-            String packageName, boolean isSuggestion, String realm) {
+            String packageName, boolean isSuggestion, String realm,
+            boolean addServiceFriendlyNames) {
         WifiConfiguration wifiConfig = WifiConfigurationTestUtil.generateWifiConfig(-1, TEST_UID,
                 "\"PasspointTestSSID\"", true, true,
                 fqdn, friendlyName, SECURITY_EAP);
 
-        return addTestProvider(fqdn, friendlyName, packageName, wifiConfig, isSuggestion, realm);
+        return addTestProvider(fqdn, friendlyName, packageName, wifiConfig, isSuggestion, realm,
+                addServiceFriendlyNames);
     }
 
     /**
@@ -425,10 +425,18 @@
      * @return {@link PasspointProvider}
      */
     private PasspointProvider addTestProvider(String fqdn, String friendlyName,
-            String packageName, WifiConfiguration wifiConfig, boolean isSuggestion, String realm) {
+            String packageName, WifiConfiguration wifiConfig, boolean isSuggestion, String realm,
+            boolean addServiceFriendlyNames) {
         PasspointConfiguration config =
                 createTestConfigWithUserCredentialAndRealm(fqdn, friendlyName, realm);
         wifiConfig.setPasspointUniqueId(config.getUniqueId());
+        if (addServiceFriendlyNames) {
+            Map<String, String> friendlyNames = new HashMap<>();
+            friendlyNames.put("en", friendlyName);
+            friendlyNames.put("kr", friendlyName + 1);
+            friendlyNames.put("jp", friendlyName + 2);
+            config.setServiceFriendlyNames(friendlyNames);
+        }
         PasspointProvider provider = createMockProvider(config, wifiConfig, isSuggestion);
         when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
                 eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
@@ -1045,7 +1053,7 @@
                 com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession().mockStatic(
                         InformationElementUtil.class).startMocking();
         try {
-            addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+            addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null, false);
 
             when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(null);
             InformationElementUtil.Vsa vsa = new InformationElementUtil.Vsa();
@@ -1074,7 +1082,7 @@
     @Test
     public void matchProviderAsHomeProvider() throws Exception {
         PasspointProvider provider =
-                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null, false);
         ANQPData entry = new ANQPData(mClock, null);
 
         when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry);
@@ -1095,7 +1103,7 @@
     @Test
     public void matchProviderAsRoamingProvider() throws Exception {
         PasspointProvider provider =
-                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null, false);
         ANQPData entry = new ANQPData(mClock, null);
 
         when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry);
@@ -1116,7 +1124,7 @@
     @Test
     public void matchProviderWithNoMatch() throws Exception {
         PasspointProvider provider =
-                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null, false);
         ANQPData entry = new ANQPData(mClock, null);
 
         when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry);
@@ -1175,7 +1183,7 @@
                         InformationElementUtil.class).startMocking();
         try {
             PasspointProvider provider = addTestProvider(TEST_FQDN + 0, TEST_FRIENDLY_NAME,
-                    TEST_PACKAGE, false, null);
+                    TEST_PACKAGE, false, null, false);
             when(provider.tryUpdateCarrierId()).thenReturn(true);
             reset(mWifiConfigManager);
 
@@ -1209,15 +1217,15 @@
                         InformationElementUtil.class).startMocking();
         try {
             PasspointProvider providerHome = addTestProvider(TEST_FQDN + 0, TEST_FRIENDLY_NAME,
-                    TEST_PACKAGE, false, null);
+                    TEST_PACKAGE, false, null, false);
             providerHome.getWifiConfig().isHomeProviderNetwork = true;
             PasspointProvider providerRoaming = addTestProvider(TEST_FQDN + 1, TEST_FRIENDLY_NAME,
-                    TEST_PACKAGE, false, null);
+                    TEST_PACKAGE, false, null, false);
             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, null);
+                    TEST_PACKAGE, wifiConfiguration, false, null, false);
             ANQPData entry = new ANQPData(mClock, null);
             InformationElementUtil.Vsa vsa = new InformationElementUtil.Vsa();
             vsa.anqpDomainID = TEST_ANQP_DOMAIN_ID2;
@@ -1266,21 +1274,21 @@
     @Test
     public void getWifiConfigsForPasspointProfiles() {
         PasspointProvider provider1 = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
-                TEST_PACKAGE, false, null);
+                TEST_PACKAGE, false, null, false);
         WifiConfiguration config1 = provider1.getWifiConfig();
         when(mWifiConfigManager.getConfiguredNetwork(provider1.getConfig().getUniqueId()))
                 .thenReturn(config1);
         PasspointProvider provider2 = addTestProvider(TEST_FQDN + 1, TEST_FRIENDLY_NAME,
-                TEST_PACKAGE, false, null);
+                TEST_PACKAGE, false, null, false);
         PasspointProvider provider3 = addTestProvider(TEST_FQDN + 2, TEST_FRIENDLY_NAME,
-                TEST_PACKAGE, true, null);
+                TEST_PACKAGE, true, null, false);
         when(mWifiNetworkSuggestionsManager
                 .isPasspointSuggestionSharedWithUser(provider3.getWifiConfig())).thenReturn(false);
         WifiConfiguration config3 = provider3.getWifiConfig();
         when(mWifiConfigManager.getConfiguredNetwork(provider3.getConfig().getUniqueId()))
                 .thenReturn(config3);
         PasspointProvider provider4 = addTestProvider(TEST_FQDN + 3, TEST_FRIENDLY_NAME,
-                TEST_PACKAGE, true, null);
+                TEST_PACKAGE, true, null, false);
         when(mWifiNetworkSuggestionsManager
                 .isPasspointSuggestionSharedWithUser(provider4.getWifiConfig())).thenReturn(true);
         WifiConfiguration config4 = provider4.getWifiConfig();
@@ -1310,7 +1318,7 @@
         when(mMacAddressUtil.calculatePersistentMac(any(), any())).thenReturn(randomizedMacAddress);
         when(mWifiConfigManager.shouldUseNonPersistentRandomization(any())).thenReturn(false);
         PasspointProvider provider = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
-                TEST_PACKAGE, false, null);
+                TEST_PACKAGE, false, null, false);
         WifiConfiguration configuration = provider.getWifiConfig();
         when(mWifiConfigManager.getConfiguredNetwork(provider.getConfig().getUniqueId()))
                 .thenReturn(configuration);
@@ -1333,7 +1341,7 @@
         when(mMacAddressUtil.calculatePersistentMac(any(), any())).thenReturn(randomizedMacAddress);
         when(mWifiConfigManager.shouldUseNonPersistentRandomization(any())).thenReturn(true);
         PasspointProvider provider = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
-                TEST_PACKAGE, false, null);
+                TEST_PACKAGE, false, null, false);
         WifiConfiguration configuration = provider.getWifiConfig();
         when(mWifiConfigManager.getConfiguredNetwork(provider.getConfig().getUniqueId()))
                 .thenReturn(configuration);
@@ -1536,9 +1544,9 @@
     @Test
     public void getMatchingPasspointConfigsForOsuProvidersWithMatch() {
         PasspointProvider provider1 =
-                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null, true);
         PasspointProvider provider2 =
-                addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME2, TEST_PACKAGE, false, null);
+                addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME2, TEST_PACKAGE, false, null, true);
 
         List<OsuProvider> osuProviders = new ArrayList<>();
         Map<String, String> friendlyNames = new HashMap<>();
@@ -1565,8 +1573,8 @@
      */
     @Test
     public void getMatchingPasspointConfigsForOsuProvidersWitNoMatch() {
-        addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
-        addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME2, TEST_PACKAGE, false, null);
+        addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null, false);
+        addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME2, TEST_PACKAGE, false, null, false);
 
         List<OsuProvider> osuProviders = new ArrayList<>();
 
@@ -1867,7 +1875,7 @@
     @Test
     public void providerNetworkConnectedFirstTime() throws Exception {
         PasspointProvider provider =
-                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null, false);
         when(provider.getHasEverConnected()).thenReturn(false);
         mManager.onPasspointNetworkConnected(provider.getConfig().getUniqueId());
         verify(provider).setHasEverConnected(eq(true));
@@ -1883,7 +1891,7 @@
     @Test
     public void providerNetworkConnectedNotFirstTime() throws Exception {
         PasspointProvider provider =
-                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null, false);
         when(provider.getHasEverConnected()).thenReturn(true);
         mManager.onPasspointNetworkConnected(TEST_FQDN);
         verify(provider, never()).setHasEverConnected(anyBoolean());
@@ -1898,7 +1906,7 @@
     @Test
     public void updateMetrics() {
         PasspointProvider provider =
-                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null, false);
         ArgumentCaptor<Map<String, PasspointProvider>> argCaptor = ArgumentCaptor.forClass(
                 Map.class);
         // Provider have not provided a successful network connection.
@@ -1945,7 +1953,7 @@
         WifiConfiguration currentConfiguration = WifiConfigurationTestUtil.createPasspointNetwork();
         currentConfiguration.FQDN = TEST_FQDN;
         PasspointProvider passpointProvider =
-                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null, false);
         currentConfiguration.setPasspointUniqueId(passpointProvider.getConfig().getUniqueId());
         verify(mAppOpsManager).startWatchingMode(eq(OPSTR_CHANGE_WIFI_STATE), eq(TEST_PACKAGE),
                 mAppOpChangedListenerCaptor.capture());
@@ -2307,17 +2315,17 @@
                         InformationElementUtil.class).startMocking();
         try {
             PasspointProvider providerHome = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
-                    TEST_PACKAGE, false, null);
+                    TEST_PACKAGE, false, null, false);
             providerHome.getConfig().setSubscriptionExpirationTimeInMillis(
                     System.currentTimeMillis() + 100000);
             providerHome.getWifiConfig().isHomeProviderNetwork = true;
             PasspointProvider providerRoaming = addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME,
-                    TEST_PACKAGE, false, null);
+                    TEST_PACKAGE, false, null, false);
             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, null);
+                    TEST_PACKAGE, wifiConfiguration, false, null, false);
             ANQPData entry = new ANQPData(mClock, null);
             InformationElementUtil.Vsa vsa = new InformationElementUtil.Vsa();
             vsa.anqpDomainID = TEST_ANQP_DOMAIN_ID;
@@ -2357,17 +2365,17 @@
                         InformationElementUtil.class).startMocking();
         try {
             PasspointProvider providerHome = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
-                    TEST_PACKAGE, false, null);
+                    TEST_PACKAGE, false, null, false);
             providerHome.getConfig().setSubscriptionExpirationTimeInMillis(
                     System.currentTimeMillis() - 10000);
             providerHome.getWifiConfig().isHomeProviderNetwork = true;
             PasspointProvider providerRoaming = addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME,
-                    TEST_PACKAGE, false, null);
+                    TEST_PACKAGE, false, null, false);
             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, null);
+                    TEST_PACKAGE, wifiConfiguration, false, null, false);
             ANQPData entry = new ANQPData(mClock, null);
             InformationElementUtil.Vsa vsa = new InformationElementUtil.Vsa();
             vsa.anqpDomainID = TEST_ANQP_DOMAIN_ID;
@@ -2407,19 +2415,19 @@
                         InformationElementUtil.class).startMocking();
         try {
             PasspointProvider providerHome = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
-                    TEST_PACKAGE, false, null);
+                    TEST_PACKAGE, false, null, false);
             providerHome.getConfig().setSubscriptionExpirationTimeInMillis(
                     System.currentTimeMillis() - 10000);
             providerHome.getWifiConfig().isHomeProviderNetwork = true;
             PasspointProvider providerRoaming = addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME,
-                    TEST_PACKAGE, false, null);
+                    TEST_PACKAGE, false, null, false);
             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, null);
+                    TEST_PACKAGE, wifiConfiguration, false, null, false);
             ANQPData entry = new ANQPData(mClock, null);
             InformationElementUtil.Vsa vsa = new InformationElementUtil.Vsa();
             vsa.anqpDomainID = TEST_ANQP_DOMAIN_ID;
@@ -2570,11 +2578,11 @@
     @Test
     public void removeAllProvidersWithSameFqdn() {
         PasspointProvider provider1 = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
-                TEST_PACKAGE, false, TEST_REALM);
+                TEST_PACKAGE, false, TEST_REALM, false);
         PasspointProvider provider2 = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
-                TEST_PACKAGE, false, TEST_REALM2);
+                TEST_PACKAGE, false, TEST_REALM2, false);
         PasspointProvider provider3 = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
-                TEST_PACKAGE, false, TEST_REALM3);
+                TEST_PACKAGE, false, TEST_REALM3, false);
 
         List<PasspointProvider> providers = mUserDataSource.getProviders();
         assertEquals(3, providers.size());
@@ -2713,7 +2721,7 @@
 
         PasspointProvider provider =
                 addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, wifiConfig, false,
-                        null);
+                        null, false);
         WnmData event = WnmData.createDeauthImminentEvent(Utils.parseMac(TEST_BSSID_STRING), "",
                 true, 30);
 
@@ -2733,7 +2741,7 @@
 
         PasspointProvider provider =
                 addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, wifiConfig, false,
-                        null);
+                        null, false);
 
         wifiConfig.enterpriseConfig.setAnonymousIdentity(TEST_ANONYMOUS_IDENTITY);
         mManager.setAnonymousIdentity(wifiConfig);
@@ -2756,7 +2764,7 @@
 
         PasspointProvider provider =
                 addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, wifiConfig, false,
-                        null);
+                        null, false);
 
         WifiConfiguration wifiConfig2 = WifiConfigurationTestUtil.generateWifiConfig(11, TEST_UID,
                 "\"PasspointTestSSID\"", true, true, TEST_FQDN2,
@@ -2764,7 +2772,7 @@
 
         PasspointProvider provider2 =
                 addTestProvider(TEST_FQDN2, TEST_FRIENDLY_NAME, TEST_PACKAGE, wifiConfig2, false,
-                        null);
+                        null, false);
 
         WifiConfigManager.OnNetworkUpdateListener listener = mNetworkListenerCaptor.getValue();
         reset(mWifiConfigManager);
@@ -2968,7 +2976,7 @@
     public void testHandleTermsAndConditionsEvent() throws Exception {
         WifiConfiguration config = WifiConfigurationTestUtil.createPasspointNetwork();
         PasspointProvider passpointProvider = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
-                TEST_PACKAGE, config, false, null);
+                TEST_PACKAGE, config, false, null, false);
         assertEquals(TEST_TERMS_AND_CONDITIONS_URL, mManager.handleTermsAndConditionsEvent(
                 WnmData.createTermsAndConditionsAccetanceRequiredEvent(TEST_BSSID,
                         TEST_TERMS_AND_CONDITIONS_URL), config).toString());
@@ -3009,7 +3017,7 @@
     @Test
     public void testClearAnqpRequestsAndFlushCache() throws Exception {
         PasspointProvider provider = addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME,
-                TEST_PACKAGE, false, TEST_REALM);
+                TEST_PACKAGE, false, TEST_REALM, false);
 
         mManager.clearAnqpRequestsAndFlushCache();
         verify(mAnqpRequestManager).clear();
@@ -3048,7 +3056,7 @@
     @Test
     public void testPasspointEnableDisable() throws Exception {
         PasspointProvider provider =
-                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null);
+                addTestProvider(TEST_FQDN, TEST_FRIENDLY_NAME, TEST_PACKAGE, false, null, false);
         ANQPData entry = new ANQPData(mClock, null);
 
         when(mAnqpCache.getEntry(TEST_ANQP_KEY)).thenReturn(entry);
