wifi: catch UnsupportedOperationException for getMatchingWifiConfig
On a device without Passpoint support, an UnsupportedOperationException
will be thrown when invoking WifiManager#getMatchingWifiConfig.
So catch it to avoid crash.
Bug: 36649203
Test: manually set config_wifi_hotspot2_enabled to false and verify
Settings app doesn't crash
Change-Id: I69f37897449033da9d21edda9953ad2738f7e314
(cherry picked from commit 0ffb89d1d1ebcd6388ee99652beaedd4c11ea3d4)
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
index 55c886e..dc1e897 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
@@ -525,9 +525,13 @@
// the given ScanResult. This is used for showing that a given AP
// (ScanResult) is available via a Passpoint provider (provider friendly
// name).
- WifiConfiguration config = mWifiManager.getMatchingWifiConfig(result);
- if (config != null) {
- accessPoint.update(config);
+ try {
+ WifiConfiguration config = mWifiManager.getMatchingWifiConfig(result);
+ if (config != null) {
+ accessPoint.update(config);
+ }
+ } catch (UnsupportedOperationException e) {
+ // Passpoint not supported on the device.
}
}