diff options
author | Glen Kuhne <kuh@google.com> | 2017-04-21 19:46:06 -0700 |
---|---|---|
committer | Glen Kuhne <kuh@google.com> | 2017-04-26 10:16:45 -0700 |
commit | b8adfb745a2c1540db40af204f7de9b1a815071f (patch) | |
tree | e37cfd1984c0c381623fd4d4d5e24f16a9e792a8 /service | |
parent | a208bbfb1b4755327c54bc3fcb8bce954f3d76f5 (diff) |
P2P: Modify loadGroups & fix NPE
Some of the loadGroups logic was incorrectly transformed from socket to
HIDL supplicant calls, (isCurrent vs !isCurrent). Fixed that.
startWpsPbc no longer accepts a null value as a wildcard, and causes a
NPE. Fixed that too.
Bug: 37286961
Test: Manual + CTS Verifier + new unit test
Change-Id: Ie24e89f7bc9d0f03511ace2e5c0ac1cbbe31e359
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java | 46 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java | 1 |
2 files changed, 23 insertions, 24 deletions
diff --git a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java index fc63894b8..6f4543edb 100644 --- a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java +++ b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java @@ -1471,23 +1471,19 @@ public class SupplicantP2pIfaceHal { * @return true, if operation was successful. */ public boolean startWpsPbc(String groupIfName, String bssid) { - if (TextUtils.isEmpty(groupIfName)) return false; + if (TextUtils.isEmpty(groupIfName)) { + Log.e(TAG, "Group name required when requesting WPS PBC. Got (" + groupIfName + ")"); + return false; + } synchronized (mLock) { if (!checkSupplicantP2pIfaceAndLogFailure("startWpsPbc")) return false; - if (groupIfName == null) { - Log.e(TAG, "Group name required when requesting WPS PBC."); - return false; - } - // Null values should be fine, since bssid can be empty. byte[] macAddress = null; - if (bssid != null) { - try { - macAddress = NativeUtil.macAddressToByteArray(bssid); - } catch (Exception e) { - Log.e(TAG, "Could not parse BSSID.", e); - return false; - } + try { + macAddress = NativeUtil.macAddressToByteArray(bssid); + } catch (Exception e) { + Log.e(TAG, "Could not parse BSSID.", e); + return false; } SupplicantResult<Void> result = new SupplicantResult( @@ -1556,13 +1552,11 @@ public class SupplicantP2pIfaceHal { // Null values should be fine, since bssid can be empty. byte[] macAddress = null; - if (bssid != null) { - try { - macAddress = NativeUtil.macAddressToByteArray(bssid); - } catch (Exception e) { - Log.e(TAG, "Could not parse BSSID.", e); - return null; - } + try { + macAddress = NativeUtil.macAddressToByteArray(bssid); + } catch (Exception e) { + Log.e(TAG, "Could not parse BSSID.", e); + return null; } SupplicantResult<String> result = new SupplicantResult( @@ -1746,8 +1740,9 @@ public class SupplicantP2pIfaceHal { } /** - * Populate list of available networks or update existing list. + * Get the persistent group list from wpa_supplicant's p2p mgmt interface * + * @param groups WifiP2pGroupList to store persistent groups in * @return true, if list has been modified. */ public boolean loadGroups(WifiP2pGroupList groups) { @@ -1774,8 +1769,10 @@ public class SupplicantP2pIfaceHal { Log.e(TAG, "ISupplicantP2pIface exception: " + e); supplicantServiceDiedHandler(); } - if (!resultIsCurrent.isSuccess() || !resultIsCurrent.getResult()) { - Log.i(TAG, "Skipping non current network"); + /** Skip the current network, if we're somehow getting networks from the p2p GO + interface, instead of p2p mgmt interface*/ + if (!resultIsCurrent.isSuccess() || resultIsCurrent.getResult()) { + Log.i(TAG, "Skipping current network"); continue; } @@ -1796,7 +1793,8 @@ public class SupplicantP2pIfaceHal { } if (resultSsid.isSuccess() && resultSsid.getResult() != null && !resultSsid.getResult().isEmpty()) { - group.setNetworkName(NativeUtil.encodeSsid(resultSsid.getResult())); + group.setNetworkName(NativeUtil.removeEnclosingQuotes( + NativeUtil.encodeSsid(resultSsid.getResult()))); } SupplicantResult<byte[]> resultBssid = diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java index 0c7a91d1c..623a2f0c3 100644 --- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java +++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java @@ -2364,6 +2364,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { pw.println("mWifiP2pInfo " + mWifiP2pInfo); pw.println("mGroup " + mGroup); pw.println("mSavedPeerConfig " + mSavedPeerConfig); + pw.println("mGroups" + mGroups); pw.println(); } |