diff options
author | Zhao Sun <zhao.x.sun@sony.com> | 2018-05-04 20:53:07 +0800 |
---|---|---|
committer | Jong Wook Kim <jongwook@google.com> | 2018-05-22 13:56:20 -0700 |
commit | 719b6ae422910df0c17ae36deba0acc08d9a8943 (patch) | |
tree | bb67c614987987e96b21229a90f904be98202161 /service | |
parent | 76b64fecb6dd8ef593582295f01e543eb41f46a7 (diff) |
Add null check on getting p2p iface name
Cherry-picked from partners
After tearing down client interface, p2p interface will be invalid and
null is returned when getting p2p interface name. When Wifi on/off is
quickly repeated, a crash happens due to NullPointerException because
WifiP2pNative#setupInterface is called and trying to get p2p interface
name at that time while p2p iface is marked as invalid (client mode is
shutting down). This patch adds null check on getting p2p iface name
to avoid crash.
Bug: 80095183
Test: manual
Change-Id: I8aee5e3ca4d77eae3ed94aa76f6666649424e690
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/p2p/WifiP2pNative.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pNative.java b/service/java/com/android/server/wifi/p2p/WifiP2pNative.java index 07ee11e3b..de608b133 100644 --- a/service/java/com/android/server/wifi/p2p/WifiP2pNative.java +++ b/service/java/com/android/server/wifi/p2p/WifiP2pNative.java @@ -24,6 +24,7 @@ import android.net.wifi.p2p.WifiP2pGroup; import android.net.wifi.p2p.WifiP2pGroupList; import android.net.wifi.p2p.nsd.WifiP2pServiceInfo; import android.os.Handler; +import android.text.TextUtils; import android.util.Log; import com.android.server.wifi.HalDeviceManager; @@ -190,7 +191,13 @@ public class WifiP2pNative { teardownInterface(); return null; } - if (!mSupplicantP2pIfaceHal.setupIface(HalDeviceManager.getName(mIWifiP2pIface))) { + String ifaceName = HalDeviceManager.getName(mIWifiP2pIface); + if (TextUtils.isEmpty(ifaceName)) { + Log.e(TAG, "Failed to get p2p iface name"); + teardownInterface(); + return null; + } + if (!mSupplicantP2pIfaceHal.setupIface(ifaceName)) { Log.e(TAG, "Failed to setup P2p iface in supplicant"); teardownInterface(); return null; |