diff --git a/wpa_supplicant/hidl/hidl_manager.cpp b/wpa_supplicant/hidl/hidl_manager.cpp
index c5705d1..90a0c22 100644
--- a/wpa_supplicant/hidl/hidl_manager.cpp
+++ b/wpa_supplicant/hidl/hidl_manager.cpp
@@ -91,9 +91,11 @@
     std::map<const std::string, android::sp<ObjectType>> &object_map)
 {
 	// Return failure if we dont have an object for that |key|.
-	if (object_map.find(key) == object_map.end())
+	const auto &object_iter = object_map.find(key);
+	if (object_iter == object_map.end())
 		return 1;
-	object_map.erase(key);
+	object_iter->second->invalidate();
+	object_map.erase(object_iter);
 	return 0;
 }
 
diff --git a/wpa_supplicant/hidl/hidl_return_macros.h b/wpa_supplicant/hidl/hidl_return_macros.h
deleted file mode 100644
index 25e8f49..0000000
--- a/wpa_supplicant/hidl/hidl_return_macros.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * hidl interface for wpa_supplicant daemon
- * Copyright (c) 2004-2016, Jouni Malinen <j@w1.fi>
- * Copyright (c) 2004-2016, Roshan Pius <rpius@google.com>
- *
- * This software may be distributed under the terms of the BSD license.
- * See README for more details.
- */
-
-// Macros to invoke the _hidl_cb to return status along with any return values.
-#define HIDL_RETURN(status_code, ...)                         \
-	do {                                                  \
-		SupplicantStatus status{.code = status_code}; \
-		_hidl_cb(status, ##__VA_ARGS__);              \
-		return Void();                                \
-	} while (false)
diff --git a/wpa_supplicant/hidl/hidl_return_util.h b/wpa_supplicant/hidl/hidl_return_util.h
new file mode 100644
index 0000000..c077fc8
--- /dev/null
+++ b/wpa_supplicant/hidl/hidl_return_util.h
@@ -0,0 +1,101 @@
+/*
+ * hidl interface for wpa_supplicant daemon
+ * Copyright (c) 2004-2016, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2016, Roshan Pius <rpius@google.com>
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+#ifndef HIDL_RETURN_UTIL_H_
+#define HIDL_RETURN_UTIL_H_
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace supplicant {
+namespace V1_0 {
+namespace implementation {
+namespace hidl_return_util {
+
+/**
+ * These utility functions are used to invoke a method on the provided
+ * HIDL interface object.
+ * These functions checks if the provided HIDL interface object is valid.
+ * a) if valid, Invokes the corresponding internal implementation function of
+ * the HIDL method. It then invokes the HIDL continuation callback with
+ * the status and any returned values.
+ * b) if invalid, invokes the HIDL continuation callback with the
+ * provided error status and default values.
+ */
+// Use for HIDL methods which return only an instance of SupplicantStatus.
+template <typename ObjT, typename WorkFuncT, typename... Args>
+Return<void> validateAndCall(
+    ObjT* obj, SupplicantStatusCode status_code_if_invalid, WorkFuncT&& work,
+    const std::function<void(const SupplicantStatus&)>& hidl_cb, Args&&... args)
+{
+	if (obj->isValid()) {
+		hidl_cb((obj->*work)(std::forward<Args>(args)...));
+	} else {
+		hidl_cb({status_code_if_invalid, ""});
+	}
+	return Void();
+}
+
+// Use for HIDL methods which return instance of SupplicantStatus and a single
+// return value.
+template <typename ObjT, typename WorkFuncT, typename ReturnT, typename... Args>
+Return<void> validateAndCall(
+    ObjT* obj, SupplicantStatusCode status_code_if_invalid, WorkFuncT&& work,
+    const std::function<void(const SupplicantStatus&, ReturnT)>& hidl_cb,
+    Args&&... args)
+{
+	if (obj->isValid()) {
+		const auto& ret_pair =
+		    (obj->*work)(std::forward<Args>(args)...);
+		const SupplicantStatus& status = std::get<0>(ret_pair);
+		const auto& ret_value = std::get<1>(ret_pair);
+		hidl_cb(status, ret_value);
+	} else {
+		hidl_cb(
+		    {status_code_if_invalid, ""},
+		    typename std::remove_reference<ReturnT>::type());
+	}
+	return Void();
+}
+
+// Use for HIDL methods which return instance of SupplicantStatus and 2 return
+// values.
+template <
+    typename ObjT, typename WorkFuncT, typename ReturnT1, typename ReturnT2,
+    typename... Args>
+Return<void> validateAndCall(
+    ObjT* obj, SupplicantStatusCode status_code_if_invalid, WorkFuncT&& work,
+    const std::function<void(const SupplicantStatus&, ReturnT1, ReturnT2)>&
+	hidl_cb,
+    Args&&... args)
+{
+	if (obj->isValid()) {
+		const auto& ret_tuple =
+		    (obj->*work)(std::forward<Args>(args)...);
+		const SupplicantStatus& status = std::get<0>(ret_tuple);
+		const auto& ret_value1 = std::get<1>(ret_tuple);
+		const auto& ret_value2 = std::get<2>(ret_tuple);
+		hidl_cb(status, ret_value1, ret_value2);
+	} else {
+		hidl_cb(
+		    {status_code_if_invalid, ""},
+		    typename std::remove_reference<ReturnT1>::type(),
+		    typename std::remove_reference<ReturnT2>::type());
+	}
+	return Void();
+}
+
+}  // namespace hidl_util
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace supplicant
+}  // namespace wifi
+}  // namespace hardware
+}  // namespace android
+#endif  // HIDL_RETURN_UTIL_H_
diff --git a/wpa_supplicant/hidl/p2p_iface.cpp b/wpa_supplicant/hidl/p2p_iface.cpp
index e9ee986..47f3cc5 100644
--- a/wpa_supplicant/hidl/p2p_iface.cpp
+++ b/wpa_supplicant/hidl/p2p_iface.cpp
@@ -8,7 +8,7 @@
  */
 
 #include "hidl_manager.h"
-#include "hidl_return_macros.h"
+#include "hidl_return_util.h"
 #include "p2p_iface.h"
 
 namespace android {
@@ -17,137 +17,557 @@
 namespace supplicant {
 namespace V1_0 {
 namespace implementation {
+using hidl_return_util::validateAndCall;
 
-P2pIface::P2pIface(struct wpa_global *wpa_global, const char ifname[])
-    : wpa_global_(wpa_global), ifname_(ifname)
+P2pIface::P2pIface(struct wpa_global* wpa_global, const char ifname[])
+    : wpa_global_(wpa_global), ifname_(ifname), is_valid_(true)
 {
 }
 
+void P2pIface::invalidate() { is_valid_ = false; }
+bool P2pIface::isValid()
+{
+	return (is_valid_ && (retrieveIfacePtr() != nullptr));
+}
 Return<void> P2pIface::getName(getName_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID, ifname_);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifname_);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::getNameInternal, _hidl_cb);
 }
 
 Return<void> P2pIface::getType(getType_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID,
-		    IfaceType::STA);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, IfaceType::STA);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::getTypeInternal, _hidl_cb);
 }
 
 Return<void> P2pIface::addNetwork(addNetwork_cb _hidl_cb)
 {
-	android::sp<ISupplicantP2pNetwork> network;
-	struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID, network);
-	}
-
-	struct wpa_ssid *ssid = wpa_supplicant_add_network(wpa_s);
-	if (!ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
-	}
-
-	HidlManager *hidl_manager = HidlManager::getInstance();
-	if (!hidl_manager ||
-	    hidl_manager->getP2pNetworkHidlObjectByIfnameAndNetworkId(
-		wpa_s->ifname, ssid->id, &network)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, network);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::addNetworkInternal, _hidl_cb);
 }
 
-Return<void> P2pIface::removeNetwork(uint32_t id, removeNetwork_cb _hidl_cb)
+Return<void> P2pIface::removeNetwork(
+    SupplicantNetworkId id, removeNetwork_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
-	}
-
-	int result = wpa_supplicant_remove_network(wpa_s, id);
-	if (result == -1) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN);
-	}
-
-	if (result != 0) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::removeNetworkInternal, _hidl_cb, id);
 }
 
-Return<void> P2pIface::getNetwork(uint32_t id, getNetwork_cb _hidl_cb)
+Return<void> P2pIface::getNetwork(
+    SupplicantNetworkId id, getNetwork_cb _hidl_cb)
 {
-	android::sp<ISupplicantP2pNetwork> network;
-	struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID, network);
-	}
-
-	struct wpa_ssid *ssid = wpa_config_get_network(wpa_s->conf, id);
-	if (!ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN, network);
-	}
-
-	HidlManager *hidl_manager = HidlManager::getInstance();
-	if (!hidl_manager ||
-	    hidl_manager->getP2pNetworkHidlObjectByIfnameAndNetworkId(
-		wpa_s->ifname, ssid->id, &network)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, network);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::getNetworkInternal, _hidl_cb, id);
 }
 
 Return<void> P2pIface::listNetworks(listNetworks_cb _hidl_cb)
 {
-	std::vector<uint32_t> network_ids;
-
-	struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID, network_ids);
-	}
-
-	for (struct wpa_ssid *wpa_ssid = wpa_s->conf->ssid; wpa_ssid;
-	     wpa_ssid = wpa_ssid->next) {
-		network_ids.emplace_back(wpa_ssid->id);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, network_ids);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::listNetworksInternal, _hidl_cb);
 }
 
 Return<void> P2pIface::registerCallback(
-    const sp<ISupplicantP2pIfaceCallback> &callback,
+    const sp<ISupplicantP2pIfaceCallback>& callback,
     registerCallback_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveP2pIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
-	}
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::registerCallbackInternal, _hidl_cb, callback);
+}
 
-	HidlManager *hidl_manager = HidlManager::getInstance();
+Return<void> P2pIface::getDeviceAddress(getDeviceAddress_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::getDeviceAddressInternal, _hidl_cb);
+}
+
+Return<void> P2pIface::setSsidPostfix(
+    const hidl_string& postfix, setSsidPostfix_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::setSsidPostfixInternal, _hidl_cb, postfix);
+}
+
+Return<void> P2pIface::setGroupIdle(
+    uint32_t timeout_in_sec, setGroupIdle_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::setGroupIdleInternal, _hidl_cb, timeout_in_sec);
+}
+
+Return<void> P2pIface::setPowerSave(bool enable, setPowerSave_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::setPowerSaveInternal, _hidl_cb, enable);
+}
+
+Return<void> P2pIface::find(uint32_t timeout_in_sec, find_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::findInternal, _hidl_cb, timeout_in_sec);
+}
+
+Return<void> P2pIface::stopFind(stopFind_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::stopFindInternal, _hidl_cb);
+}
+
+Return<void> P2pIface::flush(flush_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::flushInternal, _hidl_cb);
+}
+
+Return<void> P2pIface::connect(
+    const hidl_array<uint8_t, 6>& peer_address,
+    ISupplicantP2pIface::WpsProvisionMethod provision_method,
+    const hidl_vec<uint8_t>& pre_selected_pin, bool join_existing_group,
+    bool persistent, uint32_t go_intent, connect_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::connectInternal, _hidl_cb, peer_address,
+	    provision_method, pre_selected_pin, join_existing_group, persistent,
+	    go_intent);
+}
+
+Return<void> P2pIface::cancelConnect(cancelConnect_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::cancelConnectInternal, _hidl_cb);
+}
+
+Return<void> P2pIface::provisionDiscovery(
+    const hidl_array<uint8_t, 6>& peer_address,
+    ISupplicantP2pIface::WpsProvisionMethod provision_method,
+    provisionDiscovery_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::provisionDiscoveryInternal, _hidl_cb, peer_address,
+	    provision_method);
+}
+
+Return<void> P2pIface::addGroup(
+    bool persistent, uint32_t persistent_network_id, addGroup_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::addGroupInternal, _hidl_cb, persistent,
+	    persistent_network_id);
+}
+
+Return<void> P2pIface::removeGroup(
+    const hidl_string& group_ifname, removeGroup_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::removeGroupInternal, _hidl_cb, group_ifname);
+}
+
+Return<void> P2pIface::reject(
+    const hidl_array<uint8_t, 6>& peer_address, reject_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::rejectInternal, _hidl_cb, peer_address);
+}
+
+Return<void> P2pIface::invite(
+    const hidl_string& group_ifname,
+    const hidl_array<uint8_t, 6>& go_device_address,
+    const hidl_array<uint8_t, 6>& peer_address, invite_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::inviteInternal, _hidl_cb, go_device_address,
+	    peer_address);
+}
+
+Return<void> P2pIface::reinvoke(
+    uint32_t persistent_network_id, const hidl_array<uint8_t, 6>& peer_address,
+    reinvoke_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::reinvokeInternal, _hidl_cb, persistent_network_id,
+	    peer_address);
+}
+
+Return<void> P2pIface::configureExtListen(
+    bool enable, uint32_t period_in_millis, uint32_t interval_in_millis,
+    configureExtListen_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::configureExtListenInternal, _hidl_cb, enable,
+	    period_in_millis, interval_in_millis);
+}
+
+Return<void> P2pIface::setListenChannel(
+    uint32_t channel, uint32_t operating_class, setListenChannel_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::setListenChannelInternal, _hidl_cb, channel,
+	    operating_class);
+}
+
+Return<void> P2pIface::getSsid(
+    const hidl_array<uint8_t, 6>& peer_address, getSsid_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::getSsidInternal, _hidl_cb, peer_address);
+}
+
+Return<void> P2pIface::getGroupCapability(
+    const hidl_array<uint8_t, 6>& peer_address, getGroupCapability_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::getGroupCapabilityInternal, _hidl_cb, peer_address);
+}
+
+Return<void> P2pIface::addBonjourService(
+    const hidl_vec<uint8_t>& query, const hidl_vec<uint8_t>& response,
+    addBonjourService_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::addBonjourServiceInternal, _hidl_cb, query, response);
+}
+
+Return<void> P2pIface::removeBonjourService(
+    const hidl_vec<uint8_t>& query, removeBonjourService_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::removeBonjourServiceInternal, _hidl_cb, query);
+}
+
+Return<void> P2pIface::addUpnpService(
+    uint32_t version, const hidl_string& service_name,
+    addUpnpService_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::addUpnpServiceInternal, _hidl_cb, version, service_name);
+}
+
+Return<void> P2pIface::removeUpnpService(
+    uint32_t version, const hidl_string& service_name,
+    removeUpnpService_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::removeUpnpServiceInternal, _hidl_cb, version,
+	    service_name);
+}
+
+Return<void> P2pIface::flushServices(
+    uint32_t version, const hidl_string& service_name,
+    flushServices_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::flushServicesInternal, _hidl_cb, version, service_name);
+}
+
+Return<void> P2pIface::requestServiceDiscovery(
+    const hidl_array<uint8_t, 6>& peer_address, const hidl_vec<uint8_t>& query,
+    requestServiceDiscovery_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::requestServiceDiscoveryInternal, _hidl_cb, version,
+	    peer_address, query);
+}
+
+Return<void> P2pIface::cancelServiceDiscovery(
+    uint64_t identifier, cancelServiceDiscovery_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &P2pIface::cancelServiceDiscoveryInternal, _hidl_cb, identifier);
+}
+
+std::pair<SupplicantStatus, std::string> P2pIface::getNameInternal()
+{
+	return {{SupplicantStatusCode::SUCCESS, ""}, ifname_};
+}
+
+std::pair<SupplicantStatus, IfaceType> P2pIface::getTypeInternal()
+{
+	return {{SupplicantStatusCode::SUCCESS, ""}, IfaceType::P2P};
+}
+
+std::pair<SupplicantStatus, sp<ISupplicantP2pNetwork>>
+P2pIface::addNetworkInternal()
+{
+	android::sp<ISupplicantP2pNetwork> network;
+	struct wpa_supplicant* wpa_s = retrieveIfacePtr();
+	struct wpa_ssid* ssid = wpa_supplicant_add_network(wpa_s);
+	if (!ssid) {
+		return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, network};
+	}
+	HidlManager* hidl_manager = HidlManager::getInstance();
+	if (!hidl_manager ||
+	    hidl_manager->getP2pNetworkHidlObjectByIfnameAndNetworkId(
+		wpa_s->ifname, ssid->id, &network)) {
+		return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, network};
+	}
+	return {{SupplicantStatusCode::SUCCESS, ""}, network};
+}
+
+SupplicantStatus P2pIface::removeNetworkInternal(SupplicantNetworkId id)
+{
+	struct wpa_supplicant* wpa_s = retrieveIfacePtr();
+	int result = wpa_supplicant_remove_network(wpa_s, id);
+	if (result == -1) {
+		return {SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN, ""};
+	}
+	if (result != 0) {
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+	}
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+std::pair<SupplicantStatus, sp<ISupplicantP2pNetwork>>
+P2pIface::getNetworkInternal(SupplicantNetworkId id)
+{
+	android::sp<ISupplicantP2pNetwork> network;
+	struct wpa_supplicant* wpa_s = retrieveIfacePtr();
+	struct wpa_ssid* ssid = wpa_config_get_network(wpa_s->conf, id);
+	if (!ssid) {
+		return {{SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN, ""},
+			network};
+	}
+	HidlManager* hidl_manager = HidlManager::getInstance();
+	if (!hidl_manager ||
+	    hidl_manager->getP2pNetworkHidlObjectByIfnameAndNetworkId(
+		wpa_s->ifname, ssid->id, &network)) {
+		return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, network};
+	}
+	return {{SupplicantStatusCode::SUCCESS, ""}, network};
+}
+
+std::pair<SupplicantStatus, std::vector<SupplicantNetworkId>>
+P2pIface::listNetworksInternal()
+{
+	std::vector<SupplicantNetworkId> network_ids;
+	struct wpa_supplicant* wpa_s = retrieveIfacePtr();
+	for (struct wpa_ssid* wpa_ssid = wpa_s->conf->ssid; wpa_ssid;
+	     wpa_ssid = wpa_ssid->next) {
+		network_ids.emplace_back(wpa_ssid->id);
+	}
+	return {{SupplicantStatusCode::SUCCESS, ""}, std::move(network_ids)};
+}
+
+SupplicantStatus P2pIface::registerCallbackInternal(
+    const sp<ISupplicantP2pIfaceCallback>& callback)
+{
+	HidlManager* hidl_manager = HidlManager::getInstance();
 	if (!hidl_manager ||
 	    hidl_manager->addP2pIfaceCallbackHidlObject(ifname_, callback)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
 
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+std::pair<SupplicantStatus, std::array<uint8_t, 6>>
+P2pIface::getDeviceAddressInternal()
+{
+	// TODO: Add implementation.
+	return {{SupplicantStatusCode::SUCCESS, ""}, {}};
+}
+
+SupplicantStatus P2pIface::setSsidPostfixInternal(const hidl_string& postfix)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::setGroupIdleInternal(uint32_t timeout_in_sec)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::setPowerSaveInternal(bool enable)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::findInternal(uint32_t timeout_in_sec)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::stopFindInternal()
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::flushInternal()
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+std::pair<SupplicantStatus, std::vector<uint8_t>> P2pIface::connectInternal(
+    const hidl_array<uint8_t, 6>& peer_address,
+    ISupplicantP2pIface::WpsProvisionMethod provision_method,
+    const hidl_vec<uint8_t>& pre_selected_pin, bool join_existing_group,
+    bool persistent, uint32_t go_intent)
+{
+	// TODO: Add implementation.
+	return {{SupplicantStatusCode::SUCCESS, ""}, {}};
+}
+
+SupplicantStatus P2pIface::cancelConnectInternal()
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::provisionDiscoveryInternal(
+    const hidl_array<uint8_t, 6>& peer_address,
+    ISupplicantP2pIface::WpsProvisionMethod provision_method)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::addGroupInternal(
+    bool persistent, uint32_t persistent_network_id)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::removeGroupInternal(const hidl_string& group_ifname)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::rejectInternal(
+    const hidl_array<uint8_t, 6>& peer_address)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::inviteInternal(
+    const hidl_string& group_ifname,
+    const hidl_array<uint8_t, 6>& go_device_address,
+    const hidl_array<uint8_t, 6>& peer_address)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::reinvokeInternal(
+    uint32_t persistent_network_id, const hidl_array<uint8_t, 6>& peer_address)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::configureExtListenInternal(
+    bool enable, uint32_t period_in_millis, uint32_t interval_in_millis)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::setListenChannelInternal(
+    uint32_t channel, uint32_t operating_class)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+std::pair<SupplicantStatus, std::vector<uint8_t>> P2pIface::getSsidInternal(
+    const hidl_array<uint8_t, 6>& peer_address)
+{
+	// TODO: Add implementation.
+	return {{SupplicantStatusCode::SUCCESS, ""}, {}};
+}
+
+std::pair<SupplicantStatus, uint32_t> P2pIface::getGroupCapabilityInternal(
+    const hidl_array<uint8_t, 6>& peer_address)
+{
+	// TODO: Add implementation.
+	return {{SupplicantStatusCode::SUCCESS, ""}, 0};
+}
+
+SupplicantStatus P2pIface::addBonjourServiceInternal(
+    const hidl_vec<uint8_t>& query, const hidl_vec<uint8_t>& response)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::removeBonjourServiceInternal(
+    const hidl_vec<uint8_t>& query)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::addUpnpServiceInternal(
+    uint32_t version, const hidl_string& service_name)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::removeUpnpServiceInternal(
+    uint32_t version, const hidl_string& service_name)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus P2pIface::flushServicesInternal(
+    uint32_t version, const hidl_string& service_name)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+std::pair<SupplicantStatus, uint64_t> P2pIface::requestServiceDiscoveryInternal(
+    const hidl_array<uint8_t, 6>& peer_address, const hidl_vec<uint8_t>& query)
+{
+	// TODO: Add implementation.
+	return {{SupplicantStatusCode::SUCCESS, ""}, 0};
+}
+
+SupplicantStatus P2pIface::cancelServiceDiscoveryInternal(uint64_t identifier)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
 /**
@@ -156,10 +576,10 @@
  * If the underlying iface is removed, then all RPC method calls on this object
  * will return failure.
  */
-wpa_supplicant *P2pIface::retrieveP2pIfacePtr()
+wpa_supplicant* P2pIface::retrieveIfacePtr()
 {
 	return wpa_supplicant_get_iface(
-	    (struct wpa_global *)wpa_global_, ifname_.c_str());
+	    (struct wpa_global*)wpa_global_, ifname_.c_str());
 }
 
 }  // namespace implementation
diff --git a/wpa_supplicant/hidl/p2p_iface.h b/wpa_supplicant/hidl/p2p_iface.h
index a003cf5..f4992c3 100644
--- a/wpa_supplicant/hidl/p2p_iface.h
+++ b/wpa_supplicant/hidl/p2p_iface.h
@@ -10,6 +10,9 @@
 #ifndef WPA_SUPPLICANT_HIDL_P2P_IFACE_H
 #define WPA_SUPPLICANT_HIDL_P2P_IFACE_H
 
+#include <array>
+#include <vector>
+
 #include <android-base/macros.h>
 
 #include <android/hardware/wifi/supplicant/1.0/ISupplicantP2pIface.h>
@@ -42,27 +45,167 @@
 public:
 	P2pIface(struct wpa_global* wpa_global, const char ifname[]);
 	~P2pIface() override = default;
+	// Refer to |StaIface::invalidate()|.
+	void invalidate();
+	bool isValid();
 
 	// Hidl methods exposed.
 	Return<void> getName(getName_cb _hidl_cb) override;
 	Return<void> getType(getType_cb _hidl_cb) override;
 	Return<void> addNetwork(addNetwork_cb _hidl_cb) override;
 	Return<void> removeNetwork(
-	    uint32_t id, removeNetwork_cb _hidl_cb) override;
-	Return<void> getNetwork(uint32_t id, getNetwork_cb _hidl_cb) override;
+	    SupplicantNetworkId id, removeNetwork_cb _hidl_cb) override;
+	Return<void> getNetwork(
+	    SupplicantNetworkId id, getNetwork_cb _hidl_cb) override;
 	Return<void> listNetworks(listNetworks_cb _hidl_cb) override;
 	Return<void> registerCallback(
 	    const sp<ISupplicantP2pIfaceCallback>& callback,
 	    registerCallback_cb _hidl_cb) override;
+	Return<void> getDeviceAddress(getDeviceAddress_cb _hidl_cb) override;
+	Return<void> setSsidPostfix(
+	    const hidl_string& postfix, setSsidPostfix_cb _hidl_cb) override;
+	Return<void> setGroupIdle(
+	    uint32_t timeout_in_sec, setGroupIdle_cb _hidl_cb) override;
+	Return<void> setPowerSave(
+	    bool enable, setPowerSave_cb _hidl_cb) override;
+	Return<void> find(uint32_t timeout_in_sec, find_cb _hidl_cb) override;
+	Return<void> stopFind(stopFind_cb _hidl_cb) override;
+	Return<void> flush(flush_cb _hidl_cb) override;
+	Return<void> connect(
+	    const hidl_array<uint8_t, 6>& peer_address,
+	    ISupplicantP2pIface::WpsProvisionMethod provision_method,
+	    const hidl_vec<uint8_t>& pre_selected_pin, bool join_existing_group,
+	    bool persistent, uint32_t go_intent, connect_cb _hidl_cb) override;
+	Return<void> cancelConnect(cancelConnect_cb _hidl_cb) override;
+	Return<void> provisionDiscovery(
+	    const hidl_array<uint8_t, 6>& peer_address,
+	    ISupplicantP2pIface::WpsProvisionMethod provision_method,
+	    provisionDiscovery_cb _hidl_cb) override;
+	Return<void> addGroup(
+	    bool persistent, uint32_t persistent_network_id,
+	    addGroup_cb _hidl_cb) override;
+	Return<void> removeGroup(
+	    const hidl_string& group_ifname, removeGroup_cb _hidl_cb) override;
+	Return<void> reject(
+	    const hidl_array<uint8_t, 6>& peer_address,
+	    reject_cb _hidl_cb) override;
+	Return<void> invite(
+	    const hidl_string& group_ifname,
+	    const hidl_array<uint8_t, 6>& go_device_address,
+	    const hidl_array<uint8_t, 6>& peer_address,
+	    invite_cb _hidl_cb) override;
+	Return<void> reinvoke(
+	    uint32_t persistent_network_id,
+	    const hidl_array<uint8_t, 6>& peer_address,
+	    reinvoke_cb _hidl_cb) override;
+	Return<void> configureExtListen(
+	    bool enable, uint32_t period_in_millis, uint32_t interval_in_millis,
+	    configureExtListen_cb _hidl_cb) override;
+	Return<void> setListenChannel(
+	    uint32_t channel, uint32_t operating_class,
+	    setListenChannel_cb _hidl_cb) override;
+	Return<void> getSsid(
+	    const hidl_array<uint8_t, 6>& peer_address,
+	    getSsid_cb _hidl_cb) override;
+	Return<void> getGroupCapability(
+	    const hidl_array<uint8_t, 6>& peer_address,
+	    getGroupCapability_cb _hidl_cb) override;
+	Return<void> addBonjourService(
+	    const hidl_vec<uint8_t>& query, const hidl_vec<uint8_t>& response,
+	    addBonjourService_cb _hidl_cb) override;
+	Return<void> removeBonjourService(
+	    const hidl_vec<uint8_t>& query,
+	    removeBonjourService_cb _hidl_cb) override;
+	Return<void> addUpnpService(
+	    uint32_t version, const hidl_string& service_name,
+	    addUpnpService_cb _hidl_cb) override;
+	Return<void> removeUpnpService(
+	    uint32_t version, const hidl_string& service_name,
+	    removeUpnpService_cb _hidl_cb) override;
+	Return<void> flushServices(
+	    uint32_t version, const hidl_string& service_name,
+	    flushServices_cb _hidl_cb) override;
+	Return<void> requestServiceDiscovery(
+	    const hidl_array<uint8_t, 6>& peer_address,
+	    const hidl_vec<uint8_t>& query,
+	    requestServiceDiscovery_cb _hidl_cb) override;
+	Return<void> cancelServiceDiscovery(
+	    uint64_t identifier, cancelServiceDiscovery_cb _hidl_cb) override;
 
 private:
-	struct wpa_supplicant* retrieveP2pIfacePtr();
+	// Corresponding worker functions for the HIDL methods.
+	std::pair<SupplicantStatus, std::string> getNameInternal();
+	std::pair<SupplicantStatus, IfaceType> getTypeInternal();
+	std::pair<SupplicantStatus, sp<ISupplicantP2pNetwork>>
+	addNetworkInternal();
+	SupplicantStatus removeNetworkInternal(SupplicantNetworkId id);
+	std::pair<SupplicantStatus, sp<ISupplicantP2pNetwork>>
+	getNetworkInternal(SupplicantNetworkId id);
+	std::pair<SupplicantStatus, std::vector<SupplicantNetworkId>>
+	listNetworksInternal();
+	SupplicantStatus registerCallbackInternal(
+	    const sp<ISupplicantP2pIfaceCallback>& callback);
+	std::pair<SupplicantStatus, std::array<uint8_t, 6>>
+	getDeviceAddressInternal();
+	SupplicantStatus setSsidPostfixInternal(const hidl_string& postfix);
+	SupplicantStatus setGroupIdleInternal(uint32_t timeout_in_sec);
+	SupplicantStatus setPowerSaveInternal(bool enable);
+	SupplicantStatus findInternal(uint32_t timeout_in_sec);
+	SupplicantStatus stopFindInternal();
+	SupplicantStatus flushInternal();
+	std::pair<SupplicantStatus, std::vector<uint8_t>> connectInternal(
+	    const hidl_array<uint8_t, 6>& peer_address,
+	    ISupplicantP2pIface::WpsProvisionMethod provision_method,
+	    const hidl_vec<uint8_t>& pre_selected_pin, bool join_existing_group,
+	    bool persistent, uint32_t go_intent);
+	SupplicantStatus cancelConnectInternal();
+	SupplicantStatus provisionDiscoveryInternal(
+	    const hidl_array<uint8_t, 6>& peer_address,
+	    ISupplicantP2pIface::WpsProvisionMethod provision_method);
+	SupplicantStatus addGroupInternal(
+	    bool persistent, uint32_t persistent_network_id);
+	SupplicantStatus removeGroupInternal(const hidl_string& group_ifname);
+	SupplicantStatus rejectInternal(
+	    const hidl_array<uint8_t, 6>& peer_address);
+	SupplicantStatus inviteInternal(
+	    const hidl_string& group_ifname,
+	    const hidl_array<uint8_t, 6>& go_device_address,
+	    const hidl_array<uint8_t, 6>& peer_address);
+	SupplicantStatus reinvokeInternal(
+	    uint32_t persistent_network_id,
+	    const hidl_array<uint8_t, 6>& peer_address);
+	SupplicantStatus configureExtListenInternal(
+	    bool enable, uint32_t period_in_millis,
+	    uint32_t interval_in_millis);
+	SupplicantStatus setListenChannelInternal(
+	    uint32_t channel, uint32_t operating_class);
+	std::pair<SupplicantStatus, std::vector<uint8_t>> getSsidInternal(
+	    const hidl_array<uint8_t, 6>& peer_address);
+	std::pair<SupplicantStatus, uint32_t> getGroupCapabilityInternal(
+	    const hidl_array<uint8_t, 6>& peer_address);
+	SupplicantStatus addBonjourServiceInternal(
+	    const hidl_vec<uint8_t>& query, const hidl_vec<uint8_t>& response);
+	SupplicantStatus removeBonjourServiceInternal(
+	    const hidl_vec<uint8_t>& query);
+	SupplicantStatus addUpnpServiceInternal(
+	    uint32_t version, const hidl_string& service_name);
+	SupplicantStatus removeUpnpServiceInternal(
+	    uint32_t version, const hidl_string& service_name);
+	SupplicantStatus flushServicesInternal(
+	    uint32_t version, const hidl_string& service_name);
+	std::pair<SupplicantStatus, uint64_t> requestServiceDiscoveryInternal(
+	    const hidl_array<uint8_t, 6>& peer_address,
+	    const hidl_vec<uint8_t>& query);
+	SupplicantStatus cancelServiceDiscoveryInternal(uint64_t identifier);
+
+	struct wpa_supplicant* retrieveIfacePtr();
 
 	// Reference to the global wpa_struct. This is assumed to be valid for
 	// the lifetime of the process.
 	const struct wpa_global* wpa_global_;
 	// Name of the iface this hidl object controls
 	const std::string ifname_;
+	bool is_valid_;
 
 	DISALLOW_COPY_AND_ASSIGN(P2pIface);
 };
diff --git a/wpa_supplicant/hidl/p2p_network.cpp b/wpa_supplicant/hidl/p2p_network.cpp
index 7de950e..ce02179 100644
--- a/wpa_supplicant/hidl/p2p_network.cpp
+++ b/wpa_supplicant/hidl/p2p_network.cpp
@@ -8,7 +8,7 @@
  */
 
 #include "hidl_manager.h"
-#include "hidl_return_macros.h"
+#include "hidl_return_util.h"
 #include "p2p_network.h"
 
 namespace android {
@@ -17,65 +17,78 @@
 namespace supplicant {
 namespace V1_0 {
 namespace implementation {
+using hidl_return_util::validateAndCall;
 
 P2pNetwork::P2pNetwork(
     struct wpa_global *wpa_global, const char ifname[], int network_id)
-    : wpa_global_(wpa_global), ifname_(ifname), network_id_(network_id)
+    : wpa_global_(wpa_global),
+      ifname_(ifname),
+      network_id_(network_id),
+      is_valid_(true)
 {
 }
 
+void P2pNetwork::invalidate() { is_valid_ = false; }
+bool P2pNetwork::isValid()
+{
+	return (is_valid_ && (retrieveNetworkPtr() != nullptr));
+}
+
 Return<void> P2pNetwork::getId(getId_cb _hidl_cb)
 {
-	uint32_t id = UINT32_MAX;
-	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID, id);
-	}
-
-	id = network_id_;
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, id);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &P2pNetwork::getIdInternal, _hidl_cb);
 }
 
 Return<void> P2pNetwork::getInterfaceName(getInterfaceName_cb _hidl_cb)
 {
-	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID, ifname_);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifname_);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &P2pNetwork::getInterfaceNameInternal, _hidl_cb);
 }
 
 Return<void> P2pNetwork::getType(getType_cb _hidl_cb)
 {
-	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID,
-		    IfaceType::P2P);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, IfaceType::P2P);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &P2pNetwork::getTypeInternal, _hidl_cb);
 }
 
 Return<void> P2pNetwork::registerCallback(
     const sp<ISupplicantP2pNetworkCallback> &callback,
     registerCallback_cb _hidl_cb)
 {
-	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &P2pNetwork::registerCallbackInternal, _hidl_cb, callback);
+}
 
+std::pair<SupplicantStatus, uint32_t> P2pNetwork::getIdInternal()
+{
+	return {{SupplicantStatusCode::SUCCESS, ""}, network_id_};
+}
+
+std::pair<SupplicantStatus, std::string> P2pNetwork::getInterfaceNameInternal()
+{
+	return {{SupplicantStatusCode::SUCCESS, ""}, ifname_};
+}
+
+std::pair<SupplicantStatus, IfaceType> P2pNetwork::getTypeInternal()
+{
+	return {{SupplicantStatusCode::SUCCESS, ""}, IfaceType::P2P};
+}
+
+SupplicantStatus P2pNetwork::registerCallbackInternal(
+    const sp<ISupplicantP2pNetworkCallback> &callback)
+{
 	HidlManager *hidl_manager = HidlManager::getInstance();
 	if (!hidl_manager ||
 	    hidl_manager->addP2pNetworkCallbackHidlObject(
 		ifname_, network_id_, callback)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
 /**
diff --git a/wpa_supplicant/hidl/p2p_network.h b/wpa_supplicant/hidl/p2p_network.h
index 92eddd2..023e902 100644
--- a/wpa_supplicant/hidl/p2p_network.h
+++ b/wpa_supplicant/hidl/p2p_network.h
@@ -44,6 +44,9 @@
 	P2pNetwork(
 	    struct wpa_global* wpa_global, const char ifname[], int network_id);
 	~P2pNetwork() override = default;
+	// Refer to |StaIface::invalidate()|.
+	void invalidate();
+	bool isValid();
 
 	// Hidl methods exposed.
 	Return<void> getId(getId_cb _hidl_cb) override;
@@ -54,6 +57,13 @@
 	    registerCallback_cb _hidl_cb) override;
 
 private:
+	// Corresponding worker functions for the HIDL methods.
+	std::pair<SupplicantStatus, uint32_t> getIdInternal();
+	std::pair<SupplicantStatus, std::string> getInterfaceNameInternal();
+	std::pair<SupplicantStatus, IfaceType> getTypeInternal();
+	SupplicantStatus registerCallbackInternal(
+	    const sp<ISupplicantP2pNetworkCallback>& callback);
+
 	struct wpa_ssid* retrieveNetworkPtr();
 	struct wpa_supplicant* retrieveIfacePtr();
 
@@ -64,6 +74,7 @@
 	const std::string ifname_;
 	// Id of the network this hidl object controls.
 	const int network_id_;
+	bool is_valid_;
 
 	DISALLOW_COPY_AND_ASSIGN(P2pNetwork);
 };
diff --git a/wpa_supplicant/hidl/sta_iface.cpp b/wpa_supplicant/hidl/sta_iface.cpp
index e3a384b..4379dd5 100644
--- a/wpa_supplicant/hidl/sta_iface.cpp
+++ b/wpa_supplicant/hidl/sta_iface.cpp
@@ -8,7 +8,7 @@
  */
 
 #include "hidl_manager.h"
-#include "hidl_return_macros.h"
+#include "hidl_return_util.h"
 #include "sta_iface.h"
 
 namespace android {
@@ -17,216 +17,278 @@
 namespace supplicant {
 namespace V1_0 {
 namespace implementation {
+using hidl_return_util::validateAndCall;
 
 StaIface::StaIface(struct wpa_global *wpa_global, const char ifname[])
-    : wpa_global_(wpa_global), ifname_(ifname)
+    : wpa_global_(wpa_global), ifname_(ifname), is_valid_(true)
 {
 }
 
+void StaIface::invalidate() { is_valid_ = false; }
+bool StaIface::isValid()
+{
+	return (is_valid_ && (retrieveIfacePtr() != nullptr));
+}
+
 Return<void> StaIface::getName(getName_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID, ifname_);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifname_);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::getNameInternal, _hidl_cb);
 }
 
 Return<void> StaIface::getType(getType_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID,
-		    IfaceType::STA);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, IfaceType::STA);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::getTypeInternal, _hidl_cb);
 }
 
 Return<void> StaIface::addNetwork(addNetwork_cb _hidl_cb)
 {
-	android::sp<ISupplicantStaNetwork> network;
-	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID, network);
-	}
-
-	struct wpa_ssid *ssid = wpa_supplicant_add_network(wpa_s);
-	if (!ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
-	}
-
-	HidlManager *hidl_manager = HidlManager::getInstance();
-	if (!hidl_manager ||
-	    hidl_manager->getStaNetworkHidlObjectByIfnameAndNetworkId(
-		wpa_s->ifname, ssid->id, &network)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, network);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::addNetworkInternal, _hidl_cb);
 }
 
-Return<void> StaIface::removeNetwork(uint32_t id, removeNetwork_cb _hidl_cb)
+Return<void> StaIface::removeNetwork(
+    SupplicantNetworkId id, removeNetwork_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
-	}
-
-	int result = wpa_supplicant_remove_network(wpa_s, id);
-	if (result == -1) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN);
-	}
-
-	if (result != 0) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::removeNetworkInternal, _hidl_cb, id);
 }
 
-Return<void> StaIface::getNetwork(uint32_t id, getNetwork_cb _hidl_cb)
+Return<void> StaIface::getNetwork(
+    SupplicantNetworkId id, getNetwork_cb _hidl_cb)
 {
-	android::sp<ISupplicantStaNetwork> network;
-	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID, network);
-	}
-
-	struct wpa_ssid *ssid = wpa_config_get_network(wpa_s->conf, id);
-	if (!ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN, network);
-	}
-
-	HidlManager *hidl_manager = HidlManager::getInstance();
-	if (!hidl_manager ||
-	    hidl_manager->getStaNetworkHidlObjectByIfnameAndNetworkId(
-		wpa_s->ifname, ssid->id, &network)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN, network);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, network);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::getNetworkInternal, _hidl_cb, id);
 }
 
 Return<void> StaIface::listNetworks(listNetworks_cb _hidl_cb)
 {
-	std::vector<uint32_t> network_ids;
-
-	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID, network_ids);
-	}
-
-	for (struct wpa_ssid *wpa_ssid = wpa_s->conf->ssid; wpa_ssid;
-	     wpa_ssid = wpa_ssid->next) {
-		network_ids.emplace_back(wpa_ssid->id);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, network_ids);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::listNetworksInternal, _hidl_cb);
 }
 
 Return<void> StaIface::registerCallback(
     const sp<ISupplicantStaIfaceCallback> &callback,
     registerCallback_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
-	}
-
-	HidlManager *hidl_manager = HidlManager::getInstance();
-	if (!hidl_manager ||
-	    hidl_manager->addStaIfaceCallbackHidlObject(ifname_, callback)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::registerCallbackInternal, _hidl_cb, callback);
 }
 
 Return<void> StaIface::reassociate(reassociate_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
-	}
-
-	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_DISABLED);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::reassociateInternal, _hidl_cb);
 }
 
 Return<void> StaIface::reconnect(reconnect_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
-	}
-
-	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_DISABLED);
-	}
-	if (!wpa_s->disconnected) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_NOT_DISCONNECTED);
-	}
-
-	wpas_request_connection(wpa_s);
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::reconnectInternal, _hidl_cb);
 }
 
 Return<void> StaIface::disconnect(disconnect_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
-	}
-
-	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_DISABLED);
-	}
-
-	wpas_request_disconnection(wpa_s);
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::disconnectInternal, _hidl_cb);
 }
 
 Return<void> StaIface::setPowerSave(bool enable, setPowerSave_cb _hidl_cb)
 {
-	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
-	}
-
-	if (wpa_drv_set_p2p_powersave(wpa_s, enable, -1, -1)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::setPowerSaveInternal, _hidl_cb, enable);
 }
 
 Return<void> StaIface::initiateTdlsDiscover(
-    const hidl_array<uint8_t, 6 /* 6 */> &mac_address,
-    initiateTdlsDiscover_cb _hidl_cb)
+    const hidl_array<uint8_t, 6> &mac_address, initiateTdlsDiscover_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::initiateTdlsDiscoverInternal, _hidl_cb, mac_address);
+}
+
+Return<void> StaIface::initiateTdlsSetup(
+    const hidl_array<uint8_t, 6> &mac_address, initiateTdlsSetup_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::initiateTdlsSetupInternal, _hidl_cb, mac_address);
+}
+
+Return<void> StaIface::initiateTdlsTeardown(
+    const hidl_array<uint8_t, 6> &mac_address, initiateTdlsTeardown_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::initiateTdlsTeardownInternal, _hidl_cb, mac_address);
+}
+Return<void> StaIface::initiateAnqpQuery(
+    const hidl_array<uint8_t, 6> &mac_address,
+    const hidl_vec<ISupplicantStaIface::AnqpInfoId> &info_elements,
+    const hidl_vec<ISupplicantStaIface::Hs20AnqpSubtypes> &sub_types,
+    initiateAnqpQuery_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::initiateAnqpQueryInternal, _hidl_cb, mac_address,
+	    info_elements, sub_types);
+}
+
+Return<void> StaIface::initiateHs20IconQuery(
+    const hidl_array<uint8_t, 6> &mac_address, const hidl_string &file_name,
+    initiateHs20IconQuery_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &StaIface::initiateHs20IconQueryInternal, _hidl_cb, mac_address,
+	    file_name);
+}
+
+std::pair<SupplicantStatus, std::string> StaIface::getNameInternal()
+{
+	return {{SupplicantStatusCode::SUCCESS, ""}, ifname_};
+}
+
+std::pair<SupplicantStatus, IfaceType> StaIface::getTypeInternal()
+{
+	return {{SupplicantStatusCode::SUCCESS, ""}, IfaceType::STA};
+}
+
+std::pair<SupplicantStatus, sp<ISupplicantNetwork>>
+StaIface::addNetworkInternal()
+{
+	android::sp<ISupplicantStaNetwork> network;
+	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+	struct wpa_ssid *ssid = wpa_supplicant_add_network(wpa_s);
+	if (!ssid) {
+		return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, network};
+	}
+	HidlManager *hidl_manager = HidlManager::getInstance();
+	if (!hidl_manager ||
+	    hidl_manager->getStaNetworkHidlObjectByIfnameAndNetworkId(
+		wpa_s->ifname, ssid->id, &network)) {
+		return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, network};
+	}
+	return {{SupplicantStatusCode::SUCCESS, ""}, network};
+}
+
+SupplicantStatus StaIface::removeNetworkInternal(SupplicantNetworkId id)
 {
 	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
+	int result = wpa_supplicant_remove_network(wpa_s, id);
+	if (result == -1) {
+		return {SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN, ""};
 	}
-
-	if (!mac_address.data()) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+	if (result != 0) {
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
 
+std::pair<SupplicantStatus, sp<ISupplicantNetwork>>
+StaIface::getNetworkInternal(SupplicantNetworkId id)
+{
+	android::sp<ISupplicantStaNetwork> network;
+	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+	struct wpa_ssid *ssid = wpa_config_get_network(wpa_s->conf, id);
+	if (!ssid) {
+		return {{SupplicantStatusCode::FAILURE_NETWORK_UNKNOWN, ""},
+			network};
+	}
+	HidlManager *hidl_manager = HidlManager::getInstance();
+	if (!hidl_manager ||
+	    hidl_manager->getStaNetworkHidlObjectByIfnameAndNetworkId(
+		wpa_s->ifname, ssid->id, &network)) {
+		return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, network};
+	}
+	return {{SupplicantStatusCode::SUCCESS, ""}, network};
+}
+
+std::pair<SupplicantStatus, std::vector<SupplicantNetworkId>>
+StaIface::listNetworksInternal()
+{
+	std::vector<SupplicantNetworkId> network_ids;
+	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+	for (struct wpa_ssid *wpa_ssid = wpa_s->conf->ssid; wpa_ssid;
+	     wpa_ssid = wpa_ssid->next) {
+		network_ids.emplace_back(wpa_ssid->id);
+	}
+	return {{SupplicantStatusCode::SUCCESS, ""}, std::move(network_ids)};
+}
+
+SupplicantStatus StaIface::registerCallbackInternal(
+    const sp<ISupplicantStaIfaceCallback> &callback)
+{
+	HidlManager *hidl_manager = HidlManager::getInstance();
+	if (!hidl_manager ||
+	    hidl_manager->addStaIfaceCallbackHidlObject(ifname_, callback)) {
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+	}
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus StaIface::reassociateInternal()
+{
+	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
+		return {SupplicantStatusCode::FAILURE_IFACE_DISABLED, ""};
+	}
+	wpas_request_connection(wpa_s);
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus StaIface::reconnectInternal()
+{
+	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
+		return {SupplicantStatusCode::FAILURE_IFACE_DISABLED, ""};
+	}
+	if (!wpa_s->disconnected) {
+		return {SupplicantStatusCode::FAILURE_IFACE_NOT_DISCONNECTED,
+			""};
+	}
+	wpas_request_connection(wpa_s);
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus StaIface::disconnectInternal()
+{
+	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
+		return {SupplicantStatusCode::FAILURE_IFACE_DISABLED, ""};
+	}
+	wpas_request_disconnection(wpa_s);
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus StaIface::setPowerSaveInternal(bool enable)
+{
+	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
+	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
+		return {SupplicantStatusCode::FAILURE_IFACE_DISABLED, ""};
+	}
+	if (wpa_drv_set_p2p_powersave(wpa_s, enable, -1, -1)) {
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+	}
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus StaIface::initiateTdlsDiscoverInternal(
+    const std::array<uint8_t, 6> &mac_address)
+{
+	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
 	int ret;
 	const u8 *peer = mac_address.data();
 	if (wpa_tdls_is_external_setup(wpa_s->wpa)) {
@@ -235,25 +297,15 @@
 		ret = wpa_drv_tdls_oper(wpa_s, TDLS_DISCOVERY_REQ, peer);
 	}
 	if (ret) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaIface::initiateTdlsSetup(
-    const hidl_array<uint8_t, 6 /* 6 */> &mac_address,
-    initiateTdlsSetup_cb _hidl_cb)
+SupplicantStatus StaIface::initiateTdlsSetupInternal(
+    const std::array<uint8_t, 6> &mac_address)
 {
 	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
-	}
-
-	if (!mac_address.data()) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
-	}
-
 	int ret;
 	const u8 *peer = mac_address.data();
 	if (wpa_tdls_is_external_setup(wpa_s->wpa) &&
@@ -264,25 +316,15 @@
 		ret = wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, peer);
 	}
 	if (ret) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaIface::initiateTdlsTeardown(
-    const hidl_array<uint8_t, 6 /* 6 */> &mac_address,
-    initiateTdlsTeardown_cb _hidl_cb)
+SupplicantStatus StaIface::initiateTdlsTeardownInternal(
+    const std::array<uint8_t, 6> &mac_address)
 {
 	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
-	if (!wpa_s) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_IFACE_INVALID);
-	}
-
-	if (!mac_address.data()) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
-	}
-
 	int ret;
 	const u8 *peer = mac_address.data();
 	if (wpa_tdls_is_external_setup(wpa_s->wpa) &&
@@ -292,12 +334,26 @@
 	} else {
 		ret = wpa_drv_tdls_oper(wpa_s, TDLS_TEARDOWN, peer);
 	}
-
 	if (ret) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
 
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+SupplicantStatus StaIface::initiateAnqpQueryInternal(
+    const std::array<uint8_t, 6> &mac_address,
+    const std::vector<ISupplicantStaIface::AnqpInfoId> &info_elements,
+    const std::vector<ISupplicantStaIface::Hs20AnqpSubtypes> &sub_types)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus StaIface::initiateHs20IconQueryInternal(
+    const std::array<uint8_t, 6> &mac_address, const std::string &file_name)
+{
+	// TODO: Add implementation.
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
 /**
diff --git a/wpa_supplicant/hidl/sta_iface.h b/wpa_supplicant/hidl/sta_iface.h
index f246bbc..a4177aa 100644
--- a/wpa_supplicant/hidl/sta_iface.h
+++ b/wpa_supplicant/hidl/sta_iface.h
@@ -10,6 +10,9 @@
 #ifndef WPA_SUPPLICANT_HIDL_STA_IFACE_H
 #define WPA_SUPPLICANT_HIDL_STA_IFACE_H
 
+#include <array>
+#include <vector>
+
 #include <android-base/macros.h>
 
 #include <android/hardware/wifi/supplicant/1.0/ISupplicantStaIface.h>
@@ -43,14 +46,29 @@
 public:
 	StaIface(struct wpa_global* wpa_global, const char ifname[]);
 	~StaIface() override = default;
+	// HIDL does not provide a built-in mechanism to let the server
+	// invalidate a HIDL interface object after creation. If any client
+	// process holds onto a reference to the object in their context,
+	// any method calls on that reference will continue to be directed to
+	// the server.
+	// However Supplicant HAL needs to control the lifetime of these
+	// objects. So, add a public |invalidate| method to all |Iface| and
+	// |Network| objects.
+	// This will be used to mark an object invalid when the corresponding
+	// iface or network is removed.
+	// All HIDL method implementations should check if the object is still
+	// marked valid before processing them.
+	void invalidate();
+	bool isValid();
 
 	// Hidl methods exposed.
 	Return<void> getName(getName_cb _hidl_cb) override;
 	Return<void> getType(getType_cb _hidl_cb) override;
 	Return<void> addNetwork(addNetwork_cb _hidl_cb) override;
 	Return<void> removeNetwork(
-	    uint32_t id, removeNetwork_cb _hidl_cb) override;
-	Return<void> getNetwork(uint32_t id, getNetwork_cb _hidl_cb) override;
+	    SupplicantNetworkId id, removeNetwork_cb _hidl_cb) override;
+	Return<void> getNetwork(
+	    SupplicantNetworkId id, getNetwork_cb _hidl_cb) override;
 	Return<void> listNetworks(listNetworks_cb _hidl_cb) override;
 	Return<void> registerCallback(
 	    const sp<ISupplicantStaIfaceCallback>& callback,
@@ -61,16 +79,56 @@
 	Return<void> setPowerSave(
 	    bool enable, setPowerSave_cb _hidl_cb) override;
 	Return<void> initiateTdlsDiscover(
-	    const hidl_array<uint8_t, 6 /* 6 */>& mac_address,
+	    const hidl_array<uint8_t, 6>& mac_address,
 	    initiateTdlsDiscover_cb _hidl_cb) override;
 	Return<void> initiateTdlsSetup(
-	    const hidl_array<uint8_t, 6 /* 6 */>& mac_address,
+	    const hidl_array<uint8_t, 6>& mac_address,
 	    initiateTdlsSetup_cb _hidl_cb) override;
 	Return<void> initiateTdlsTeardown(
-	    const hidl_array<uint8_t, 6 /* 6 */>& mac_address,
+	    const hidl_array<uint8_t, 6>& mac_address,
 	    initiateTdlsTeardown_cb _hidl_cb) override;
+	Return<void> initiateAnqpQuery(
+	    const hidl_array<uint8_t, 6>& mac_address,
+	    const hidl_vec<ISupplicantStaIface::AnqpInfoId>& info_elements,
+	    const hidl_vec<ISupplicantStaIface::Hs20AnqpSubtypes>& sub_types,
+	    initiateAnqpQuery_cb _hidl_cb) override;
+	Return<void> initiateHs20IconQuery(
+	    const hidl_array<uint8_t, 6>& mac_address,
+	    const hidl_string& file_name,
+	    initiateHs20IconQuery_cb _hidl_cb) override;
 
 private:
+	// Corresponding worker functions for the HIDL methods.
+	std::pair<SupplicantStatus, std::string> getNameInternal();
+	std::pair<SupplicantStatus, IfaceType> getTypeInternal();
+	std::pair<SupplicantStatus, sp<ISupplicantNetwork>>
+	addNetworkInternal();
+	SupplicantStatus removeNetworkInternal(SupplicantNetworkId id);
+	std::pair<SupplicantStatus, sp<ISupplicantNetwork>> getNetworkInternal(
+	    SupplicantNetworkId id);
+	std::pair<SupplicantStatus, std::vector<SupplicantNetworkId>>
+	listNetworksInternal();
+	SupplicantStatus registerCallbackInternal(
+	    const sp<ISupplicantStaIfaceCallback>& callback);
+	SupplicantStatus reassociateInternal();
+	SupplicantStatus reconnectInternal();
+	SupplicantStatus disconnectInternal();
+	SupplicantStatus setPowerSaveInternal(bool enable);
+	SupplicantStatus initiateTdlsDiscoverInternal(
+	    const std::array<uint8_t, 6>& mac_address);
+	SupplicantStatus initiateTdlsSetupInternal(
+	    const std::array<uint8_t, 6>& mac_address);
+	SupplicantStatus initiateTdlsTeardownInternal(
+	    const std::array<uint8_t, 6>& mac_address);
+	SupplicantStatus initiateAnqpQueryInternal(
+	    const std::array<uint8_t, 6>& mac_address,
+	    const std::vector<ISupplicantStaIface::AnqpInfoId>& info_elements,
+	    const std::vector<ISupplicantStaIface::Hs20AnqpSubtypes>&
+		sub_types);
+	SupplicantStatus initiateHs20IconQueryInternal(
+	    const std::array<uint8_t, 6>& mac_address,
+	    const std::string& file_name);
+
 	struct wpa_supplicant* retrieveIfacePtr();
 
 	// Reference to the global wpa_struct. This is assumed to be valid for
@@ -78,6 +136,7 @@
 	const struct wpa_global* wpa_global_;
 	// Name of the iface this hidl object controls
 	const std::string ifname_;
+	bool is_valid_;
 
 	DISALLOW_COPY_AND_ASSIGN(StaIface);
 };
diff --git a/wpa_supplicant/hidl/sta_network.cpp b/wpa_supplicant/hidl/sta_network.cpp
index c782101..15e628f 100644
--- a/wpa_supplicant/hidl/sta_network.cpp
+++ b/wpa_supplicant/hidl/sta_network.cpp
@@ -8,7 +8,7 @@
  */
 
 #include "hidl_manager.h"
-#include "hidl_return_macros.h"
+#include "hidl_return_util.h"
 #include "sta_network.h"
 
 namespace {
@@ -56,106 +56,446 @@
 namespace supplicant {
 namespace V1_0 {
 namespace implementation {
+using hidl_return_util::validateAndCall;
 
 StaNetwork::StaNetwork(
     struct wpa_global *wpa_global, const char ifname[], int network_id)
-    : wpa_global_(wpa_global), ifname_(ifname), network_id_(network_id)
+    : wpa_global_(wpa_global),
+      ifname_(ifname),
+      network_id_(network_id),
+      is_valid_(true)
 {
 }
 
+void StaNetwork::invalidate() { is_valid_ = false; }
+bool StaNetwork::isValid()
+{
+	return (is_valid_ && (retrieveNetworkPtr() != nullptr));
+}
+
 Return<void> StaNetwork::getId(getId_cb _hidl_cb)
 {
-	uint32_t id = UINT32_MAX;
-	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID, id);
-	}
-
-	id = network_id_;
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, id);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getIdInternal, _hidl_cb);
 }
 
 Return<void> StaNetwork::getInterfaceName(getInterfaceName_cb _hidl_cb)
 {
-	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID, ifname_);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifname_);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getInterfaceNameInternal, _hidl_cb);
 }
 
 Return<void> StaNetwork::getType(getType_cb _hidl_cb)
 {
-	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_INVALID,
-		    IfaceType::STA);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, IfaceType::STA);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getTypeInternal, _hidl_cb);
 }
 
 Return<void> StaNetwork::registerCallback(
     const sp<ISupplicantStaNetworkCallback> &callback,
     registerCallback_cb _hidl_cb)
 {
-	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
-	HidlManager *hidl_manager = HidlManager::getInstance();
-	if (!hidl_manager ||
-	    hidl_manager->addStaNetworkCallbackHidlObject(
-		ifname_, network_id_, callback)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::registerCallbackInternal, _hidl_cb, callback);
 }
 
 Return<void> StaNetwork::setSsid(
     const hidl_vec<uint8_t> &ssid, setSsid_cb _hidl_cb)
 {
-	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setSsidInternal, _hidl_cb, ssid);
+}
 
+Return<void> StaNetwork::setBssid(
+    const hidl_array<uint8_t, 6> &bssid, setBssid_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setBssidInternal, _hidl_cb, bssid);
+}
+
+Return<void> StaNetwork::setScanSsid(bool enable, setScanSsid_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setScanSsidInternal, _hidl_cb, enable);
+}
+
+Return<void> StaNetwork::setKeyMgmt(
+    uint32_t key_mgmt_mask, setKeyMgmt_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setKeyMgmtInternal, _hidl_cb, key_mgmt_mask);
+}
+
+Return<void> StaNetwork::setProto(uint32_t proto_mask, setProto_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setProtoInternal, _hidl_cb, proto_mask);
+}
+
+Return<void> StaNetwork::setAuthAlg(
+    uint32_t auth_alg_mask,
+    std::function<void(const SupplicantStatus &status)> _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setAuthAlgInternal, _hidl_cb, auth_alg_mask);
+}
+
+Return<void> StaNetwork::setGroupCipher(
+    uint32_t group_cipher_mask, setGroupCipher_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setGroupCipherInternal, _hidl_cb, group_cipher_mask);
+}
+
+Return<void> StaNetwork::setPairwiseCipher(
+    uint32_t pairwise_cipher_mask, setPairwiseCipher_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setPairwiseCipherInternal, _hidl_cb,
+	    pairwise_cipher_mask);
+}
+
+Return<void> StaNetwork::setPskPassphrase(
+    const hidl_string &psk, setPskPassphrase_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setPskPassphraseInternal, _hidl_cb, psk);
+}
+
+Return<void> StaNetwork::setWepKey(
+    uint32_t key_idx, const hidl_vec<uint8_t> &wep_key, setWepKey_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setWepKeyInternal, _hidl_cb, key_idx, wep_key);
+}
+
+Return<void> StaNetwork::setWepTxKeyIdx(
+    uint32_t key_idx, setWepTxKeyIdx_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setWepTxKeyIdxInternal, _hidl_cb, key_idx);
+}
+
+Return<void> StaNetwork::setRequirePmf(bool enable, setRequirePmf_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setRequirePmfInternal, _hidl_cb, enable);
+}
+
+Return<void> StaNetwork::setEapMethod(
+    ISupplicantStaNetwork::EapMethod method, setEapMethod_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapMethodInternal, _hidl_cb, method);
+}
+
+Return<void> StaNetwork::setEapPhase2Method(
+    ISupplicantStaNetwork::EapPhase2Method method,
+    setEapPhase2Method_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapPhase2MethodInternal, _hidl_cb, method);
+}
+
+Return<void> StaNetwork::setEapIdentity(
+    const hidl_vec<uint8_t> &identity, setEapIdentity_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapIdentityInternal, _hidl_cb, identity);
+}
+
+Return<void> StaNetwork::setEapAnonymousIdentity(
+    const hidl_vec<uint8_t> &identity, setEapAnonymousIdentity_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapAnonymousIdentityInternal, _hidl_cb, identity);
+}
+
+Return<void> StaNetwork::setEapPassword(
+    const hidl_vec<uint8_t> &password, setEapPassword_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapPasswordInternal, _hidl_cb, password);
+}
+
+Return<void> StaNetwork::setEapCACert(
+    const hidl_string &path, setEapCACert_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapCACertInternal, _hidl_cb, path);
+}
+
+Return<void> StaNetwork::setEapCAPath(
+    const hidl_string &path, setEapCAPath_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapCAPathInternal, _hidl_cb, path);
+}
+
+Return<void> StaNetwork::setEapClientCert(
+    const hidl_string &path, setEapClientCert_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapClientCertInternal, _hidl_cb, path);
+}
+
+Return<void> StaNetwork::setEapPrivateKey(
+    const hidl_string &path, setEapPrivateKey_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapPrivateKeyInternal, _hidl_cb, path);
+}
+
+Return<void> StaNetwork::setEapSubjectMatch(
+    const hidl_string &match, setEapSubjectMatch_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapSubjectMatchInternal, _hidl_cb, match);
+}
+
+Return<void> StaNetwork::setEapAltSubjectMatch(
+    const hidl_string &match, setEapAltSubjectMatch_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapAltSubjectMatchInternal, _hidl_cb, match);
+}
+
+Return<void> StaNetwork::setEapEngine(bool enable, setEapEngine_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapEngineInternal, _hidl_cb, enable);
+}
+
+Return<void> StaNetwork::setEapEngineID(
+    const hidl_string &id, setEapEngineID_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapEngineIDInternal, _hidl_cb, id);
+}
+
+Return<void> StaNetwork::setEapDomainSuffixMatch(
+    const hidl_string &match, setEapDomainSuffixMatch_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::setEapDomainSuffixMatchInternal, _hidl_cb, match);
+}
+
+Return<void> StaNetwork::getSsid(getSsid_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getSsidInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::getBssid(getBssid_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getBssidInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::getScanSsid(getScanSsid_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getScanSsidInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::getKeyMgmt(getKeyMgmt_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getKeyMgmtInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::getProto(getProto_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getProtoInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::getAuthAlg(getAuthAlg_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getAuthAlgInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::getGroupCipher(getGroupCipher_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getGroupCipherInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::getPairwiseCipher(getPairwiseCipher_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getPairwiseCipherInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::getPskPassphrase(getPskPassphrase_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getPskPassphraseInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::getWepKey(uint32_t key_idx, getWepKey_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getWepKeyInternal, _hidl_cb, key_idx);
+}
+
+Return<void> StaNetwork::getWepTxKeyIdx(getWepTxKeyIdx_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getWepTxKeyIdxInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::getRequirePmf(getRequirePmf_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::getRequirePmfInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::enable(bool no_connect, enable_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::enableInternal, _hidl_cb, no_connect);
+}
+
+Return<void> StaNetwork::disable(disable_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::disableInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::select(select_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::selectInternal, _hidl_cb);
+}
+
+Return<void> StaNetwork::sendNetworkEapSimGsmAuthResponse(
+    const ISupplicantStaNetwork::NetworkResponseEapSimGsmAuthParams &params,
+    sendNetworkEapSimGsmAuthResponse_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::sendNetworkEapSimGsmAuthResponseInternal, _hidl_cb,
+	    params);
+}
+
+Return<void> StaNetwork::sendNetworkEapSimUmtsAuthResponse(
+    const ISupplicantStaNetwork::NetworkResponseEapSimUmtsAuthParams &params,
+    sendNetworkEapSimUmtsAuthResponse_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::sendNetworkEapSimUmtsAuthResponseInternal, _hidl_cb,
+	    params);
+}
+
+Return<void> StaNetwork::sendNetworkEapIdentityResponse(
+    const hidl_vec<uint8_t> &identity,
+    sendNetworkEapIdentityResponse_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_NETWORK_INVALID,
+	    &StaNetwork::sendNetworkEapIdentityResponseInternal, _hidl_cb,
+	    identity);
+}
+
+std::pair<SupplicantStatus, uint32_t> StaNetwork::getIdInternal()
+{
+	return {{SupplicantStatusCode::SUCCESS, ""}, network_id_};
+}
+
+std::pair<SupplicantStatus, std::string> StaNetwork::getInterfaceNameInternal()
+{
+	return {{SupplicantStatusCode::SUCCESS, ""}, ifname_};
+}
+
+std::pair<SupplicantStatus, IfaceType> StaNetwork::getTypeInternal()
+{
+	return {{SupplicantStatusCode::SUCCESS, ""}, IfaceType::STA};
+}
+
+SupplicantStatus StaNetwork::registerCallbackInternal(
+    const sp<ISupplicantStaNetworkCallback> &callback)
+{
+	HidlManager *hidl_manager = HidlManager::getInstance();
+	if (!hidl_manager ||
+	    hidl_manager->addStaNetworkCallbackHidlObject(
+		ifname_, network_id_, callback)) {
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+	}
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus StaNetwork::setSsidInternal(const std::vector<uint8_t> &ssid)
+{
+	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
 	if (ssid.size() == 0 ||
 	    ssid.size() >
 		static_cast<uint32_t>(ISupplicantStaNetwork::ParamSizeLimits::
 					  SSID_MAX_LEN_IN_BYTES)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+		return {SupplicantStatusCode::FAILURE_ARGS_INVALID, ""};
 	}
-
 	if (setByteArrayFieldAndResetState(
 		ssid.data(), ssid.size(), &(wpa_ssid->ssid),
 		&(wpa_ssid->ssid_len), "ssid")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
 	if (wpa_ssid->passphrase) {
 		wpa_config_update_psk(wpa_ssid);
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setBssid(
-    const hidl_array<uint8_t, 6 /* 6 */> &bssid, setBssid_cb _hidl_cb)
+SupplicantStatus StaNetwork::setBssidInternal(
+    const std::array<uint8_t, 6> &bssid)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
-	if (!bssid.data()) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
-	}
-
 	int prev_bssid_set = wpa_ssid->bssid_set;
 	u8 prev_bssid[ETH_ALEN];
 	os_memcpy(prev_bssid, wpa_ssid->bssid, ETH_ALEN);
@@ -173,156 +513,111 @@
 	     os_memcmp(wpa_ssid->bssid, prev_bssid, ETH_ALEN) != 0)) {
 		wpas_notify_network_bssid_set_changed(wpa_s, wpa_ssid);
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setScanSsid(bool enable, setScanSsid_cb _hidl_cb)
+SupplicantStatus StaNetwork::setScanSsidInternal(bool enable)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	wpa_ssid->scan_ssid = enable ? 1 : 0;
 	resetInternalStateAfterParamsUpdate();
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setKeyMgmt(
-    uint32_t key_mgmt_mask, setKeyMgmt_cb _hidl_cb)
+SupplicantStatus StaNetwork::setKeyMgmtInternal(uint32_t key_mgmt_mask)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (key_mgmt_mask & ~kAllowedKeyMgmtMask) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+		return {SupplicantStatusCode::FAILURE_ARGS_INVALID, ""};
 	}
 	wpa_ssid->key_mgmt = key_mgmt_mask;
 	wpa_printf(MSG_MSGDUMP, "key_mgmt: 0x%x", wpa_ssid->key_mgmt);
 	resetInternalStateAfterParamsUpdate();
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setProto(uint32_t proto_mask, setProto_cb _hidl_cb)
+SupplicantStatus StaNetwork::setProtoInternal(uint32_t proto_mask)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (proto_mask & ~kAllowedproto_mask) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+		return {SupplicantStatusCode::FAILURE_ARGS_INVALID, ""};
 	}
 	wpa_ssid->proto = proto_mask;
 	wpa_printf(MSG_MSGDUMP, "proto: 0x%x", wpa_ssid->proto);
 	resetInternalStateAfterParamsUpdate();
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setAuthAlg(
-    uint32_t auth_alg_mask,
-    std::function<void(const SupplicantStatus &status)> _hidl_cb)
+SupplicantStatus StaNetwork::setAuthAlgInternal(uint32_t auth_alg_mask)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (auth_alg_mask & ~kAllowedauth_alg_mask) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+		return {SupplicantStatusCode::FAILURE_ARGS_INVALID, ""};
 	}
 	wpa_ssid->auth_alg = auth_alg_mask;
 	wpa_printf(MSG_MSGDUMP, "auth_alg: 0x%x", wpa_ssid->auth_alg);
 	resetInternalStateAfterParamsUpdate();
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setGroupCipher(
-    uint32_t group_cipher_mask, setGroupCipher_cb _hidl_cb)
+SupplicantStatus StaNetwork::setGroupCipherInternal(uint32_t group_cipher_mask)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (group_cipher_mask & ~kAllowedgroup_cipher_mask) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+		return {SupplicantStatusCode::FAILURE_ARGS_INVALID, ""};
 	}
 	wpa_ssid->group_cipher = group_cipher_mask;
 	wpa_printf(MSG_MSGDUMP, "group_cipher: 0x%x", wpa_ssid->group_cipher);
 	resetInternalStateAfterParamsUpdate();
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setPairwiseCipher(
-    uint32_t pairwise_cipher_mask, setPairwiseCipher_cb _hidl_cb)
+SupplicantStatus StaNetwork::setPairwiseCipherInternal(
+    uint32_t pairwise_cipher_mask)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (pairwise_cipher_mask & ~kAllowedpairwise_cipher_mask) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+		return {SupplicantStatusCode::FAILURE_ARGS_INVALID, ""};
 	}
 	wpa_ssid->pairwise_cipher = pairwise_cipher_mask;
 	wpa_printf(
 	    MSG_MSGDUMP, "pairwise_cipher: 0x%x", wpa_ssid->pairwise_cipher);
 	resetInternalStateAfterParamsUpdate();
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setPskPassphrase(
-    const hidl_string &psk, setPskPassphrase_cb _hidl_cb)
+SupplicantStatus StaNetwork::setPskPassphraseInternal(const std::string &psk)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (isPskPassphraseValid(psk)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+		return {SupplicantStatusCode::FAILURE_ARGS_INVALID, ""};
 	}
 	if (wpa_ssid->passphrase &&
 	    os_strlen(wpa_ssid->passphrase) == psk.size() &&
 	    os_memcmp(wpa_ssid->passphrase, psk.c_str(), psk.size()) == 0) {
-		HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+		return {SupplicantStatusCode::SUCCESS, ""};
 	}
 	// Flag to indicate if raw psk is calculated or not using
 	// |wpa_config_update_psk|. Deferred if ssid not already set.
 	wpa_ssid->psk_set = 0;
 	if (setStringKeyFieldAndResetState(
 		psk.c_str(), &(wpa_ssid->passphrase), "psk passphrase")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
 	if (wpa_ssid->ssid_len) {
 		wpa_config_update_psk(wpa_ssid);
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setWepKey(
-    uint32_t key_idx, const hidl_vec<uint8_t> &wep_key, setWepKey_cb _hidl_cb)
+SupplicantStatus StaNetwork::setWepKeyInternal(
+    uint32_t key_idx, const std::vector<uint8_t> &wep_key)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (key_idx >=
 	    static_cast<uint32_t>(
 		ISupplicantStaNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+		return {SupplicantStatusCode::FAILURE_ARGS_INVALID, ""};
 	}
 	if (wep_key.size() !=
 		static_cast<uint32_t>(ISupplicantStaNetwork::ParamSizeLimits::
@@ -330,7 +625,7 @@
 	    wep_key.size() !=
 		static_cast<uint32_t>(ISupplicantStaNetwork::ParamSizeLimits::
 					  WEP104_KEY_LEN_IN_BYTES)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+		return {SupplicantStatusCode::FAILURE_ARGS_INVALID, ""};
 	}
 	os_memcpy(wpa_ssid->wep_key[key_idx], wep_key.data(), wep_key.size());
 	wpa_ssid->wep_key_len[key_idx] = wep_key.size();
@@ -339,52 +634,36 @@
 	    MSG_MSGDUMP, msg_dump_title.c_str(), wpa_ssid->wep_key[key_idx],
 	    wpa_ssid->wep_key_len[key_idx]);
 	resetInternalStateAfterParamsUpdate();
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setWepTxKeyIdx(
-    uint32_t key_idx, setWepTxKeyIdx_cb _hidl_cb)
+SupplicantStatus StaNetwork::setWepTxKeyIdxInternal(uint32_t key_idx)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (key_idx >=
 	    static_cast<uint32_t>(
 		ISupplicantStaNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_ARGS_INVALID);
+		return {SupplicantStatusCode::FAILURE_ARGS_INVALID, ""};
 	}
 	wpa_ssid->wep_tx_keyidx = key_idx;
 	resetInternalStateAfterParamsUpdate();
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setRequirePmf(bool enable, setRequirePmf_cb _hidl_cb)
+SupplicantStatus StaNetwork::setRequirePmfInternal(bool enable)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	wpa_ssid->ieee80211w =
 	    enable ? MGMT_FRAME_PROTECTION_REQUIRED : NO_MGMT_FRAME_PROTECTION;
 	resetInternalStateAfterParamsUpdate();
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapMethod(
-    ISupplicantStaNetwork::EapMethod method, setEapMethod_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapMethodInternal(
+    ISupplicantStaNetwork::EapMethod method)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
 	int retrieved_vendor, retrieved_method;
-
 	const char *method_str =
 	    kEapMethodStrings[static_cast<uint32_t>(method)];
 	// This string lookup is needed to check if the device supports the
@@ -392,9 +671,8 @@
 	retrieved_method = eap_peer_get_type(method_str, &retrieved_vendor);
 	if (retrieved_vendor == EAP_VENDOR_IETF &&
 	    retrieved_method == EAP_TYPE_NONE) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
 	if (wpa_ssid->eap.eap_methods) {
 		os_free(wpa_ssid->eap.eap_methods);
 	}
@@ -406,7 +684,7 @@
 	wpa_ssid->eap.eap_methods =
 	    (eap_method_type *)os_malloc(sizeof(eap_method_type) * 2);
 	if (!wpa_ssid->eap.eap_methods) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
 	wpa_ssid->eap.eap_methods[0].vendor = retrieved_vendor;
 	wpa_ssid->eap.eap_methods[0].method = retrieved_method;
@@ -421,432 +699,263 @@
 	} else {
 		wpa_ssid->non_leap++;
 	}
-
 	wpa_hexdump(
 	    MSG_MSGDUMP, "eap methods", (u8 *)wpa_ssid->eap.eap_methods,
 	    sizeof(eap_method_type) * 2);
 	resetInternalStateAfterParamsUpdate();
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapPhase2Method(
-    ISupplicantStaNetwork::EapPhase2Method method,
-    setEapPhase2Method_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapPhase2MethodInternal(
+    ISupplicantStaNetwork::EapPhase2Method method)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setStringFieldAndResetState(
 		kEapPhase2MethodStrings[static_cast<uint32_t>(method)],
 		&(wpa_ssid->eap.phase2), "eap phase2")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapIdentity(
-    const hidl_vec<uint8_t> &identity, setEapIdentity_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapIdentityInternal(
+    const std::vector<uint8_t> &identity)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setByteArrayFieldAndResetState(
 		identity.data(), identity.size(), &(wpa_ssid->eap.identity),
 		&(wpa_ssid->eap.identity_len), "eap identity")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapAnonymousIdentity(
-    const hidl_vec<uint8_t> &identity, setEapAnonymousIdentity_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapAnonymousIdentityInternal(
+    const std::vector<uint8_t> &identity)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setByteArrayFieldAndResetState(
 		identity.data(), identity.size(),
 		&(wpa_ssid->eap.anonymous_identity),
 		&(wpa_ssid->eap.anonymous_identity_len),
 		"eap anonymous_identity")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapPassword(
-    const hidl_vec<uint8_t> &password, setEapPassword_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapPasswordInternal(
+    const std::vector<uint8_t> &password)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setByteArrayKeyFieldAndResetState(
 		password.data(), password.size(), &(wpa_ssid->eap.password),
 		&(wpa_ssid->eap.password_len), "eap password")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
 	wpa_ssid->eap.flags &= ~EAP_CONFIG_FLAGS_PASSWORD_NTHASH;
 	wpa_ssid->eap.flags &= ~EAP_CONFIG_FLAGS_EXT_PASSWORD;
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapCACert(
-    const hidl_string &path, setEapCACert_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapCACertInternal(const std::string &path)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setStringFieldAndResetState(
 		path.c_str(), &(wpa_ssid->eap.ca_cert), "eap ca_cert")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapCAPath(
-    const hidl_string &path, setEapCAPath_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapCAPathInternal(const std::string &path)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setStringFieldAndResetState(
 		path.c_str(), &(wpa_ssid->eap.ca_path), "eap ca_path")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapClientCert(
-    const hidl_string &path, setEapClientCert_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapClientCertInternal(const std::string &path)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setStringFieldAndResetState(
 		path.c_str(), &(wpa_ssid->eap.client_cert),
 		"eap client_cert")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapPrivateKey(
-    const hidl_string &path, setEapPrivateKey_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapPrivateKeyInternal(const std::string &path)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setStringFieldAndResetState(
 		path.c_str(), &(wpa_ssid->eap.private_key),
 		"eap private_key")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapSubjectMatch(
-    const hidl_string &match, setEapSubjectMatch_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapSubjectMatchInternal(
+    const std::string &match)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setStringFieldAndResetState(
 		match.c_str(), &(wpa_ssid->eap.subject_match),
 		"eap subject_match")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapAltSubjectMatch(
-    const hidl_string &match, setEapAltSubjectMatch_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapAltSubjectMatchInternal(
+    const std::string &match)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setStringFieldAndResetState(
 		match.c_str(), &(wpa_ssid->eap.altsubject_match),
 		"eap altsubject_match")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapEngine(bool enable, setEapEngine_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapEngineInternal(bool enable)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	wpa_ssid->eap.engine = enable ? 1 : 0;
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapEngineID(
-    const hidl_string &id, setEapEngineID_cb _hidl_cb)
-
+SupplicantStatus StaNetwork::setEapEngineIDInternal(const std::string &id)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setStringFieldAndResetState(
 		id.c_str(), &(wpa_ssid->eap.engine_id), "eap engine_id")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::setEapDomainSuffixMatch(
-    const hidl_string &match, setEapDomainSuffixMatch_cb _hidl_cb)
+SupplicantStatus StaNetwork::setEapDomainSuffixMatchInternal(
+    const std::string &match)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (setStringFieldAndResetState(
 		match.c_str(), &(wpa_ssid->eap.domain_suffix_match),
 		"eap domain_suffix_match")) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::getSsid(getSsid_cb _hidl_cb)
+std::pair<SupplicantStatus, std::vector<uint8_t>> StaNetwork::getSsidInternal()
 {
+	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
 	std::vector<uint8_t> ssid;
-	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID, ssid);
-	}
-
 	ssid.assign(wpa_ssid->ssid, wpa_ssid->ssid + wpa_ssid->ssid_len);
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, ssid);
+	return {{SupplicantStatusCode::SUCCESS, ""}, std::move(ssid)};
 }
 
-Return<void> StaNetwork::getBssid(getBssid_cb _hidl_cb)
+std::pair<SupplicantStatus, std::array<uint8_t, 6>>
+StaNetwork::getBssidInternal()
 {
-	hidl_array<uint8_t, 6> bssid;
-	os_memcpy(bssid.data(), kZeroBssid, ETH_ALEN);
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID, bssid);
-	}
-
+	std::array<uint8_t, 6> bssid{};
+	os_memcpy(bssid.data(), kZeroBssid, ETH_ALEN);
 	if (wpa_ssid->bssid_set) {
 		os_memcpy(bssid.data(), wpa_ssid->bssid, ETH_ALEN);
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, bssid);
+	return {{SupplicantStatusCode::SUCCESS, ""}, std::move(bssid)};
 }
 
-Return<void> StaNetwork::getScanSsid(getScanSsid_cb _hidl_cb)
+std::pair<SupplicantStatus, bool> StaNetwork::getScanSsidInternal()
 {
-	bool enabled = false;
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID, enabled);
-	}
-
-	enabled = (wpa_ssid->scan_ssid == 1);
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, enabled);
+	return {{SupplicantStatusCode::SUCCESS, ""},
+		(wpa_ssid->scan_ssid == 1)};
 }
 
-Return<void> StaNetwork::getKeyMgmt(getKeyMgmt_cb _hidl_cb)
+std::pair<SupplicantStatus, uint32_t> StaNetwork::getKeyMgmtInternal()
 {
-	uint32_t key_mgmt_mask = 0;
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID,
-		    key_mgmt_mask);
-	}
-
-	key_mgmt_mask = wpa_ssid->key_mgmt;
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, key_mgmt_mask);
+	return {{SupplicantStatusCode::SUCCESS, ""}, wpa_ssid->key_mgmt};
 }
 
-Return<void> StaNetwork::getProto(getProto_cb _hidl_cb)
+std::pair<SupplicantStatus, uint32_t> StaNetwork::getProtoInternal()
 {
-	uint32_t proto_mask = 0;
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID, proto_mask);
-	}
-
-	proto_mask = wpa_ssid->proto;
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, proto_mask);
+	return {{SupplicantStatusCode::SUCCESS, ""}, wpa_ssid->proto};
 }
 
-Return<void> StaNetwork::getAuthAlg(getAuthAlg_cb _hidl_cb)
+std::pair<SupplicantStatus, uint32_t> StaNetwork::getAuthAlgInternal()
 {
-	uint32_t auth_alg_mask = 0;
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID,
-		    auth_alg_mask);
-	}
-
-	auth_alg_mask = wpa_ssid->auth_alg;
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, auth_alg_mask);
+	return {{SupplicantStatusCode::SUCCESS, ""}, wpa_ssid->auth_alg};
 }
 
-Return<void> StaNetwork::getGroupCipher(getGroupCipher_cb _hidl_cb)
+std::pair<SupplicantStatus, uint32_t> StaNetwork::getGroupCipherInternal()
 {
-	uint32_t group_cipher_mask = 0;
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID,
-		    group_cipher_mask);
-	}
-
-	group_cipher_mask = wpa_ssid->group_cipher;
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, group_cipher_mask);
+	return {{SupplicantStatusCode::SUCCESS, ""}, wpa_ssid->group_cipher};
 }
 
-Return<void> StaNetwork::getPairwiseCipher(getPairwiseCipher_cb _hidl_cb)
+std::pair<SupplicantStatus, uint32_t> StaNetwork::getPairwiseCipherInternal()
 {
-	uint32_t pairwise_cipher_mask = 0;
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID,
-		    pairwise_cipher_mask);
-	}
-
-	pairwise_cipher_mask = wpa_ssid->pairwise_cipher;
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, pairwise_cipher_mask);
+	return {{SupplicantStatusCode::SUCCESS, ""}, wpa_ssid->pairwise_cipher};
 }
 
-Return<void> StaNetwork::getPskPassphrase(getPskPassphrase_cb _hidl_cb)
+std::pair<SupplicantStatus, std::string> StaNetwork::getPskPassphraseInternal()
 {
-	hidl_string psk;
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID, psk);
-	}
-
+	std::string psk;
 	if (wpa_ssid->passphrase) {
 		psk = wpa_ssid->passphrase;
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, psk);
+	return {{SupplicantStatusCode::SUCCESS, ""}, std::move(psk)};
 }
 
-Return<void> StaNetwork::getWepKey(uint32_t key_idx, getWepKey_cb _hidl_cb)
+std::pair<SupplicantStatus, std::vector<uint8_t>> StaNetwork::getWepKeyInternal(
+    uint32_t key_idx)
 {
 	std::vector<uint8_t> wep_key;
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID, wep_key);
-		return Void();
-	}
-
 	if (key_idx >=
 	    static_cast<uint32_t>(
 		ISupplicantStaNetwork::ParamSizeLimits::WEP_KEYS_MAX_NUM)) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_ARGS_INVALID, wep_key);
+		return {{SupplicantStatusCode::FAILURE_ARGS_INVALID, ""},
+			wep_key};
 	}
-
 	wep_key.assign(
 	    wpa_ssid->wep_key[key_idx],
 	    wpa_ssid->wep_key[key_idx] + wpa_ssid->wep_key_len[key_idx]);
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, wep_key);
+	return {{SupplicantStatusCode::SUCCESS, ""}, std::move(wep_key)};
 }
 
-Return<void> StaNetwork::getWepTxKeyIdx(getWepTxKeyIdx_cb _hidl_cb)
+std::pair<SupplicantStatus, uint32_t> StaNetwork::getWepTxKeyIdxInternal()
 {
-	uint32_t wep_tx_key_idx = UINT32_MAX;
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID,
-		    wep_tx_key_idx);
-	}
-
-	wep_tx_key_idx = wpa_ssid->wep_tx_keyidx;
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, wep_tx_key_idx);
+	return {{SupplicantStatusCode::SUCCESS, ""}, wpa_ssid->wep_tx_keyidx};
 }
 
-Return<void> StaNetwork::getRequirePmf(getRequirePmf_cb _hidl_cb)
+std::pair<SupplicantStatus, bool> StaNetwork::getRequirePmfInternal()
 {
-	bool enabled = false;
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_NETWORK_INVALID, enabled);
-	}
-
-	enabled = (wpa_ssid->ieee80211w == MGMT_FRAME_PROTECTION_REQUIRED);
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, enabled);
+	return {{SupplicantStatusCode::SUCCESS, ""},
+		(wpa_ssid->ieee80211w == MGMT_FRAME_PROTECTION_REQUIRED)};
 }
 
-Return<void> StaNetwork::enable(bool no_connect, enable_cb _hidl_cb)
+SupplicantStatus StaNetwork::enableInternal(bool no_connect)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (wpa_ssid->disabled != 0) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
 	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
 	if (no_connect) {
 		wpa_ssid->disabled = 0;
@@ -855,55 +964,37 @@
 		wpa_s->scan_min_time.usec = 0;
 		wpa_supplicant_enable_network(wpa_s, wpa_ssid);
 	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::disable(disable_cb _hidl_cb)
+SupplicantStatus StaNetwork::disableInternal()
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (wpa_ssid->disabled == 2) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
 	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
 	wpa_supplicant_disable_network(wpa_s, wpa_ssid);
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::select(select_cb _hidl_cb)
+SupplicantStatus StaNetwork::selectInternal()
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	if (wpa_ssid->disabled == 2) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
-
 	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
 	wpa_s->scan_min_time.sec = 0;
 	wpa_s->scan_min_time.usec = 0;
 	wpa_supplicant_select_network(wpa_s, wpa_ssid);
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::sendNetworkEapSimGsmAuthResponse(
-    const ISupplicantStaNetwork::NetworkResponseEapSimGsmAuthParams &params,
-    sendNetworkEapSimGsmAuthResponse_cb _hidl_cb)
+SupplicantStatus StaNetwork::sendNetworkEapSimGsmAuthResponseInternal(
+    const ISupplicantStaNetwork::NetworkResponseEapSimGsmAuthParams &params)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	// Convert the incoming parameters to a string to pass to
 	// wpa_supplicant.
 	std::string ctrl_rsp_param;
@@ -912,7 +1003,7 @@
 	uint32_t sres_hex_len = params.sres.size() * 2 + 1;
 	char *sres_hex = (char *)malloc(sres_hex_len);
 	if (!kc_hex || !sres_hex) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
 	wpa_snprintf_hex(
 	    kc_hex, kc_hex_len, params.kc.data(), params.kc.size());
@@ -922,30 +1013,23 @@
 	ctrl_rsp_param += kc_hex;
 	ctrl_rsp_param += " sres:";
 	ctrl_rsp_param += sres_hex;
-
 	enum wpa_ctrl_req_type rtype = WPA_CTRL_REQ_SIM;
 	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
 	if (wpa_supplicant_ctrl_rsp_handle(
 		wpa_s, wpa_ssid, rtype, ctrl_rsp_param.c_str())) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
 	eapol_sm_notify_ctrl_response(wpa_s->eapol);
 	wpa_hexdump_ascii_key(
 	    MSG_DEBUG, "network sim gsm auth response param",
 	    (const u8 *)ctrl_rsp_param.c_str(), ctrl_rsp_param.size());
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::sendNetworkEapSimUmtsAuthResponse(
-    const ISupplicantStaNetwork::NetworkResponseEapSimUmtsAuthParams &params,
-    sendNetworkEapSimUmtsAuthResponse_cb _hidl_cb)
+SupplicantStatus StaNetwork::sendNetworkEapSimUmtsAuthResponseInternal(
+    const ISupplicantStaNetwork::NetworkResponseEapSimUmtsAuthParams &params)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	// Convert the incoming parameters to a string to pass to
 	// wpa_supplicant.
 	std::string ctrl_rsp_param;
@@ -956,7 +1040,7 @@
 	uint32_t res_hex_len = params.res.size() * 2 + 1;
 	char *res_hex = (char *)malloc(res_hex_len);
 	if (!ik_hex || !ck_hex || !res_hex) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
 	wpa_snprintf_hex(
 	    ik_hex, ik_hex_len, params.ik.data(), params.ik.size());
@@ -970,54 +1054,45 @@
 	ctrl_rsp_param += ck_hex;
 	ctrl_rsp_param += " res:";
 	ctrl_rsp_param += res_hex;
-
 	enum wpa_ctrl_req_type rtype = WPA_CTRL_REQ_SIM;
 	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
 	if (wpa_supplicant_ctrl_rsp_handle(
 		wpa_s, wpa_ssid, rtype, ctrl_rsp_param.c_str())) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
 	eapol_sm_notify_ctrl_response(wpa_s->eapol);
 	wpa_hexdump_ascii_key(
 	    MSG_DEBUG, "network sim umts auth response param",
 	    (const u8 *)ctrl_rsp_param.c_str(), ctrl_rsp_param.size());
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
-Return<void> StaNetwork::sendNetworkEapIdentityResponse(
-    const hidl_vec<uint8_t> &identity,
-    sendNetworkEapIdentityResponse_cb _hidl_cb)
+SupplicantStatus StaNetwork::sendNetworkEapIdentityResponseInternal(
+    const std::vector<uint8_t> &identity)
 {
 	struct wpa_ssid *wpa_ssid = retrieveNetworkPtr();
-	if (!wpa_ssid) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_NETWORK_INVALID);
-	}
-
 	// Convert the incoming parameters to a string to pass to
 	// wpa_supplicant.
 	uint32_t identity_hex_len = identity.size() * 2 + 1;
 	char *identity_hex = (char *)malloc(identity_hex_len);
 	std::string ctrl_rsp_param;
 	if (!identity_hex) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
 	wpa_snprintf_hex(
 	    identity_hex, identity_hex_len, identity.data(), identity.size());
 	ctrl_rsp_param = identity_hex;
-
 	enum wpa_ctrl_req_type rtype = WPA_CTRL_REQ_EAP_IDENTITY;
 	struct wpa_supplicant *wpa_s = retrieveIfacePtr();
 	if (wpa_supplicant_ctrl_rsp_handle(
 		wpa_s, wpa_ssid, rtype, ctrl_rsp_param.c_str())) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
 	}
 	eapol_sm_notify_ctrl_response(wpa_s->eapol);
 	wpa_hexdump_ascii_key(
 	    MSG_DEBUG, "network identity response param",
 	    (const u8 *)ctrl_rsp_param.c_str(), ctrl_rsp_param.size());
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return {SupplicantStatusCode::SUCCESS, ""};
 }
 
 /**
@@ -1052,7 +1127,7 @@
  *
  * Returns 0 if valid, 1 otherwise.
  */
-int StaNetwork::isPskPassphraseValid(const hidl_string &psk)
+int StaNetwork::isPskPassphraseValid(const std::string &psk)
 {
 	if (psk.size() <
 		static_cast<uint32_t>(ISupplicantStaNetwork::ParamSizeLimits::
diff --git a/wpa_supplicant/hidl/sta_network.h b/wpa_supplicant/hidl/sta_network.h
index a2055c3..f35f230 100644
--- a/wpa_supplicant/hidl/sta_network.h
+++ b/wpa_supplicant/hidl/sta_network.h
@@ -10,6 +10,9 @@
 #ifndef WPA_SUPPLICANT_HIDL_STA_NETWORK_H
 #define WPA_SUPPLICANT_HIDL_STA_NETWORK_H
 
+#include <array>
+#include <vector>
+
 #include <android-base/macros.h>
 
 #include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
@@ -44,6 +47,9 @@
 	StaNetwork(
 	    struct wpa_global* wpa_global, const char ifname[], int network_id);
 	~StaNetwork() override = default;
+	// Refer to |StaIface::invalidate()|.
+	void invalidate();
+	bool isValid();
 
 	// Hidl methods exposed.
 	Return<void> getId(getId_cb _hidl_cb) override;
@@ -55,8 +61,7 @@
 	Return<void> setSsid(
 	    const hidl_vec<uint8_t>& ssid, setSsid_cb _hidl_cb) override;
 	Return<void> setBssid(
-	    const hidl_array<uint8_t, 6 /* 6 */>& bssid,
-	    setBssid_cb _hidl_cb) override;
+	    const hidl_array<uint8_t, 6>& bssid, setBssid_cb _hidl_cb) override;
 	Return<void> setScanSsid(bool enable, setScanSsid_cb _hidl_cb) override;
 	Return<void> setKeyMgmt(
 	    uint32_t key_mgmt_mask, setKeyMgmt_cb _hidl_cb) override;
@@ -142,9 +147,75 @@
 	    sendNetworkEapIdentityResponse_cb _hidl_cb) override;
 
 private:
+	// Corresponding worker functions for the HIDL methods.
+	std::pair<SupplicantStatus, uint32_t> getIdInternal();
+	std::pair<SupplicantStatus, std::string> getInterfaceNameInternal();
+	std::pair<SupplicantStatus, IfaceType> getTypeInternal();
+	SupplicantStatus registerCallbackInternal(
+	    const sp<ISupplicantStaNetworkCallback>& callback);
+	SupplicantStatus setSsidInternal(const std::vector<uint8_t>& ssid);
+	SupplicantStatus setBssidInternal(const std::array<uint8_t, 6>& bssid);
+	SupplicantStatus setScanSsidInternal(bool enable);
+	SupplicantStatus setKeyMgmtInternal(uint32_t key_mgmt_mask);
+	SupplicantStatus setProtoInternal(uint32_t proto_mask);
+	SupplicantStatus setAuthAlgInternal(uint32_t auth_alg_mask);
+	SupplicantStatus setGroupCipherInternal(uint32_t group_cipher_mask);
+	SupplicantStatus setPairwiseCipherInternal(
+	    uint32_t pairwise_cipher_mask);
+	SupplicantStatus setPskPassphraseInternal(const std::string& psk);
+	SupplicantStatus setWepKeyInternal(
+	    uint32_t key_idx, const std::vector<uint8_t>& wep_key);
+	SupplicantStatus setWepTxKeyIdxInternal(uint32_t key_idx);
+	SupplicantStatus setRequirePmfInternal(bool enable);
+	SupplicantStatus setEapMethodInternal(
+	    ISupplicantStaNetwork::EapMethod method);
+	SupplicantStatus setEapPhase2MethodInternal(
+	    ISupplicantStaNetwork::EapPhase2Method method);
+	SupplicantStatus setEapIdentityInternal(
+	    const std::vector<uint8_t>& identity);
+	SupplicantStatus setEapAnonymousIdentityInternal(
+	    const std::vector<uint8_t>& identity);
+	SupplicantStatus setEapPasswordInternal(
+	    const std::vector<uint8_t>& password);
+	SupplicantStatus setEapCACertInternal(const std::string& path);
+	SupplicantStatus setEapCAPathInternal(const std::string& path);
+	SupplicantStatus setEapClientCertInternal(const std::string& path);
+	SupplicantStatus setEapPrivateKeyInternal(const std::string& path);
+	SupplicantStatus setEapSubjectMatchInternal(const std::string& match);
+	SupplicantStatus setEapAltSubjectMatchInternal(
+	    const std::string& match);
+	SupplicantStatus setEapEngineInternal(bool enable);
+	SupplicantStatus setEapEngineIDInternal(const std::string& id);
+	SupplicantStatus setEapDomainSuffixMatchInternal(
+	    const std::string& match);
+	std::pair<SupplicantStatus, std::vector<uint8_t>> getSsidInternal();
+	std::pair<SupplicantStatus, std::array<uint8_t, 6>> getBssidInternal();
+	std::pair<SupplicantStatus, bool> getScanSsidInternal();
+	std::pair<SupplicantStatus, uint32_t> getKeyMgmtInternal();
+	std::pair<SupplicantStatus, uint32_t> getProtoInternal();
+	std::pair<SupplicantStatus, uint32_t> getAuthAlgInternal();
+	std::pair<SupplicantStatus, uint32_t> getGroupCipherInternal();
+	std::pair<SupplicantStatus, uint32_t> getPairwiseCipherInternal();
+	std::pair<SupplicantStatus, std::string> getPskPassphraseInternal();
+	std::pair<SupplicantStatus, std::vector<uint8_t>> getWepKeyInternal(
+	    uint32_t key_idx);
+	std::pair<SupplicantStatus, uint32_t> getWepTxKeyIdxInternal();
+	std::pair<SupplicantStatus, bool> getRequirePmfInternal();
+	SupplicantStatus enableInternal(bool no_connect);
+	SupplicantStatus disableInternal();
+	SupplicantStatus selectInternal();
+	SupplicantStatus sendNetworkEapSimGsmAuthResponseInternal(
+	    const ISupplicantStaNetwork::NetworkResponseEapSimGsmAuthParams&
+		params);
+	SupplicantStatus sendNetworkEapSimUmtsAuthResponseInternal(
+	    const ISupplicantStaNetwork::NetworkResponseEapSimUmtsAuthParams&
+		params);
+	SupplicantStatus sendNetworkEapIdentityResponseInternal(
+	    const std::vector<uint8_t>& identity);
+
 	struct wpa_ssid* retrieveNetworkPtr();
 	struct wpa_supplicant* retrieveIfacePtr();
-	int isPskPassphraseValid(const android::hardware::hidl_string& psk);
+	int isPskPassphraseValid(const std::string& psk);
 	void resetInternalStateAfterParamsUpdate();
 	int setStringFieldAndResetState(
 	    const char* value, uint8_t** to_update_field,
@@ -171,6 +242,7 @@
 	const std::string ifname_;
 	// Id of the network this hidl object controls.
 	const int network_id_;
+	bool is_valid_;
 
 	DISALLOW_COPY_AND_ASSIGN(StaNetwork);
 };
diff --git a/wpa_supplicant/hidl/supplicant.cpp b/wpa_supplicant/hidl/supplicant.cpp
index f32ceb9..aba4402 100644
--- a/wpa_supplicant/hidl/supplicant.cpp
+++ b/wpa_supplicant/hidl/supplicant.cpp
@@ -8,7 +8,7 @@
  */
 
 #include "hidl_manager.h"
-#include "hidl_return_macros.h"
+#include "hidl_return_util.h"
 #include "supplicant.h"
 
 namespace android {
@@ -17,6 +17,7 @@
 namespace supplicant {
 namespace V1_0 {
 namespace implementation {
+using hidl_return_util::validateAndCall;
 
 // These are hardcoded for android.
 const char Supplicant::kDriverName[] = "nl80211";
@@ -24,93 +25,148 @@
     "/data/misc/wifi/wpa_supplicant.conf";
 
 Supplicant::Supplicant(struct wpa_global* global) : wpa_global_(global) {}
+bool Supplicant::isValid()
+{
+	// This top level object cannot be invalidated.
+	return true;
+}
+
 Return<void> Supplicant::getInterface(
     const IfaceInfo& iface_info, getInterface_cb _hidl_cb)
 {
-	struct wpa_supplicant* wpa_s =
-	    wpa_supplicant_get_iface(wpa_global_, iface_info.name.c_str());
-	if (!wpa_s) {
-		HIDL_RETURN(
-		    SupplicantStatusCode::FAILURE_IFACE_UNKNOWN, nullptr);
-	}
-
-	HidlManager* hidl_manager = HidlManager::getInstance();
-	if (iface_info.type == IfaceType::P2P) {
-		android::sp<ISupplicantP2pIface> iface;
-		if (!hidl_manager ||
-		    hidl_manager->getP2pIfaceHidlObjectByIfname(
-			wpa_s->ifname, &iface)) {
-			HIDL_RETURN(
-			    SupplicantStatusCode::FAILURE_UNKNOWN, iface);
-		}
-
-		HIDL_RETURN(SupplicantStatusCode::SUCCESS, iface);
-	} else {
-		android::sp<ISupplicantStaIface> iface;
-		if (!hidl_manager ||
-		    hidl_manager->getStaIfaceHidlObjectByIfname(
-			wpa_s->ifname, &iface)) {
-			HIDL_RETURN(
-			    SupplicantStatusCode::FAILURE_UNKNOWN, iface);
-		}
-
-		HIDL_RETURN(SupplicantStatusCode::SUCCESS, iface);
-	}
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &Supplicant::getInterfaceInternal, _hidl_cb, iface_info);
 }
 
 Return<void> Supplicant::listInterfaces(listInterfaces_cb _hidl_cb)
 {
-	std::vector<ISupplicant::IfaceInfo> ifaces;
-	for (struct wpa_supplicant* wpa_s = wpa_global_->ifaces; wpa_s;
-	     wpa_s = wpa_s->next) {
-		if (wpa_s->global->p2p_init_wpa_s == wpa_s) {
-			ifaces.emplace_back({IfaceType::P2P, wpa_s->ifname});
-		} else {
-			ifaces.emplace_back({IfaceType::STA, wpa_s->ifname});
-		}
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS, ifaces);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &Supplicant::listInterfacesInternal, _hidl_cb);
 }
 
 Return<void> Supplicant::registerCallback(
     const sp<ISupplicantCallback>& callback, registerCallback_cb _hidl_cb)
 {
-	HidlManager* hidl_manager = HidlManager::getInstance();
-	if (!hidl_manager ||
-	    hidl_manager->addSupplicantCallbackHidlObject(callback)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
-	}
-
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &Supplicant::registerCallbackInternal, _hidl_cb, callback);
 }
 
 Return<void> Supplicant::setDebugParams(
     ISupplicant::DebugLevel level, bool show_timestamp, bool show_keys,
     setDebugParams_cb _hidl_cb)
 {
-	if (wpa_supplicant_set_debug_params(
-		wpa_global_, static_cast<uint32_t>(level), show_timestamp,
-		show_keys)) {
-		HIDL_RETURN(SupplicantStatusCode::FAILURE_UNKNOWN);
-	}
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &Supplicant::setDebugParamsInternal, _hidl_cb, level,
+	    show_timestamp, show_keys);
+}
 
-	HIDL_RETURN(SupplicantStatusCode::SUCCESS);
+Return<void> Supplicant::setConcurrencyPriority(
+    IfaceType type, setConcurrencyPriority_cb _hidl_cb)
+{
+	return validateAndCall(
+	    this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
+	    &Supplicant::setConcurrencyPriorityInternal, _hidl_cb, type);
 }
 
 Return<ISupplicant::DebugLevel> Supplicant::getDebugLevel()
 {
+	// TODO: Add SupplicantStatus in this method return for uniformity with
+	// the other methods in supplicant HIDL interface.
 	return (ISupplicant::DebugLevel)wpa_debug_level;
 }
 
 Return<bool> Supplicant::isDebugShowTimestampEnabled()
 {
-	return (wpa_debug_timestamp ? true : false);
+	// TODO: Add SupplicantStatus in this method return for uniformity with
+	// the other methods in supplicant HIDL interface.
+	return ((wpa_debug_timestamp != 0) ? true : false);
 }
 
 Return<bool> Supplicant::isDebugShowKeysEnabled()
 {
-	return (wpa_debug_show_keys ? true : false);
+	// TODO: Add SupplicantStatus in this method return for uniformity with
+	// the other methods in supplicant HIDL interface.
+	return ((wpa_debug_show_keys != 0) ? true : false);
+}
+
+std::pair<SupplicantStatus, sp<ISupplicantIface>>
+Supplicant::getInterfaceInternal(const IfaceInfo& iface_info)
+{
+	struct wpa_supplicant* wpa_s =
+	    wpa_supplicant_get_iface(wpa_global_, iface_info.name.c_str());
+	if (!wpa_s) {
+		return {{SupplicantStatusCode::FAILURE_IFACE_UNKNOWN, ""},
+			nullptr};
+	}
+	HidlManager* hidl_manager = HidlManager::getInstance();
+	if (iface_info.type == IfaceType::P2P) {
+		android::sp<ISupplicantP2pIface> iface;
+		if (!hidl_manager ||
+		    hidl_manager->getP2pIfaceHidlObjectByIfname(
+			wpa_s->ifname, &iface)) {
+			return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""},
+				iface};
+		}
+		return {{SupplicantStatusCode::SUCCESS, ""}, iface};
+	} else {
+		android::sp<ISupplicantStaIface> iface;
+		if (!hidl_manager ||
+		    hidl_manager->getStaIfaceHidlObjectByIfname(
+			wpa_s->ifname, &iface)) {
+			return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""},
+				iface};
+		}
+		return {{SupplicantStatusCode::SUCCESS, ""}, iface};
+	}
+}
+
+std::pair<SupplicantStatus, std::vector<ISupplicant::IfaceInfo>>
+Supplicant::listInterfacesInternal()
+{
+	std::vector<ISupplicant::IfaceInfo> ifaces;
+	for (struct wpa_supplicant* wpa_s = wpa_global_->ifaces; wpa_s;
+	     wpa_s = wpa_s->next) {
+		if (wpa_s->global->p2p_init_wpa_s == wpa_s) {
+			ifaces.emplace_back(ISupplicant::IfaceInfo{
+			    IfaceType::P2P, wpa_s->ifname});
+		} else {
+			ifaces.emplace_back(ISupplicant::IfaceInfo{
+			    IfaceType::STA, wpa_s->ifname});
+		}
+	}
+	return {{SupplicantStatusCode::SUCCESS, ""}, std::move(ifaces)};
+}
+
+SupplicantStatus Supplicant::registerCallbackInternal(
+    const sp<ISupplicantCallback>& callback)
+{
+	HidlManager* hidl_manager = HidlManager::getInstance();
+	if (!hidl_manager ||
+	    hidl_manager->addSupplicantCallbackHidlObject(callback)) {
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+	}
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus Supplicant::setDebugParamsInternal(
+    ISupplicant::DebugLevel level, bool show_timestamp, bool show_keys)
+{
+	if (wpa_supplicant_set_debug_params(
+		wpa_global_, static_cast<uint32_t>(level), show_timestamp,
+		show_keys)) {
+		return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
+	}
+	return {SupplicantStatusCode::SUCCESS, ""};
+}
+
+SupplicantStatus Supplicant::setConcurrencyPriorityInternal(IfaceType type)
+{
+	// TODO: Add implementation.
+	return SupplicantStatus{SupplicantStatusCode::SUCCESS, ""};
 }
 }  // namespace implementation
 }  // namespace V1_0
diff --git a/wpa_supplicant/hidl/supplicant.h b/wpa_supplicant/hidl/supplicant.h
index f4a77d9..1ad8402 100644
--- a/wpa_supplicant/hidl/supplicant.h
+++ b/wpa_supplicant/hidl/supplicant.h
@@ -39,6 +39,7 @@
 public:
 	Supplicant(struct wpa_global* global);
 	~Supplicant() override = default;
+	bool isValid();
 
 	// Hidl methods exposed.
 	Return<void> getInterface(
@@ -53,8 +54,21 @@
 	Return<ISupplicant::DebugLevel> getDebugLevel() override;
 	Return<bool> isDebugShowTimestampEnabled() override;
 	Return<bool> isDebugShowKeysEnabled() override;
+	Return<void> setConcurrencyPriority(
+	    IfaceType type, setConcurrencyPriority_cb _hidl_cb) override;
 
 private:
+	// Corresponding worker functions for the HIDL methods.
+	std::pair<SupplicantStatus, sp<ISupplicantIface>> getInterfaceInternal(
+	    const IfaceInfo& iface_info);
+	std::pair<SupplicantStatus, std::vector<ISupplicant::IfaceInfo>>
+	listInterfacesInternal();
+	SupplicantStatus registerCallbackInternal(
+	    const sp<ISupplicantCallback>& callback);
+	SupplicantStatus setDebugParamsInternal(
+	    ISupplicant::DebugLevel level, bool show_timestamp, bool show_keys);
+	SupplicantStatus setConcurrencyPriorityInternal(IfaceType type);
+
 	// Raw pointer to the global structure maintained by the core.
 	struct wpa_global* wpa_global_;
 	// Driver name to be used for creating interfaces.
