diff options
author | Quang Luong <qal@google.com> | 2020-03-10 00:04:23 -0700 |
---|---|---|
committer | Quang Luong <qal@google.com> | 2020-03-11 00:26:01 +0000 |
commit | 140ee33e15766de9687b77adbb0671c4f545228d (patch) | |
tree | 171a414c4292337a075dfb0a507d3888d08e90a8 /libs | |
parent | 7df8f4f20fdc02a9839130102ed017ad8113998e (diff) |
[WifiTrackerLib] Fix NPE when refreshing link properties
Add a null check when referencing link properties due to a race
condition where a connected WifiEntry receives a link properties changed
callback that is null.
Bug: 148752497
Test: atest WifiTrackerLibTests
Change-Id: I86d6d1c48b2945e111f66122bd9ace91dd63db12
Diffstat (limited to 'libs')
-rw-r--r-- | libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java index ff230e76c..221829312 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java @@ -304,6 +304,10 @@ public abstract class WifiEntry implements Comparable<WifiEntry> { * Returns null if getConnectedState() != CONNECTED_STATE_CONNECTED. */ public ConnectedInfo getConnectedInfo() { + if (getConnectedState() != CONNECTED_STATE_CONNECTED) { + return null; + } + return mConnectedInfo; } @@ -585,7 +589,9 @@ public abstract class WifiEntry implements Comparable<WifiEntry> { // Method for WifiTracker to update the link properties, which is valid for all WifiEntry types. @WorkerThread void updateLinkProperties(@Nullable LinkProperties linkProperties) { - if (getConnectedState() != CONNECTED_STATE_CONNECTED) { + if (linkProperties == null || getConnectedState() != CONNECTED_STATE_CONNECTED) { + mConnectedInfo = null; + notifyOnUpdated(); return; } |