ANDROID: filter USD events for mainline supplicant

Mainline supplicant should ignore most events to avoid affecting normal
operation of the primary vendor supplicant. Allow only USD-relevant
event processing on mainline.

Bug: 365585450
Test: Ran vendor supplicant and mainline supplicant at the same time,
connected to wifi network, no more constant connection drops.

Change-Id: I9a80628d8040193ce4078d45afe6e6ebc61b246c
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 09a2bbb..f045e52 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -6159,6 +6159,15 @@
 		wpa_s->valid_links);
 }
 
+#ifdef MAINLINE_SUPPLICANT
+static bool is_event_allowlisted(enum wpa_event_type event) {
+	return event == EVENT_RX_MGMT ||
+	       event == EVENT_REMAIN_ON_CHANNEL ||
+	       event == EVENT_CANCEL_REMAIN_ON_CHANNEL ||
+	       event == EVENT_TX_WAIT_EXPIRE;
+}
+#endif /* MAINLINE_SUPPLICANT */
+
 
 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 			  union wpa_event_data *data)
@@ -6170,6 +6179,15 @@
 	int level = MSG_DEBUG;
 #endif /* CONFIG_NO_STDOUT_DEBUG */
 
+#ifdef MAINLINE_SUPPLICANT
+	if (!is_event_allowlisted(event)) {
+		wpa_dbg(wpa_s, MSG_DEBUG,
+			"Ignore event %s (%d) which is not allowlisted",
+			event_to_string(event), event);
+		return;
+	}
+#endif /* MAINLINE_SUPPLICANT */
+
 	if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
 	    event != EVENT_INTERFACE_ENABLED &&
 	    event != EVENT_INTERFACE_STATUS &&