From 10652a95b16909acf26f31cdafc0c6aa09212f26 Mon Sep 17 00:00:00 2001 From: Vinit Deshapnde Date: Mon, 9 Sep 2013 16:24:36 -0700 Subject: Fix invalid Wifi Network system crash There is some validation code that is eventually detecting that we have an invalid network; only the result is a crash. The right thing to do is to do validation up front; and fail calls if the network configuration looks invalid. Bug: 10571289 Change-Id: I100506b777a34b26ac9a310ba508140560f87a90 --- wifi/java/android/net/wifi/WifiConfiguration.java | 14 ++++++++++++++ wifi/java/android/net/wifi/WifiManager.java | 7 +++++++ 2 files changed, 21 insertions(+) (limited to 'wifi') diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index de377ee..2ce584b 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -348,6 +348,20 @@ public class WifiConfiguration implements Parcelable { linkProperties = new LinkProperties(); } + /** + * indicates whether the configuration is valid + * @return true if valid, false otherwise + * @hide + */ + public boolean isValid() { + if (allowedKeyManagement.cardinality() > 1) { + return false; + } + + // TODO: Add more checks + return true; + } + @Override public String toString() { StringBuilder sbuf = new StringBuilder(); diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 5f5d54f..d6d0b8c 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -1366,6 +1366,13 @@ public class WifiManager { /** WPS timed out {@hide} */ public static final int WPS_TIMED_OUT = 7; + /** + * Passed with {@link ActionListener#onFailure}. + * Indicates that the operation failed due to invalid inputs + * @hide + */ + public static final int INVALID_ARGS = 8; + /** Interface for callback invocation on an application action {@hide} */ public interface ActionListener { /** The operation succeeded */ -- cgit v1.1