• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.server.wifi;
18 
19 import android.annotation.IntDef;
20 import android.net.MacAddress;
21 import android.net.wifi.SupplicantState;
22 import android.net.wifi.WifiEnterpriseConfig;
23 import android.net.wifi.WifiManager;
24 import android.net.wifi.WifiSsid;
25 import android.os.Handler;
26 import android.os.Message;
27 import android.util.ArraySet;
28 import android.util.Log;
29 import android.util.SparseArray;
30 
31 import androidx.annotation.Keep;
32 
33 import com.android.internal.annotations.VisibleForTesting;
34 import com.android.internal.util.Protocol;
35 import com.android.server.wifi.MboOceController.BtmFrameData;
36 import com.android.server.wifi.SupplicantStaIfaceHal.QosPolicyRequest;
37 import com.android.server.wifi.SupplicantStaIfaceHal.SupplicantEventCode;
38 import com.android.server.wifi.WifiCarrierInfoManager.SimAuthRequestData;
39 import com.android.server.wifi.hotspot2.AnqpEvent;
40 import com.android.server.wifi.hotspot2.IconEvent;
41 import com.android.server.wifi.hotspot2.WnmData;
42 
43 import java.lang.annotation.Retention;
44 import java.lang.annotation.RetentionPolicy;
45 import java.util.ArrayList;
46 import java.util.BitSet;
47 import java.util.HashMap;
48 import java.util.List;
49 import java.util.Map;
50 import java.util.Set;
51 
52 /**
53  * Listen for events from the wpa_supplicant & wificond and broadcast them on
54  * to the various {@link ClientModeImpl} modules interested in handling these events.
55  */
56 public class WifiMonitor {
57     private static final String TAG = "WifiMonitor";
58 
59     /* Supplicant events reported to a state machine */
60     private static final int BASE = Protocol.BASE_WIFI_MONITOR;
61 
62    /* Network connection completed */
63     public static final int NETWORK_CONNECTION_EVENT             = BASE + 3;
64     /* Network disconnection completed */
65     public static final int NETWORK_DISCONNECTION_EVENT          = BASE + 4;
66     /* Scan results are available */
67     public static final int SCAN_RESULTS_EVENT                   = BASE + 5;
68     /* Supplicate state changed */
69     public static final int SUPPLICANT_STATE_CHANGE_EVENT        = BASE + 6;
70     /* Password failure and EAP authentication failure */
71     public static final int AUTHENTICATION_FAILURE_EVENT         = BASE + 7;
72     /* WPS success detected */
73     public static final int WPS_SUCCESS_EVENT                    = BASE + 8;
74     /* WPS failure detected */
75     public static final int WPS_FAIL_EVENT                       = BASE + 9;
76      /* WPS overlap detected */
77     public static final int WPS_OVERLAP_EVENT                    = BASE + 10;
78      /* WPS timeout detected */
79     public static final int WPS_TIMEOUT_EVENT                    = BASE + 11;
80 
81     /* Request Identity */
82     public static final int SUP_REQUEST_IDENTITY                 = BASE + 15;
83 
84     /* Request SIM Auth */
85     public static final int SUP_REQUEST_SIM_AUTH                 = BASE + 16;
86 
87     public static final int SCAN_FAILED_EVENT                    = BASE + 17;
88     /* Pno scan results are available */
89     public static final int PNO_SCAN_RESULTS_EVENT               = BASE + 18;
90 
91 
92     /* Indicates assoc reject event */
93     public static final int ASSOCIATION_REJECTION_EVENT          = BASE + 43;
94     public static final int ANQP_DONE_EVENT                      = BASE + 44;
95     public static final int ASSOCIATED_BSSID_EVENT               = BASE + 45;
96     public static final int TARGET_BSSID_EVENT                   = BASE + 46;
97     public static final int NETWORK_NOT_FOUND_EVENT              = BASE + 47;
98 
99     /* Passpoint ANQP events */
100     public static final int GAS_QUERY_START_EVENT                = BASE + 51;
101     public static final int GAS_QUERY_DONE_EVENT                 = BASE + 52;
102     public static final int RX_HS20_ANQP_ICON_EVENT              = BASE + 53;
103 
104     /* Passpoint events */
105     public static final int HS20_REMEDIATION_EVENT               = BASE + 61;
106     public static final int HS20_DEAUTH_IMMINENT_EVENT           = BASE + 62;
107     public static final int HS20_TERMS_AND_CONDITIONS_ACCEPTANCE_REQUIRED_EVENT = BASE + 63;
108 
109     /* MBO/OCE events */
110     public static final int MBO_OCE_BSS_TM_HANDLING_DONE         = BASE + 71;
111 
112     /* Transition Disable Indication */
113     public static final int TRANSITION_DISABLE_INDICATION        = BASE + 72;
114 
115     /* Trust On First Use incoming certificate event */
116     public static final int TOFU_CERTIFICATE_EVENT               = BASE + 73;
117 
118     /* Auxiliary supplicant event */
119     public static final int AUXILIARY_SUPPLICANT_EVENT           = BASE + 74;
120 
121     /* Quality of Service (QoS) events */
122     public static final int QOS_POLICY_RESET_EVENT               = BASE + 75;
123     public static final int QOS_POLICY_REQUEST_EVENT             = BASE + 76;
124 
125     /* MLO links change event */
126     public static final int MLO_LINKS_INFO_CHANGED              = BASE + 77;
127 
128     /* the AT_PERMANENT_ID_REQ denied indication for EAP-SIM/AKA/AKA' */
129     public static final int PERMANENT_ID_REQ_DENIED_INDICATION = BASE + 78;
130 
131     /* BSS frequency changed event (when STA switches the channel due to CSA) */
132     public static final int BSS_FREQUENCY_CHANGED_EVENT = BASE + 79;
133 
134     /* WPS config errrors */
135     private static final int CONFIG_MULTIPLE_PBC_DETECTED = 12;
136     private static final int CONFIG_AUTH_FAILURE = 18;
137 
138     /* WPS error indications */
139     private static final int REASON_TKIP_ONLY_PROHIBITED = 1;
140     private static final int REASON_WEP_PROHIBITED = 2;
141 
142     /* Transition disable indication */
143     public static final int TDI_USE_WPA3_PERSONAL = 1 << 0;
144     public static final int TDI_USE_SAE_PK = 1 << 1;
145     public static final int TDI_USE_WPA3_ENTERPRISE = 1 << 2;
146     public static final int TDI_USE_ENHANCED_OPEN = 1 << 3;
147 
148     @IntDef(flag = true, prefix = { "TDI_" }, value = {
149             TDI_USE_WPA3_PERSONAL,
150             TDI_USE_SAE_PK,
151             TDI_USE_WPA3_ENTERPRISE,
152             TDI_USE_ENHANCED_OPEN,
153     })
154     @Retention(RetentionPolicy.SOURCE)
155     @interface TransitionDisableIndication{}
156 
157     /* MLO links change event reason codes */
158     public enum MloLinkInfoChangeReason {
159         UNKNOWN,
160         TID_TO_LINK_MAP,
161         MULTI_LINK_RECONFIG_AP_REMOVAL,
162     }
163 
164     /**
165      * Use this key to get the interface name of the message sent by WifiMonitor,
166      * or null if not available.
167      *
168      * <br />
169      * Sample code:
170      * <code>
171      * message.getData().getString(KEY_IFACE)
172      * </code>
173      */
174     public static final String KEY_IFACE = "com.android.server.wifi.WifiMonitor.KEY_IFACE";
175 
176     private boolean mVerboseLoggingEnabled = false;
177 
enableVerboseLogging(boolean verbose)178     void enableVerboseLogging(boolean verbose) {
179         mVerboseLoggingEnabled = verbose;
180     }
181 
182     private final Map<String, SparseArray<Set<Handler>>> mHandlerMap = new HashMap<>();
183     @Keep
registerHandler(String iface, int what, Handler handler)184     public synchronized void registerHandler(String iface, int what, Handler handler) {
185         SparseArray<Set<Handler>> ifaceHandlers = mHandlerMap.get(iface);
186         if (ifaceHandlers == null) {
187             ifaceHandlers = new SparseArray<>();
188             mHandlerMap.put(iface, ifaceHandlers);
189         }
190         Set<Handler> ifaceWhatHandlers = ifaceHandlers.get(what);
191         if (ifaceWhatHandlers == null) {
192             ifaceWhatHandlers = new ArraySet<>();
193             ifaceHandlers.put(what, ifaceWhatHandlers);
194         }
195         ifaceWhatHandlers.add(handler);
196     }
197 
198     /**
199      * Deregister the given |handler|
200      * @param iface
201      * @param what
202      * @param handler
203      */
204     @Keep
deregisterHandler(String iface, int what, Handler handler)205     public synchronized void deregisterHandler(String iface, int what, Handler handler) {
206         SparseArray<Set<Handler>> ifaceHandlers = mHandlerMap.get(iface);
207         if (ifaceHandlers == null) {
208             return;
209         }
210         Set<Handler> ifaceWhatHandlers = ifaceHandlers.get(what);
211         if (ifaceWhatHandlers == null) {
212             return;
213         }
214         ifaceWhatHandlers.remove(handler);
215     }
216 
217     private final Map<String, Boolean> mMonitoringMap = new HashMap<>();
isMonitoring(String iface)218     private boolean isMonitoring(String iface) {
219         Boolean val = mMonitoringMap.get(iface);
220         if (val == null) {
221             return false;
222         } else {
223             return val.booleanValue();
224         }
225     }
226 
227     /**
228      * Enable/Disable monitoring for the provided iface.
229      *
230      * @param iface Name of the iface.
231      * @param enabled true to enable, false to disable.
232      */
233     @VisibleForTesting
setMonitoring(String iface, boolean enabled)234     public void setMonitoring(String iface, boolean enabled) {
235         mMonitoringMap.put(iface, enabled);
236     }
237 
238     /**
239      * Start Monitoring for wpa_supplicant events.
240      *
241      * @param iface Name of iface.
242      */
startMonitoring(String iface)243     public synchronized void startMonitoring(String iface) {
244         if (mVerboseLoggingEnabled) Log.d(TAG, "startMonitoring(" + iface + ")");
245         setMonitoring(iface, true);
246     }
247 
248     /**
249      * Stop Monitoring for wpa_supplicant events.
250      *
251      * @param iface Name of iface.
252      */
stopMonitoring(String iface)253     public synchronized void stopMonitoring(String iface) {
254         if (mVerboseLoggingEnabled) Log.d(TAG, "stopMonitoring(" + iface + ")");
255         setMonitoring(iface, true);
256         setMonitoring(iface, false);
257     }
258 
259     /**
260      * Returns the names of any interfaces that are being monitored.
261      */
getMonitoredIfaceNames()262     public List<String> getMonitoredIfaceNames() {
263         List<String> monitoringIfaceList = new ArrayList<>();
264         for (String iface : mMonitoringMap.keySet()) {
265             if (mMonitoringMap.get(iface)) {
266                 monitoringIfaceList.add(iface);
267             }
268         }
269         return monitoringIfaceList;
270     }
271 
272     /**
273      * Similar functions to Handler#sendMessage that send the message to the registered handler
274      * for the given interface and message what.
275      * All of these should be called with the WifiMonitor class lock
276      */
sendMessage(String iface, int what)277     private void sendMessage(String iface, int what) {
278         sendMessage(iface, Message.obtain(null, what));
279     }
280 
sendMessage(String iface, int what, Object obj)281     private void sendMessage(String iface, int what, Object obj) {
282         sendMessage(iface, Message.obtain(null, what, obj));
283     }
284 
sendMessage(String iface, int what, int arg1)285     private void sendMessage(String iface, int what, int arg1) {
286         sendMessage(iface, Message.obtain(null, what, arg1, 0));
287     }
288 
sendMessage(String iface, int what, int arg1, int arg2)289     private void sendMessage(String iface, int what, int arg1, int arg2) {
290         sendMessage(iface, Message.obtain(null, what, arg1, arg2));
291     }
292 
sendMessage(String iface, int what, int arg1, int arg2, Object obj)293     private void sendMessage(String iface, int what, int arg1, int arg2, Object obj) {
294         sendMessage(iface, Message.obtain(null, what, arg1, arg2, obj));
295     }
296 
sendMessage(String iface, Message message)297     private void sendMessage(String iface, Message message) {
298         SparseArray<Set<Handler>> ifaceHandlers = mHandlerMap.get(iface);
299         if (iface != null && ifaceHandlers != null) {
300             if (isMonitoring(iface)) {
301                 Set<Handler> ifaceWhatHandlers = ifaceHandlers.get(message.what);
302                 if (ifaceWhatHandlers != null) {
303                     for (Handler handler : ifaceWhatHandlers) {
304                         if (handler != null) {
305                             sendMessage(iface, handler, Message.obtain(message));
306                         }
307                     }
308                 }
309             } else {
310                 if (mVerboseLoggingEnabled) {
311                     Log.d(TAG, "Dropping event because (" + iface + ") is stopped");
312                 }
313             }
314         } else {
315             if (mVerboseLoggingEnabled) {
316                 Log.d(TAG, "Sending to all monitors because there's no matching iface");
317             }
318             for (Map.Entry<String, SparseArray<Set<Handler>>> entry : mHandlerMap.entrySet()) {
319                 iface = entry.getKey();
320                 if (isMonitoring(iface)) {
321                     Set<Handler> ifaceWhatHandlers = entry.getValue().get(message.what);
322                     if (ifaceWhatHandlers == null) continue;
323                     for (Handler handler : ifaceWhatHandlers) {
324                         if (handler != null) {
325                             sendMessage(iface, handler, Message.obtain(message));
326                         }
327                     }
328                 }
329             }
330         }
331 
332         message.recycle();
333     }
334 
sendMessage(String iface, Handler handler, Message message)335     private void sendMessage(String iface, Handler handler, Message message) {
336         message.setTarget(handler);
337         // getData() will return the existing Bundle if it exists, or create a new one
338         // This prevents clearing the existing data.
339         message.getData().putString(KEY_IFACE, iface);
340         message.sendToTarget();
341     }
342 
343     /**
344      * Broadcast the WPS fail event to all the handlers registered for this event.
345      *
346      * @param iface Name of iface on which this occurred.
347      * @param cfgError Configuration error code.
348      * @param vendorErrorCode Vendor specific error indication code.
349      */
broadcastWpsFailEvent(String iface, int cfgError, int vendorErrorCode)350     public void broadcastWpsFailEvent(String iface, int cfgError, int vendorErrorCode) {
351         int reason = 0;
352         switch(vendorErrorCode) {
353             case REASON_TKIP_ONLY_PROHIBITED:
354                 sendMessage(iface, WPS_FAIL_EVENT, WifiManager.WPS_TKIP_ONLY_PROHIBITED);
355                 return;
356             case REASON_WEP_PROHIBITED:
357                 sendMessage(iface, WPS_FAIL_EVENT, WifiManager.WPS_WEP_PROHIBITED);
358                 return;
359             default:
360                 reason = vendorErrorCode;
361                 break;
362         }
363         switch(cfgError) {
364             case CONFIG_AUTH_FAILURE:
365                 sendMessage(iface, WPS_FAIL_EVENT, WifiManager.WPS_AUTH_FAILURE);
366                 return;
367             case CONFIG_MULTIPLE_PBC_DETECTED:
368                 sendMessage(iface, WPS_FAIL_EVENT, WifiManager.WPS_OVERLAP_ERROR);
369                 return;
370             default:
371                 if (reason == 0) {
372                     reason = cfgError;
373                 }
374                 break;
375         }
376         //For all other errors, return a generic internal error
377         sendMessage(iface, WPS_FAIL_EVENT, WifiManager.ActionListener.FAILURE_INTERNAL_ERROR,
378                 reason);
379     }
380 
381    /**
382     * Broadcast the WPS succes event to all the handlers registered for this event.
383     *
384     * @param iface Name of iface on which this occurred.
385     */
broadcastWpsSuccessEvent(String iface)386     public void broadcastWpsSuccessEvent(String iface) {
387         sendMessage(iface, WPS_SUCCESS_EVENT);
388     }
389 
390     /**
391      * Broadcast the WPS overlap event to all the handlers registered for this event.
392      *
393      * @param iface Name of iface on which this occurred.
394      */
broadcastWpsOverlapEvent(String iface)395     public void broadcastWpsOverlapEvent(String iface) {
396         sendMessage(iface, WPS_OVERLAP_EVENT);
397     }
398 
399     /**
400      * Broadcast the WPS timeout event to all the handlers registered for this event.
401      *
402      * @param iface Name of iface on which this occurred.
403      */
broadcastWpsTimeoutEvent(String iface)404     public void broadcastWpsTimeoutEvent(String iface) {
405         sendMessage(iface, WPS_TIMEOUT_EVENT);
406     }
407 
408     /**
409      * Broadcast the ANQP done event to all the handlers registered for this event.
410      *
411      * @param iface Name of iface on which this occurred.
412      * @param anqpEvent ANQP result retrieved.
413      */
broadcastAnqpDoneEvent(String iface, AnqpEvent anqpEvent)414     public void broadcastAnqpDoneEvent(String iface, AnqpEvent anqpEvent) {
415         sendMessage(iface, ANQP_DONE_EVENT, anqpEvent);
416     }
417 
418     /**
419      * Broadcast the Icon done event to all the handlers registered for this event.
420      *
421      * @param iface Name of iface on which this occurred.
422      * @param iconEvent Instance of IconEvent containing the icon data retrieved.
423      */
broadcastIconDoneEvent(String iface, IconEvent iconEvent)424     public void broadcastIconDoneEvent(String iface, IconEvent iconEvent) {
425         sendMessage(iface, RX_HS20_ANQP_ICON_EVENT, iconEvent);
426     }
427 
428     /**
429      * Broadcast the WNM event to all the handlers registered for this event.
430      *
431      * @param iface Name of iface on which this occurred.
432      * @param wnmData Instance of WnmData containing the event data.
433      */
broadcastWnmEvent(String iface, WnmData wnmData)434     public void broadcastWnmEvent(String iface, WnmData wnmData) {
435         if (mVerboseLoggingEnabled) Log.d(TAG, "WNM-Notification " + wnmData.getEventType());
436         switch (wnmData.getEventType()) {
437             case WnmData.HS20_REMEDIATION_EVENT:
438                 sendMessage(iface, HS20_REMEDIATION_EVENT, wnmData);
439                 break;
440 
441             case WnmData.HS20_DEAUTH_IMMINENT_EVENT:
442                 sendMessage(iface, HS20_DEAUTH_IMMINENT_EVENT, wnmData);
443                 break;
444 
445             case WnmData.HS20_TERMS_AND_CONDITIONS_ACCEPTANCE_REQUIRED_EVENT:
446                 sendMessage(iface, HS20_TERMS_AND_CONDITIONS_ACCEPTANCE_REQUIRED_EVENT, wnmData);
447                 break;
448 
449             default:
450                 Log.e(TAG, "Broadcast request for an unknown WNM-notification "
451                         + wnmData.getEventType());
452                 break;
453         }
454     }
455 
456     /**
457      * Broadcast the Network identity request event to all the handlers registered for this event.
458      *
459      * @param iface Name of iface on which this occurred.
460      * @param networkId ID of the network in wpa_supplicant.
461      * @param ssid SSID of the network.
462      */
broadcastNetworkIdentityRequestEvent(String iface, int networkId, String ssid)463     public void broadcastNetworkIdentityRequestEvent(String iface, int networkId, String ssid) {
464         sendMessage(iface, SUP_REQUEST_IDENTITY, 0, networkId, ssid);
465     }
466 
467     /**
468      * Broadcast the transition disable event to all the handlers registered for this event.
469      *
470      * @param iface Name of iface on which this occurred.
471      * @param networkId ID of the network in wpa_supplicant.
472      * @param indicationBits bits of the disable indication.
473      */
broadcastTransitionDisableEvent( String iface, int networkId, @TransitionDisableIndication int indicationBits)474     public void broadcastTransitionDisableEvent(
475             String iface, int networkId,
476             @TransitionDisableIndication int indicationBits) {
477         sendMessage(iface, TRANSITION_DISABLE_INDICATION, networkId, indicationBits);
478     }
479 
480     /**
481      * Broadcast the Network Gsm Sim auth request event to all the handlers registered for this
482      * event.
483      *
484      * @param iface Name of iface on which this occurred.
485      * @param networkId ID of the network in wpa_supplicant.
486      * @param ssid SSID of the network.
487      * @param data Accompanying event data.
488      */
broadcastNetworkGsmAuthRequestEvent(String iface, int networkId, String ssid, String[] data)489     public void broadcastNetworkGsmAuthRequestEvent(String iface, int networkId, String ssid,
490                                                     String[] data) {
491         sendMessage(iface, SUP_REQUEST_SIM_AUTH,
492                 new SimAuthRequestData(networkId, WifiEnterpriseConfig.Eap.SIM, ssid, data));
493     }
494 
495     /**
496      * Broadcast the Network Umts Sim auth request event to all the handlers registered for this
497      * event.
498      *
499      * @param iface Name of iface on which this occurred.
500      * @param networkId ID of the network in wpa_supplicant.
501      * @param ssid SSID of the network.
502      * @param data Accompanying event data.
503      */
broadcastNetworkUmtsAuthRequestEvent(String iface, int networkId, String ssid, String[] data)504     public void broadcastNetworkUmtsAuthRequestEvent(String iface, int networkId, String ssid,
505                                                      String[] data) {
506         sendMessage(iface, SUP_REQUEST_SIM_AUTH,
507                 new SimAuthRequestData(networkId, WifiEnterpriseConfig.Eap.AKA, ssid, data));
508     }
509 
510     /**
511      * Broadcast scan result event to all the handlers registered for this event.
512      * @param iface Name of iface on which this occurred.
513      */
broadcastScanResultEvent(String iface)514     public void broadcastScanResultEvent(String iface) {
515         sendMessage(iface, SCAN_RESULTS_EVENT);
516     }
517 
518     /**
519      * Broadcast pno scan result event to all the handlers registered for this event.
520      * @param iface Name of iface on which this occurred.
521      */
broadcastPnoScanResultEvent(String iface)522     public void broadcastPnoScanResultEvent(String iface) {
523         sendMessage(iface, PNO_SCAN_RESULTS_EVENT);
524     }
525 
526     /**
527      * Broadcast scan failed event to all the handlers registered for this event.
528      * @param iface Name of iface on which this occurred.
529      */
broadcastScanFailedEvent(String iface, int errorCode)530     public void broadcastScanFailedEvent(String iface, int errorCode) {
531         sendMessage(iface, SCAN_FAILED_EVENT, errorCode);
532     }
533 
534     /**
535      * Broadcast the authentication failure event to all the handlers registered for this event.
536      *
537      * @param iface Name of iface on which this occurred.
538      * @param reason Reason for authentication failure. This has to be one of the
539      *               {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_NONE},
540      *               {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_TIMEOUT},
541      *               {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_WRONG_PSWD},
542      *               {@link android.net.wifi.WifiManager#ERROR_AUTH_FAILURE_EAP_FAILURE}
543      * @param errorCode Error code associated with the authentication failure event.
544      *               A value of -1 is used when no error code is reported.
545      */
broadcastAuthenticationFailureEvent(String iface, int reason, int errorCode, String ssid, MacAddress bssid)546     public void broadcastAuthenticationFailureEvent(String iface, int reason, int errorCode,
547             String ssid, MacAddress bssid) {
548         sendMessage(iface, AUTHENTICATION_FAILURE_EVENT,
549                 new AuthenticationFailureEventInfo(ssid, bssid, reason, errorCode));
550     }
551 
552     /**
553      * Broadcast the association rejection event to all the handlers registered for this event.
554      *
555      * @param iface Name of iface on which this occurred.
556      * @param assocRejectInfo Instance of AssocRejectEventInfo containing the association
557      *                        rejection info.
558      */
broadcastAssociationRejectionEvent(String iface, AssocRejectEventInfo assocRejectInfo)559     public void broadcastAssociationRejectionEvent(String iface,
560             AssocRejectEventInfo assocRejectInfo) {
561         sendMessage(iface, ASSOCIATION_REJECTION_EVENT, assocRejectInfo);
562     }
563 
564     /**
565      * Broadcast the association success event to all the handlers registered for this event.
566      *
567      * @param iface Name of iface on which this occurred.
568      * @param bssid BSSID of the access point.
569      */
broadcastAssociatedBssidEvent(String iface, String bssid)570     public void broadcastAssociatedBssidEvent(String iface, String bssid) {
571         sendMessage(iface, ASSOCIATED_BSSID_EVENT, 0, 0, bssid);
572     }
573 
574     /**
575      * Broadcast the start of association event to all the handlers registered for this event.
576      *
577      * @param iface Name of iface on which this occurred.
578      * @param bssid BSSID of the access point.
579      */
broadcastTargetBssidEvent(String iface, String bssid)580     public void broadcastTargetBssidEvent(String iface, String bssid) {
581         sendMessage(iface, TARGET_BSSID_EVENT, 0, 0, bssid);
582     }
583 
584     /**
585      * Broadcast the network connection event to all the handlers registered for this event.
586      *
587      * @param iface Name of iface on which this occurred.
588      * @param networkId ID of the network in wpa_supplicant.
589      * @param filsHlpSent Whether the connection used FILS.
590      * @param bssid BSSID of the access point.
591      */
broadcastNetworkConnectionEvent(String iface, int networkId, boolean filsHlpSent, WifiSsid ssid, String bssid)592     public void broadcastNetworkConnectionEvent(String iface, int networkId, boolean filsHlpSent,
593             WifiSsid ssid, String bssid) {
594         broadcastNetworkConnectionEvent(iface, networkId, filsHlpSent, ssid, bssid, null);
595     }
596 
597     /**
598      * Broadcast the network connection event to all the handlers registered for this event.
599      *
600      * @param iface Name of iface on which this occurred.
601      * @param networkId ID of the network in wpa_supplicant.
602      * @param filsHlpSent Whether the connection used FILS.
603      * @param bssid BSSID of the access point.
604      * @param keyMgmtMask Current used key management mask.
605      */
broadcastNetworkConnectionEvent(String iface, int networkId, boolean filsHlpSent, WifiSsid ssid, String bssid, BitSet keyMgmtMask)606     public void broadcastNetworkConnectionEvent(String iface, int networkId, boolean filsHlpSent,
607             WifiSsid ssid, String bssid, BitSet keyMgmtMask) {
608         sendMessage(iface, NETWORK_CONNECTION_EVENT,
609                 new NetworkConnectionEventInfo(networkId, ssid, bssid, filsHlpSent, keyMgmtMask));
610     }
611 
612     /**
613      * Broadcast the network disconnection event to all the handlers registered for this event.
614      *
615      * @param iface Name of iface on which this occurred.
616      * @param locallyGenerated Whether the disconnect was locally triggered.
617      * @param reason Disconnect reason code.
618      * @param ssid SSID of the access point.
619      * @param bssid BSSID of the access point.
620      */
broadcastNetworkDisconnectionEvent(String iface, boolean locallyGenerated, int reason, String ssid, String bssid)621     public void broadcastNetworkDisconnectionEvent(String iface, boolean locallyGenerated,
622             int reason, String ssid, String bssid) {
623         sendMessage(iface, NETWORK_DISCONNECTION_EVENT,
624                 new DisconnectEventInfo(ssid, bssid, reason, locallyGenerated));
625     }
626 
627     /**
628      * Broadcast the supplicant state change event to all the handlers registered for this event.
629      *
630      * @param iface Name of iface on which this occurred.
631      * @param networkId ID of the network in wpa_supplicant.
632      * @param bssid BSSID of the access point.
633      * @param frequencyMhz Frequency of the connected channel in MHz
634      * @param newSupplicantState New supplicant state.
635      */
broadcastSupplicantStateChangeEvent(String iface, int networkId, WifiSsid wifiSsid, String bssid, int frequencyMhz, SupplicantState newSupplicantState)636     public void broadcastSupplicantStateChangeEvent(String iface, int networkId, WifiSsid wifiSsid,
637                                                     String bssid, int frequencyMhz,
638                                                     SupplicantState newSupplicantState) {
639         sendMessage(iface, SUPPLICANT_STATE_CHANGE_EVENT, 0, 0,
640                 new StateChangeResult(networkId, wifiSsid, bssid, frequencyMhz,
641                         newSupplicantState));
642     }
643 
644     /**
645      * Broadcast the bss transition management frame handling event
646      * to all the handlers registered for this event.
647      *
648      * @param iface Name of iface on which this occurred.
649      */
broadcastBssTmHandlingDoneEvent(String iface, BtmFrameData btmFrmData)650     public void broadcastBssTmHandlingDoneEvent(String iface, BtmFrameData btmFrmData) {
651         sendMessage(iface, MBO_OCE_BSS_TM_HANDLING_DONE, btmFrmData);
652     }
653 
654     /**
655      * Broadcast network not found event
656      * to all the handlers registered for this event.
657      *
658      * @param iface Name of iface on which this occurred.
659      */
broadcastNetworkNotFoundEvent(String iface, String ssid)660     public void broadcastNetworkNotFoundEvent(String iface, String ssid) {
661         sendMessage(iface, NETWORK_NOT_FOUND_EVENT, ssid);
662     }
663 
664     /**
665      * Broadcast the certification event which takes place during TOFU process.
666      *
667      * @param iface Name of iface on which this occurred.
668      * @param networkId ID of the network in wpa_supplicant.
669      * @param ssid SSID of the network.
670      * @param depth the depth of this cert in the chain, 0 is the leaf, i.e. the server cert.
671      * @param certificateEventInfo the certificate data.
672      */
broadcastCertificationEvent(String iface, int networkId, String ssid, int depth, CertificateEventInfo certificateEventInfo)673     public void broadcastCertificationEvent(String iface, int networkId, String ssid,
674             int depth, CertificateEventInfo certificateEventInfo) {
675         sendMessage(iface, TOFU_CERTIFICATE_EVENT, networkId, depth, certificateEventInfo);
676     }
677 
678     /**
679      * Broadcast the indication of AT_PERMANENT_ID_REQ denied for EAP-SIM/AKA/AKA'
680      * when the strict conservative peer mode is enabled.
681      *
682      * @param iface Name of iface on which this occurred.
683      * @param networkId ID of the network in wpa_supplicant.
684      * @param ssid SSID of the network.
685      */
broadcastPermanentIdReqDenied(String iface, int networkId, String ssid)686     public void broadcastPermanentIdReqDenied(String iface, int networkId,
687             String ssid) {
688         sendMessage(iface, PERMANENT_ID_REQ_DENIED_INDICATION, 0, networkId, ssid);
689     }
690 
691     /**
692      * Broadcast an auxiliary supplicant event to all handlers registered for this event.
693      *
694      * @param iface Name of iface on which this occurred.
695      * @param eventCode SupplicantEventCode for the event that occurred.
696      * @param bssid BSSID of the network.
697      * @param reasonString Optional string containing more information about why the
698      *                     event occurred.
699      */
broadcastAuxiliarySupplicantEvent(String iface, @SupplicantEventCode int eventCode, MacAddress bssid, String reasonString)700     public void broadcastAuxiliarySupplicantEvent(String iface, @SupplicantEventCode int eventCode,
701             MacAddress bssid, String reasonString) {
702         sendMessage(iface, AUXILIARY_SUPPLICANT_EVENT, 0, 0,
703                 new SupplicantEventInfo(eventCode, bssid, reasonString));
704     }
705 
706     /**
707      * Broadcast the QoS policy reset event to all the handlers
708      * registered for this event.
709      *
710      * @param iface Name of iface on which this occurred.
711      */
broadcastQosPolicyResetEvent(String iface)712     public void broadcastQosPolicyResetEvent(String iface) {
713         sendMessage(iface, QOS_POLICY_RESET_EVENT);
714     }
715 
716     /**
717      * Broadcast the QoS policy request event to all the handlers
718      * registered for this event.
719      *
720      * @param iface Name of iface on which this occurred.
721      * @param qosPolicyRequestId Dialog token to identify the request.
722      * @param qosPolicyData List of QoS policies requested by the AP.
723      */
broadcastQosPolicyRequestEvent(String iface, int qosPolicyRequestId, List<QosPolicyRequest> qosPolicyData)724     public void broadcastQosPolicyRequestEvent(String iface, int qosPolicyRequestId,
725             List<QosPolicyRequest> qosPolicyData) {
726         sendMessage(iface, QOS_POLICY_REQUEST_EVENT, qosPolicyRequestId, 0, qosPolicyData);
727     }
728 
729     /**
730      * Broadcast the MLO link changes with reason code to all handlers registered for this event.
731      *
732      * @param iface Name of the iface on which this occurred.
733      * @param reason Reason code for the MLO link info change.
734      */
broadcastMloLinksInfoChanged(String iface, WifiMonitor.MloLinkInfoChangeReason reason)735     public void broadcastMloLinksInfoChanged(String iface,
736             WifiMonitor.MloLinkInfoChangeReason reason) {
737         sendMessage(iface, MLO_LINKS_INFO_CHANGED, reason);
738     }
739 
740     /**
741      * Broadcast the BSS frequency changed event.
742      * This message is sent when STA switches the channel due to channel
743      * switch announcement from the connected access point.
744      *
745      * @param iface Name of the iface on which this occurred.
746      * @param frequencyMhz New frequency in MHz.
747      */
broadcastBssFrequencyChanged(String iface, int frequencyMhz)748     public void broadcastBssFrequencyChanged(String iface, int frequencyMhz) {
749         sendMessage(iface, BSS_FREQUENCY_CHANGED_EVENT, frequencyMhz);
750     }
751 }
752