Merge "wifi: set TLS signature algorithm list param to the connection context"
diff --git a/hostapd/Android.bp b/hostapd/Android.bp
new file mode 100644
index 0000000..d7cc39b
--- /dev/null
+++ b/hostapd/Android.bp
@@ -0,0 +1,321 @@
+// Copyright (C) 2021 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.
+
+package {
+    default_applicable_licenses: [
+        "external_wpa_supplicant_8_license",
+        "external_wpa_supplicant_8_hostapd_license",
+    ],
+}
+
+license {
+    name: "external_wpa_supplicant_8_hostapd_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-BSD-3-Clause",
+        "SPDX-license-identifier-ISC",
+        "legacy_unencumbered",
+    ],
+}
+
+cc_library_headers {
+    name: "hostapd_headers",
+    export_include_dirs: [
+        ".",
+        "src",
+        "src/utils",
+    ],
+    soc_specific: true,
+}
+
+
+cc_defaults {
+    name: "hostapd_defaults",
+    defaults: ["hostapd_cflags_defaults"],
+    srcs: [":hostapd_srcs"],
+    shared_libs: [
+        "android.hardware.wifi.hostapd-V1-ndk",
+        "libbase",
+        "libutils",
+        "libbinder_ndk",
+        "libc",
+        "libcutils",
+        "liblog",
+        "libcrypto",
+        "libssl",
+        "libnl",
+        "libkeystore-wifi-hidl",
+    ],
+    relative_install_path: "hw",
+    soc_specific: true,
+    static_libs: [
+        "libhostapd_aidl_bp",
+    ],
+    header_libs: [
+        "hostapd_headers",
+        "libhostapd_aidl_headers",
+    ],
+}
+
+soong_config_module_type {
+    name: "hostapd_cflags_cc_defaults",
+    module_type: "cc_defaults",
+    config_namespace: "hostapd",
+    value_variables: [
+        "platform_version",
+        "nl80211_driver",
+    ],
+    properties: ["cflags"],
+}
+
+hostapd_cflags_cc_defaults {
+    name: "hostapd_cflags_defaults",
+    soong_config_variables: {
+        // Devices that include this module should set these soong config vars appropriately.
+        // For example:
+        //   $(call add_soong_config_namespace, wpa_supplicant)
+        //   $(call add_soong_config_var_value, wpa_supplicant, platform_version, $(PLATFORM_VERSION))
+        //   $(call add_soong_config_var_value, wpa_supplicant, nl80211_driver, CONFIG_DRIVER_NL80211_QCA)
+        platform_version: {
+            cflags: ["-DVERSION_STR_POSTFIX=\"-%s\""],
+            conditions_default: {
+                // Default value
+                cflags: ["-DVERSION_STR_POSTFIX=\"-Android\""],
+            },
+        },
+        nl80211_driver: {
+            cflags: ["-D%s"],
+            // Flag is optional, so no default value provided.
+        },
+    },
+    // Generated by building hostapd and printing LOCAL_CFLAGS.
+    cflags: [
+        "-DWPA_IGNORE_CONFIG_ERRORS",
+        "-DANDROID_LOG_NAME=\"hostapd\"",
+        "-DANDROID_P2P",
+        "-DCONFIG_CTRL_IFACE_CLIENT_DIR=\"/data/vendor/wifi/hostapd/sockets\"",
+        "-DCONFIG_CTRL_IFACE_DIR=\"/data/vendor/wifi/hostapd/ctrl\"",
+        "-DCONFIG_HOSTAPD_CLI_HISTORY_DIR=\"/data/vendor/wifi/hostapd\"",
+        "-DHOSTAPD",
+        "-DHOSTAPD_DUMP_STATE",
+        "-DCONFIG_NO_RADIUS",
+        "-DCONFIG_NO_ACCOUNTING",
+        "-DCONFIG_CTRL_IFACE",
+        "-DCONFIG_CTRL_IFACE_UNIX",
+        "-DCONFIG_SUITEB",
+        "-DCONFIG_SUITEB192",
+        "-DCONFIG_IEEE80211R",
+        "-DCONFIG_IEEE80211R_AP",
+        "-DCONFIG_ETH_P_OUI",
+        "-DCONFIG_SAE",
+        "-DCONFIG_SAE_PK",
+        "-DCONFIG_OWE",
+        "-DCONFIG_FILS",
+        "-DCONFIG_WNM",
+        "-DCONFIG_WNM_AP",
+        "-DCONFIG_IEEE80211AC",
+        "-DCONFIG_MBO",
+        "-DCONFIG_WEP",
+        "-DCONFIG_DRIVER_NL80211",
+        "-DEAP_SERVER_MD5",
+        "-DEAP_SERVER_TLS",
+        "-DEAP_SERVER_PEAP",
+        "-DEAP_SERVER_TTLS",
+        "-DEAP_SERVER_MSCHAPV2",
+        "-DEAP_SERVER_GTC",
+        "-DEAP_SERVER_SIM",
+        "-DEAP_SERVER_AKA",
+        "-DEAP_SERVER_AKA_PRIME",
+        "-DEAP_SERVER_PWD",
+        "-DCONFIG_WPS",
+        "-DEAP_SERVER_WSC",
+        "-DCONFIG_WPS_NFC",
+        "-DCONFIG_WPS_OOB",
+        "-DCONFIG_DPP",
+        "-DCONFIG_DPP2",
+        "-DEAP_SERVER_IDENTITY",
+        "-DEAP_SERVER",
+        "-DPKCS12_FUNCS",
+        "-DEAP_TLS_FUNCS",
+        "-DTLS_DEFAULT_CIPHERS=\"DEFAULT:!EXP:!LOW\"",
+        "-DCONFIG_SHA256",
+        "-DCONFIG_SHA384",
+        "-DCONFIG_SHA512",
+        "-DCONFIG_ECC",
+        "-DCONFIG_NO_RANDOM_POOL",
+        "-DCONFIG_IPV6",
+        "-DCONFIG_JSON",
+        "-DNEED_AP_MLME",
+        "-DCONFIG_HS20",
+        "-DCONFIG_INTERWORKING",
+        "-DCONFIG_PROXYARP",
+        "-DCONFIG_ACS",
+        "-DCONFIG_ANDROID_LOG",
+        "-DCONFIG_CTRL_IFACE_AIDL",
+        "-Wall",
+        "-Werror",
+        "-Wno-unused-parameter",
+        "-Wno-unused-variable",
+        "-Wno-macro-redefined",
+    ],
+}
+
+
+// Generated by building hostapd and printing LOCAL_SRC_FILES.
+filegroup {
+    name: "hostapd_srcs",
+    srcs: [
+        "main.c",
+        "config_file.c",
+        "ctrl_iface.c",
+        "eap_register.c",
+        "src/ap/hostapd.c",
+        "src/ap/wpa_auth_glue.c",
+        "src/ap/drv_callbacks.c",
+        "src/ap/ap_drv_ops.c",
+        "src/ap/utils.c",
+        "src/ap/authsrv.c",
+        "src/ap/ieee802_1x.c",
+        "src/ap/ap_config.c",
+        "src/ap/eap_user_db.c",
+        "src/ap/ieee802_11_auth.c",
+        "src/ap/sta_info.c",
+        "src/ap/wpa_auth.c",
+        "src/ap/tkip_countermeasures.c",
+        "src/ap/ap_mlme.c",
+        "src/ap/wpa_auth_ie.c",
+        "src/ap/preauth_auth.c",
+        "src/ap/pmksa_cache_auth.c",
+        "src/ap/ieee802_11_shared.c",
+        "src/ap/beacon.c",
+        "src/ap/bss_load.c",
+        "src/ap/neighbor_db.c",
+        "src/ap/rrm.c",
+        "src/drivers/drivers.c",
+        "src/utils/eloop.c",
+        "src/utils/common.c",
+        "src/utils/wpa_debug.c",
+        "src/utils/wpabuf.c",
+        "src/utils/os_unix.c",
+        "src/utils/ip_addr.c",
+        "src/utils/crc32.c",
+        "src/common/ieee802_11_common.c",
+        "src/common/wpa_common.c",
+        "src/common/hw_features_common.c",
+        "src/eapol_auth/eapol_auth_sm.c",
+        "src/eapol_auth/eapol_auth_dump.c",
+        "src/ap/vlan_init.c",
+        "src/ap/vlan_ifconfig.c",
+        "src/ap/vlan.c",
+        "src/common/ctrl_iface_common.c",
+        "src/ap/ctrl_iface_ap.c",
+        "src/ap/wpa_auth_ft.c",
+        "src/ap/eth_p_oui.c",
+        "src/common/sae.c",
+        "src/common/sae_pk.c",
+        "src/ap/fils_hlp.c",
+        "src/ap/wnm_ap.c",
+        "src/ap/mbo_ap.c",
+        "src/drivers/driver_nl80211.c",
+        "src/drivers/driver_nl80211_android.c",
+        "src/drivers/driver_nl80211_capa.c",
+        "src/drivers/driver_nl80211_event.c",
+        "src/drivers/driver_nl80211_monitor.c",
+        "src/drivers/driver_nl80211_scan.c",
+        "src/drivers/netlink.c",
+        "src/drivers/rfkill.c",
+        "src/utils/radiotap.c",
+        "src/drivers/linux_ioctl.c",
+        "src/l2_packet/l2_packet_linux.c",
+        "src/eap_server/eap_server_md5.c",
+        "src/eap_server/eap_server_tls.c",
+        "src/eap_server/eap_server_peap.c",
+        "src/eap_common/eap_peap_common.c",
+        "src/eap_server/eap_server_ttls.c",
+        "src/eap_server/eap_server_mschapv2.c",
+        "src/eap_server/eap_server_gtc.c",
+        "src/eap_server/eap_server_sim.c",
+        "src/eap_server/eap_server_aka.c",
+        "src/eap_common/eap_sim_common.c",
+        "src/eap_server/eap_sim_db.c",
+        "src/eap_server/eap_server_pwd.c",
+        "src/eap_common/eap_pwd_common.c",
+        "src/utils/uuid.c",
+        "src/ap/wps_hostapd.c",
+        "src/eap_server/eap_server_wsc.c",
+        "src/eap_common/eap_wsc_common.c",
+        "src/wps/wps.c",
+        "src/wps/wps_common.c",
+        "src/wps/wps_attr_parse.c",
+        "src/wps/wps_attr_build.c",
+        "src/wps/wps_attr_process.c",
+        "src/wps/wps_dev_attr.c",
+        "src/wps/wps_enrollee.c",
+        "src/wps/wps_registrar.c",
+        "src/wps/ndef.c",
+        "src/common/dpp.c",
+        "src/common/dpp_auth.c",
+        "src/common/dpp_backup.c",
+        "src/common/dpp_crypto.c",
+        "src/common/dpp_pkex.c",
+        "src/common/dpp_reconfig.c",
+        "src/common/dpp_tcp.c",
+        "src/ap/dpp_hostapd.c",
+        "src/ap/gas_query_ap.c",
+        "src/eap_server/eap_server.c",
+        "src/eap_common/eap_common.c",
+        "src/eap_server/eap_server_methods.c",
+        "src/eap_server/eap_server_identity.c",
+        "src/common/dragonfly.c",
+        "src/crypto/ms_funcs.c",
+        "src/eap_common/chap.c",
+        "src/eap_server/eap_server_tls_common.c",
+        "src/crypto/tls_openssl.c",
+        "src/crypto/tls_openssl_ocsp.c",
+        "src/crypto/crypto_openssl.c",
+        "src/crypto/fips_prf_openssl.c",
+        "src/crypto/aes-siv.c",
+        "src/crypto/aes-ctr.c",
+        "src/crypto/aes-omac1.c",
+        "src/crypto/sha1-prf.c",
+        "src/crypto/sha1-tlsprf.c",
+        "src/crypto/sha256-prf.c",
+        "src/crypto/sha256-tlsprf.c",
+        "src/crypto/sha256-kdf.c",
+        "src/crypto/sha384-kdf.c",
+        "src/crypto/sha512-kdf.c",
+        "src/crypto/sha384-prf.c",
+        "src/crypto/sha512-prf.c",
+        "src/tls/asn1.c",
+        "src/crypto/dh_groups.c",
+        "src/utils/base64.c",
+        "src/utils/json.c",
+        "src/ap/wmm.c",
+        "src/ap/ap_list.c",
+        "src/ap/ieee802_11.c",
+        "src/ap/hw_features.c",
+        "src/ap/dfs.c",
+        "src/ap/ieee802_11_ht.c",
+        "src/ap/ieee802_11_vht.c",
+        "src/ap/hs20.c",
+        "src/common/gas.c",
+        "src/ap/gas_serv.c",
+        "src/ap/x_snoop.c",
+        "src/ap/dhcp_snoop.c",
+        "src/ap/ndisc_snoop.c",
+        "src/drivers/driver_common.c",
+        "src/ap/acs.c",
+    ],
+
+}
diff --git a/hostapd/aidl/Android.bp b/hostapd/aidl/Android.bp
new file mode 100644
index 0000000..3cbccee
--- /dev/null
+++ b/hostapd/aidl/Android.bp
@@ -0,0 +1,48 @@
+// Copyright (C) 2021 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.
+
+package {
+    default_applicable_licenses: [
+        "external_wpa_supplicant_8_license",
+        "external_wpa_supplicant_8_hostapd_license",
+    ],
+}
+
+cc_library_headers {
+    name: "libhostapd_aidl_headers",
+    export_include_dirs: ["."],
+    soc_specific: true,
+}
+
+cc_library_static {
+    name: "libhostapd_aidl_bp",
+    srcs: ["*.cpp"],
+    defaults: ["hostapd_cflags_defaults"],
+    soc_specific: true,
+    shared_libs: [
+        "android.hardware.wifi.hostapd-V1-ndk",
+        "libbinder_ndk",
+        "libbase",
+        "libutils",
+        "liblog",
+    ],
+    cppflags: [
+        "-Wall",
+        "-Werror",
+    ],
+    header_libs: [
+        "hostapd_headers",
+        "libhostapd_aidl_headers",
+    ],
+}
diff --git a/wpa_supplicant/Android.bp b/wpa_supplicant/Android.bp
index eefce6e..a5cb2bb 100644
--- a/wpa_supplicant/Android.bp
+++ b/wpa_supplicant/Android.bp
@@ -135,7 +135,7 @@
         "-DCONFIG_FILS",
         "-DCONFIG_GAS",
         "-DCONFIG_GAS_SERVER",
-        "-DCONFIG_HIDL",
+        "-DCONFIG_AIDL",
         "-DCONFIG_HMAC_SHA256_KDF",
         "-DCONFIG_HMAC_SHA384_KDF",
         "-DCONFIG_HMAC_SHA512_KDF",
diff --git a/wpa_supplicant/aidl/aidl.cpp b/wpa_supplicant/aidl/aidl.cpp
index f3f04a3..f078e71 100644
--- a/wpa_supplicant/aidl/aidl.cpp
+++ b/wpa_supplicant/aidl/aidl.cpp
@@ -921,3 +921,43 @@
 
 	aidl_manager->notifyNetworkNotFound(wpa_s);
 }
+
+void wpas_aidl_notify_bss_freq_changed(struct wpa_supplicant *wpa_s)
+{
+	if (!wpa_s)
+		return;
+
+	AidlManager *aidl_manager = AidlManager::getInstance();
+	if (!aidl_manager)
+		return;
+
+	wpa_printf(MSG_DEBUG, "Notify %s frequency changed to %d",
+	    wpa_s->ifname, wpa_s->assoc_freq);
+
+	aidl_manager->notifyBssFreqChanged(wpa_s);
+}
+
+void wpas_aidl_notify_ceritification(struct wpa_supplicant *wpa_s,
+		int depth, const char *subject,
+		const char *altsubject[],
+		int num_altsubject,
+		const char *cert_hash,
+		const struct wpabuf *cert)
+{
+	if (!wpa_s)
+		return;
+
+	AidlManager *aidl_manager = AidlManager::getInstance();
+	if (!aidl_manager)
+		return;
+
+	wpa_printf(MSG_DEBUG, "Notify certification");
+
+	aidl_manager->notifyCertification(wpa_s,
+			depth,
+			subject,
+			altsubject,
+			num_altsubject,
+			cert_hash,
+			cert);
+}
diff --git a/wpa_supplicant/aidl/aidl.h b/wpa_supplicant/aidl/aidl.h
index 899f99cd..71275e3 100644
--- a/wpa_supplicant/aidl/aidl.h
+++ b/wpa_supplicant/aidl/aidl.h
@@ -126,6 +126,13 @@
 	void wpas_aidl_notify_transition_disable(
 		struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, u8 bitmap);
 	void wpas_aidl_notify_network_not_found(struct wpa_supplicant *wpa_s);
+	void wpas_aidl_notify_bss_freq_changed(struct wpa_supplicant *wpa_s);
+	void wpas_aidl_notify_ceritification(struct wpa_supplicant *wpa_s,
+		int depth, const char *subject,
+		const char *altsubject[],
+		int num_altsubject,
+		const char *cert_hash,
+		const struct wpabuf *cert);
 #else   // CONFIG_CTRL_IFACE_AIDL
 static inline int wpas_aidl_register_interface(struct wpa_supplicant *wpa_s)
 {
@@ -277,6 +284,15 @@
 {}
 static void wpas_aidl_notify_network_not_found(struct wpa_supplicant *wpa_s)
 {}
+void wpas_aidl_notify_bss_freq_changed(struct wpa_supplicant *wpa_s)
+{}
+void wpas_aidl_notify_ceritification(struct wpa_supplicant *wpa_s,
+	int depth, const char *subject,
+	const char *altsubject[],
+	int num_altsubject,
+	const char *cert_hash,
+	const struct wpabuf *cert)
+{}
 #endif  // CONFIG_CTRL_IFACE_AIDL
 
 #ifdef _cplusplus
diff --git a/wpa_supplicant/aidl/aidl_manager.cpp b/wpa_supplicant/aidl/aidl_manager.cpp
index 1ce9326..780ee92 100644
--- a/wpa_supplicant/aidl/aidl_manager.cpp
+++ b/wpa_supplicant/aidl/aidl_manager.cpp
@@ -1892,6 +1892,75 @@
 	callWithEachStaIfaceCallback(misc_utils::charBufToString(wpa_s->ifname), func);
 }
 
+void AidlManager::notifyBssFreqChanged(struct wpa_supplicant *wpa_group_s)
+{
+	if (!wpa_group_s || !wpa_group_s->parent)
+		return;
+
+	// For group notifications, need to use the parent iface for callbacks.
+	struct wpa_supplicant *wpa_s = getTargetP2pIfaceForGroup(wpa_group_s);
+	if (!wpa_s) {
+		wpa_printf(MSG_INFO, "Drop BSS frequency changed event");
+		return;
+	}
+
+	uint32_t aidl_freq = wpa_group_s->current_bss
+				? wpa_group_s->current_bss->freq
+				: wpa_group_s->assoc_freq;
+
+	const std::function<
+		ndk::ScopedAStatus(std::shared_ptr<ISupplicantP2pIfaceCallback>)>
+		func = std::bind(&ISupplicantP2pIfaceCallback::onGroupFrequencyChanged,
+		std::placeholders::_1, misc_utils::charBufToString(wpa_group_s->ifname), aidl_freq);
+	callWithEachP2pIfaceCallback(misc_utils::charBufToString(wpa_s->ifname), func);
+}
+
+void AidlManager::notifyCertification(struct wpa_supplicant *wpa_s,
+		int depth, const char *subject,
+		const char *altsubject[],
+		int num_altsubject,
+		const char *cert_hash,
+		const struct wpabuf *cert)
+{
+	if (!wpa_s->current_ssid) {
+		wpa_printf(MSG_ERROR, "Current network NULL. Drop Certification event!");
+		return;
+	}
+	struct wpa_ssid *current_ssid = wpa_s->current_ssid;
+	if (NULL == subject || NULL == cert_hash || NULL == cert) {
+		wpa_printf(MSG_ERROR,
+				"Incomplete certificate information. Drop Certification event!");
+		return;
+	}
+	if (!wpa_key_mgmt_wpa_ieee8021x(current_ssid->key_mgmt)) {
+		wpa_printf(MSG_ERROR, "Not 802.1x configuration, Drop Certification event!");
+		return;
+	}
+	if (current_ssid->eap.cert.ca_path || current_ssid->eap.cert.ca_cert) {
+		wpa_printf(MSG_DEBUG, "Already has CA certificate. Drop Certification event!");
+		return;
+	}
+
+	wpa_printf(MSG_DEBUG, "notifyCertification: depth=%d subject=%s hash=%s cert-size=%zu",
+			depth, subject, cert_hash, cert->used);
+	std::vector<uint8_t> subjectBlob(subject, subject + strlen(subject));
+	std::vector<uint8_t> certHashBlob(cert_hash, cert_hash + strlen(cert_hash));
+	std::vector<uint8_t> certBlob(cert->buf, cert->buf + cert->used);
+
+	const std::function<
+		ndk::ScopedAStatus(std::shared_ptr<ISupplicantStaNetworkCallback>)>
+		func = std::bind(
+		&ISupplicantStaNetworkCallback::onServerCertificateAvailable,
+		std::placeholders::_1,
+		depth,
+		subjectBlob,
+		certHashBlob,
+		certBlob);
+
+	callWithEachStaNetworkCallback(
+		misc_utils::charBufToString(wpa_s->ifname), current_ssid->id, func);
+}
+
 /**
  * Retrieve the |ISupplicantP2pIface| aidl object reference using the provided
  * ifname.
diff --git a/wpa_supplicant/aidl/aidl_manager.h b/wpa_supplicant/aidl/aidl_manager.h
index b538e36..babb2cc 100644
--- a/wpa_supplicant/aidl/aidl_manager.h
+++ b/wpa_supplicant/aidl/aidl_manager.h
@@ -143,6 +143,13 @@
 			struct wpa_ssid *ssid,
 			u8 bitmap);
 	void notifyNetworkNotFound(struct wpa_supplicant *wpa_s);
+	void notifyBssFreqChanged(struct wpa_supplicant *wpa_s);
+	void notifyCertification(struct wpa_supplicant *wpa_s,
+			int depth, const char *subject,
+			const char *altsubject[],
+			int num_altsubject,
+			const char *cert_hash,
+			const struct wpabuf *cert);
 
 	// Methods called from aidl objects.
 	void notifyExtRadioWorkStart(struct wpa_supplicant *wpa_s, uint32_t id);
diff --git a/wpa_supplicant/aidl/p2p_iface.cpp b/wpa_supplicant/aidl/p2p_iface.cpp
index 42b57e9..8dcaad5 100644
--- a/wpa_supplicant/aidl/p2p_iface.cpp
+++ b/wpa_supplicant/aidl/p2p_iface.cpp
@@ -1900,7 +1900,7 @@
 
 		wpa_printf(MSG_ERROR, "P2P: Failed to find the group with "
 			"network name %s - stop join attempt",
-			ssid.data());
+			wpa_ssid_txt(ssid.data(), ssid.size()));
 		notifyGroupJoinFailure(wpa_s);
 		pending_scan_res_join_callback = NULL;
 	};
diff --git a/wpa_supplicant/aidl/sta_iface.cpp b/wpa_supplicant/aidl/sta_iface.cpp
index 7238267..abde780 100644
--- a/wpa_supplicant/aidl/sta_iface.cpp
+++ b/wpa_supplicant/aidl/sta_iface.cpp
@@ -1688,6 +1688,8 @@
 #endif
 	mask |= static_cast<uint32_t>(WpaDriverCapabilitiesMask::WFD_R2);
 
+	mask |= static_cast<uint32_t>(WpaDriverCapabilitiesMask::TRUST_ON_FIRST_USE);
+
 	wpa_printf(MSG_DEBUG, "Driver capability mask: 0x%x", mask);
 
 	return {static_cast<WpaDriverCapabilitiesMask>(mask),
diff --git a/wpa_supplicant/aidl/sta_network.cpp b/wpa_supplicant/aidl/sta_network.cpp
index b6294da..b59d103 100644
--- a/wpa_supplicant/aidl/sta_network.cpp
+++ b/wpa_supplicant/aidl/sta_network.cpp
@@ -2071,6 +2071,15 @@
 	ss.write((char *) serializedEntry.data(), std::streamsize(serializedEntry.size()));
 	misc_utils::deserializePmkCacheEntry(ss, new_entry);
 	new_entry->network_ctx = wpa_ssid;
+
+	// If there is an entry has a later expiration, ignore this one.
+	struct rsn_pmksa_cache_entry *existing_entry = wpa_sm_pmksa_cache_get(
+		wpa_s->wpa, new_entry->aa, NULL, NULL, new_entry->akmp);
+	if (NULL != existing_entry &&
+		existing_entry->expiration >= new_entry->expiration) {
+		return ndk::ScopedAStatus::ok();
+	}
+
 	wpa_sm_pmksa_cache_add_entry(wpa_s->wpa, new_entry);
 
 	return ndk::ScopedAStatus::ok();
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index b3cb287..aaa2269 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -467,6 +467,8 @@
 		return;
 
 	wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
+
+	wpas_aidl_notify_bss_freq_changed(wpa_s);
 }
 
 
@@ -904,6 +906,10 @@
 		wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
 			"depth=%d %s", cert->depth, cert->altsubject[i]);
 
+	wpas_aidl_notify_ceritification(wpa_s, cert->depth, cert->subject,
+				       cert->altsubject, cert->num_altsubject,
+				       cert_hash, cert->cert);
+
 	/* notify the new DBus API */
 	wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
 				       cert->altsubject, cert->num_altsubject,
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index c68e515..bc55161 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -1405,11 +1405,13 @@
 			persistent = ssid->p2p_persistent_group;
 			os_memcpy(go_dev_addr, wpa_s->global->p2p_dev_addr,
 				  ETH_ALEN);
-		} else
+		} else {
+			os_memset(go_dev_addr, 0, ETH_ALEN);
 			persistent = wpas_p2p_persistent_group(wpa_s,
 							       go_dev_addr,
 							       ssid->ssid,
 							       ssid->ssid_len);
+		}
 	} else {
 		client = wpa_s->p2p_group_interface ==
 			P2P_GROUP_INTERFACE_CLIENT;