Merge "Use getpwnam() instead of AID_* macros"
am: a124b81ac8

Change-Id: I14c697f537a83a8d99bed697a2fbba105c9cb2a3
diff --git a/hostapd/Android.mk b/hostapd/Android.mk
index b3deedd..d9c4b97 100644
--- a/hostapd/Android.mk
+++ b/hostapd/Android.mk
@@ -998,6 +998,7 @@
 include $(CLEAR_VARS)
 LOCAL_MODULE := hostapd_cli
 LOCAL_MODULE_TAGS := debug
+LOCAL_PROPRIETARY_MODULE := true
 LOCAL_SHARED_LIBRARIES := libc libcutils liblog
 LOCAL_CFLAGS := $(L_CFLAGS)
 LOCAL_SRC_FILES := $(OBJS_c)
@@ -1008,6 +1009,7 @@
 include $(CLEAR_VARS)
 LOCAL_MODULE := hostapd
 LOCAL_MODULE_TAGS := optional
+LOCAL_PROPRIETARY_MODULE := true
 ifdef CONFIG_DRIVER_CUSTOM
 LOCAL_STATIC_LIBRARIES := libCustomWifi
 endif
diff --git a/hostapd/CleanSpec.mk b/hostapd/CleanSpec.mk
new file mode 100644
index 0000000..653aebb
--- /dev/null
+++ b/hostapd/CleanSpec.mk
@@ -0,0 +1,52 @@
+# -*- mode: makefile -*-
+#  Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list.  These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+#     $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+#     $(call add-clean-step, rm -rf $(OUT_DIR)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list.  E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+#
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/obj/SHARED_LIBRARIES/libdvm*)
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/hostapd)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/hostapd_cli)
diff --git a/hostapd/hostapd.android.rc b/hostapd/hostapd.android.rc
index 0ae27ca..672e188 100644
--- a/hostapd/hostapd.android.rc
+++ b/hostapd/hostapd.android.rc
@@ -9,12 +9,12 @@
 on post-fs-data
     mkdir /data/misc/wifi/hostapd 0770 wifi wifi
 
-service hostapd /system/bin/hostapd \
+service hostapd /vendor/bin/hostapd \
         -e /data/misc/wifi/entropy.bin \
         /data/misc/wifi/hostapd.conf
     class main
     user wifi
-    group wifi
+    group wifi net_raw net_admin
     writepid /data/misc/wifi/hostapd.pid
     disabled
     oneshot
diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk
index 5bab1f1..867af85 100644
--- a/wpa_supplicant/Android.mk
+++ b/wpa_supplicant/Android.mk
@@ -1610,12 +1610,12 @@
 LOCAL_SHARED_LIBRARIES += $(LIB_SHARED_EAP_PROXY)
 endif
 ifeq ($(CONFIG_TLS), openssl)
-LOCAL_SHARED_LIBRARIES += libcrypto libssl libkeystore_binder
+LOCAL_SHARED_LIBRARIES += libcrypto libssl libkeystore-wifi-hidl
 endif
 
 # With BoringSSL we need libkeystore-engine in order to provide access to
 # keystore keys.
-LOCAL_SHARED_LIBRARIES += libkeystore-engine
+LOCAL_SHARED_LIBRARIES += libkeystore-engine-wifi-hidl
 
 ifdef CONFIG_DRIVER_NL80211
 ifneq ($(wildcard external/libnl),)
@@ -1681,20 +1681,23 @@
 LOCAL_CPPFLAGS := $(L_CPPFLAGS)
 LOCAL_CFLAGS := $(L_CFLAGS)
 LOCAL_C_INCLUDES := $(INCLUDES)
+HIDL_INTERFACE_VERSION = 1.0
 LOCAL_SRC_FILES := \
-    hidl/hidl.cpp \
-    hidl/hidl_manager.cpp \
-    hidl/iface_config_utils.cpp \
-    hidl/p2p_iface.cpp \
-    hidl/p2p_network.cpp \
-    hidl/sta_iface.cpp \
-    hidl/sta_network.cpp \
-    hidl/supplicant.cpp
+    hidl/$(HIDL_INTERFACE_VERSION)/hidl.cpp \
+    hidl/$(HIDL_INTERFACE_VERSION)/hidl_manager.cpp \
+    hidl/$(HIDL_INTERFACE_VERSION)/iface_config_utils.cpp \
+    hidl/$(HIDL_INTERFACE_VERSION)/p2p_iface.cpp \
+    hidl/$(HIDL_INTERFACE_VERSION)/p2p_network.cpp \
+    hidl/$(HIDL_INTERFACE_VERSION)/sta_iface.cpp \
+    hidl/$(HIDL_INTERFACE_VERSION)/sta_network.cpp \
+    hidl/$(HIDL_INTERFACE_VERSION)/supplicant.cpp
 LOCAL_SHARED_LIBRARIES := \
-    android.hardware.wifi.supplicant@1.0 \
+    android.hardware.wifi.supplicant@$(HIDL_INTERFACE_VERSION) \
     libhidlbase \
     libhidltransport \
     libhwbinder \
     libutils
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
+    $(LOCAL_PATH)/hidl/$(HIDL_INTERFACE_VERSION)
 include $(BUILD_STATIC_LIBRARY)
 endif # WPA_SUPPLICANT_USE_HIDL == y
diff --git a/wpa_supplicant/hidl/hidl.cpp b/wpa_supplicant/hidl/1.0/hidl.cpp
similarity index 97%
rename from wpa_supplicant/hidl/hidl.cpp
rename to wpa_supplicant/hidl/1.0/hidl.cpp
index 753c87b..e5f5303 100644
--- a/wpa_supplicant/hidl/hidl.cpp
+++ b/wpa_supplicant/hidl/1.0/hidl.cpp
@@ -370,7 +370,7 @@
     const struct p2p_peer_info *info, const u8 *peer_wfd_device_info,
     u8 peer_wfd_device_info_len)
 {
-	if (!wpa_s || !addr || !info || !peer_wfd_device_info)
+	if (!wpa_s || !addr || !info)
 		return;
 
 	wpa_printf(
@@ -474,9 +474,9 @@
 
 void wpas_hidl_notify_p2p_group_started(
     struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, int persistent,
-    int client, const u8 *ip)
+    int client)
 {
-	if (!wpa_s || !ssid || !ip)
+	if (!wpa_s || !ssid)
 		return;
 
 	wpa_printf(
@@ -487,8 +487,7 @@
 	if (!hidl_manager)
 		return;
 
-	hidl_manager->notifyP2pGroupStarted(
-	    wpa_s, ssid, persistent, client, ip);
+	hidl_manager->notifyP2pGroupStarted(wpa_s, ssid, persistent, client);
 }
 
 void wpas_hidl_notify_p2p_group_removed(
@@ -590,7 +589,7 @@
 void wpas_hidl_notify_ap_sta_authorized(
     struct wpa_supplicant *wpa_s, const u8 *sta, const u8 *p2p_dev_addr)
 {
-	if (!wpa_s || !sta || !p2p_dev_addr)
+	if (!wpa_s || !sta)
 		return;
 
 	wpa_printf(
@@ -608,7 +607,7 @@
 void wpas_hidl_notify_ap_sta_deauthorized(
     struct wpa_supplicant *wpa_s, const u8 *sta, const u8 *p2p_dev_addr)
 {
-	if (!wpa_s || !sta || !p2p_dev_addr)
+	if (!wpa_s || !sta)
 		return;
 
 	wpa_printf(
diff --git a/wpa_supplicant/hidl/hidl.h b/wpa_supplicant/hidl/1.0/hidl.h
similarity index 98%
rename from wpa_supplicant/hidl/hidl.h
rename to wpa_supplicant/hidl/1.0/hidl.h
index 9e2d650..96631f2 100644
--- a/wpa_supplicant/hidl/hidl.h
+++ b/wpa_supplicant/hidl/1.0/hidl.h
@@ -71,7 +71,7 @@
     struct wpa_supplicant *wpa_s, const char *reason);
 void wpas_hidl_notify_p2p_group_started(
     struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, int persistent,
-    int client, const u8 *ip);
+    int client);
 void wpas_hidl_notify_p2p_group_removed(
     struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid,
     const char *role);
@@ -177,7 +177,7 @@
 }
 static void wpas_hidl_notify_p2p_group_started(
     struct wpa_supplicant *wpa_s, const struct wpa_ssid *ssid, int persistent,
-    int client, const u8 *ip)
+    int client)
 {
 }
 static void wpas_hidl_notify_p2p_group_removed(
diff --git a/wpa_supplicant/hidl/hidl_constants.h b/wpa_supplicant/hidl/1.0/hidl_constants.h
similarity index 100%
rename from wpa_supplicant/hidl/hidl_constants.h
rename to wpa_supplicant/hidl/1.0/hidl_constants.h
diff --git a/wpa_supplicant/hidl/hidl_i.h b/wpa_supplicant/hidl/1.0/hidl_i.h
similarity index 100%
rename from wpa_supplicant/hidl/hidl_i.h
rename to wpa_supplicant/hidl/1.0/hidl_i.h
diff --git a/wpa_supplicant/hidl/hidl_manager.cpp b/wpa_supplicant/hidl/1.0/hidl_manager.cpp
similarity index 97%
rename from wpa_supplicant/hidl/hidl_manager.cpp
rename to wpa_supplicant/hidl/1.0/hidl_manager.cpp
index a6749e8..72b53a4 100644
--- a/wpa_supplicant/hidl/hidl_manager.cpp
+++ b/wpa_supplicant/hidl/1.0/hidl_manager.cpp
@@ -30,7 +30,7 @@
 constexpr size_t kGsmRandLenBytes = GSM_RAND_LEN;
 constexpr size_t kUmtsRandLenBytes = EAP_AKA_RAND_LEN;
 constexpr size_t kUmtsAutnLenBytes = EAP_AKA_AUTN_LEN;
-
+constexpr u8 kZeroBssid[6] = {0, 0, 0, 0, 0, 0};
 /**
  * Check if the provided |wpa_supplicant| structure represents a P2P iface or
  * not.
@@ -1058,17 +1058,24 @@
     const struct p2p_peer_info *info, const u8 *peer_wfd_device_info,
     u8 peer_wfd_device_info_len)
 {
-	if (!wpa_s || !addr || !info || !peer_wfd_device_info)
+	if (!wpa_s || !addr || !info)
 		return;
 
 	if (p2p_iface_object_map_.find(wpa_s->ifname) ==
 	    p2p_iface_object_map_.end())
 		return;
 
-	if (peer_wfd_device_info_len != kWfdDeviceInfoLen) {
-		wpa_printf(
-		    MSG_ERROR, "Unexpected WFD device info len: %d",
-		    peer_wfd_device_info_len);
+	std::array<uint8_t, kWfdDeviceInfoLen> hidl_peer_wfd_device_info{};
+	if (peer_wfd_device_info) {
+		if (peer_wfd_device_info_len != kWfdDeviceInfoLen) {
+			wpa_printf(
+			    MSG_ERROR, "Unexpected WFD device info len: %d",
+			    peer_wfd_device_info_len);
+		} else {
+			os_memcpy(
+			    hidl_peer_wfd_device_info.data(),
+			    peer_wfd_device_info, kWfdDeviceInfoLen);
+		}
 	}
 
 	callWithEachP2pIfaceCallback(
@@ -1077,7 +1084,7 @@
 		&ISupplicantP2pIfaceCallback::onDeviceFound,
 		std::placeholders::_1, addr, info->p2p_device_addr,
 		info->pri_dev_type, info->device_name, info->config_methods,
-		info->dev_capab, info->group_capab, peer_wfd_device_info));
+		info->dev_capab, info->group_capab, hidl_peer_wfd_device_info));
 }
 
 void HidlManager::notifyP2pDeviceLost(
@@ -1168,10 +1175,9 @@
 }
 
 void HidlManager::notifyP2pGroupStarted(
-    struct wpa_supplicant *wpa_group_s, const struct wpa_ssid *ssid,
-    int persistent, int client, const u8 *ip)
+    struct wpa_supplicant *wpa_group_s, const struct wpa_ssid *ssid, int persistent, int client)
 {
-	if (!wpa_group_s || !wpa_group_s->parent || !ssid || !ip)
+	if (!wpa_group_s || !wpa_group_s->parent || !ssid)
 		return;
 
 	// For group notifications, need to use the parent iface for callbacks.
@@ -1317,33 +1323,30 @@
 void HidlManager::notifyApStaAuthorized(
     struct wpa_supplicant *wpa_s, const u8 *sta, const u8 *p2p_dev_addr)
 {
-	if (!wpa_s || !sta || !p2p_dev_addr)
+	if (!wpa_s || !wpa_s->parent || !sta)
 		return;
-
-	if (p2p_iface_object_map_.find(wpa_s->ifname) ==
+	if (p2p_iface_object_map_.find(wpa_s->parent->ifname) ==
 	    p2p_iface_object_map_.end())
 		return;
-
 	callWithEachP2pIfaceCallback(
-	    wpa_s->ifname, std::bind(
+	    wpa_s->parent->ifname, std::bind(
 			       &ISupplicantP2pIfaceCallback::onStaAuthorized,
-			       std::placeholders::_1, sta, p2p_dev_addr));
+			       std::placeholders::_1, sta, p2p_dev_addr ? p2p_dev_addr : kZeroBssid));
 }
 
 void HidlManager::notifyApStaDeauthorized(
     struct wpa_supplicant *wpa_s, const u8 *sta, const u8 *p2p_dev_addr)
 {
-	if (!wpa_s || !sta || !p2p_dev_addr)
+	if (!wpa_s || !wpa_s->parent || !sta)
 		return;
-
-	if (p2p_iface_object_map_.find(wpa_s->ifname) ==
+	if (p2p_iface_object_map_.find(wpa_s->parent->ifname) ==
 	    p2p_iface_object_map_.end())
 		return;
 
 	callWithEachP2pIfaceCallback(
-	    wpa_s->ifname, std::bind(
+	    wpa_s->parent->ifname, std::bind(
 			       &ISupplicantP2pIfaceCallback::onStaDeauthorized,
-			       std::placeholders::_1, sta, p2p_dev_addr));
+			       std::placeholders::_1, sta, p2p_dev_addr ? p2p_dev_addr : kZeroBssid));
 }
 
 void HidlManager::notifyExtRadioWorkStart(
diff --git a/wpa_supplicant/hidl/hidl_manager.h b/wpa_supplicant/hidl/1.0/hidl_manager.h
similarity index 99%
rename from wpa_supplicant/hidl/hidl_manager.h
rename to wpa_supplicant/hidl/1.0/hidl_manager.h
index ada9324..9d9527c 100644
--- a/wpa_supplicant/hidl/hidl_manager.h
+++ b/wpa_supplicant/hidl/1.0/hidl_manager.h
@@ -99,7 +99,7 @@
 	    struct wpa_supplicant *wpa_s, const char *reason);
 	void notifyP2pGroupStarted(
 	    struct wpa_supplicant *wpa_group_s, const struct wpa_ssid *ssid,
-	    int persistent, int client, const u8 *ip);
+	    int persistent, int client);
 	void notifyP2pGroupRemoved(
 	    struct wpa_supplicant *wpa_group_s, const struct wpa_ssid *ssid,
 	    const char *role);
diff --git a/wpa_supplicant/hidl/hidl_return_util.h b/wpa_supplicant/hidl/1.0/hidl_return_util.h
similarity index 100%
rename from wpa_supplicant/hidl/hidl_return_util.h
rename to wpa_supplicant/hidl/1.0/hidl_return_util.h
diff --git a/wpa_supplicant/hidl/iface_config_utils.cpp b/wpa_supplicant/hidl/1.0/iface_config_utils.cpp
similarity index 97%
rename from wpa_supplicant/hidl/iface_config_utils.cpp
rename to wpa_supplicant/hidl/1.0/iface_config_utils.cpp
index b6bd3d8..7dc5a6c 100644
--- a/wpa_supplicant/hidl/iface_config_utils.cpp
+++ b/wpa_supplicant/hidl/1.0/iface_config_utils.cpp
@@ -62,7 +62,10 @@
 	      {WpsConfigMethods::P2PS, "p2ps"},
 	      {WpsConfigMethods::VIRT_DISPLAY, "virtual_display"},
 	      {WpsConfigMethods::PHY_DISPLAY, "physical_display"}}) {
-		if (config_methods & flag_and_name.first) {
+		const auto flag =
+		    static_cast<std::underlying_type<WpsConfigMethods>::type>(
+			flag_and_name.first);
+		if ((config_methods & flag) == flag) {
 			config_methods_str += flag_and_name.second;
 			config_methods_str += " ";
 		}
diff --git a/wpa_supplicant/hidl/iface_config_utils.h b/wpa_supplicant/hidl/1.0/iface_config_utils.h
similarity index 100%
rename from wpa_supplicant/hidl/iface_config_utils.h
rename to wpa_supplicant/hidl/1.0/iface_config_utils.h
diff --git a/wpa_supplicant/hidl/misc_utils.h b/wpa_supplicant/hidl/1.0/misc_utils.h
similarity index 100%
rename from wpa_supplicant/hidl/misc_utils.h
rename to wpa_supplicant/hidl/1.0/misc_utils.h
diff --git a/wpa_supplicant/hidl/p2p_iface.cpp b/wpa_supplicant/hidl/1.0/p2p_iface.cpp
similarity index 95%
rename from wpa_supplicant/hidl/p2p_iface.cpp
rename to wpa_supplicant/hidl/1.0/p2p_iface.cpp
index 195c6b9..ab4014d 100644
--- a/wpa_supplicant/hidl/p2p_iface.cpp
+++ b/wpa_supplicant/hidl/1.0/p2p_iface.cpp
@@ -2,6 +2,7 @@
  * hidl interface for wpa_supplicant daemon
  * Copyright (c) 2004-2016, Jouni Malinen <j@w1.fi>
  * Copyright (c) 2004-2016, Roshan Pius <rpius@google.com>
+ * Copyright (C) 2017 Sony Mobile Communications Inc.
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -14,6 +15,7 @@
 #include "p2p_iface.h"
 
 extern "C" {
+#include "ap.h"
 #include "wps_supplicant.h"
 #include "wifi_display.h"
 }
@@ -24,6 +26,7 @@
 const char kConfigMethodStrKeypad[] = "keypad";
 constexpr char kSetMiracastMode[] = "MIRACAST ";
 constexpr uint8_t kWfdDeviceInfoSubelemId = 0;
+constexpr char kWfdDeviceInfoSubelemLenHexStr[] = "0006";
 
 using android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIface;
 uint8_t convertHidlMiracastModeToInternal(
@@ -681,6 +684,7 @@
 	if (go_intent > 15) {
 		return {{SupplicantStatusCode::FAILURE_ARGS_INVALID, ""}, {}};
 	}
+	int go_intent_signed = join_existing_group ? -1 : go_intent;
 	p2p_wps_method wps_method = {};
 	switch (provision_method) {
 	case WpsProvisionMethod::PBC:
@@ -693,9 +697,10 @@
 		wps_method = WPS_PIN_KEYPAD;
 		break;
 	}
+	const char* pin = pre_selected_pin.length() > 0 ? pre_selected_pin.data() : nullptr;
 	int new_pin = wpas_p2p_connect(
-	    wpa_s, peer_address.data(), pre_selected_pin.data(), wps_method,
-	    persistent, false, join_existing_group, false, go_intent, 0, 0, -1,
+	    wpa_s, peer_address.data(), pin, wps_method,
+	    persistent, false, join_existing_group, false, go_intent_signed, 0, 0, -1,
 	    false, false, false, VHT_CHANWIDTH_USE_HT, nullptr, 0);
 	if (new_pin < 0) {
 		return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, {}};
@@ -856,21 +861,22 @@
 SupplicantStatus P2pIface::setDisallowedFrequenciesInternal(
     const std::vector<FreqRange>& ranges)
 {
-	if (ranges.size() == 0) {
-		return {SupplicantStatusCode::FAILURE_ARGS_INVALID, ""};
-	}
 	struct wpa_supplicant* wpa_s = retrieveIfacePtr();
 	using DestT = struct wpa_freq_range_list::wpa_freq_range;
-	DestT* freq_ranges =
-	    static_cast<DestT*>(os_malloc(sizeof(DestT) * ranges.size()));
-	if (!freq_ranges) {
-		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
-	}
-	uint32_t i = 0;
-	for (const auto& range : ranges) {
-		freq_ranges[i].min = range.min;
-		freq_ranges[i].max = range.max;
-		i++;
+	DestT* freq_ranges = nullptr;
+	// Empty ranges is used to enable all frequencies.
+	if (ranges.size() != 0) {
+		freq_ranges =
+		    static_cast<DestT*>(os_malloc(sizeof(DestT) * ranges.size()));
+		if (!freq_ranges) {
+			return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+		}
+		uint32_t i = 0;
+		for (const auto& range : ranges) {
+			freq_ranges[i].min = range.min;
+			freq_ranges[i].max = range.max;
+			i++;
+		}
 	}
 
 	os_free(wpa_s->global->p2p_disallow_freq.range);
@@ -983,8 +989,11 @@
 	if (!query_buf) {
 		return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, {}};
 	}
+	const uint8_t* dst_addr = is_zero_ether_addr(peer_address.data())
+				      ? nullptr
+				      : peer_address.data();
 	uint64_t identifier =
-	    wpas_p2p_sd_request(wpa_s, peer_address.data(), query_buf.get());
+	    wpas_p2p_sd_request(wpa_s, dst_addr, query_buf.get());
 	if (identifier == 0) {
 		return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, {}};
 	}
@@ -1028,6 +1037,14 @@
 	}
 	const uint8_t* bssid_addr =
 	    is_zero_ether_addr(bssid.data()) ? nullptr : bssid.data();
+#ifdef CONFIG_AP
+	if (wpa_group_s->ap_iface) {
+		if (wpa_supplicant_ap_wps_pbc(wpa_group_s, bssid_addr, NULL)) {
+			return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+		}
+		return {SupplicantStatusCode::SUCCESS, ""};
+	}
+#endif /* CONFIG_AP */
 	if (wpas_wps_start_pbc(wpa_group_s, bssid_addr, 0)) {
 		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
@@ -1042,6 +1059,15 @@
 	if (!wpa_group_s) {
 		return {SupplicantStatusCode::FAILURE_IFACE_UNKNOWN, ""};
 	}
+#ifdef CONFIG_AP
+	if (wpa_group_s->ap_iface) {
+		if (wpa_supplicant_ap_wps_pin(
+				wpa_group_s, nullptr, pin.c_str(), nullptr, 0, 0) < 0) {
+			return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+		}
+		return {SupplicantStatusCode::SUCCESS, ""};
+	}
+#endif /* CONFIG_AP */
 	if (wpas_wps_start_pin(
 		wpa_group_s, nullptr, pin.c_str(), 0, DEV_PW_DEFAULT)) {
 		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
@@ -1137,14 +1163,16 @@
     const std::array<uint8_t, 6>& info)
 {
 	struct wpa_supplicant* wpa_s = retrieveIfacePtr();
-	uint32_t wfd_device_info_hex_len = info.size() * 2 + 1;
-	std::vector<char> wfd_device_info_hex(wfd_device_info_hex_len);
+	std::vector<char> wfd_device_info_hex(info.size() * 2 + 1);
 	wpa_snprintf_hex(
 	    wfd_device_info_hex.data(), wfd_device_info_hex.size(), info.data(),
 	    info.size());
+	// |wifi_display_subelem_set| expects the first 2 bytes
+	// to hold the lenght of the subelement. In this case it's
+	// fixed to 6, so prepend that.
 	std::string wfd_device_info_set_cmd_str =
 	    std::to_string(kWfdDeviceInfoSubelemId) + " " +
-	    wfd_device_info_hex.data();
+	    kWfdDeviceInfoSubelemLenHexStr + wfd_device_info_hex.data();
 	std::vector<char> wfd_device_info_set_cmd(
 	    wfd_device_info_set_cmd_str.c_str(),
 	    wfd_device_info_set_cmd_str.c_str() +
diff --git a/wpa_supplicant/hidl/p2p_iface.h b/wpa_supplicant/hidl/1.0/p2p_iface.h
similarity index 100%
rename from wpa_supplicant/hidl/p2p_iface.h
rename to wpa_supplicant/hidl/1.0/p2p_iface.h
diff --git a/wpa_supplicant/hidl/p2p_network.cpp b/wpa_supplicant/hidl/1.0/p2p_network.cpp
similarity index 100%
rename from wpa_supplicant/hidl/p2p_network.cpp
rename to wpa_supplicant/hidl/1.0/p2p_network.cpp
diff --git a/wpa_supplicant/hidl/p2p_network.h b/wpa_supplicant/hidl/1.0/p2p_network.h
similarity index 100%
rename from wpa_supplicant/hidl/p2p_network.h
rename to wpa_supplicant/hidl/1.0/p2p_network.h
diff --git a/wpa_supplicant/hidl/sta_iface.cpp b/wpa_supplicant/hidl/1.0/sta_iface.cpp
similarity index 99%
rename from wpa_supplicant/hidl/sta_iface.cpp
rename to wpa_supplicant/hidl/1.0/sta_iface.cpp
index d3a430f..8498e69 100644
--- a/wpa_supplicant/hidl/sta_iface.cpp
+++ b/wpa_supplicant/hidl/1.0/sta_iface.cpp
@@ -638,7 +638,7 @@
 		ret = wpa_drv_tdls_oper(wpa_s, TDLS_DISCOVERY_REQ, peer);
 	}
 	if (ret) {
-		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+		wpa_printf(MSG_INFO, "StaIface: TDLS discover failed: %d", ret);
 	}
 	return {SupplicantStatusCode::SUCCESS, ""};
 }
@@ -657,7 +657,7 @@
 		ret = wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, peer);
 	}
 	if (ret) {
-		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+		wpa_printf(MSG_INFO, "StaIface: TDLS setup failed: %d", ret);
 	}
 	return {SupplicantStatusCode::SUCCESS, ""};
 }
@@ -676,7 +676,7 @@
 		ret = wpa_drv_tdls_oper(wpa_s, TDLS_TEARDOWN, peer);
 	}
 	if (ret) {
-		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+		wpa_printf(MSG_INFO, "StaIface: TDLS teardown failed: %d", ret);
 	}
 	return {SupplicantStatusCode::SUCCESS, ""};
 }
diff --git a/wpa_supplicant/hidl/sta_iface.h b/wpa_supplicant/hidl/1.0/sta_iface.h
similarity index 100%
rename from wpa_supplicant/hidl/sta_iface.h
rename to wpa_supplicant/hidl/1.0/sta_iface.h
diff --git a/wpa_supplicant/hidl/sta_network.cpp b/wpa_supplicant/hidl/1.0/sta_network.cpp
similarity index 99%
rename from wpa_supplicant/hidl/sta_network.cpp
rename to wpa_supplicant/hidl/1.0/sta_network.cpp
index a2d0126..72185b3 100644
--- a/wpa_supplicant/hidl/sta_network.cpp
+++ b/wpa_supplicant/hidl/1.0/sta_network.cpp
@@ -527,7 +527,7 @@
 {
 	return validateAndCall(
 	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
-	    &StaNetwork::getEapSubjectMatchInternal, _hidl_cb);
+	    &StaNetwork::getEapAltSubjectMatchInternal, _hidl_cb);
 }
 
 Return<void> StaNetwork::getEapEngine(getEapEngine_cb _hidl_cb)
diff --git a/wpa_supplicant/hidl/sta_network.h b/wpa_supplicant/hidl/1.0/sta_network.h
similarity index 100%
rename from wpa_supplicant/hidl/sta_network.h
rename to wpa_supplicant/hidl/1.0/sta_network.h
diff --git a/wpa_supplicant/hidl/supplicant.cpp b/wpa_supplicant/hidl/1.0/supplicant.cpp
similarity index 100%
rename from wpa_supplicant/hidl/supplicant.cpp
rename to wpa_supplicant/hidl/1.0/supplicant.cpp
diff --git a/wpa_supplicant/hidl/supplicant.h b/wpa_supplicant/hidl/1.0/supplicant.h
similarity index 100%
rename from wpa_supplicant/hidl/supplicant.h
rename to wpa_supplicant/hidl/1.0/supplicant.h
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index d7adaa0..9464c4b 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -23,7 +23,7 @@
 #include "p2p_supplicant.h"
 #include "sme.h"
 #include "notify.h"
-#include "hidl/hidl.h"
+#include "hidl.h"
 
 int wpas_notify_supplicant_initialized(struct wpa_global *global)
 {
@@ -364,6 +364,7 @@
 {
 #ifdef CONFIG_P2P
 	wpas_dbus_register_persistent_group(wpa_s, ssid);
+	wpas_hidl_register_network(wpa_s, ssid);
 #endif /* CONFIG_P2P */
 }
 
@@ -373,6 +374,7 @@
 {
 #ifdef CONFIG_P2P
 	wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
+	wpas_hidl_unregister_network(wpa_s, ssid);
 #endif /* CONFIG_P2P */
 }
 
@@ -735,7 +737,7 @@
 
 	wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
 
-	wpas_hidl_notify_p2p_group_started(wpa_s, ssid, persistent, client, ip);
+	wpas_hidl_notify_p2p_group_started(wpa_s, ssid, persistent, client);
 }
 
 
diff --git a/wpa_supplicant/wpa_supplicant_conf.mk b/wpa_supplicant/wpa_supplicant_conf.mk
index 74986ea..4293976 100644
--- a/wpa_supplicant/wpa_supplicant_conf.mk
+++ b/wpa_supplicant/wpa_supplicant_conf.mk
@@ -16,7 +16,7 @@
 LOCAL_MODULE := wpa_supplicant.conf
 LOCAL_MODULE_CLASS := ETC
 LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/wifi
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/wifi
 
 include $(BUILD_SYSTEM)/base_rules.mk