From aa3941598e26f7645d22e4715469967695919a45 Mon Sep 17 00:00:00 2001 From: David Su Date: Mon, 3 Aug 2020 15:01:08 -0700 Subject: WifiP2pServiceImpl: check for null group owner Bug: 162705230 Test: atest FrameworksWifiTests Change-Id: I1d46ee06ebc6879b1f3924a74e81bd5b107b8691 --- .../java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java index 61e6c16bc..219da3884 100644 --- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java +++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java @@ -114,6 +114,7 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; /** * WifiP2pService includes a state machine to perform Wi-Fi p2p operations. Applications @@ -240,7 +241,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { private final boolean mP2pSupported; - private WifiP2pDevice mThisDevice = new WifiP2pDevice(); + private final WifiP2pDevice mThisDevice = new WifiP2pDevice(); // When a group has been explicitly created by an app, we persist the group // even after all clients have been disconnected until an explicit remove @@ -3323,7 +3324,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { /** * This method unifies the persisent group list, cleans up unused * networks and if required, updates corresponding broadcast receivers - * @param boolean if true, reload the group list from scratch + * @param reload if true, reload the group list from scratch * and send broadcast message with fresh list */ private void updatePersistentNetworks(boolean reload) { @@ -3333,7 +3334,11 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { // no network has been found. if (mWifiNative.p2pListNetworks(mGroups) || reload) { for (WifiP2pGroup group : mGroups.getGroupList()) { - if (mThisDevice.deviceAddress.equals(group.getOwner().deviceAddress)) { + if (group.getOwner() == null) { + Log.d(TAG, "group.getOwner() null"); + continue; + } + if (Objects.equals(mThisDevice.deviceAddress, group.getOwner().deviceAddress)) { group.setOwner(mThisDevice); } } -- cgit v1.2.3