diff options
author | Roshan Pius <rpius@google.com> | 2017-03-14 11:30:25 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2017-03-15 17:37:56 -0700 |
commit | d19743b66ba214a8c4a5166d1fe7d938f97a3f03 (patch) | |
tree | aac9508af6bcb5654e6743fda8d5ff843e73ac93 /service | |
parent | 1df53b3ec09d8bd1713b55167ebe283bd1c1a9e9 (diff) |
SupplicantHal: Fix Wps PBC/Display setup
For Wps PBC/Display the app can choose to send a null bssid to indicate
that we want to indicate wildcard. So, add support for it.
Change NativeUtil.macAddressToByteArray to allow null/empty strings
which would return all zero'ed bssid.
Bug: 34714021
Test: Unit tests
Test: WPS setup can now be initiated via settings app.
Change-Id: I223eb9666163a0f02fe6b68480b1a05895563803
Diffstat (limited to 'service')
3 files changed, 10 insertions, 13 deletions
diff --git a/service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java b/service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java index 72cce457b..ba7064b4d 100644 --- a/service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java +++ b/service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java @@ -1468,11 +1468,11 @@ public class SupplicantP2pIfaceHal { * AP/Registrar at about the same time (2 minute window). * * @param groupIfName Group interface name to use. - * @param bssid BSSID of the AP. Use zero'ed bssid to indicate wildcard. + * @param bssid BSSID of the AP. Use empty bssid to indicate wildcard. * @return true, if operation was successful. */ public boolean startWpsPbc(String groupIfName, String bssid) { - if (TextUtils.isEmpty(groupIfName) || TextUtils.isEmpty(bssid)) return false; + if (TextUtils.isEmpty(groupIfName)) return false; synchronized (mLock) { if (!checkSupplicantP2pIfaceAndLogFailure("startWpsPbc")) return false; if (groupIfName == null) { @@ -1543,11 +1543,11 @@ public class SupplicantP2pIfaceHal { * Initiate WPS Pin Display setup. * * @param groupIfName Group interface name to use. - * @param bssid BSSID of the AP. Use zero'ed bssid to indicate wildcard. + * @param bssid BSSID of the AP. Use empty bssid to indicate wildcard. * @return generated pin if operation was successful, null otherwise. */ public String startWpsPinDisplay(String groupIfName, String bssid) { - if (TextUtils.isEmpty(groupIfName) || TextUtils.isEmpty(bssid)) return null; + if (TextUtils.isEmpty(groupIfName)) return null; synchronized (mLock) { if (!checkSupplicantP2pIfaceAndLogFailure("startWpsPinDisplay")) return null; if (groupIfName == null) { diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java index 66bda1e64..9d063d247 100644 --- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java +++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java @@ -1334,11 +1334,10 @@ public class SupplicantStaIfaceHal { /** * Start WPS pin display operation with the specified peer. * - * @param bssidStr BSSID of the peer. + * @param bssidStr BSSID of the peer. Use empty bssid to indicate wildcard. * @return true if request is sent successfully, false otherwise. */ public boolean startWpsPbc(String bssidStr) { - if (TextUtils.isEmpty(bssidStr)) return false; return startWpsPbc(NativeUtil.macAddressToByteArray(bssidStr)); } @@ -1381,11 +1380,10 @@ public class SupplicantStaIfaceHal { /** * Start WPS pin display operation with the specified peer. * - * @param bssidStr BSSID of the peer. + * @param bssidStr BSSID of the peer. Use empty bssid to indicate wildcard. * @return new pin generated on success, null otherwise. */ public String startWpsPinDisplay(String bssidStr) { - if (TextUtils.isEmpty(bssidStr)) return null; return startWpsPinDisplay(NativeUtil.macAddressToByteArray(bssidStr)); } diff --git a/service/java/com/android/server/wifi/util/NativeUtil.java b/service/java/com/android/server/wifi/util/NativeUtil.java index 4abb0f4ea..50f32fa4d 100644 --- a/service/java/com/android/server/wifi/util/NativeUtil.java +++ b/service/java/com/android/server/wifi/util/NativeUtil.java @@ -16,6 +16,8 @@ package com.android.server.wifi.util; +import android.text.TextUtils; + import libcore.util.HexEncoding; import java.nio.ByteBuffer; @@ -102,14 +104,11 @@ public class NativeUtil { * * @param macStr string of format: "XX:XX:XX:XX:XX:XX" or "XXXXXXXXXXXX", where X is any * hexadecimal digit. - * Passing "any" is the same as 00:00:00:00:00:00 + * Passing null, empty string or "any" is the same as 00:00:00:00:00:00 * @throws IllegalArgumentException for various malformed inputs. */ public static byte[] macAddressToByteArray(String macStr) { - if (macStr == null) { - throw new IllegalArgumentException("null mac string"); - } - if (ANY_MAC_STR.equals(macStr)) return ANY_MAC_BYTES; + if (TextUtils.isEmpty(macStr) || ANY_MAC_STR.equals(macStr)) return ANY_MAC_BYTES; String cleanMac = macStr.replace(":", ""); if (cleanMac.length() != MAC_LENGTH * 2) { throw new IllegalArgumentException("invalid mac string length: " + cleanMac); |