am 7bf0939e: am 7298e5ab: am 2f3c1638: (-s ours) am 89d125ec: (-s ours) Reconcile with jb-mr1-release - do not merge

* commit '7bf0939e106c975ac897b5d701e116b6c86ab75a':
diff --git a/Android.mk b/Android.mk
index 77d72ea..1fd458c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,3 +1,10 @@
+LOCAL_PATH:= $(call my-dir)
+
 ifeq ($(WPA_SUPPLICANT_VERSION),VER_0_8_X)
-    include $(call all-subdir-makefiles)
+# The order of the 2 Android.mks does matter!
+# TODO: Clean up the Android.mks, reset all the temporary variables at the
+# end of each Android.mk, so that one Android.mk doesn't depend on variables
+# set up in the other Android.mk.
+include $(LOCAL_PATH)/hostapd/Android.mk \
+        $(LOCAL_PATH)/wpa_supplicant/Android.mk
 endif
diff --git a/hostapd/Android.mk b/hostapd/Android.mk
index cea6aa1..4571002 100644
--- a/hostapd/Android.mk
+++ b/hostapd/Android.mk
@@ -53,7 +53,7 @@
 INCLUDES += $(LOCAL_PATH)/src
 INCLUDES += $(LOCAL_PATH)/src/utils
 INCLUDES += external/openssl/include
-INCLUDES += system/security/keystore
+INCLUDES += system/security/keystore/include
 ifdef CONFIG_DRIVER_NL80211
 INCLUDES += external/libnl-headers
 endif
diff --git a/src/crypto/tls_openssl.c b/src/crypto/tls_openssl.c
index dfb63ad..2bf47c7 100644
--- a/src/crypto/tls_openssl.c
+++ b/src/crypto/tls_openssl.c
@@ -24,11 +24,6 @@
 #include <openssl/engine.h>
 #endif /* OPENSSL_NO_ENGINE */
 
-#ifdef ANDROID
-#include <openssl/pem.h>
-#include "keystore_get.h"
-#endif /* ANDROID */
-
 #include "common.h"
 #include "crypto.h"
 #include "tls.h"
@@ -49,6 +44,23 @@
 #endif
 #endif
 
+#ifdef ANDROID
+#include <openssl/pem.h>
+#include <keystore/keystore_get.h>
+
+static BIO * BIO_from_keystore(const char *key)
+{
+    BIO *bio = NULL;
+    uint8_t *value = NULL;
+    int length = keystore_get(key, strlen(key), &value);
+    if (length != -1 && (bio = BIO_new(BIO_s_mem())) != NULL) {
+        BIO_write(bio, value, length);
+    }
+    free(value);
+    return bio;
+}
+#endif /* ANDROID */
+
 static int tls_openssl_ref_count = 0;
 
 struct tls_global {
@@ -1333,19 +1345,6 @@
 #endif /* OPENSSL_NO_STDIO */
 
 
-#ifdef ANDROID
-static BIO * BIO_from_keystore(const char *key)
-{
-	BIO *bio = NULL;
-	char value[KEYSTORE_MESSAGE_SIZE];
-	int length = keystore_get(key, strlen(key), value);
-	if (length != -1 && (bio = BIO_new(BIO_s_mem())) != NULL)
-		BIO_write(bio, value, length);
-	return bio;
-}
-#endif /* ANDROID */
-
-
 static int tls_connection_ca_cert(void *_ssl_ctx, struct tls_connection *conn,
 				  const char *ca_cert, const u8 *ca_cert_blob,
 				  size_t ca_cert_blob_len, const char *ca_path)
diff --git a/src/eap_peer/eap.c b/src/eap_peer/eap.c
index 2ed74b8..a4c9b25 100644
--- a/src/eap_peer/eap.c
+++ b/src/eap_peer/eap.c
@@ -348,6 +348,7 @@
 {
 	struct wpabuf *eapReqData;
 	struct eap_method_ret ret;
+	int min_len = 1;
 
 	SM_ENTRY(EAP, METHOD);
 	if (sm->m == NULL) {
@@ -356,7 +357,9 @@
 	}
 
 	eapReqData = eapol_get_eapReqData(sm);
-	if (!eap_hdr_len_valid(eapReqData, 1))
+	if (sm->m->vendor == EAP_VENDOR_IETF && sm->m->method == EAP_TYPE_LEAP)
+		min_len = 0; /* LEAP uses EAP-Success without payload */
+	if (!eap_hdr_len_valid(eapReqData, min_len))
 		return;
 
 	/*
diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c
index 23a93be..1e21fb7 100644
--- a/src/utils/os_unix.c
+++ b/src/utils/os_unix.c
@@ -11,7 +11,7 @@
 #include <time.h>
 
 #ifdef ANDROID
-#include <linux/capability.h>
+#include <sys/capability.h>
 #include <linux/prctl.h>
 #include <private/android_filesystem_config.h>
 #endif /* ANDROID */
diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk
index 9b787d1..33e4579 100644
--- a/wpa_supplicant/Android.mk
+++ b/wpa_supplicant/Android.mk
@@ -1520,7 +1520,7 @@
 endif
 LOCAL_SHARED_LIBRARIES := libc libcutils
 ifeq ($(CONFIG_TLS), openssl)
-LOCAL_SHARED_LIBRARIES += libcrypto libssl
+LOCAL_SHARED_LIBRARIES += libcrypto libssl libkeystore_binder
 endif
 ifdef CONFIG_DRIVER_NL80211
 LOCAL_STATIC_LIBRARIES += libnl_2