[WifiInstaller] Remove Passpoint profile before installing
Due to a change in the addOrUpdatePasspointProfile behavior, Wi-Fi
cert installer needs to delete existing Passpoint profile before
installing a new one with the same FQDN.
Bug: 156405566
Test: Install a new cert, verify correctness.
Change-Id: Ib258750f546f81cdf1081bbff5c0f1c4c23fd070
diff --git a/src/com/android/certinstaller/WiFiInstaller.java b/src/com/android/certinstaller/WiFiInstaller.java
index 90b8eb7..41827f6 100644
--- a/src/com/android/certinstaller/WiFiInstaller.java
+++ b/src/com/android/certinstaller/WiFiInstaller.java
@@ -93,6 +93,13 @@
public void run() {
boolean success = true;
try {
+ mWifiManager.removePasspointConfiguration(
+ mPasspointConfig.getHomeSp().getFqdn());
+ } catch (IllegalArgumentException e) {
+ // Do nothing. This is expected if a profile with this FQDN does not
+ // exist.
+ }
+ try {
mWifiManager.addOrUpdatePasspointConfiguration(mPasspointConfig);
} catch (RuntimeException rte) {
Log.w(TAG, "Caught exception while installing wifi config: " +