autojoin fix for devices which are using the enableNEtwork API

Bug: 15000352

Change-Id: Ib8b5dfd517e48444913f0ad0e5d08749d6eaa757
diff --git a/framework/java/android/net/wifi/WifiConfiguration.java b/framework/java/android/net/wifi/WifiConfiguration.java
index f22e8a9..e73cce1 100644
--- a/framework/java/android/net/wifi/WifiConfiguration.java
+++ b/framework/java/android/net/wifi/WifiConfiguration.java
@@ -802,8 +802,28 @@
         return configKey(false);
     }
 
+    /** @hide
+     * return the config key string based on a scan result
+     */
+    static public String configKey(ScanResult result) {
+        String key = "\"" + result.SSID + "\"";
 
-        /** Implement the Parcelable interface {@hide} */
+        if (result.capabilities.contains("WEP")) {
+            key = key + "-WEP";
+        }
+
+        if (result.capabilities.contains("PSK")) {
+            key = key + "-" + KeyMgmt.strings[KeyMgmt.WPA_PSK];
+        }
+
+        if (result.capabilities.contains("EAP")) {
+            key = key + "-" + KeyMgmt.strings[KeyMgmt.WPA_EAP];
+        }
+
+        return key;
+    }
+
+    /** Implement the Parcelable interface {@hide} */
     public int describeContents() {
         return 0;
     }