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