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