From a9d5ac2ceaa275e23b1673dd2f9845fd319dd0a7 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 10 Aug 2020 09:13:14 -0700 Subject: [WifiTrackerLib] Add null check to setOsuWifiEntry() PasspointWifiEntry.setOsuWifiEntry() needs a null check for the passed in OsuWifiEntry. This flow happens if the user is on the network details page for a passpoint network and a corresponding OSU AP is also in range. If the user exits the range of the OSU AP or scan results fail to come in, then setOsuWifiEntry(null) will be called and cause an NPE. Bug: 163328661 Test: atest WifiTrackerLibTests Change-Id: I01790893a067489b671997a4fb4069ca4d3be8d3 --- .../src/com/android/wifitrackerlib/PasspointWifiEntry.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java index d873c25e5..cbc5bd4ac 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java @@ -614,7 +614,9 @@ public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntry /** Pass a reference to a matching OsuWifiEntry for expiration handling */ void setOsuWifiEntry(OsuWifiEntry osuWifiEntry) { mOsuWifiEntry = osuWifiEntry; - mOsuWifiEntry.setListener(this); + if (mOsuWifiEntry != null) { + mOsuWifiEntry.setListener(this); + } } /** Callback for updates to the linked OsuWifiEntry */ -- cgit v1.2.3