• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 package com.android.server.wifi;
17 
18 import android.annotation.IntDef;
19 import android.annotation.NonNull;
20 import android.content.Context;
21 import android.net.MacAddress;
22 import android.net.wifi.SecurityParams;
23 import android.net.wifi.WifiConfiguration;
24 import android.os.Handler;
25 import android.util.Log;
26 import android.util.Range;
27 
28 import com.android.internal.annotations.VisibleForTesting;
29 
30 import java.lang.annotation.Retention;
31 import java.lang.annotation.RetentionPolicy;
32 import java.net.InetAddress;
33 import java.net.UnknownHostException;
34 import java.util.ArrayList;
35 import java.util.List;
36 import java.util.Map;
37 
38 import javax.annotation.concurrent.ThreadSafe;
39 
40 /**
41  * To maintain thread-safety, the locking protocol is that every non-static method (regardless of
42  * access level) acquires mLock.
43  */
44 @ThreadSafe
45 public class SupplicantStaIfaceHal {
46     private static final String TAG = "SupplicantStaIfaceHal";
47     private final Object mLock = new Object();
48     private final Context mContext;
49     private final WifiMonitor mWifiMonitor;
50     private final FrameworkFacade mFrameworkFacade;
51     private final Handler mEventHandler;
52     private final Clock mClock;
53     private final WifiMetrics mWifiMetrics;
54     private final WifiGlobals mWifiGlobals;
55 
56     // HAL interface object - might be implemented by HIDL or AIDL
57     private ISupplicantStaIfaceHal mStaIfaceHal;
58 
59     // Common enums declared here to be independent from HIDL/AIDL.
60     // See HAL comments for more information on each.
61     protected static class DppAkm {
62         public static final int PSK = 0;
63         public static final int PSK_SAE = 1;
64         public static final int SAE = 2;
65         public static final int DPP = 3;
66     }
67 
68     protected static class DppCurve {
69         public static final int PRIME256V1 = 0;
70         public static final int SECP384R1 = 1;
71         public static final int SECP521R1 = 2;
72         public static final int BRAINPOOLP256R1 = 3;
73         public static final int BRAINPOOLP384R1 = 4;
74         public static final int BRAINPOOLP512R1 = 5;
75     }
76 
77     protected static class DppNetRole {
78         public static final int STA = 0;
79         public static final int AP = 1;
80     }
81 
82     protected static class DppEventType {
83         public static final int CONFIGURATION_SENT = 0;
84         public static final int CONFIGURATION_APPLIED = 1;
85     }
86 
87     protected static class DppFailureCode {
88         public static final int INVALID_URI = 0;
89         public static final int AUTHENTICATION = 1;
90         public static final int NOT_COMPATIBLE = 2;
91         public static final int CONFIGURATION = 3;
92         public static final int BUSY = 4;
93         public static final int TIMEOUT = 5;
94         public static final int FAILURE = 6;
95         public static final int NOT_SUPPORTED = 7;
96         public static final int CONFIGURATION_REJECTED = 8;
97         public static final int CANNOT_FIND_NETWORK = 9;
98         public static final int ENROLLEE_AUTHENTICATION = 10;
99         public static final int URI_GENERATION = 11;
100     }
101 
102     protected static class DppProgressCode {
103         public static final int AUTHENTICATION_SUCCESS = 0;
104         public static final int RESPONSE_PENDING = 1;
105         public static final int CONFIGURATION_SENT_WAITING_RESPONSE = 2;
106         public static final int CONFIGURATION_ACCEPTED = 3;
107     }
108 
109     protected static class MboAssocDisallowedReasonCode {
110         public static final byte RESERVED = 0;
111         public static final byte UNSPECIFIED = 1;
112         public static final byte MAX_NUM_STA_ASSOCIATED = 2;
113         public static final byte AIR_INTERFACE_OVERLOADED = 3;
114         public static final byte AUTH_SERVER_OVERLOADED = 4;
115         public static final byte INSUFFICIENT_RSSI = 5;
116     }
117 
118     protected static class StaIfaceReasonCode {
119         public static final int UNSPECIFIED = 1;
120         public static final int PREV_AUTH_NOT_VALID = 2;
121         public static final int DEAUTH_LEAVING = 3;
122         public static final int DISASSOC_DUE_TO_INACTIVITY = 4;
123         public static final int DISASSOC_AP_BUSY = 5;
124         public static final int CLASS2_FRAME_FROM_NONAUTH_STA = 6;
125         public static final int CLASS3_FRAME_FROM_NONASSOC_STA = 7;
126         public static final int DISASSOC_STA_HAS_LEFT = 8;
127         public static final int STA_REQ_ASSOC_WITHOUT_AUTH = 9;
128         public static final int PWR_CAPABILITY_NOT_VALID = 10;
129         public static final int SUPPORTED_CHANNEL_NOT_VALID = 11;
130         public static final int BSS_TRANSITION_DISASSOC = 12;
131         public static final int INVALID_IE = 13;
132         public static final int MICHAEL_MIC_FAILURE = 14;
133         public static final int FOURWAY_HANDSHAKE_TIMEOUT = 15;
134         public static final int GROUP_KEY_UPDATE_TIMEOUT = 16;
135         public static final int IE_IN_4WAY_DIFFERS = 17;
136         public static final int GROUP_CIPHER_NOT_VALID = 18;
137         public static final int PAIRWISE_CIPHER_NOT_VALID = 19;
138         public static final int AKMP_NOT_VALID = 20;
139         public static final int UNSUPPORTED_RSN_IE_VERSION = 21;
140         public static final int INVALID_RSN_IE_CAPAB = 22;
141         public static final int IEEE_802_1X_AUTH_FAILED = 23;
142         public static final int CIPHER_SUITE_REJECTED = 24;
143         public static final int TDLS_TEARDOWN_UNREACHABLE = 25;
144         public static final int TDLS_TEARDOWN_UNSPECIFIED = 26;
145         public static final int SSP_REQUESTED_DISASSOC = 27;
146         public static final int NO_SSP_ROAMING_AGREEMENT = 28;
147         public static final int BAD_CIPHER_OR_AKM = 29;
148         public static final int NOT_AUTHORIZED_THIS_LOCATION = 30;
149         public static final int SERVICE_CHANGE_PRECLUDES_TS = 31;
150         public static final int UNSPECIFIED_QOS_REASON = 32;
151         public static final int NOT_ENOUGH_BANDWIDTH = 33;
152         public static final int DISASSOC_LOW_ACK = 34;
153         public static final int EXCEEDED_TXOP = 35;
154         public static final int STA_LEAVING = 36;
155         public static final int END_TS_BA_DLS = 37;
156         public static final int UNKNOWN_TS_BA = 38;
157         public static final int TIMEOUT = 39;
158         public static final int PEERKEY_MISMATCH = 45;
159         public static final int AUTHORIZED_ACCESS_LIMIT_REACHED = 46;
160         public static final int EXTERNAL_SERVICE_REQUIREMENTS = 47;
161         public static final int INVALID_FT_ACTION_FRAME_COUNT = 48;
162         public static final int INVALID_PMKID = 49;
163         public static final int INVALID_MDE = 50;
164         public static final int INVALID_FTE = 51;
165         public static final int MESH_PEERING_CANCELLED = 52;
166         public static final int MESH_MAX_PEERS = 53;
167         public static final int MESH_CONFIG_POLICY_VIOLATION = 54;
168         public static final int MESH_CLOSE_RCVD = 55;
169         public static final int MESH_MAX_RETRIES = 56;
170         public static final int MESH_CONFIRM_TIMEOUT = 57;
171         public static final int MESH_INVALID_GTK = 58;
172         public static final int MESH_INCONSISTENT_PARAMS = 59;
173         public static final int MESH_INVALID_SECURITY_CAP = 60;
174         public static final int MESH_PATH_ERROR_NO_PROXY_INFO = 61;
175         public static final int MESH_PATH_ERROR_NO_FORWARDING_INFO = 62;
176         public static final int MESH_PATH_ERROR_DEST_UNREACHABLE = 63;
177         public static final int MAC_ADDRESS_ALREADY_EXISTS_IN_MBSS = 64;
178         public static final int MESH_CHANNEL_SWITCH_REGULATORY_REQ = 65;
179         public static final int MESH_CHANNEL_SWITCH_UNSPECIFIED = 66;
180 
toString(int code)181         public static String toString(int code) {
182             switch(code) {
183                 case UNSPECIFIED:
184                     return "UNSPECIFIED";
185                 case PREV_AUTH_NOT_VALID:
186                     return "PREV_AUTH_NOT_VALID";
187                 case DEAUTH_LEAVING:
188                     return "DEAUTH_LEAVING";
189                 case DISASSOC_DUE_TO_INACTIVITY:
190                     return "DISASSOC_DUE_TO_INACTIVITY";
191                 case DISASSOC_AP_BUSY:
192                     return "DISASSOC_AP_BUSY";
193                 case CLASS2_FRAME_FROM_NONAUTH_STA:
194                     return "CLASS2_FRAME_FROM_NONAUTH_STA";
195                 case CLASS3_FRAME_FROM_NONASSOC_STA:
196                     return "CLASS3_FRAME_FROM_NONASSOC_STA";
197                 case DISASSOC_STA_HAS_LEFT:
198                     return "DISASSOC_STA_HAS_LEFT";
199                 case STA_REQ_ASSOC_WITHOUT_AUTH:
200                     return "STA_REQ_ASSOC_WITHOUT_AUTH";
201                 case PWR_CAPABILITY_NOT_VALID:
202                     return "PWR_CAPABILITY_NOT_VALID";
203                 case SUPPORTED_CHANNEL_NOT_VALID:
204                     return "SUPPORTED_CHANNEL_NOT_VALID";
205                 case BSS_TRANSITION_DISASSOC:
206                     return "BSS_TRANSITION_DISASSOC";
207                 case INVALID_IE:
208                     return "INVALID_IE";
209                 case MICHAEL_MIC_FAILURE:
210                     return "MICHAEL_MIC_FAILURE";
211                 case FOURWAY_HANDSHAKE_TIMEOUT:
212                     return "FOURWAY_HANDSHAKE_TIMEOUT";
213                 case GROUP_KEY_UPDATE_TIMEOUT:
214                     return "GROUP_KEY_UPDATE_TIMEOUT";
215                 case IE_IN_4WAY_DIFFERS:
216                     return "IE_IN_4WAY_DIFFERS";
217                 case GROUP_CIPHER_NOT_VALID:
218                     return "GROUP_CIPHER_NOT_VALID";
219                 case PAIRWISE_CIPHER_NOT_VALID:
220                     return "PAIRWISE_CIPHER_NOT_VALID";
221                 case AKMP_NOT_VALID:
222                     return "AKMP_NOT_VALID";
223                 case UNSUPPORTED_RSN_IE_VERSION:
224                     return "UNSUPPORTED_RSN_IE_VERSION";
225                 case INVALID_RSN_IE_CAPAB:
226                     return "INVALID_RSN_IE_CAPAB";
227                 case IEEE_802_1X_AUTH_FAILED:
228                     return "IEEE_802_1X_AUTH_FAILED";
229                 case CIPHER_SUITE_REJECTED:
230                     return "CIPHER_SUITE_REJECTED";
231                 case TDLS_TEARDOWN_UNREACHABLE:
232                     return "TDLS_TEARDOWN_UNREACHABLE";
233                 case TDLS_TEARDOWN_UNSPECIFIED:
234                     return "TDLS_TEARDOWN_UNSPECIFIED";
235                 case SSP_REQUESTED_DISASSOC:
236                     return "SSP_REQUESTED_DISASSOC";
237                 case NO_SSP_ROAMING_AGREEMENT:
238                     return "NO_SSP_ROAMING_AGREEMENT";
239                 case BAD_CIPHER_OR_AKM:
240                     return "BAD_CIPHER_OR_AKM";
241                 case NOT_AUTHORIZED_THIS_LOCATION:
242                     return "NOT_AUTHORIZED_THIS_LOCATION";
243                 case SERVICE_CHANGE_PRECLUDES_TS:
244                     return "SERVICE_CHANGE_PRECLUDES_TS";
245                 case UNSPECIFIED_QOS_REASON:
246                     return "UNSPECIFIED_QOS_REASON";
247                 case NOT_ENOUGH_BANDWIDTH:
248                     return "NOT_ENOUGH_BANDWIDTH";
249                 case DISASSOC_LOW_ACK:
250                     return "DISASSOC_LOW_ACK";
251                 case EXCEEDED_TXOP:
252                     return "EXCEEDED_TXOP";
253                 case STA_LEAVING:
254                     return "STA_LEAVING";
255                 case END_TS_BA_DLS:
256                     return "END_TS_BA_DLS";
257                 case UNKNOWN_TS_BA:
258                     return "UNKNOWN_TS_BA";
259                 case TIMEOUT:
260                     return "TIMEOUT";
261                 case PEERKEY_MISMATCH:
262                     return "PEERKEY_MISMATCH";
263                 case AUTHORIZED_ACCESS_LIMIT_REACHED:
264                     return "AUTHORIZED_ACCESS_LIMIT_REACHED";
265                 case EXTERNAL_SERVICE_REQUIREMENTS:
266                     return "EXTERNAL_SERVICE_REQUIREMENTS";
267                 case INVALID_FT_ACTION_FRAME_COUNT:
268                     return "INVALID_FT_ACTION_FRAME_COUNT";
269                 case INVALID_PMKID:
270                     return "INVALID_PMKID";
271                 case INVALID_MDE:
272                     return "INVALID_MDE";
273                 case INVALID_FTE:
274                     return "INVALID_FTE";
275                 case MESH_PEERING_CANCELLED:
276                     return "MESH_PEERING_CANCELLED";
277                 case MESH_MAX_PEERS:
278                     return "MESH_MAX_PEERS";
279                 case MESH_CONFIG_POLICY_VIOLATION:
280                     return "MESH_CONFIG_POLICY_VIOLATION";
281                 case MESH_CLOSE_RCVD:
282                     return "MESH_CLOSE_RCVD";
283                 case MESH_MAX_RETRIES:
284                     return "MESH_MAX_RETRIES";
285                 case MESH_CONFIRM_TIMEOUT:
286                     return "MESH_CONFIRM_TIMEOUT";
287                 case MESH_INVALID_GTK:
288                     return "MESH_INVALID_GTK";
289                 case MESH_INCONSISTENT_PARAMS:
290                     return "MESH_INCONSISTENT_PARAMS";
291                 case MESH_INVALID_SECURITY_CAP:
292                     return "MESH_INVALID_SECURITY_CAP";
293                 case MESH_PATH_ERROR_NO_PROXY_INFO:
294                     return "MESH_PATH_ERROR_NO_PROXY_INFO";
295                 case MESH_PATH_ERROR_NO_FORWARDING_INFO:
296                     return "MESH_PATH_ERROR_NO_FORWARDING_INFO";
297                 case MESH_PATH_ERROR_DEST_UNREACHABLE:
298                     return "MESH_PATH_ERROR_DEST_UNREACHABLE";
299                 case MAC_ADDRESS_ALREADY_EXISTS_IN_MBSS:
300                     return "MAC_ADDRESS_ALREADY_EXISTS_IN_MBSS";
301                 case MESH_CHANNEL_SWITCH_REGULATORY_REQ:
302                     return "MESH_CHANNEL_SWITCH_REGULATORY_REQ";
303                 case MESH_CHANNEL_SWITCH_UNSPECIFIED:
304                     return "MESH_CHANNEL_SWITCH_UNSPECIFIED";
305                 default:
306                     return "Unknown StaIfaceReasonCode: " + code;
307             }
308         }
309     }
310 
311     protected static class StaIfaceStatusCode {
312         public static final int SUCCESS = 0;
313         public static final int UNSPECIFIED_FAILURE = 1;
314         public static final int TDLS_WAKEUP_ALTERNATE = 2;
315         public static final int TDLS_WAKEUP_REJECT = 3;
316         public static final int SECURITY_DISABLED = 5;
317         public static final int UNACCEPTABLE_LIFETIME = 6;
318         public static final int NOT_IN_SAME_BSS = 7;
319         public static final int CAPS_UNSUPPORTED = 10;
320         public static final int REASSOC_NO_ASSOC = 11;
321         public static final int ASSOC_DENIED_UNSPEC = 12;
322         public static final int NOT_SUPPORTED_AUTH_ALG = 13;
323         public static final int UNKNOWN_AUTH_TRANSACTION = 14;
324         public static final int CHALLENGE_FAIL = 15;
325         public static final int AUTH_TIMEOUT = 16;
326         public static final int AP_UNABLE_TO_HANDLE_NEW_STA = 17;
327         public static final int ASSOC_DENIED_RATES = 18;
328         public static final int ASSOC_DENIED_NOSHORT = 19;
329         public static final int SPEC_MGMT_REQUIRED = 22;
330         public static final int PWR_CAPABILITY_NOT_VALID = 23;
331         public static final int SUPPORTED_CHANNEL_NOT_VALID = 24;
332         public static final int ASSOC_DENIED_NO_SHORT_SLOT_TIME = 25;
333         public static final int ASSOC_DENIED_NO_HT = 27;
334         public static final int R0KH_UNREACHABLE = 28;
335         public static final int ASSOC_DENIED_NO_PCO = 29;
336         public static final int ASSOC_REJECTED_TEMPORARILY = 30;
337         public static final int ROBUST_MGMT_FRAME_POLICY_VIOLATION = 31;
338         public static final int UNSPECIFIED_QOS_FAILURE = 32;
339         public static final int DENIED_INSUFFICIENT_BANDWIDTH = 33;
340         public static final int DENIED_POOR_CHANNEL_CONDITIONS = 34;
341         public static final int DENIED_QOS_NOT_SUPPORTED = 35;
342         public static final int REQUEST_DECLINED = 37;
343         public static final int INVALID_PARAMETERS = 38;
344         public static final int REJECTED_WITH_SUGGESTED_CHANGES = 39;
345         public static final int INVALID_IE = 40;
346         public static final int GROUP_CIPHER_NOT_VALID = 41;
347         public static final int PAIRWISE_CIPHER_NOT_VALID = 42;
348         public static final int AKMP_NOT_VALID = 43;
349         public static final int UNSUPPORTED_RSN_IE_VERSION = 44;
350         public static final int INVALID_RSN_IE_CAPAB = 45;
351         public static final int CIPHER_REJECTED_PER_POLICY = 46;
352         public static final int TS_NOT_CREATED = 47;
353         public static final int DIRECT_LINK_NOT_ALLOWED = 48;
354         public static final int DEST_STA_NOT_PRESENT = 49;
355         public static final int DEST_STA_NOT_QOS_STA = 50;
356         public static final int ASSOC_DENIED_LISTEN_INT_TOO_LARGE = 51;
357         public static final int INVALID_FT_ACTION_FRAME_COUNT = 52;
358         public static final int INVALID_PMKID = 53;
359         public static final int INVALID_MDIE = 54;
360         public static final int INVALID_FTIE = 55;
361         public static final int REQUESTED_TCLAS_NOT_SUPPORTED = 56;
362         public static final int INSUFFICIENT_TCLAS_PROCESSING_RESOURCES = 57;
363         public static final int TRY_ANOTHER_BSS = 58;
364         public static final int GAS_ADV_PROTO_NOT_SUPPORTED = 59;
365         public static final int NO_OUTSTANDING_GAS_REQ = 60;
366         public static final int GAS_RESP_NOT_RECEIVED = 61;
367         public static final int STA_TIMED_OUT_WAITING_FOR_GAS_RESP = 62;
368         public static final int GAS_RESP_LARGER_THAN_LIMIT = 63;
369         public static final int REQ_REFUSED_HOME = 64;
370         public static final int ADV_SRV_UNREACHABLE = 65;
371         public static final int REQ_REFUSED_SSPN = 67;
372         public static final int REQ_REFUSED_UNAUTH_ACCESS = 68;
373         public static final int INVALID_RSNIE = 72;
374         public static final int U_APSD_COEX_NOT_SUPPORTED = 73;
375         public static final int U_APSD_COEX_MODE_NOT_SUPPORTED = 74;
376         public static final int BAD_INTERVAL_WITH_U_APSD_COEX = 75;
377         public static final int ANTI_CLOGGING_TOKEN_REQ = 76;
378         public static final int FINITE_CYCLIC_GROUP_NOT_SUPPORTED = 77;
379         public static final int CANNOT_FIND_ALT_TBTT = 78;
380         public static final int TRANSMISSION_FAILURE = 79;
381         public static final int REQ_TCLAS_NOT_SUPPORTED = 80;
382         public static final int TCLAS_RESOURCES_EXCHAUSTED = 81;
383         public static final int REJECTED_WITH_SUGGESTED_BSS_TRANSITION = 82;
384         public static final int REJECT_WITH_SCHEDULE = 83;
385         public static final int REJECT_NO_WAKEUP_SPECIFIED = 84;
386         public static final int SUCCESS_POWER_SAVE_MODE = 85;
387         public static final int PENDING_ADMITTING_FST_SESSION = 86;
388         public static final int PERFORMING_FST_NOW = 87;
389         public static final int PENDING_GAP_IN_BA_WINDOW = 88;
390         public static final int REJECT_U_PID_SETTING = 89;
391         public static final int REFUSED_EXTERNAL_REASON = 92;
392         public static final int REFUSED_AP_OUT_OF_MEMORY = 93;
393         public static final int REJECTED_EMERGENCY_SERVICE_NOT_SUPPORTED = 94;
394         public static final int QUERY_RESP_OUTSTANDING = 95;
395         public static final int REJECT_DSE_BAND = 96;
396         public static final int TCLAS_PROCESSING_TERMINATED = 97;
397         public static final int TS_SCHEDULE_CONFLICT = 98;
398         public static final int DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL = 99;
399         public static final int MCCAOP_RESERVATION_CONFLICT = 100;
400         public static final int MAF_LIMIT_EXCEEDED = 101;
401         public static final int MCCA_TRACK_LIMIT_EXCEEDED = 102;
402         public static final int DENIED_DUE_TO_SPECTRUM_MANAGEMENT = 103;
403         public static final int ASSOC_DENIED_NO_VHT = 104;
404         public static final int ENABLEMENT_DENIED = 105;
405         public static final int RESTRICTION_FROM_AUTHORIZED_GDB = 106;
406         public static final int AUTHORIZATION_DEENABLED = 107;
407         public static final int FILS_AUTHENTICATION_FAILURE = 112;
408         public static final int UNKNOWN_AUTHENTICATION_SERVER = 113;
409 
toString(int code)410         public static String toString(int code) {
411             switch(code) {
412                 case SUCCESS:
413                     return "SUCCESS";
414                 case UNSPECIFIED_FAILURE:
415                     return "UNSPECIFIED_FAILURE";
416                 case TDLS_WAKEUP_ALTERNATE:
417                     return "TDLS_WAKEUP_ALTERNATE";
418                 case TDLS_WAKEUP_REJECT:
419                     return "TDLS_WAKEUP_REJECT";
420                 case SECURITY_DISABLED:
421                     return "SECURITY_DISABLED";
422                 case UNACCEPTABLE_LIFETIME:
423                     return "UNACCEPTABLE_LIFETIME";
424                 case NOT_IN_SAME_BSS:
425                     return "NOT_IN_SAME_BSS";
426                 case CAPS_UNSUPPORTED:
427                     return "CAPS_UNSUPPORTED";
428                 case REASSOC_NO_ASSOC:
429                     return "REASSOC_NO_ASSOC";
430                 case ASSOC_DENIED_UNSPEC:
431                     return "ASSOC_DENIED_UNSPEC";
432                 case NOT_SUPPORTED_AUTH_ALG:
433                     return "NOT_SUPPORTED_AUTH_ALG";
434                 case UNKNOWN_AUTH_TRANSACTION:
435                     return "UNKNOWN_AUTH_TRANSACTION";
436                 case CHALLENGE_FAIL:
437                     return "CHALLENGE_FAIL";
438                 case AUTH_TIMEOUT:
439                     return "AUTH_TIMEOUT";
440                 case AP_UNABLE_TO_HANDLE_NEW_STA:
441                     return "AP_UNABLE_TO_HANDLE_NEW_STA";
442                 case ASSOC_DENIED_RATES:
443                     return "ASSOC_DENIED_RATES";
444                 case ASSOC_DENIED_NOSHORT:
445                     return "ASSOC_DENIED_NOSHORT";
446                 case SPEC_MGMT_REQUIRED:
447                     return "SPEC_MGMT_REQUIRED";
448                 case PWR_CAPABILITY_NOT_VALID:
449                     return "PWR_CAPABILITY_NOT_VALID";
450                 case SUPPORTED_CHANNEL_NOT_VALID:
451                     return "SUPPORTED_CHANNEL_NOT_VALID";
452                 case ASSOC_DENIED_NO_SHORT_SLOT_TIME:
453                     return "ASSOC_DENIED_NO_SHORT_SLOT_TIME";
454                 case ASSOC_DENIED_NO_HT:
455                     return "ASSOC_DENIED_NO_HT";
456                 case R0KH_UNREACHABLE:
457                     return "R0KH_UNREACHABLE";
458                 case ASSOC_DENIED_NO_PCO:
459                     return "ASSOC_DENIED_NO_PCO";
460                 case ASSOC_REJECTED_TEMPORARILY:
461                     return "ASSOC_REJECTED_TEMPORARILY";
462                 case ROBUST_MGMT_FRAME_POLICY_VIOLATION:
463                     return "ROBUST_MGMT_FRAME_POLICY_VIOLATION";
464                 case UNSPECIFIED_QOS_FAILURE:
465                     return "UNSPECIFIED_QOS_FAILURE";
466                 case DENIED_INSUFFICIENT_BANDWIDTH:
467                     return "DENIED_INSUFFICIENT_BANDWIDTH";
468                 case DENIED_POOR_CHANNEL_CONDITIONS:
469                     return "DENIED_POOR_CHANNEL_CONDITIONS";
470                 case DENIED_QOS_NOT_SUPPORTED:
471                     return "DENIED_QOS_NOT_SUPPORTED";
472                 case REQUEST_DECLINED:
473                     return "REQUEST_DECLINED";
474                 case INVALID_PARAMETERS:
475                     return "INVALID_PARAMETERS";
476                 case REJECTED_WITH_SUGGESTED_CHANGES:
477                     return "REJECTED_WITH_SUGGESTED_CHANGES";
478                 case INVALID_IE:
479                     return "INVALID_IE";
480                 case GROUP_CIPHER_NOT_VALID:
481                     return "GROUP_CIPHER_NOT_VALID";
482                 case PAIRWISE_CIPHER_NOT_VALID:
483                     return "PAIRWISE_CIPHER_NOT_VALID";
484                 case AKMP_NOT_VALID:
485                     return "AKMP_NOT_VALID";
486                 case UNSUPPORTED_RSN_IE_VERSION:
487                     return "UNSUPPORTED_RSN_IE_VERSION";
488                 case INVALID_RSN_IE_CAPAB:
489                     return "INVALID_RSN_IE_CAPAB";
490                 case CIPHER_REJECTED_PER_POLICY:
491                     return "CIPHER_REJECTED_PER_POLICY";
492                 case TS_NOT_CREATED:
493                     return "TS_NOT_CREATED";
494                 case DIRECT_LINK_NOT_ALLOWED:
495                     return "DIRECT_LINK_NOT_ALLOWED";
496                 case DEST_STA_NOT_PRESENT:
497                     return "DEST_STA_NOT_PRESENT";
498                 case DEST_STA_NOT_QOS_STA:
499                     return "DEST_STA_NOT_QOS_STA";
500                 case ASSOC_DENIED_LISTEN_INT_TOO_LARGE:
501                     return "ASSOC_DENIED_LISTEN_INT_TOO_LARGE";
502                 case INVALID_FT_ACTION_FRAME_COUNT:
503                     return "INVALID_FT_ACTION_FRAME_COUNT";
504                 case INVALID_PMKID:
505                     return "INVALID_PMKID";
506                 case INVALID_MDIE:
507                     return "INVALID_MDIE";
508                 case INVALID_FTIE:
509                     return "INVALID_FTIE";
510                 case REQUESTED_TCLAS_NOT_SUPPORTED:
511                     return "REQUESTED_TCLAS_NOT_SUPPORTED";
512                 case INSUFFICIENT_TCLAS_PROCESSING_RESOURCES:
513                     return "INSUFFICIENT_TCLAS_PROCESSING_RESOURCES";
514                 case TRY_ANOTHER_BSS:
515                     return "TRY_ANOTHER_BSS";
516                 case GAS_ADV_PROTO_NOT_SUPPORTED:
517                     return "GAS_ADV_PROTO_NOT_SUPPORTED";
518                 case NO_OUTSTANDING_GAS_REQ:
519                     return "NO_OUTSTANDING_GAS_REQ";
520                 case GAS_RESP_NOT_RECEIVED:
521                     return "GAS_RESP_NOT_RECEIVED";
522                 case STA_TIMED_OUT_WAITING_FOR_GAS_RESP:
523                     return "STA_TIMED_OUT_WAITING_FOR_GAS_RESP";
524                 case GAS_RESP_LARGER_THAN_LIMIT:
525                     return "GAS_RESP_LARGER_THAN_LIMIT";
526                 case REQ_REFUSED_HOME:
527                     return "REQ_REFUSED_HOME";
528                 case ADV_SRV_UNREACHABLE:
529                     return "ADV_SRV_UNREACHABLE";
530                 case REQ_REFUSED_SSPN:
531                     return "REQ_REFUSED_SSPN";
532                 case REQ_REFUSED_UNAUTH_ACCESS:
533                     return "REQ_REFUSED_UNAUTH_ACCESS";
534                 case INVALID_RSNIE:
535                     return "INVALID_RSNIE";
536                 case U_APSD_COEX_NOT_SUPPORTED:
537                     return "U_APSD_COEX_NOT_SUPPORTED";
538                 case U_APSD_COEX_MODE_NOT_SUPPORTED:
539                     return "U_APSD_COEX_MODE_NOT_SUPPORTED";
540                 case BAD_INTERVAL_WITH_U_APSD_COEX:
541                     return "BAD_INTERVAL_WITH_U_APSD_COEX";
542                 case ANTI_CLOGGING_TOKEN_REQ:
543                     return "ANTI_CLOGGING_TOKEN_REQ";
544                 case FINITE_CYCLIC_GROUP_NOT_SUPPORTED:
545                     return "FINITE_CYCLIC_GROUP_NOT_SUPPORTED";
546                 case CANNOT_FIND_ALT_TBTT:
547                     return "CANNOT_FIND_ALT_TBTT";
548                 case TRANSMISSION_FAILURE:
549                     return "TRANSMISSION_FAILURE";
550                 case REQ_TCLAS_NOT_SUPPORTED:
551                     return "REQ_TCLAS_NOT_SUPPORTED";
552                 case TCLAS_RESOURCES_EXCHAUSTED:
553                     return "TCLAS_RESOURCES_EXCHAUSTED";
554                 case REJECTED_WITH_SUGGESTED_BSS_TRANSITION:
555                     return "REJECTED_WITH_SUGGESTED_BSS_TRANSITION";
556                 case REJECT_WITH_SCHEDULE:
557                     return "REJECT_WITH_SCHEDULE";
558                 case REJECT_NO_WAKEUP_SPECIFIED:
559                     return "REJECT_NO_WAKEUP_SPECIFIED";
560                 case SUCCESS_POWER_SAVE_MODE:
561                     return "SUCCESS_POWER_SAVE_MODE";
562                 case PENDING_ADMITTING_FST_SESSION:
563                     return "PENDING_ADMITTING_FST_SESSION";
564                 case PERFORMING_FST_NOW:
565                     return "PERFORMING_FST_NOW";
566                 case PENDING_GAP_IN_BA_WINDOW:
567                     return "PENDING_GAP_IN_BA_WINDOW";
568                 case REJECT_U_PID_SETTING:
569                     return "REJECT_U_PID_SETTING";
570                 case REFUSED_EXTERNAL_REASON:
571                     return "REFUSED_EXTERNAL_REASON";
572                 case REFUSED_AP_OUT_OF_MEMORY:
573                     return "REFUSED_AP_OUT_OF_MEMORY";
574                 case REJECTED_EMERGENCY_SERVICE_NOT_SUPPORTED:
575                     return "REJECTED_EMERGENCY_SERVICE_NOT_SUPPORTED";
576                 case QUERY_RESP_OUTSTANDING:
577                     return "QUERY_RESP_OUTSTANDING";
578                 case REJECT_DSE_BAND:
579                     return "REJECT_DSE_BAND";
580                 case TCLAS_PROCESSING_TERMINATED:
581                     return "TCLAS_PROCESSING_TERMINATED";
582                 case TS_SCHEDULE_CONFLICT:
583                     return "TS_SCHEDULE_CONFLICT";
584                 case DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL:
585                     return "DENIED_WITH_SUGGESTED_BAND_AND_CHANNEL";
586                 case MCCAOP_RESERVATION_CONFLICT:
587                     return "MCCAOP_RESERVATION_CONFLICT";
588                 case MAF_LIMIT_EXCEEDED:
589                     return "MAF_LIMIT_EXCEEDED";
590                 case MCCA_TRACK_LIMIT_EXCEEDED:
591                     return "MCCA_TRACK_LIMIT_EXCEEDED";
592                 case DENIED_DUE_TO_SPECTRUM_MANAGEMENT:
593                     return "DENIED_DUE_TO_SPECTRUM_MANAGEMENT";
594                 case ASSOC_DENIED_NO_VHT:
595                     return "ASSOC_DENIED_NO_VHT";
596                 case ENABLEMENT_DENIED:
597                     return "ENABLEMENT_DENIED";
598                 case RESTRICTION_FROM_AUTHORIZED_GDB:
599                     return "RESTRICTION_FROM_AUTHORIZED_GDB";
600                 case AUTHORIZATION_DEENABLED:
601                     return "AUTHORIZATION_DEENABLED";
602                 case FILS_AUTHENTICATION_FAILURE:
603                     return "FILS_AUTHENTICATION_FAILURE";
604                 case UNKNOWN_AUTHENTICATION_SERVER:
605                     return "UNKNOWN_AUTHENTICATION_SERVER";
606                 default:
607                     return "Unknown StaIfaceStatusCode: " + code;
608             }
609         }
610     }
611 
612     protected static final int SUPPLICANT_EVENT_CONNECTED = 0;
613     protected static final int SUPPLICANT_EVENT_DISCONNECTED = 1;
614     protected static final int SUPPLICANT_EVENT_ASSOCIATING = 2;
615     protected static final int SUPPLICANT_EVENT_ASSOCIATED = 3;
616     protected static final int SUPPLICANT_EVENT_EAP_METHOD_SELECTED = 4;
617     protected static final int SUPPLICANT_EVENT_EAP_FAILURE = 5;
618     protected static final int SUPPLICANT_EVENT_SSID_TEMP_DISABLED = 6;
619     protected static final int SUPPLICANT_EVENT_OPEN_SSL_FAILURE = 7;
620 
621     @IntDef(prefix = { "SUPPLICANT_EVENT_" }, value = {
622             SUPPLICANT_EVENT_CONNECTED,
623             SUPPLICANT_EVENT_DISCONNECTED,
624             SUPPLICANT_EVENT_ASSOCIATING,
625             SUPPLICANT_EVENT_ASSOCIATED,
626             SUPPLICANT_EVENT_EAP_METHOD_SELECTED,
627             SUPPLICANT_EVENT_EAP_FAILURE,
628             SUPPLICANT_EVENT_SSID_TEMP_DISABLED,
629             SUPPLICANT_EVENT_OPEN_SSL_FAILURE,
630     })
631     @Retention(RetentionPolicy.SOURCE)
632     protected @interface SupplicantEventCode {}
633 
supplicantEventCodeToString(@upplicantEventCode int eventCode)634     protected static String supplicantEventCodeToString(@SupplicantEventCode int eventCode) {
635         switch (eventCode) {
636             case SUPPLICANT_EVENT_CONNECTED:
637                 return "CONNECTED";
638             case SUPPLICANT_EVENT_DISCONNECTED:
639                 return "DISCONNECTED";
640             case SUPPLICANT_EVENT_ASSOCIATING:
641                 return "ASSOCIATING";
642             case SUPPLICANT_EVENT_ASSOCIATED:
643                 return "ASSOCIATED";
644             case SUPPLICANT_EVENT_EAP_METHOD_SELECTED:
645                 return "EAP_METHOD_SELECTED";
646             case SUPPLICANT_EVENT_EAP_FAILURE:
647                 return "EAP_FAILURE";
648             case SUPPLICANT_EVENT_SSID_TEMP_DISABLED:
649                 return "SSID_TEMP_DISABLED";
650             case SUPPLICANT_EVENT_OPEN_SSL_FAILURE:
651                 return "OPEN_SSL_FAILURE";
652             default:
653                 return "Invalid SupplicantEventCode: " + eventCode;
654         }
655     }
656 
657     protected static final int QOS_POLICY_REQUEST_ADD = 0;
658     protected static final int QOS_POLICY_REQUEST_REMOVE = 1;
659 
660     @IntDef(prefix = { "QOS_POLICY_REQUEST_" }, value = {
661             QOS_POLICY_REQUEST_ADD,
662             QOS_POLICY_REQUEST_REMOVE
663     })
664     @Retention(RetentionPolicy.SOURCE)
665     protected @interface QosPolicyRequestType {}
666 
667     protected static class QosPolicyRequest {
668         public final byte policyId;
669         public final @QosPolicyRequestType int requestType;
670         public final byte dscp;
671         public final QosPolicyClassifierParams classifierParams;
672 
QosPolicyRequest(byte halPolicyId, @QosPolicyRequestType int halRequestType, byte halDscp, @NonNull QosPolicyClassifierParams frameworkClassifierParams)673         public QosPolicyRequest(byte halPolicyId, @QosPolicyRequestType int halRequestType,
674                 byte halDscp, @NonNull QosPolicyClassifierParams frameworkClassifierParams) {
675             policyId = halPolicyId;
676             dscp = halDscp;
677             requestType = halRequestType;
678             classifierParams = frameworkClassifierParams;
679         }
680 
isAddRequest()681         public boolean isAddRequest() {
682             return requestType == QOS_POLICY_REQUEST_ADD;
683         }
684 
isRemoveRequest()685         public boolean isRemoveRequest() {
686             return requestType == QOS_POLICY_REQUEST_REMOVE;
687         }
688 
689         @Override
toString()690         public String toString() {
691             return "policyId: " + policyId + ", isAddRequest: " + this.isAddRequest()
692                     + ", isRemoveRequest: " + this.isRemoveRequest() + ", dscp: " + dscp
693                     + ", classifierParams: {" + classifierParams + "}";
694         }
695     }
696 
697     protected static class QosPolicyClassifierParams {
698         public InetAddress srcIp = null;
699         public InetAddress dstIp = null;
700         public Range dstPortRange = null;
701         public final int srcPort;
702         public final int protocol;
703 
704         public final boolean hasSrcIp;
705         public final boolean hasDstIp;
706         public boolean isValid = true;
707 
QosPolicyClassifierParams(boolean halHasSrcIp, byte[] halSrcIp, boolean halHasDstIp, byte[] halDstIp, int halSrcPort, @NonNull int[] halDstPortRange, int halProtocol)708         public QosPolicyClassifierParams(boolean halHasSrcIp, byte[] halSrcIp, boolean halHasDstIp,
709                 byte[] halDstIp, int halSrcPort, @NonNull int[] halDstPortRange,
710                 int halProtocol) {
711             srcPort = halSrcPort;
712             protocol = halProtocol;
713 
714             hasSrcIp = halHasSrcIp;
715             if (hasSrcIp) {
716                 try {
717                     srcIp = InetAddress.getByAddress(halSrcIp);
718                 } catch (UnknownHostException e) {
719                     isValid = false;
720                 }
721             }
722 
723             hasDstIp = halHasDstIp;
724             if (hasDstIp) {
725                 try {
726                     dstIp = InetAddress.getByAddress(halDstIp);
727                 } catch (UnknownHostException e) {
728                     isValid = false;
729                 }
730             }
731 
732             if (halDstPortRange[0] > halDstPortRange[1]) {
733                 isValid = false;
734             } else {
735                 dstPortRange = new Range(halDstPortRange[0], halDstPortRange[1]);
736             }
737         }
738 
739         @Override
toString()740         public String toString() {
741             return "isValid: " + isValid + ", hasSrcIp: " + hasSrcIp + ", hasDstIp: " + hasDstIp
742                     + ", srcIp: " + srcIp + ", dstIp: " + dstIp + ", dstPortRange: " + dstPortRange
743                     + ", srcPort: " + srcPort + ", protocol: " + protocol;
744         }
745     }
746 
747     protected static class QosPolicyStatus {
748         public final int policyId;
749         public final int dscpPolicyStatus;
750 
QosPolicyStatus(int id, int status)751         public QosPolicyStatus(int id, int status) {
752             policyId = id;
753             dscpPolicyStatus = status;
754         }
755     }
756 
SupplicantStaIfaceHal(Context context, WifiMonitor monitor, FrameworkFacade frameworkFacade, Handler handler, Clock clock, WifiMetrics wifiMetrics, WifiGlobals wifiGlobals)757     public SupplicantStaIfaceHal(Context context, WifiMonitor monitor,
758             FrameworkFacade frameworkFacade, Handler handler,
759             Clock clock, WifiMetrics wifiMetrics,
760             WifiGlobals wifiGlobals) {
761         mContext = context;
762         mWifiMonitor = monitor;
763         mFrameworkFacade = frameworkFacade;
764         mEventHandler = handler;
765         mClock = clock;
766         mWifiMetrics = wifiMetrics;
767         mWifiGlobals = wifiGlobals;
768         mStaIfaceHal = createStaIfaceHalMockable();
769         if (mStaIfaceHal == null) {
770             Log.wtf(TAG, "Failed to get internal ISupplicantStaIfaceHal instance.");
771         }
772     }
773 
774     /**
775      * Enable/Disable verbose logging.
776      * @param verboseEnabled Verbose flag set in overlay XML.
777      * @param halVerboseEnabled Verbose flag set by the user.
778      */
enableVerboseLogging(boolean verboseEnabled, boolean halVerboseEnabled)779     void enableVerboseLogging(boolean verboseEnabled, boolean halVerboseEnabled) {
780         synchronized (mLock) {
781             if (mStaIfaceHal != null) {
782                 mStaIfaceHal.enableVerboseLogging(verboseEnabled, halVerboseEnabled);
783             }
784         }
785     }
786 
787     /**
788      * Initialize the STA Iface HAL. Creates the internal ISupplicantStaIfaceHal
789      * object and calls its initialize method.
790      *
791      * @return true if the initialization succeeded
792      */
initialize()793     public boolean initialize() {
794         synchronized (mLock) {
795             if (mStaIfaceHal == null) {
796                 Log.wtf(TAG, "Internal ISupplicantStaIfaceHal instance does not exist.");
797                 return false;
798             }
799             if (!mStaIfaceHal.initialize()) {
800                 Log.e(TAG, "Failed to init ISupplicantStaIfaceHal, stopping startup.");
801                 return false;
802             }
803             return true;
804         }
805     }
806 
807     /**
808      * Wrapper function to create the ISupplicantStaIfaceHal object.
809      * Created to be mockable in unit tests.
810      */
811     @VisibleForTesting
createStaIfaceHalMockable()812     protected ISupplicantStaIfaceHal createStaIfaceHalMockable() {
813         synchronized (mLock) {
814             // Prefer AIDL implementation if service is declared.
815             if (SupplicantStaIfaceHalAidlImpl.serviceDeclared()) {
816                 Log.i(TAG, "Initializing SupplicantStaIfaceHal using AIDL implementation.");
817                 return new SupplicantStaIfaceHalAidlImpl(mContext, mWifiMonitor,
818                         mEventHandler, mClock, mWifiMetrics, mWifiGlobals);
819 
820             } else if (SupplicantStaIfaceHalHidlImpl.serviceDeclared()) {
821                 Log.i(TAG, "Initializing SupplicantStaIfaceHal using HIDL implementation.");
822                 return new SupplicantStaIfaceHalHidlImpl(mContext, mWifiMonitor, mFrameworkFacade,
823                         mEventHandler, mClock, mWifiMetrics, mWifiGlobals);
824             }
825             Log.e(TAG, "No HIDL or AIDL service available for SupplicantStaIfaceHal.");
826             return null;
827         }
828     }
829 
830     /**
831      * Setup a STA interface for the specified iface name.
832      *
833      * @param ifaceName Name of the interface.
834      * @return true on success, false otherwise.
835      */
setupIface(@onNull String ifaceName)836     public boolean setupIface(@NonNull String ifaceName) {
837         synchronized (mLock) {
838             String methodStr = "setupIface";
839             if (mStaIfaceHal == null) {
840                 return handleNullHal(methodStr);
841             }
842             return mStaIfaceHal.setupIface(ifaceName);
843         }
844     }
845 
846     /**
847      * Teardown a STA interface for the specified iface name.
848      *
849      * @param ifaceName Name of the interface.
850      * @return true on success, false otherwise.
851      */
teardownIface(@onNull String ifaceName)852     public boolean teardownIface(@NonNull String ifaceName) {
853         synchronized (mLock) {
854             String methodStr = "teardownIface";
855             if (mStaIfaceHal == null) {
856                 return handleNullHal(methodStr);
857             }
858             return mStaIfaceHal.teardownIface(ifaceName);
859         }
860     }
861 
862     /**
863      * Registers a death notification for supplicant.
864      * @return Returns true on success.
865      */
registerDeathHandler(@onNull WifiNative.SupplicantDeathEventHandler handler)866     public boolean registerDeathHandler(@NonNull WifiNative.SupplicantDeathEventHandler handler) {
867         synchronized (mLock) {
868             String methodStr = "registerDeathHandler";
869             if (mStaIfaceHal == null) {
870                 return handleNullHal(methodStr);
871             }
872             return mStaIfaceHal.registerDeathHandler(handler);
873         }
874     }
875 
876     /**
877      * Deregisters a death notification for supplicant.
878      * @return Returns true on success.
879      */
deregisterDeathHandler()880     public boolean deregisterDeathHandler() {
881         synchronized (mLock) {
882             String methodStr = "deregisterDeathHandler";
883             if (mStaIfaceHal == null) {
884                 return handleNullHal(methodStr);
885             }
886             return mStaIfaceHal.deregisterDeathHandler();
887         }
888     }
889 
890     /**
891      * Signals whether initialization started successfully.
892      */
isInitializationStarted()893     public boolean isInitializationStarted() {
894         synchronized (mLock) {
895             String methodStr = "isInitializationStarted";
896             if (mStaIfaceHal == null) {
897                 return handleNullHal(methodStr);
898             }
899             return mStaIfaceHal.isInitializationStarted();
900         }
901     }
902 
903     /**
904      * Signals whether initialization completed successfully.
905      */
isInitializationComplete()906     public boolean isInitializationComplete() {
907         synchronized (mLock) {
908             String methodStr = "isInitializationComplete";
909             if (mStaIfaceHal == null) {
910                 return handleNullHal(methodStr);
911             }
912             return mStaIfaceHal.isInitializationComplete();
913         }
914     }
915 
916     /**
917      * Start the supplicant daemon.
918      *
919      * @return true on success, false otherwise.
920      */
startDaemon()921     public boolean startDaemon() {
922         synchronized (mLock) {
923             String methodStr = "startDaemon";
924             if (mStaIfaceHal == null) {
925                 return handleNullHal(methodStr);
926             }
927             return mStaIfaceHal.startDaemon();
928         }
929     }
930 
931     /**
932      * Terminate the supplicant daemon & wait for its death.
933      */
terminate()934     public void terminate() {
935         synchronized (mLock) {
936             String methodStr = "terminate";
937             if (mStaIfaceHal == null) {
938                 handleNullHal(methodStr);
939                 return;
940             }
941             mStaIfaceHal.terminate();
942         }
943     }
944 
945     /**
946      * Add the provided network configuration to wpa_supplicant and initiate connection to it.
947      * This method does the following:
948      * 1. If |config| is different to the current supplicant network, removes all supplicant
949      * networks and saves |config|.
950      * 2. Select the new network in wpa_supplicant.
951      *
952      * @param ifaceName Name of the interface.
953      * @param config WifiConfiguration parameters for the provided network.
954      * @return {@code true} if it succeeds, {@code false} otherwise
955      */
connectToNetwork(@onNull String ifaceName, @NonNull WifiConfiguration config)956     public boolean connectToNetwork(@NonNull String ifaceName, @NonNull WifiConfiguration config) {
957         synchronized (mLock) {
958             String methodStr = "connectToNetwork";
959             if (mStaIfaceHal == null) {
960                 return handleNullHal(methodStr);
961             }
962             return mStaIfaceHal.connectToNetwork(ifaceName, config);
963         }
964     }
965 
966     /**
967      * Initiates roaming to the already configured network in wpa_supplicant. If the network
968      * configuration provided does not match the already configured network, then this triggers
969      * a new connection attempt (instead of roam).
970      *
971      * @param ifaceName Name of the interface.
972      * @param config WifiConfiguration parameters for the provided network.
973      * @return {@code true} if it succeeds, {@code false} otherwise
974      */
roamToNetwork(@onNull String ifaceName, WifiConfiguration config)975     public boolean roamToNetwork(@NonNull String ifaceName, WifiConfiguration config) {
976         synchronized (mLock) {
977             String methodStr = "roamToNetwork";
978             if (mStaIfaceHal == null) {
979                 return handleNullHal(methodStr);
980             }
981             return mStaIfaceHal.roamToNetwork(ifaceName, config);
982         }
983     }
984 
985     /**
986      * Clean HAL cached data for |networkId| in the framework.
987      *
988      * @param networkId Network id of the network to be removed from supplicant.
989      */
removeNetworkCachedData(int networkId)990     public void removeNetworkCachedData(int networkId) {
991         synchronized (mLock) {
992             String methodStr = "removeNetworkCachedData";
993             if (mStaIfaceHal == null) {
994                 handleNullHal(methodStr);
995                 return;
996             }
997             mStaIfaceHal.removeNetworkCachedData(networkId);
998         }
999     }
1000 
1001     /**
1002      * Clear HAL cached data if MAC address is changed.
1003      *
1004      * @param networkId Network id of the network to be checked.
1005      * @param curMacAddress Current MAC address
1006      */
removeNetworkCachedDataIfNeeded(int networkId, MacAddress curMacAddress)1007     public void removeNetworkCachedDataIfNeeded(int networkId, MacAddress curMacAddress) {
1008         synchronized (mLock) {
1009             String methodStr = "removeNetworkCachedDataIfNeeded";
1010             if (mStaIfaceHal == null) {
1011                 handleNullHal(methodStr);
1012                 return;
1013             }
1014             mStaIfaceHal.removeNetworkCachedDataIfNeeded(networkId, curMacAddress);
1015         }
1016     }
1017 
1018     /**
1019      * Remove all networks from supplicant
1020      *
1021      * @param ifaceName Name of the interface.
1022      */
removeAllNetworks(@onNull String ifaceName)1023     public boolean removeAllNetworks(@NonNull String ifaceName) {
1024         synchronized (mLock) {
1025             String methodStr = "removeAllNetworks";
1026             if (mStaIfaceHal == null) {
1027                 return handleNullHal(methodStr);
1028             }
1029             return mStaIfaceHal.removeAllNetworks(ifaceName);
1030         }
1031     }
1032 
1033     /**
1034      * Disable the current network in supplicant
1035      *
1036      * @param ifaceName Name of the interface.
1037      */
disableCurrentNetwork(@onNull String ifaceName)1038     public boolean disableCurrentNetwork(@NonNull String ifaceName) {
1039         synchronized (mLock) {
1040             String methodStr = "disableCurrentNetwork";
1041             if (mStaIfaceHal == null) {
1042                 return handleNullHal(methodStr);
1043             }
1044             return mStaIfaceHal.disableCurrentNetwork(ifaceName);
1045         }
1046     }
1047 
1048     /**
1049      * Set the currently configured network's bssid.
1050      *
1051      * @param ifaceName Name of the interface.
1052      * @param bssidStr Bssid to set in the form of "XX:XX:XX:XX:XX:XX"
1053      * @return true if succeeds, false otherwise.
1054      */
setCurrentNetworkBssid(@onNull String ifaceName, String bssidStr)1055     public boolean setCurrentNetworkBssid(@NonNull String ifaceName, String bssidStr) {
1056         synchronized (mLock) {
1057             String methodStr = "setCurrentNetworkBssid";
1058             if (mStaIfaceHal == null) {
1059                 return handleNullHal(methodStr);
1060             }
1061             return mStaIfaceHal.setCurrentNetworkBssid(ifaceName, bssidStr);
1062         }
1063     }
1064 
1065     /**
1066      * Get the currently configured network's WPS NFC token.
1067      *
1068      * @param ifaceName Name of the interface.
1069      * @return Hex string corresponding to the WPS NFC token.
1070      */
getCurrentNetworkWpsNfcConfigurationToken(@onNull String ifaceName)1071     public String getCurrentNetworkWpsNfcConfigurationToken(@NonNull String ifaceName) {
1072         synchronized (mLock) {
1073             String methodStr = "getCurrentNetworkWpsNfcConfigurationToken";
1074             if (mStaIfaceHal == null) {
1075                 handleNullHal(methodStr);
1076                 return null;
1077             }
1078             return mStaIfaceHal.getCurrentNetworkWpsNfcConfigurationToken(ifaceName);
1079         }
1080     }
1081 
1082     /**
1083      * Get the eap anonymous identity for the currently configured network.
1084      *
1085      * @param ifaceName Name of the interface.
1086      * @return anonymous identity string if succeeds, null otherwise.
1087      */
getCurrentNetworkEapAnonymousIdentity(@onNull String ifaceName)1088     public String getCurrentNetworkEapAnonymousIdentity(@NonNull String ifaceName) {
1089         synchronized (mLock) {
1090             String methodStr = "getCurrentNetworkEapAnonymousIdentity";
1091             if (mStaIfaceHal == null) {
1092                 handleNullHal(methodStr);
1093                 return null;
1094             }
1095             return mStaIfaceHal.getCurrentNetworkEapAnonymousIdentity(ifaceName);
1096         }
1097     }
1098 
1099     /**
1100      * Send the eap identity response for the currently configured network.
1101      *
1102      * @param ifaceName Name of the interface.
1103      * @param identity Identity used for EAP-Identity
1104      * @param encryptedIdentity Encrypted identity used for EAP-AKA/EAP-SIM
1105      * @return true if succeeds, false otherwise.
1106      */
sendCurrentNetworkEapIdentityResponse( @onNull String ifaceName, @NonNull String identity, String encryptedIdentity)1107     public boolean sendCurrentNetworkEapIdentityResponse(
1108             @NonNull String ifaceName, @NonNull String identity, String encryptedIdentity) {
1109         synchronized (mLock) {
1110             String methodStr = "sendCurrentNetworkEapIdentityResponse";
1111             if (mStaIfaceHal == null) {
1112                 return handleNullHal(methodStr);
1113             }
1114             return mStaIfaceHal.sendCurrentNetworkEapIdentityResponse(
1115                     ifaceName, identity, encryptedIdentity);
1116         }
1117     }
1118 
1119     /**
1120      * Send the eap sim gsm auth response for the currently configured network.
1121      *
1122      * @param ifaceName Name of the interface.
1123      * @param paramsStr String to send.
1124      * @return true if succeeds, false otherwise.
1125      */
sendCurrentNetworkEapSimGsmAuthResponse( @onNull String ifaceName, String paramsStr)1126     public boolean sendCurrentNetworkEapSimGsmAuthResponse(
1127             @NonNull String ifaceName, String paramsStr) {
1128         synchronized (mLock) {
1129             String methodStr = "sendCurrentNetworkEapSimGsmAuthResponse";
1130             if (mStaIfaceHal == null) {
1131                 return handleNullHal(methodStr);
1132             }
1133             return mStaIfaceHal.sendCurrentNetworkEapSimGsmAuthResponse(ifaceName, paramsStr);
1134         }
1135     }
1136 
1137     /**
1138      * Send the eap sim gsm auth failure for the currently configured network.
1139      *
1140      * @param ifaceName Name of the interface.
1141      * @return true if succeeds, false otherwise.
1142      */
sendCurrentNetworkEapSimGsmAuthFailure(@onNull String ifaceName)1143     public boolean sendCurrentNetworkEapSimGsmAuthFailure(@NonNull String ifaceName) {
1144         synchronized (mLock) {
1145             String methodStr = "sendCurrentNetworkEapSimGsmAuthFailure";
1146             if (mStaIfaceHal == null) {
1147                 return handleNullHal(methodStr);
1148             }
1149             return mStaIfaceHal.sendCurrentNetworkEapSimGsmAuthFailure(ifaceName);
1150         }
1151     }
1152 
1153     /**
1154      * Send the eap sim umts auth response for the currently configured network.
1155      *
1156      * @param ifaceName Name of the interface.
1157      * @param paramsStr String to send.
1158      * @return true if succeeds, false otherwise.
1159      */
sendCurrentNetworkEapSimUmtsAuthResponse( @onNull String ifaceName, String paramsStr)1160     public boolean sendCurrentNetworkEapSimUmtsAuthResponse(
1161             @NonNull String ifaceName, String paramsStr) {
1162         synchronized (mLock) {
1163             String methodStr = "sendCurrentNetworkEapSimUmtsAuthResponse";
1164             if (mStaIfaceHal == null) {
1165                 return handleNullHal(methodStr);
1166             }
1167             return mStaIfaceHal.sendCurrentNetworkEapSimUmtsAuthResponse(ifaceName, paramsStr);
1168         }
1169     }
1170 
1171     /**
1172      * Send the eap sim umts auts response for the currently configured network.
1173      *
1174      * @param ifaceName Name of the interface.
1175      * @param paramsStr String to send.
1176      * @return true if succeeds, false otherwise.
1177      */
sendCurrentNetworkEapSimUmtsAutsResponse( @onNull String ifaceName, String paramsStr)1178     public boolean sendCurrentNetworkEapSimUmtsAutsResponse(
1179             @NonNull String ifaceName, String paramsStr) {
1180         synchronized (mLock) {
1181             String methodStr = "sendCurrentNetworkEapSimUmtsAutsResponse";
1182             if (mStaIfaceHal == null) {
1183                 return handleNullHal(methodStr);
1184             }
1185             return mStaIfaceHal.sendCurrentNetworkEapSimUmtsAutsResponse(ifaceName, paramsStr);
1186         }
1187     }
1188 
1189     /**
1190      * Send the eap sim umts auth failure for the currently configured network.
1191      *
1192      * @param ifaceName Name of the interface.
1193      * @return true if succeeds, false otherwise.
1194      */
sendCurrentNetworkEapSimUmtsAuthFailure(@onNull String ifaceName)1195     public boolean sendCurrentNetworkEapSimUmtsAuthFailure(@NonNull String ifaceName) {
1196         synchronized (mLock) {
1197             String methodStr = "sendCurrentNetworkEapSimUmtsAuthFailure";
1198             if (mStaIfaceHal == null) {
1199                 return handleNullHal(methodStr);
1200             }
1201             return mStaIfaceHal.sendCurrentNetworkEapSimUmtsAuthFailure(ifaceName);
1202         }
1203     }
1204 
1205     /**
1206      * Set WPS device name.
1207      *
1208      * @param ifaceName Name of the interface.
1209      * @param deviceName String to be set.
1210      * @return true if request is sent successfully, false otherwise.
1211      */
setWpsDeviceName(@onNull String ifaceName, String deviceName)1212     public boolean setWpsDeviceName(@NonNull String ifaceName, String deviceName) {
1213         synchronized (mLock) {
1214             String methodStr = "setWpsDeviceName";
1215             if (mStaIfaceHal == null) {
1216                 return handleNullHal(methodStr);
1217             }
1218             return mStaIfaceHal.setWpsDeviceName(ifaceName, deviceName);
1219         }
1220     }
1221 
1222     /**
1223      * Set WPS device type.
1224      *
1225      * @param ifaceName Name of the interface.
1226      * @param typeStr Type specified as a string. Used format: <categ>-<OUI>-<subcateg>
1227      * @return true if request is sent successfully, false otherwise.
1228      */
setWpsDeviceType(@onNull String ifaceName, String typeStr)1229     public boolean setWpsDeviceType(@NonNull String ifaceName, String typeStr) {
1230         synchronized (mLock) {
1231             String methodStr = "setWpsDeviceType";
1232             if (mStaIfaceHal == null) {
1233                 return handleNullHal(methodStr);
1234             }
1235             return mStaIfaceHal.setWpsDeviceType(ifaceName, typeStr);
1236         }
1237     }
1238 
1239     /**
1240      * Set WPS manufacturer.
1241      *
1242      * @param ifaceName Name of the interface.
1243      * @param manufacturer String to be set.
1244      * @return true if request is sent successfully, false otherwise.
1245      */
setWpsManufacturer(@onNull String ifaceName, String manufacturer)1246     public boolean setWpsManufacturer(@NonNull String ifaceName, String manufacturer) {
1247         synchronized (mLock) {
1248             String methodStr = "setWpsManufacturer";
1249             if (mStaIfaceHal == null) {
1250                 return handleNullHal(methodStr);
1251             }
1252             return mStaIfaceHal.setWpsManufacturer(ifaceName, manufacturer);
1253         }
1254     }
1255 
1256     /**
1257      * Set WPS model name.
1258      *
1259      * @param ifaceName Name of the interface.
1260      * @param modelName String to be set.
1261      * @return true if request is sent successfully, false otherwise.
1262      */
setWpsModelName(@onNull String ifaceName, String modelName)1263     public boolean setWpsModelName(@NonNull String ifaceName, String modelName) {
1264         synchronized (mLock) {
1265             String methodStr = "setWpsModelName";
1266             if (mStaIfaceHal == null) {
1267                 return handleNullHal(methodStr);
1268             }
1269             return mStaIfaceHal.setWpsModelName(ifaceName, modelName);
1270         }
1271     }
1272 
1273     /**
1274      * Set WPS model number.
1275      *
1276      * @param ifaceName Name of the interface.
1277      * @param modelNumber String to be set.
1278      * @return true if request is sent successfully, false otherwise.
1279      */
setWpsModelNumber(@onNull String ifaceName, String modelNumber)1280     public boolean setWpsModelNumber(@NonNull String ifaceName, String modelNumber) {
1281         synchronized (mLock) {
1282             String methodStr = "setWpsModelNumber";
1283             if (mStaIfaceHal == null) {
1284                 return handleNullHal(methodStr);
1285             }
1286             return mStaIfaceHal.setWpsModelNumber(ifaceName, modelNumber);
1287         }
1288     }
1289 
1290     /**
1291      * Set WPS serial number.
1292      *
1293      * @param ifaceName Name of the interface.
1294      * @param serialNumber String to be set.
1295      * @return true if request is sent successfully, false otherwise.
1296      */
setWpsSerialNumber(@onNull String ifaceName, String serialNumber)1297     public boolean setWpsSerialNumber(@NonNull String ifaceName, String serialNumber) {
1298         synchronized (mLock) {
1299             String methodStr = "setWpsSerialNumber";
1300             if (mStaIfaceHal == null) {
1301                 return handleNullHal(methodStr);
1302             }
1303             return mStaIfaceHal.setWpsSerialNumber(ifaceName, serialNumber);
1304         }
1305     }
1306 
1307     /**
1308      * Set WPS config methods
1309      *
1310      * @param ifaceName Name of the interface.
1311      * @param configMethodsStr List of config methods.
1312      * @return true if request is sent successfully, false otherwise.
1313      */
setWpsConfigMethods(@onNull String ifaceName, String configMethodsStr)1314     public boolean setWpsConfigMethods(@NonNull String ifaceName, String configMethodsStr) {
1315         synchronized (mLock) {
1316             String methodStr = "setWpsConfigMethods";
1317             if (mStaIfaceHal == null) {
1318                 return handleNullHal(methodStr);
1319             }
1320             return mStaIfaceHal.setWpsConfigMethods(ifaceName, configMethodsStr);
1321         }
1322     }
1323 
1324     /**
1325      * Trigger a reassociation even if the iface is currently connected.
1326      *
1327      * @param ifaceName Name of the interface.
1328      * @return true if request is sent successfully, false otherwise.
1329      */
reassociate(@onNull String ifaceName)1330     public boolean reassociate(@NonNull String ifaceName) {
1331         synchronized (mLock) {
1332             String methodStr = "reassociate";
1333             if (mStaIfaceHal == null) {
1334                 return handleNullHal(methodStr);
1335             }
1336             return mStaIfaceHal.reassociate(ifaceName);
1337         }
1338     }
1339 
1340     /**
1341      * Trigger a reconnection if the iface is disconnected.
1342      *
1343      * @param ifaceName Name of the interface.
1344      * @return true if request is sent successfully, false otherwise.
1345      */
reconnect(@onNull String ifaceName)1346     public boolean reconnect(@NonNull String ifaceName) {
1347         synchronized (mLock) {
1348             String methodStr = "reconnect";
1349             if (mStaIfaceHal == null) {
1350                 return handleNullHal(methodStr);
1351             }
1352             return mStaIfaceHal.reconnect(ifaceName);
1353         }
1354     }
1355 
1356     /**
1357      * Trigger a disconnection from the currently connected network.
1358      *
1359      * @param ifaceName Name of the interface.
1360      * @return true if request is sent successfully, false otherwise.
1361      */
disconnect(@onNull String ifaceName)1362     public boolean disconnect(@NonNull String ifaceName) {
1363         synchronized (mLock) {
1364             String methodStr = "disconnect";
1365             if (mStaIfaceHal == null) {
1366                 return handleNullHal(methodStr);
1367             }
1368             return mStaIfaceHal.disconnect(ifaceName);
1369         }
1370     }
1371 
1372     /**
1373      * Enable or disable power save mode.
1374      *
1375      * @param ifaceName Name of the interface.
1376      * @param enable true to enable, false to disable.
1377      * @return true if request is sent successfully, false otherwise.
1378      */
setPowerSave(@onNull String ifaceName, boolean enable)1379     public boolean setPowerSave(@NonNull String ifaceName, boolean enable) {
1380         synchronized (mLock) {
1381             String methodStr = "setPowerSave";
1382             if (mStaIfaceHal == null) {
1383                 return handleNullHal(methodStr);
1384             }
1385             return mStaIfaceHal.setPowerSave(ifaceName, enable);
1386         }
1387     }
1388 
1389     /**
1390      * Initiate TDLS discover with the specified AP.
1391      *
1392      * @param ifaceName Name of the interface.
1393      * @param macAddress MAC Address of the AP.
1394      * @return true if request is sent successfully, false otherwise.
1395      */
initiateTdlsDiscover(@onNull String ifaceName, String macAddress)1396     public boolean initiateTdlsDiscover(@NonNull String ifaceName, String macAddress) {
1397         synchronized (mLock) {
1398             String methodStr = "initiateTdlsDiscover";
1399             if (mStaIfaceHal == null) {
1400                 return handleNullHal(methodStr);
1401             }
1402             return mStaIfaceHal.initiateTdlsDiscover(ifaceName, macAddress);
1403         }
1404     }
1405 
1406     /**
1407      * Initiate TDLS setup with the specified AP.
1408      *
1409      * @param ifaceName Name of the interface.
1410      * @param macAddress MAC Address of the AP.
1411      * @return true if request is sent successfully, false otherwise.
1412      */
initiateTdlsSetup(@onNull String ifaceName, String macAddress)1413     public boolean initiateTdlsSetup(@NonNull String ifaceName, String macAddress) {
1414         synchronized (mLock) {
1415             String methodStr = "initiateTdlsSetup";
1416             if (mStaIfaceHal == null) {
1417                 return handleNullHal(methodStr);
1418             }
1419             return mStaIfaceHal.initiateTdlsSetup(ifaceName, macAddress);
1420         }
1421     }
1422 
1423     /**
1424      * Initiate TDLS teardown with the specified AP.
1425      * @param ifaceName Name of the interface.
1426      * @param macAddress MAC Address of the AP.
1427      * @return true if request is sent successfully, false otherwise.
1428      */
initiateTdlsTeardown(@onNull String ifaceName, String macAddress)1429     public boolean initiateTdlsTeardown(@NonNull String ifaceName, String macAddress) {
1430         synchronized (mLock) {
1431             String methodStr = "initiateTdlsTeardown";
1432             if (mStaIfaceHal == null) {
1433                 return handleNullHal(methodStr);
1434             }
1435             return mStaIfaceHal.initiateTdlsTeardown(ifaceName, macAddress);
1436         }
1437     }
1438 
1439     /**
1440      * Request the specified ANQP elements |elements| from the specified AP |bssid|.
1441      *
1442      * @param ifaceName Name of the interface.
1443      * @param bssid BSSID of the AP
1444      * @param infoElements ANQP elements to be queried. Refer to ISupplicantStaIface.AnqpInfoId.
1445      * @param hs20SubTypes HS subtypes to be queried. Refer to ISupplicantStaIface.Hs20AnqpSubTypes.
1446      * @return true if request is sent successfully, false otherwise.
1447      */
initiateAnqpQuery(@onNull String ifaceName, String bssid, ArrayList<Short> infoElements, ArrayList<Integer> hs20SubTypes)1448     public boolean initiateAnqpQuery(@NonNull String ifaceName, String bssid,
1449             ArrayList<Short> infoElements,
1450             ArrayList<Integer> hs20SubTypes) {
1451         synchronized (mLock) {
1452             String methodStr = "initiateAnqpQuery";
1453             if (mStaIfaceHal == null) {
1454                 return handleNullHal(methodStr);
1455             }
1456             return mStaIfaceHal.initiateAnqpQuery(ifaceName, bssid, infoElements, hs20SubTypes);
1457         }
1458     }
1459 
1460     /**
1461      * Request Venue URL ANQP element from the specified AP |bssid|.
1462      *
1463      * @param ifaceName Name of the interface.
1464      * @param bssid BSSID of the AP
1465      * @return true if request is sent successfully, false otherwise.
1466      */
initiateVenueUrlAnqpQuery(@onNull String ifaceName, String bssid)1467     public boolean initiateVenueUrlAnqpQuery(@NonNull String ifaceName, String bssid) {
1468         synchronized (mLock) {
1469             String methodStr = "initiateVenueUrlAnqpQuery";
1470             if (mStaIfaceHal == null) {
1471                 return handleNullHal(methodStr);
1472             }
1473             return mStaIfaceHal.initiateVenueUrlAnqpQuery(ifaceName, bssid);
1474         }
1475     }
1476 
1477     /**
1478      * Request the specified ANQP ICON from the specified AP |bssid|.
1479      *
1480      * @param ifaceName Name of the interface.
1481      * @param bssid BSSID of the AP
1482      * @param fileName Name of the file to request.
1483      * @return true if request is sent successfully, false otherwise.
1484      */
initiateHs20IconQuery(@onNull String ifaceName, String bssid, String fileName)1485     public boolean initiateHs20IconQuery(@NonNull String ifaceName, String bssid, String fileName) {
1486         synchronized (mLock) {
1487             String methodStr = "initiateHs20IconQuery";
1488             if (mStaIfaceHal == null) {
1489                 return handleNullHal(methodStr);
1490             }
1491             return mStaIfaceHal.initiateHs20IconQuery(ifaceName, bssid, fileName);
1492         }
1493     }
1494 
1495     /**
1496      * Gets MAC address from the supplicant.
1497      *
1498      * @param ifaceName Name of the interface.
1499      * @return string containing the MAC address, or null on a failed call
1500      */
getMacAddress(@onNull String ifaceName)1501     public String getMacAddress(@NonNull String ifaceName) {
1502         synchronized (mLock) {
1503             String methodStr = "getMacAddress";
1504             if (mStaIfaceHal == null) {
1505                 handleNullHal(methodStr);
1506                 return null;
1507             }
1508             return mStaIfaceHal.getMacAddress(ifaceName);
1509         }
1510     }
1511 
1512     /**
1513      * Start using the added RX filters.
1514      *
1515      * @param ifaceName Name of the interface.
1516      * @return true if request is sent successfully, false otherwise.
1517      */
startRxFilter(@onNull String ifaceName)1518     public boolean startRxFilter(@NonNull String ifaceName) {
1519         synchronized (mLock) {
1520             String methodStr = "startRxFilter";
1521             if (mStaIfaceHal == null) {
1522                 return handleNullHal(methodStr);
1523             }
1524             return mStaIfaceHal.startRxFilter(ifaceName);
1525         }
1526     }
1527 
1528     /**
1529      * Stop using the added RX filters.
1530      *
1531      * @param ifaceName Name of the interface.
1532      * @return true if request is sent successfully, false otherwise.
1533      */
stopRxFilter(@onNull String ifaceName)1534     public boolean stopRxFilter(@NonNull String ifaceName) {
1535         synchronized (mLock) {
1536             String methodStr = "stopRxFilter";
1537             if (mStaIfaceHal == null) {
1538                 return handleNullHal(methodStr);
1539             }
1540             return mStaIfaceHal.stopRxFilter(ifaceName);
1541         }
1542     }
1543 
1544     /**
1545      * Add an RX filter.
1546      *
1547      * @param ifaceName Name of the interface.
1548      * @param type one of {@link WifiNative#RX_FILTER_TYPE_V4_MULTICAST}
1549      *        {@link WifiNative#RX_FILTER_TYPE_V6_MULTICAST} values.
1550      * @return true if request is sent successfully, false otherwise.
1551      */
addRxFilter(@onNull String ifaceName, int type)1552     public boolean addRxFilter(@NonNull String ifaceName, int type) {
1553         synchronized (mLock) {
1554             String methodStr = "addRxFilter";
1555             if (mStaIfaceHal == null) {
1556                 return handleNullHal(methodStr);
1557             }
1558             return mStaIfaceHal.addRxFilter(ifaceName, type);
1559         }
1560     }
1561 
1562     /**
1563      * Remove an RX filter.
1564      *
1565      * @param ifaceName Name of the interface.
1566      * @param type one of {@link WifiNative#RX_FILTER_TYPE_V4_MULTICAST}
1567      *        {@link WifiNative#RX_FILTER_TYPE_V6_MULTICAST} values.
1568      * @return true if request is sent successfully, false otherwise.
1569      */
removeRxFilter(@onNull String ifaceName, int type)1570     public boolean removeRxFilter(@NonNull String ifaceName, int type) {
1571         synchronized (mLock) {
1572             String methodStr = "removeRxFilter";
1573             if (mStaIfaceHal == null) {
1574                 return handleNullHal(methodStr);
1575             }
1576             return mStaIfaceHal.removeRxFilter(ifaceName, type);
1577         }
1578     }
1579 
1580     /**
1581      * Set Bt coexistence mode.
1582      *
1583      * @param ifaceName Name of the interface.
1584      * @param mode one of the above {@link WifiNative#BLUETOOTH_COEXISTENCE_MODE_DISABLED},
1585      *             {@link WifiNative#BLUETOOTH_COEXISTENCE_MODE_ENABLED} or
1586      *             {@link WifiNative#BLUETOOTH_COEXISTENCE_MODE_SENSE}.
1587      * @return true if request is sent successfully, false otherwise.
1588      */
setBtCoexistenceMode(@onNull String ifaceName, int mode)1589     public boolean setBtCoexistenceMode(@NonNull String ifaceName, int mode) {
1590         synchronized (mLock) {
1591             String methodStr = "setBtCoexistenceMode";
1592             if (mStaIfaceHal == null) {
1593                 return handleNullHal(methodStr);
1594             }
1595             return mStaIfaceHal.setBtCoexistenceMode(ifaceName, mode);
1596         }
1597     }
1598 
1599     /** Enable or disable BT coexistence mode.
1600      *
1601      * @param ifaceName Name of the interface.
1602      * @param enable true to enable, false to disable.
1603      * @return true if request is sent successfully, false otherwise.
1604      */
setBtCoexistenceScanModeEnabled(@onNull String ifaceName, boolean enable)1605     public boolean setBtCoexistenceScanModeEnabled(@NonNull String ifaceName, boolean enable) {
1606         synchronized (mLock) {
1607             String methodStr = "setBtCoexistenceScanModeEnabled";
1608             if (mStaIfaceHal == null) {
1609                 return handleNullHal(methodStr);
1610             }
1611             return mStaIfaceHal.setBtCoexistenceScanModeEnabled(ifaceName, enable);
1612         }
1613     }
1614 
1615     /**
1616      * Enable or disable suspend mode optimizations.
1617      *
1618      * @param ifaceName Name of the interface.
1619      * @param enable true to enable, false otherwise.
1620      * @return true if request is sent successfully, false otherwise.
1621      */
setSuspendModeEnabled(@onNull String ifaceName, boolean enable)1622     public boolean setSuspendModeEnabled(@NonNull String ifaceName, boolean enable) {
1623         synchronized (mLock) {
1624             String methodStr = "setSuspendModeEnabled";
1625             if (mStaIfaceHal == null) {
1626                 return handleNullHal(methodStr);
1627             }
1628             return mStaIfaceHal.setSuspendModeEnabled(ifaceName, enable);
1629         }
1630     }
1631 
1632     /**
1633      * Set country code.
1634      *
1635      * @param ifaceName Name of the interface.
1636      * @param codeStr 2 byte ASCII string. For ex: US, CA.
1637      * @return true if request is sent successfully, false otherwise.
1638      */
setCountryCode(@onNull String ifaceName, String codeStr)1639     public boolean setCountryCode(@NonNull String ifaceName, String codeStr) {
1640         synchronized (mLock) {
1641             String methodStr = "setCountryCode";
1642             if (mStaIfaceHal == null) {
1643                 return handleNullHal(methodStr);
1644             }
1645             return mStaIfaceHal.setCountryCode(ifaceName, codeStr);
1646         }
1647     }
1648 
1649     /**
1650      * Flush all previously configured HLPs.
1651      *
1652      * @param ifaceName Name of the interface.
1653      * @return true if request is sent successfully, false otherwise.
1654      */
flushAllHlp(@onNull String ifaceName)1655     public boolean flushAllHlp(@NonNull String ifaceName) {
1656         synchronized (mLock) {
1657             String methodStr = "flushAllHlp";
1658             if (mStaIfaceHal == null) {
1659                 return handleNullHal(methodStr);
1660             }
1661             return mStaIfaceHal.flushAllHlp(ifaceName);
1662         }
1663     }
1664 
1665     /**
1666      * Set FILS HLP packet.
1667      *
1668      * @param ifaceName Name of the interface.
1669      * @param dst Destination MAC address.
1670      * @param hlpPacket Hlp Packet data in hex.
1671      * @return true if request is sent successfully, false otherwise.
1672      */
addHlpReq(@onNull String ifaceName, byte [] dst, byte [] hlpPacket)1673     public boolean addHlpReq(@NonNull String ifaceName, byte [] dst, byte [] hlpPacket) {
1674         synchronized (mLock) {
1675             String methodStr = "addHlpReq";
1676             if (mStaIfaceHal == null) {
1677                 return handleNullHal(methodStr);
1678             }
1679             return mStaIfaceHal.addHlpReq(ifaceName, dst, hlpPacket);
1680         }
1681     }
1682 
1683     /**
1684      * Start WPS pin registrar operation with the specified peer and pin.
1685      *
1686      * @param ifaceName Name of the interface.
1687      * @param bssidStr BSSID of the peer.
1688      * @param pin Pin to be used.
1689      * @return true if request is sent successfully, false otherwise.
1690      */
startWpsRegistrar(@onNull String ifaceName, String bssidStr, String pin)1691     public boolean startWpsRegistrar(@NonNull String ifaceName, String bssidStr, String pin) {
1692         synchronized (mLock) {
1693             String methodStr = "startWpsRegistrar";
1694             if (mStaIfaceHal == null) {
1695                 return handleNullHal(methodStr);
1696             }
1697             return mStaIfaceHal.startWpsRegistrar(ifaceName, bssidStr, pin);
1698         }
1699     }
1700 
1701     /**
1702      * Start WPS pin display operation with the specified peer.
1703      *
1704      * @param ifaceName Name of the interface.
1705      * @param bssidStr BSSID of the peer. Use empty bssid to indicate wildcard.
1706      * @return true if request is sent successfully, false otherwise.
1707      */
startWpsPbc(@onNull String ifaceName, String bssidStr)1708     public boolean startWpsPbc(@NonNull String ifaceName, String bssidStr) {
1709         synchronized (mLock) {
1710             String methodStr = "startWpsPbc";
1711             if (mStaIfaceHal == null) {
1712                 return handleNullHal(methodStr);
1713             }
1714             return mStaIfaceHal.startWpsPbc(ifaceName, bssidStr);
1715         }
1716     }
1717 
1718     /**
1719      * Start WPS pin keypad operation with the specified pin.
1720      *
1721      * @param ifaceName Name of the interface.
1722      * @param pin Pin to be used.
1723      * @return true if request is sent successfully, false otherwise.
1724      */
startWpsPinKeypad(@onNull String ifaceName, String pin)1725     public boolean startWpsPinKeypad(@NonNull String ifaceName, String pin) {
1726         synchronized (mLock) {
1727             String methodStr = "startWpsPinKeypad";
1728             if (mStaIfaceHal == null) {
1729                 return handleNullHal(methodStr);
1730             }
1731             return mStaIfaceHal.startWpsPinKeypad(ifaceName, pin);
1732         }
1733     }
1734 
1735     /**
1736      * Start WPS pin display operation with the specified peer.
1737      *
1738      * @param ifaceName Name of the interface.
1739      * @param bssidStr BSSID of the peer. Use empty bssid to indicate wildcard.
1740      * @return new pin generated on success, null otherwise.
1741      */
startWpsPinDisplay(@onNull String ifaceName, String bssidStr)1742     public String startWpsPinDisplay(@NonNull String ifaceName, String bssidStr) {
1743         synchronized (mLock) {
1744             String methodStr = "startWpsPinDisplay";
1745             if (mStaIfaceHal == null) {
1746                 handleNullHal(methodStr);
1747                 return null;
1748             }
1749             return mStaIfaceHal.startWpsPinDisplay(ifaceName, bssidStr);
1750         }
1751     }
1752 
1753     /**
1754      * Cancels any ongoing WPS requests.
1755      *
1756      * @param ifaceName Name of the interface.
1757      * @return true if request is sent successfully, false otherwise.
1758      */
cancelWps(@onNull String ifaceName)1759     public boolean cancelWps(@NonNull String ifaceName) {
1760         synchronized (mLock) {
1761             String methodStr = "cancelWps";
1762             if (mStaIfaceHal == null) {
1763                 return handleNullHal(methodStr);
1764             }
1765             return mStaIfaceHal.cancelWps(ifaceName);
1766         }
1767     }
1768 
1769     /**
1770      * Sets whether to use external sim for SIM/USIM processing.
1771      *
1772      * @param ifaceName Name of the interface.
1773      * @param useExternalSim true to enable, false otherwise.
1774      * @return true if request is sent successfully, false otherwise.
1775      */
setExternalSim(@onNull String ifaceName, boolean useExternalSim)1776     public boolean setExternalSim(@NonNull String ifaceName, boolean useExternalSim) {
1777         synchronized (mLock) {
1778             String methodStr = "setExternalSim";
1779             if (mStaIfaceHal == null) {
1780                 return handleNullHal(methodStr);
1781             }
1782             return mStaIfaceHal.setExternalSim(ifaceName, useExternalSim);
1783         }
1784     }
1785 
1786     /**
1787      * Enable/Disable auto reconnect to networks.
1788      * Use this to prevent wpa_supplicant from trying to connect to networks
1789      * on its own.
1790      *
1791      * @param enable true to enable, false to disable.
1792      * @return true if no exceptions occurred, false otherwise
1793      */
enableAutoReconnect(@onNull String ifaceName, boolean enable)1794     public boolean enableAutoReconnect(@NonNull String ifaceName, boolean enable) {
1795         synchronized (mLock) {
1796             String methodStr = "enableAutoReconnect";
1797             if (mStaIfaceHal == null) {
1798                 return handleNullHal(methodStr);
1799             }
1800             return mStaIfaceHal.enableAutoReconnect(ifaceName, enable);
1801         }
1802     }
1803 
1804     /**
1805      * Set the debug log level for wpa_supplicant
1806      *
1807      * @param turnOnVerbose Whether to turn on verbose logging or not.
1808      * @return true if request is sent successfully, false otherwise.
1809      */
setLogLevel(boolean turnOnVerbose)1810     public boolean setLogLevel(boolean turnOnVerbose) {
1811         synchronized (mLock) {
1812             String methodStr = "setLogLevel";
1813             if (mStaIfaceHal == null) {
1814                 return handleNullHal(methodStr);
1815             }
1816             return mStaIfaceHal.setLogLevel(turnOnVerbose);
1817         }
1818     }
1819 
1820     /**
1821      * Set concurrency priority between P2P & STA operations.
1822      *
1823      * @param isStaHigherPriority Set to true to prefer STA over P2P during concurrency operations,
1824      *                            false otherwise.
1825      * @return true if request is sent successfully, false otherwise.
1826      */
setConcurrencyPriority(boolean isStaHigherPriority)1827     public boolean setConcurrencyPriority(boolean isStaHigherPriority) {
1828         synchronized (mLock) {
1829             String methodStr = "setConcurrencyPriority";
1830             if (mStaIfaceHal == null) {
1831                 return handleNullHal(methodStr);
1832             }
1833             return mStaIfaceHal.setConcurrencyPriority(isStaHigherPriority);
1834         }
1835     }
1836 
1837     /**
1838      * Returns a bitmask of advanced capabilities: WPA3 SAE/SUITE B and OWE
1839      * Bitmask used is:
1840      * - WIFI_FEATURE_WPA3_SAE
1841      * - WIFI_FEATURE_WPA3_SUITE_B
1842      * - WIFI_FEATURE_OWE
1843      *
1844      *  On error, or if these features are not supported, 0 is returned.
1845      */
getAdvancedCapabilities(@onNull String ifaceName)1846     public long getAdvancedCapabilities(@NonNull String ifaceName) {
1847         synchronized (mLock) {
1848             String methodStr = "getAdvancedCapabilities";
1849             if (mStaIfaceHal == null) {
1850                 handleNullHal(methodStr);
1851                 return 0;
1852             }
1853             return mStaIfaceHal.getAdvancedCapabilities(ifaceName);
1854         }
1855     }
1856 
1857     /**
1858      * Get the driver supported features through supplicant.
1859      *
1860      * @param ifaceName Name of the interface.
1861      * @return bitmask defined by WifiManager.WIFI_FEATURE_*.
1862      */
getWpaDriverFeatureSet(@onNull String ifaceName)1863     public long getWpaDriverFeatureSet(@NonNull String ifaceName) {
1864         synchronized (mLock) {
1865             String methodStr = "getWpaDriverFeatureSet";
1866             if (mStaIfaceHal == null) {
1867                 handleNullHal(methodStr);
1868                 return 0;
1869             }
1870             return mStaIfaceHal.getWpaDriverFeatureSet(ifaceName);
1871         }
1872     }
1873 
1874     /**
1875      * Returns connection capabilities of the current network
1876      *
1877      * @param ifaceName Name of the interface.
1878      * @return connection capabilities of the current network
1879      */
getConnectionCapabilities(@onNull String ifaceName)1880     public WifiNative.ConnectionCapabilities getConnectionCapabilities(@NonNull String ifaceName) {
1881         synchronized (mLock) {
1882             String methodStr = "getConnectionCapabilities";
1883             if (mStaIfaceHal == null) {
1884                 handleNullHal(methodStr);
1885                 return new WifiNative.ConnectionCapabilities();
1886             }
1887             return mStaIfaceHal.getConnectionCapabilities(ifaceName);
1888         }
1889     }
1890 
1891     /**
1892      * Returns connection MLO links info
1893      *
1894      * @param ifaceName Name of the interface.
1895      * @return connection MLO links info
1896      */
getConnectionMloLinksInfo(@onNull String ifaceName)1897     public WifiNative.ConnectionMloLinksInfo getConnectionMloLinksInfo(@NonNull String ifaceName) {
1898         synchronized (mLock) {
1899             String methodStr = "getConnectionMloLinksInfo";
1900             if (mStaIfaceHal == null) {
1901                 handleNullHal(methodStr);
1902                 return null;
1903             }
1904             return mStaIfaceHal.getConnectionMloLinksInfo(ifaceName);
1905         }
1906     }
1907 
1908     /**
1909      * Adds a DPP peer URI to the URI list.
1910      *
1911      * Returns an ID to be used later to refer to this URI (>0).
1912      * On error, or if these features are not supported, -1 is returned.
1913      */
addDppPeerUri(@onNull String ifaceName, @NonNull String uri)1914     public int addDppPeerUri(@NonNull String ifaceName, @NonNull String uri) {
1915         synchronized (mLock) {
1916             String methodStr = "addDppPeerUri";
1917             if (mStaIfaceHal == null) {
1918                 handleNullHal(methodStr);
1919                 return -1;
1920             }
1921             return mStaIfaceHal.addDppPeerUri(ifaceName, uri);
1922         }
1923     }
1924 
1925     /**
1926      * Removes a DPP URI to the URI list given an ID.
1927      *
1928      * Returns true when operation is successful
1929      * On error, or if these features are not supported, false is returned.
1930      */
removeDppUri(@onNull String ifaceName, int bootstrapId)1931     public boolean removeDppUri(@NonNull String ifaceName, int bootstrapId) {
1932         synchronized (mLock) {
1933             String methodStr = "removeDppUri";
1934             if (mStaIfaceHal == null) {
1935                 return handleNullHal(methodStr);
1936             }
1937             return mStaIfaceHal.removeDppUri(ifaceName, bootstrapId);
1938         }
1939     }
1940 
1941     /**
1942      * Stops/aborts DPP Initiator request
1943      *
1944      * Returns true when operation is successful
1945      * On error, or if these features are not supported, false is returned.
1946      */
stopDppInitiator(@onNull String ifaceName)1947     public boolean stopDppInitiator(@NonNull String ifaceName) {
1948         synchronized (mLock) {
1949             String methodStr = "stopDppInitiator";
1950             if (mStaIfaceHal == null) {
1951                 return handleNullHal(methodStr);
1952             }
1953             return mStaIfaceHal.stopDppInitiator(ifaceName);
1954         }
1955     }
1956 
1957     /**
1958      * Starts DPP Configurator-Initiator request
1959      *
1960      * Returns true when operation is successful
1961      * On error, or if these features are not supported, false is returned.
1962      */
startDppConfiguratorInitiator(@onNull String ifaceName, int peerBootstrapId, int ownBootstrapId, @NonNull String ssid, String password, String psk, int netRole, int securityAkm, byte[] privEcKey)1963     public boolean startDppConfiguratorInitiator(@NonNull String ifaceName, int peerBootstrapId,
1964             int ownBootstrapId, @NonNull String ssid, String password, String psk,
1965             int netRole, int securityAkm, byte[] privEcKey) {
1966         synchronized (mLock) {
1967             String methodStr = "startDppConfiguratorInitiator";
1968             if (mStaIfaceHal == null) {
1969                 return handleNullHal(methodStr);
1970             }
1971             return mStaIfaceHal.startDppConfiguratorInitiator(ifaceName, peerBootstrapId,
1972                     ownBootstrapId, ssid, password, psk, netRole, securityAkm, privEcKey);
1973         }
1974     }
1975 
1976     /**
1977      * Starts DPP Enrollee-Initiator request
1978      *
1979      * Returns true when operation is successful
1980      * On error, or if these features are not supported, false is returned.
1981      */
startDppEnrolleeInitiator(@onNull String ifaceName, int peerBootstrapId, int ownBootstrapId)1982     public boolean startDppEnrolleeInitiator(@NonNull String ifaceName, int peerBootstrapId,
1983             int ownBootstrapId) {
1984         synchronized (mLock) {
1985             String methodStr = "startDppEnrolleeInitiator";
1986             if (mStaIfaceHal == null) {
1987                 return handleNullHal(methodStr);
1988             }
1989             return mStaIfaceHal.startDppEnrolleeInitiator(
1990                     ifaceName, peerBootstrapId, ownBootstrapId);
1991         }
1992     }
1993 
1994     /**
1995      * Generate a DPP QR code based on boot strap info
1996      *
1997      * Returns DppBootstrapQrCodeInfo
1998      */
generateDppBootstrapInfoForResponder( @onNull String ifaceName, String macAddress, @NonNull String deviceInfo, int dppCurve)1999     public WifiNative.DppBootstrapQrCodeInfo generateDppBootstrapInfoForResponder(
2000             @NonNull String ifaceName, String macAddress, @NonNull String deviceInfo,
2001             int dppCurve) {
2002         synchronized (mLock) {
2003             String methodStr = "generateDppBootstrapInfoForResponder";
2004             if (mStaIfaceHal == null) {
2005                 handleNullHal(methodStr);
2006                 return new WifiNative.DppBootstrapQrCodeInfo();
2007             }
2008             return mStaIfaceHal.generateDppBootstrapInfoForResponder(
2009                     ifaceName, macAddress, deviceInfo, dppCurve);
2010         }
2011     }
2012 
2013     /**
2014      * Starts DPP Enrollee-Responder request
2015      *
2016      * Returns true when operation is successful
2017      * On error, or if these features are not supported, false is returned.
2018      */
startDppEnrolleeResponder(@onNull String ifaceName, int listenChannel)2019     public boolean startDppEnrolleeResponder(@NonNull String ifaceName, int listenChannel) {
2020         synchronized (mLock) {
2021             String methodStr = "startDppEnrolleeResponder";
2022             if (mStaIfaceHal == null) {
2023                 return handleNullHal(methodStr);
2024             }
2025             return mStaIfaceHal.startDppEnrolleeResponder(ifaceName, listenChannel);
2026         }
2027     }
2028 
2029     /**
2030      * Stops/aborts DPP Responder request.
2031      *
2032      * Returns true when operation is successful
2033      * On error, or if these features are not supported, false is returned.
2034      */
stopDppResponder(@onNull String ifaceName, int ownBootstrapId)2035     public boolean stopDppResponder(@NonNull String ifaceName, int ownBootstrapId) {
2036         synchronized (mLock) {
2037             String methodStr = "stopDppResponder";
2038             if (mStaIfaceHal == null) {
2039                 return handleNullHal(methodStr);
2040             }
2041             return mStaIfaceHal.stopDppResponder(ifaceName, ownBootstrapId);
2042         }
2043     }
2044 
2045     /**
2046      * Register callbacks for DPP events.
2047      *
2048      * @param dppCallback DPP callback object.
2049      */
registerDppCallback(WifiNative.DppEventCallback dppCallback)2050     public void registerDppCallback(WifiNative.DppEventCallback dppCallback) {
2051         synchronized (mLock) {
2052             String methodStr = "registerDppCallback";
2053             if (mStaIfaceHal == null) {
2054                 handleNullHal(methodStr);
2055                 return;
2056             }
2057             mStaIfaceHal.registerDppCallback(dppCallback);
2058         }
2059     }
2060 
2061     /**
2062      * Set MBO cellular data availability.
2063      *
2064      * @param ifaceName Name of the interface.
2065      * @param available true means cellular data available, false otherwise.
2066      * Returns true when operation is successful
2067      */
setMboCellularDataStatus(@onNull String ifaceName, boolean available)2068     public boolean setMboCellularDataStatus(@NonNull String ifaceName, boolean available) {
2069         synchronized (mLock) {
2070             String methodStr = "setMboCellularDataStatus";
2071             if (mStaIfaceHal == null) {
2072                 return handleNullHal(methodStr);
2073             }
2074             return mStaIfaceHal.setMboCellularDataStatus(ifaceName, available);
2075         }
2076     }
2077 
2078     /**
2079      * Set whether the network-centric QoS policy feature is enabled or not for this interface.
2080      *
2081      * @param ifaceName name of the interface.
2082      * @param isEnabled true if feature is enabled, false otherwise.
2083      * @return true if operation is successful, false otherwise.
2084      */
setNetworkCentricQosPolicyFeatureEnabled(@onNull String ifaceName, boolean isEnabled)2085     public boolean setNetworkCentricQosPolicyFeatureEnabled(@NonNull String ifaceName,
2086             boolean isEnabled) {
2087         synchronized (mLock) {
2088             String methodStr = "setNetworkCentricQosPolicyFeatureEnabled";
2089             if (mStaIfaceHal == null) {
2090                 return handleNullHal(methodStr);
2091             }
2092             return mStaIfaceHal.setNetworkCentricQosPolicyFeatureEnabled(ifaceName, isEnabled);
2093         }
2094     }
2095 
2096     /**
2097      * Check if we've roamed to a linked network and make the linked network the current network
2098      * if we have.
2099      *
2100      * @param ifaceName Name of the interface.
2101      * @param newNetworkId Network id of the new network we've roamed to. If fromFramework is
2102      *                     {@code true}, this will be a framework network id. Otherwise, this will
2103      *                     be a remote network id.
2104      * @param fromFramework {@code true} if the network id is a framework network id, {@code false}
2105                             if the network id is a remote network id.
2106      * @return true if we've roamed to a linked network, false if not.
2107      */
updateOnLinkedNetworkRoaming( @onNull String ifaceName, int newNetworkId, boolean fromFramework)2108     public boolean updateOnLinkedNetworkRoaming(
2109             @NonNull String ifaceName, int newNetworkId, boolean fromFramework) {
2110         synchronized (mLock) {
2111             String methodStr = "updateOnLinkedNetworkRoaming";
2112             if (mStaIfaceHal == null) {
2113                 return handleNullHal(methodStr);
2114             }
2115             return mStaIfaceHal.updateOnLinkedNetworkRoaming(
2116                     ifaceName, newNetworkId, fromFramework);
2117         }
2118     }
2119 
2120     /**
2121      * Updates the linked networks for the current network and sends them to the supplicant.
2122      *
2123      * @param ifaceName Name of the interface.
2124      * @param networkId Network id of the network to link the configurations to.
2125      * @param linkedConfigurations Map of config profile key to config for linking.
2126      * @return true if networks were successfully linked, false otherwise.
2127      */
updateLinkedNetworks(@onNull String ifaceName, int networkId, Map<String, WifiConfiguration> linkedConfigurations)2128     public boolean updateLinkedNetworks(@NonNull String ifaceName, int networkId,
2129             Map<String, WifiConfiguration> linkedConfigurations) {
2130         synchronized (mLock) {
2131             String methodStr = "updateLinkedNetworks";
2132             if (mStaIfaceHal == null) {
2133                 return handleNullHal(methodStr);
2134             }
2135             return mStaIfaceHal.updateLinkedNetworks(ifaceName, networkId, linkedConfigurations);
2136         }
2137     }
2138 
2139     /**
2140      * Gets the security params of the current network associated with this interface
2141      *
2142      * @param ifaceName Name of the interface
2143      * @return Security params of the current network associated with the interface
2144      */
getCurrentNetworkSecurityParams(@onNull String ifaceName)2145     public SecurityParams getCurrentNetworkSecurityParams(@NonNull String ifaceName) {
2146         synchronized (mLock) {
2147             String methodStr = "getCurrentNetworkSecurityParams";
2148             if (mStaIfaceHal == null) {
2149                 handleNullHal(methodStr);
2150                 return null;
2151             }
2152             return mStaIfaceHal.getCurrentNetworkSecurityParams(ifaceName);
2153         }
2154     }
2155 
2156     /**
2157      * Sends a QoS policy response.
2158      *
2159      * @param ifaceName Name of the interface.
2160      * @param qosPolicyRequestId Dialog token to identify the request.
2161      * @param morePolicies Flag to indicate more QoS policies can be accommodated.
2162      * @param qosPolicyStatusList List of framework QosPolicyStatus objects.
2163      * @return true if response is sent successfully, false otherwise.
2164      */
sendQosPolicyResponse(String ifaceName, int qosPolicyRequestId, boolean morePolicies, @NonNull List<QosPolicyStatus> qosPolicyStatusList)2165     public boolean sendQosPolicyResponse(String ifaceName, int qosPolicyRequestId,
2166             boolean morePolicies, @NonNull List<QosPolicyStatus> qosPolicyStatusList) {
2167         String methodStr = "sendQosPolicyResponse";
2168         if (mStaIfaceHal == null) {
2169             handleNullHal(methodStr);
2170             return false;
2171         }
2172         return mStaIfaceHal.sendQosPolicyResponse(ifaceName, qosPolicyRequestId,
2173                 morePolicies, qosPolicyStatusList);
2174     }
2175 
2176     /**
2177      * Indicates the removal of all active QoS policies configured by the AP.
2178      *
2179      * @param ifaceName Name of the interface.
2180      */
removeAllQosPolicies(String ifaceName)2181     public boolean removeAllQosPolicies(String ifaceName) {
2182         String methodStr = "removeAllQosPolicies";
2183         if (mStaIfaceHal == null) {
2184             return handleNullHal(methodStr);
2185         }
2186         return mStaIfaceHal.removeAllQosPolicies(ifaceName);
2187     }
2188 
2189     /**
2190      * Generate DPP credential for network access
2191      *
2192      * @param ifaceName Name of the interface.
2193      * @param ssid ssid of the network
2194      * @param privEcKey Private EC Key for DPP Configurator
2195      * Returns true when operation is successful. On error, false is returned.
2196      */
generateSelfDppConfiguration(@onNull String ifaceName, @NonNull String ssid, byte[] privEcKey)2197     public boolean generateSelfDppConfiguration(@NonNull String ifaceName, @NonNull String ssid,
2198             byte[] privEcKey) {
2199         synchronized (mLock) {
2200             String methodStr = "generateSelfDppConfiguration";
2201             if (mStaIfaceHal == null) {
2202                 return handleNullHal(methodStr);
2203             }
2204             return mStaIfaceHal.generateSelfDppConfiguration(ifaceName, ssid, privEcKey);
2205         }
2206     }
2207 
2208     /**
2209      * This set anonymous identity to supplicant.
2210      *
2211      * @param ifaceName Name of the interface.
2212      * @param anonymousIdentity the anonymouns identity.
2213      * @return true if succeeds, false otherwise.
2214      */
setEapAnonymousIdentity(@onNull String ifaceName, String anonymousIdentity)2215     public boolean setEapAnonymousIdentity(@NonNull String ifaceName, String anonymousIdentity) {
2216         String methodStr = "setEapAnonymousIdentity";
2217         if (mStaIfaceHal == null) {
2218             return handleNullHal(methodStr);
2219         }
2220         return mStaIfaceHal.setEapAnonymousIdentity(ifaceName, anonymousIdentity);
2221     }
2222 
handleNullHal(String methodStr)2223     private boolean handleNullHal(String methodStr) {
2224         Log.e(TAG, "Cannot call " + methodStr + " because HAL object is null.");
2225         return false;
2226     }
2227 }
2228