Do AIDL initialization after daemonizing the process am: a9f98ebdd2 am: 9140b3b2a6
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/wpa_supplicant_8/+/22511957
Change-Id: I014fcfa0e246c437ddff4eb756bb856fd5b71b42
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 3122c58..0f2556c 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -37,12 +37,6 @@
}
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
-#ifdef CONFIG_AIDL
- global->aidl = wpas_aidl_init(global);
- if (!global->aidl)
- return -1;
-#endif /* CONFIG_AIDL */
-
return 0;
}
@@ -68,9 +62,17 @@
return -1;
}
+#ifdef CONFIG_AIDL
+ /* AIDL initialization may not be complete at this point.
+ * Initialization is done after daemonizing in order to avoid
+ * issues with the file descriptor.
+ */
+ if (!wpa_s || !wpa_s->global->aidl)
+ return 0;
/* HIDL interface wants to keep track of the P2P mgmt iface. */
if (wpas_aidl_register_interface(wpa_s))
return -1;
+#endif
return 0;
}
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 521ff90..d84f308 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -69,6 +69,7 @@
#include "ap/ap_config.h"
#include "ap/hostapd.h"
#endif /* CONFIG_MESH */
+#include "aidl/aidl.h"
const char *const wpa_supplicant_version =
"wpa_supplicant v" VERSION_STR "\n"
@@ -7826,6 +7827,12 @@
wpa_s->ctrl_iface);
}
+#ifdef CONFIG_AIDL
+ global->aidl = wpas_aidl_init(global);
+ if (!global->aidl)
+ return -1;
+#endif /* CONFIG_AIDL */
+
eloop_register_signal_terminate(wpa_supplicant_terminate, global);
eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);