SupplicantStaNetworkHal.java revision 7c0ec884188660f72977c8a80366049705c48ffa
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 */ 16package com.android.server.wifi; 17 18import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetwork; 19import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetworkCallback; 20import android.hardware.wifi.supplicant.V1_0.SupplicantStatus; 21import android.hardware.wifi.supplicant.V1_0.SupplicantStatusCode; 22import android.net.wifi.WifiConfiguration; 23import android.net.wifi.WifiEnterpriseConfig; 24import android.os.HandlerThread; 25import android.os.RemoteException; 26import android.text.TextUtils; 27import android.util.Log; 28import android.util.MutableBoolean; 29 30import com.android.internal.annotations.VisibleForTesting; 31import com.android.internal.util.ArrayUtils; 32import com.android.server.wifi.util.NativeUtil; 33 34import java.util.ArrayList; 35import java.util.BitSet; 36import java.util.HashMap; 37import java.util.Map; 38import java.util.regex.Matcher; 39import java.util.regex.Pattern; 40 41/** 42 * Wrapper class for ISupplicantStaNetwork HAL calls. Gets and sets supplicant sta network variables 43 * and interacts with networks. 44 * Public fields should be treated as invalid until their 'get' method is called, which will set the 45 * value if it returns true 46 */ 47public class SupplicantStaNetworkHal { 48 private static final String TAG = "SupplicantStaNetworkHal"; 49 private static final boolean DBG = false; 50 @VisibleForTesting 51 public static final String ID_STRING_KEY_FQDN = "fqdn"; 52 @VisibleForTesting 53 public static final String ID_STRING_KEY_CREATOR_UID = "creatorUid"; 54 @VisibleForTesting 55 public static final String ID_STRING_KEY_CONFIG_KEY = "configKey"; 56 57 /** 58 * Regex pattern for extracting the GSM sim authentication response params from a string. 59 * Matches a strings like the following: "[:kc:<kc_value>:sres:<sres_value>]"; 60 */ 61 private static final Pattern GSM_AUTH_RESPONSE_PARAMS_PATTERN = 62 Pattern.compile(":kc:([0-9a-f]+):sres:([0-9a-f]+)"); 63 /** 64 * Regex pattern for extracting the UMTS sim authentication response params from a string. 65 * Matches a strings like the following: ":ik:<ik_value>:ck:<ck_value>:res:<res_value>"; 66 */ 67 private static final Pattern UMTS_AUTH_RESPONSE_PARAMS_PATTERN = 68 Pattern.compile(":ik:([0-9a-f]+):ck:([0-9a-f]+):res:([0-9a-f]+)"); 69 /** 70 * Regex pattern for extracting the UMTS sim auts response params from a string. 71 * Matches a strings like the following: ":<auts_value>"; 72 */ 73 private static final Pattern UMTS_AUTS_RESPONSE_PARAMS_PATTERN = Pattern.compile("([0-9a-f]+)"); 74 75 private final Object mLock = new Object(); 76 private ISupplicantStaNetwork mISupplicantStaNetwork = null; 77 private final HandlerThread mHandlerThread; 78 private int mNetworkId; 79 private String mIfaceName; 80 private ArrayList<Byte> mSsid; 81 private byte[/* 6 */] mBssid; 82 private boolean mScanSsid; 83 private int mKeyMgmtMask; 84 private int mProtoMask; 85 private int mAuthAlgMask; 86 private int mGroupCipherMask; 87 private int mPairwiseCipherMask; 88 private String mPskPassphrase; 89 private ArrayList<Byte> mWepKey; 90 private int mWepTxKeyIdx; 91 private boolean mRequirePmf; 92 private String mIdStr; 93 private int mEapMethod; 94 private int mEapPhase2Method; 95 private ArrayList<Byte> mEapIdentity; 96 private ArrayList<Byte> mEapAnonymousIdentity; 97 private ArrayList<Byte> mEapPassword; 98 private String mEapCACert; 99 private String mEapCAPath; 100 private String mEapClientCert; 101 private String mEapPrivateKey; 102 private String mEapSubjectMatch; 103 private String mEapAltSubjectMatch; 104 private boolean mEapEngine; 105 private String mEapEngineID; 106 private String mEapDomainSuffixMatch; 107 108 SupplicantStaNetworkHal(ISupplicantStaNetwork iSupplicantStaNetwork, 109 HandlerThread handlerThread) { 110 mISupplicantStaNetwork = iSupplicantStaNetwork; 111 mHandlerThread = handlerThread; 112 } 113 114 /** 115 * Read network variables from wpa_supplicant into the provided WifiConfiguration object. 116 * 117 * @param config WifiConfiguration object to be populated. 118 * @param networkExtras Map of network extras parsed from wpa_supplicant. 119 * @return true if succeeds, false otherwise. 120 */ 121 public boolean loadWifiConfiguration(WifiConfiguration config, 122 Map<String, String> networkExtras) { 123 if (config == null) return false; 124 /** SSID */ 125 config.SSID = null; 126 if (getSsid() && !ArrayUtils.isEmpty(mSsid)) { 127 config.SSID = NativeUtil.encodeSsid(mSsid); 128 } else { 129 Log.e(TAG, "failed to read ssid"); 130 return false; 131 } 132 /** Network Id */ 133 config.networkId = -1; 134 if (getId()) { 135 config.networkId = mNetworkId; 136 } else { 137 Log.e(TAG, "getId failed"); 138 return false; 139 } 140 /** BSSID */ 141 config.getNetworkSelectionStatus().setNetworkSelectionBSSID(null); 142 if (getBssid() && !ArrayUtils.isEmpty(mBssid)) { 143 config.getNetworkSelectionStatus().setNetworkSelectionBSSID( 144 NativeUtil.macAddressFromByteArray(mBssid)); 145 } 146 /** Scan SSID (Is Hidden Network?) */ 147 config.hiddenSSID = false; 148 if (getScanSsid()) { 149 config.hiddenSSID = mScanSsid; 150 } 151 /** Require PMF*/ 152 config.requirePMF = false; 153 if (getRequirePmf()) { 154 config.requirePMF = mRequirePmf; 155 } 156 /** WEP keys **/ 157 config.wepTxKeyIndex = -1; 158 if (getWepTxKeyIdx()) { 159 config.wepTxKeyIndex = mWepTxKeyIdx; 160 } 161 for (int i = 0; i < 4; i++) { 162 config.wepKeys[i] = null; 163 if (getWepKey(i) && !ArrayUtils.isEmpty(mWepKey)) { 164 config.wepKeys[i] = NativeUtil.stringFromByteArrayList(mWepKey); 165 } 166 } 167 /** PSK pass phrase */ 168 config.preSharedKey = null; 169 if (getPskPassphrase() && !TextUtils.isEmpty(mPskPassphrase)) { 170 config.preSharedKey = mPskPassphrase; 171 } 172 /** allowedKeyManagement */ 173 if (getKeyMgmt()) { 174 config.allowedKeyManagement = 175 supplicantToWifiConfigurationKeyMgmtMask(mKeyMgmtMask); 176 } 177 /** allowedProtocols */ 178 if (getProto()) { 179 config.allowedProtocols = 180 supplicantToWifiConfigurationProtoMask(mProtoMask); 181 } 182 /** allowedAuthAlgorithms */ 183 if (getAuthAlg()) { 184 config.allowedAuthAlgorithms = 185 supplicantToWifiConfigurationAuthAlgMask(mAuthAlgMask); 186 } 187 /** allowedGroupCiphers */ 188 if (getGroupCipher()) { 189 config.allowedGroupCiphers = 190 supplicantToWifiConfigurationGroupCipherMask(mGroupCipherMask); 191 } 192 /** allowedPairwiseCiphers */ 193 if (getPairwiseCipher()) { 194 config.allowedPairwiseCiphers = 195 supplicantToWifiConfigurationPairwiseCipherMask(mPairwiseCipherMask); 196 } 197 /** metadata: idstr */ 198 if (getIdStr() && !TextUtils.isEmpty(mIdStr)) { 199 Map<String, String> metadata = WifiNative.parseNetworkExtra(mIdStr); 200 networkExtras.putAll(metadata); 201 } else { 202 Log.e(TAG, "getIdStr failed"); 203 return false; 204 } 205 return loadWifiEnterpriseConfig(config.SSID, config.enterpriseConfig); 206 } 207 208 /** 209 * Save an entire WifiConfiguration to wpa_supplicant via HIDL. 210 * 211 * @param config WifiConfiguration object to be saved. 212 * @return true if succeeds, false otherwise. 213 */ 214 public boolean saveWifiConfiguration(WifiConfiguration config) { 215 if (config == null) return false; 216 /** SSID */ 217 if (config.SSID != null) { 218 if (!setSsid(NativeUtil.decodeSsid(config.SSID))) { 219 Log.e(TAG, "failed to set SSID: " + config.SSID); 220 return false; 221 } 222 } 223 /** BSSID */ 224 String bssidStr = config.getNetworkSelectionStatus().getNetworkSelectionBSSID(); 225 if (bssidStr != null) { 226 byte[] bssid = NativeUtil.macAddressToByteArray(bssidStr); 227 if (!setBssid(bssid)) { 228 Log.e(TAG, "failed to set BSSID: " + bssidStr); 229 return false; 230 } 231 } 232 /** Pre Shared Key */ 233 if (config.preSharedKey != null && !setPskPassphrase(config.preSharedKey)) { 234 Log.e(TAG, "failed to set psk"); 235 return false; 236 } 237 /** Wep Keys */ 238 boolean hasSetKey = false; 239 if (config.wepKeys != null) { 240 for (int i = 0; i < config.wepKeys.length; i++) { 241 // Prevent client screw-up by passing in a WifiConfiguration we gave it 242 // by preventing "*" as a key. 243 if (config.wepKeys[i] != null && !config.wepKeys[i].equals("*")) { 244 if (!setWepKey(i, NativeUtil.stringToByteArrayList(config.wepKeys[i]))) { 245 Log.e(TAG, "failed to set wep_key " + i); 246 return false; 247 } 248 hasSetKey = true; 249 } 250 } 251 } 252 /** Wep Tx Key Idx */ 253 if (hasSetKey) { 254 if (!setWepTxKeyIdx(config.wepTxKeyIndex)) { 255 Log.e(TAG, "failed to set wep_tx_keyidx: " + config.wepTxKeyIndex); 256 return false; 257 } 258 } 259 /** HiddenSSID */ 260 if (!setScanSsid(config.hiddenSSID)) { 261 Log.e(TAG, config.SSID + ": failed to set hiddenSSID: " + config.hiddenSSID); 262 return false; 263 } 264 /** RequirePMF */ 265 if (!setRequirePmf(config.requirePMF)) { 266 Log.e(TAG, config.SSID + ": failed to set requirePMF: " + config.requirePMF); 267 return false; 268 } 269 /** Key Management Scheme */ 270 if (config.allowedKeyManagement.cardinality() != 0 271 && !setKeyMgmt(wifiConfigurationToSupplicantKeyMgmtMask( 272 config.allowedKeyManagement))) { 273 Log.e(TAG, "failed to set Key Management"); 274 return false; 275 } 276 /** Security Protocol */ 277 if (config.allowedProtocols.cardinality() != 0 278 && !setProto(wifiConfigurationToSupplicantProtoMask(config.allowedProtocols))) { 279 Log.e(TAG, "failed to set Security Protocol"); 280 return false; 281 } 282 /** Auth Algorithm */ 283 if (config.allowedAuthAlgorithms.cardinality() != 0 284 && !setAuthAlg(wifiConfigurationToSupplicantAuthAlgMask( 285 config.allowedAuthAlgorithms))) { 286 Log.e(TAG, "failed to set AuthAlgorithm"); 287 return false; 288 } 289 /** Group Cipher */ 290 if (config.allowedGroupCiphers.cardinality() != 0 291 && !setGroupCipher(wifiConfigurationToSupplicantGroupCipherMask( 292 config.allowedGroupCiphers))) { 293 Log.e(TAG, "failed to set Group Cipher"); 294 return false; 295 } 296 /** Pairwise Cipher*/ 297 if (config.allowedPairwiseCiphers.cardinality() != 0 298 && !setPairwiseCipher(wifiConfigurationToSupplicantPairwiseCipherMask( 299 config.allowedPairwiseCiphers))) { 300 Log.e(TAG, "failed to set PairwiseCipher"); 301 return false; 302 } 303 /** metadata: FQDN + ConfigKey + CreatorUid */ 304 final Map<String, String> metadata = new HashMap<String, String>(); 305 if (config.isPasspoint()) { 306 metadata.put(ID_STRING_KEY_FQDN, config.FQDN); 307 } 308 metadata.put(ID_STRING_KEY_CONFIG_KEY, config.configKey()); 309 metadata.put(ID_STRING_KEY_CREATOR_UID, Integer.toString(config.creatorUid)); 310 if (!setIdStr(WifiNative.createNetworkExtra(metadata))) { 311 Log.e(TAG, "failed to set id string"); 312 return false; 313 } 314 /** UpdateIdentifier */ 315 if (config.updateIdentifier != null 316 && !setUpdateIdentifier(Integer.parseInt(config.updateIdentifier))) { 317 Log.e(TAG, "failed to set update identifier"); 318 return false; 319 } 320 // Finish here if no EAP config to set 321 if (config.enterpriseConfig == null 322 || config.enterpriseConfig.getEapMethod() == WifiEnterpriseConfig.Eap.NONE) { 323 return true; 324 } else { 325 return saveWifiEnterpriseConfig(config.SSID, config.enterpriseConfig); 326 } 327 } 328 329 /** 330 * Read network variables from wpa_supplicant into the provided WifiEnterpriseConfig object. 331 * 332 * @param ssid SSID of the network. (Used for logging purposes only) 333 * @param eapConfig WifiEnterpriseConfig object to be populated. 334 * @return true if succeeds, false otherwise. 335 */ 336 private boolean loadWifiEnterpriseConfig(String ssid, WifiEnterpriseConfig eapConfig) { 337 if (eapConfig == null) return false; 338 /** EAP method */ 339 if (getEapMethod()) { 340 eapConfig.setEapMethod(supplicantToWifiConfigurationEapMethod(mEapMethod)); 341 } else { 342 // Invalid eap method could be because it's not an enterprise config. 343 Log.e(TAG, "failed to get eap method. Assumimg not an enterprise network"); 344 return true; 345 } 346 /** EAP Phase 2 method */ 347 if (getEapPhase2Method()) { 348 eapConfig.setPhase2Method( 349 supplicantToWifiConfigurationEapPhase2Method(mEapPhase2Method)); 350 } else { 351 // We cannot have an invalid eap phase 2 method. Return failure. 352 Log.e(TAG, "failed to get eap phase2 method"); 353 return false; 354 } 355 /** EAP Identity */ 356 if (getEapIdentity() && !ArrayUtils.isEmpty(mEapIdentity)) { 357 eapConfig.setFieldValue( 358 WifiEnterpriseConfig.IDENTITY_KEY, 359 NativeUtil.stringFromByteArrayList(mEapIdentity)); 360 } 361 /** EAP Anonymous Identity */ 362 if (getEapAnonymousIdentity() && !ArrayUtils.isEmpty(mEapAnonymousIdentity)) { 363 eapConfig.setFieldValue( 364 WifiEnterpriseConfig.ANON_IDENTITY_KEY, 365 NativeUtil.stringFromByteArrayList(mEapAnonymousIdentity)); 366 } 367 /** EAP Password */ 368 if (getEapPassword() && !ArrayUtils.isEmpty(mEapPassword)) { 369 eapConfig.setFieldValue( 370 WifiEnterpriseConfig.PASSWORD_KEY, 371 NativeUtil.stringFromByteArrayList(mEapPassword)); 372 } 373 /** EAP Client Cert */ 374 if (getEapClientCert() && !TextUtils.isEmpty(mEapClientCert)) { 375 eapConfig.setFieldValue(WifiEnterpriseConfig.CLIENT_CERT_KEY, mEapClientCert); 376 } 377 /** EAP CA Cert */ 378 if (getEapCACert() && !TextUtils.isEmpty(mEapCACert)) { 379 eapConfig.setFieldValue(WifiEnterpriseConfig.CA_CERT_KEY, mEapCACert); 380 } 381 /** EAP Subject Match */ 382 if (getEapSubjectMatch() && !TextUtils.isEmpty(mEapSubjectMatch)) { 383 eapConfig.setFieldValue(WifiEnterpriseConfig.SUBJECT_MATCH_KEY, mEapSubjectMatch); 384 } 385 /** EAP Engine ID */ 386 if (getEapEngineID() && !TextUtils.isEmpty(mEapEngineID)) { 387 eapConfig.setFieldValue(WifiEnterpriseConfig.ENGINE_ID_KEY, mEapEngineID); 388 } 389 /** EAP Engine. Set this only if the engine id is non null. */ 390 if (getEapEngine() && !TextUtils.isEmpty(mEapEngineID)) { 391 eapConfig.setFieldValue( 392 WifiEnterpriseConfig.ENGINE_KEY, 393 mEapEngine 394 ? WifiEnterpriseConfig.ENGINE_ENABLE 395 : WifiEnterpriseConfig.ENGINE_DISABLE); 396 } 397 /** EAP Private Key */ 398 if (getEapPrivateKey() && !TextUtils.isEmpty(mEapPrivateKey)) { 399 eapConfig.setFieldValue(WifiEnterpriseConfig.PRIVATE_KEY_ID_KEY, mEapPrivateKey); 400 } 401 /** EAP Alt Subject Match */ 402 if (getEapAltSubjectMatch() && !TextUtils.isEmpty(mEapAltSubjectMatch)) { 403 eapConfig.setFieldValue(WifiEnterpriseConfig.ALTSUBJECT_MATCH_KEY, mEapAltSubjectMatch); 404 } 405 /** EAP Domain Suffix Match */ 406 if (getEapDomainSuffixMatch() && !TextUtils.isEmpty(mEapDomainSuffixMatch)) { 407 eapConfig.setFieldValue( 408 WifiEnterpriseConfig.DOM_SUFFIX_MATCH_KEY, mEapDomainSuffixMatch); 409 } 410 /** EAP CA Path*/ 411 if (getEapCAPath() && !TextUtils.isEmpty(mEapCAPath)) { 412 eapConfig.setFieldValue(WifiEnterpriseConfig.CA_PATH_KEY, mEapCAPath); 413 } 414 return true; 415 } 416 417 /** 418 * Save network variables from the provided WifiEnterpriseConfig object to wpa_supplicant. 419 * 420 * @param ssid SSID of the network. (Used for logging purposes only) 421 * @param eapConfig WifiEnterpriseConfig object to be saved. 422 * @return true if succeeds, false otherwise. 423 */ 424 private boolean saveWifiEnterpriseConfig(String ssid, WifiEnterpriseConfig eapConfig) { 425 if (eapConfig == null) return false; 426 /** EAP method */ 427 if (!setEapMethod(wifiConfigurationToSupplicantEapMethod(eapConfig.getEapMethod()))) { 428 Log.e(TAG, ssid + ": failed to set eap method: " + eapConfig.getEapMethod()); 429 return false; 430 } 431 /** EAP Phase 2 method */ 432 if (!setEapPhase2Method(wifiConfigurationToSupplicantEapPhase2Method( 433 eapConfig.getPhase2Method()))) { 434 Log.e(TAG, ssid + ": failed to set eap phase 2 method: " + eapConfig.getPhase2Method()); 435 return false; 436 } 437 String eapParam = null; 438 /** EAP Identity */ 439 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.IDENTITY_KEY); 440 if (!TextUtils.isEmpty(eapParam) 441 && !setEapIdentity(NativeUtil.stringToByteArrayList(eapParam))) { 442 Log.e(TAG, ssid + ": failed to set eap identity: " + eapParam); 443 return false; 444 } 445 /** EAP Anonymous Identity */ 446 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.ANON_IDENTITY_KEY); 447 if (!TextUtils.isEmpty(eapParam) 448 && !setEapAnonymousIdentity(NativeUtil.stringToByteArrayList(eapParam))) { 449 Log.e(TAG, ssid + ": failed to set eap anonymous identity: " + eapParam); 450 return false; 451 } 452 /** EAP Password */ 453 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.PASSWORD_KEY); 454 if (!TextUtils.isEmpty(eapParam) 455 && !setEapPassword(NativeUtil.stringToByteArrayList(eapParam))) { 456 Log.e(TAG, ssid + ": failed to set eap password"); 457 return false; 458 } 459 /** EAP Client Cert */ 460 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.CLIENT_CERT_KEY); 461 if (!TextUtils.isEmpty(eapParam) && !setEapClientCert(eapParam)) { 462 Log.e(TAG, ssid + ": failed to set eap client cert: " + eapParam); 463 return false; 464 } 465 /** EAP CA Cert */ 466 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.CA_CERT_KEY); 467 if (!TextUtils.isEmpty(eapParam) && !setEapCACert(eapParam)) { 468 Log.e(TAG, ssid + ": failed to set eap ca cert: " + eapParam); 469 return false; 470 } 471 /** EAP Subject Match */ 472 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.SUBJECT_MATCH_KEY); 473 if (!TextUtils.isEmpty(eapParam) && !setEapSubjectMatch(eapParam)) { 474 Log.e(TAG, ssid + ": failed to set eap subject match: " + eapParam); 475 return false; 476 } 477 /** EAP Engine ID */ 478 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.ENGINE_ID_KEY); 479 if (!TextUtils.isEmpty(eapParam) && !setEapEngineID(eapParam)) { 480 Log.e(TAG, ssid + ": failed to set eap engine id: " + eapParam); 481 return false; 482 } 483 /** EAP Engine */ 484 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.ENGINE_KEY); 485 if (!TextUtils.isEmpty(eapParam) && !setEapEngine( 486 eapParam.equals(WifiEnterpriseConfig.ENGINE_ENABLE) ? true : false)) { 487 Log.e(TAG, ssid + ": failed to set eap engine: " + eapParam); 488 return false; 489 } 490 /** EAP Private Key */ 491 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.PRIVATE_KEY_ID_KEY); 492 if (!TextUtils.isEmpty(eapParam) && !setEapPrivateKey(eapParam)) { 493 Log.e(TAG, ssid + ": failed to set eap private key: " + eapParam); 494 return false; 495 } 496 /** EAP Alt Subject Match */ 497 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.ALTSUBJECT_MATCH_KEY); 498 if (!TextUtils.isEmpty(eapParam) && !setEapAltSubjectMatch(eapParam)) { 499 Log.e(TAG, ssid + ": failed to set eap alt subject match: " + eapParam); 500 return false; 501 } 502 /** EAP Domain Suffix Match */ 503 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.DOM_SUFFIX_MATCH_KEY); 504 if (!TextUtils.isEmpty(eapParam) && !setEapDomainSuffixMatch(eapParam)) { 505 Log.e(TAG, ssid + ": failed to set eap domain suffix match: " + eapParam); 506 return false; 507 } 508 /** EAP CA Path*/ 509 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.CA_PATH_KEY); 510 if (!TextUtils.isEmpty(eapParam) && !setEapCAPath(eapParam)) { 511 Log.e(TAG, ssid + ": failed to set eap ca path: " + eapParam); 512 return false; 513 } 514 515 /** EAP Proactive Key Caching */ 516 eapParam = eapConfig.getFieldValue(WifiEnterpriseConfig.OPP_KEY_CACHING); 517 if (!TextUtils.isEmpty(eapParam) 518 && !setEapProactiveKeyCaching(eapParam.equals("1") ? true : false)) { 519 Log.e(TAG, ssid + ": failed to set proactive key caching: " + eapParam); 520 return false; 521 } 522 return true; 523 } 524 525 /** 526 * Maps WifiConfiguration Key Management BitSet to Supplicant HIDL bitmask int 527 * TODO(b/32571829): Update mapping when fast transition keys are added 528 * @return bitmask int describing the allowed Key Management schemes, readable by the Supplicant 529 * HIDL hal 530 */ 531 private static int wifiConfigurationToSupplicantKeyMgmtMask(BitSet keyMgmt) { 532 int mask = 0; 533 for (int bit = keyMgmt.nextSetBit(0); bit != -1; bit = keyMgmt.nextSetBit(bit + 1)) { 534 switch (bit) { 535 case WifiConfiguration.KeyMgmt.NONE: 536 mask |= ISupplicantStaNetwork.KeyMgmtMask.NONE; 537 break; 538 case WifiConfiguration.KeyMgmt.WPA_PSK: 539 mask |= ISupplicantStaNetwork.KeyMgmtMask.WPA_PSK; 540 break; 541 case WifiConfiguration.KeyMgmt.WPA_EAP: 542 mask |= ISupplicantStaNetwork.KeyMgmtMask.WPA_EAP; 543 break; 544 case WifiConfiguration.KeyMgmt.IEEE8021X: 545 mask |= ISupplicantStaNetwork.KeyMgmtMask.IEEE8021X; 546 break; 547 case WifiConfiguration.KeyMgmt.OSEN: 548 mask |= ISupplicantStaNetwork.KeyMgmtMask.OSEN; 549 break; 550 case WifiConfiguration.KeyMgmt.FT_PSK: 551 mask |= ISupplicantStaNetwork.KeyMgmtMask.FT_PSK; 552 break; 553 case WifiConfiguration.KeyMgmt.FT_EAP: 554 mask |= ISupplicantStaNetwork.KeyMgmtMask.FT_EAP; 555 break; 556 case WifiConfiguration.KeyMgmt.WPA2_PSK: // This should never happen 557 default: 558 throw new IllegalArgumentException( 559 "Invalid protoMask bit in keyMgmt: " + bit); 560 } 561 } 562 return mask; 563 } 564 565 private static int wifiConfigurationToSupplicantProtoMask(BitSet protoMask) { 566 int mask = 0; 567 for (int bit = protoMask.nextSetBit(0); bit != -1; bit = protoMask.nextSetBit(bit + 1)) { 568 switch (bit) { 569 case WifiConfiguration.Protocol.WPA: 570 mask |= ISupplicantStaNetwork.ProtoMask.WPA; 571 break; 572 case WifiConfiguration.Protocol.RSN: 573 mask |= ISupplicantStaNetwork.ProtoMask.RSN; 574 break; 575 case WifiConfiguration.Protocol.OSEN: 576 mask |= ISupplicantStaNetwork.ProtoMask.OSEN; 577 break; 578 default: 579 throw new IllegalArgumentException( 580 "Invalid protoMask bit in wificonfig: " + bit); 581 } 582 } 583 return mask; 584 }; 585 586 private static int wifiConfigurationToSupplicantAuthAlgMask(BitSet authAlgMask) { 587 int mask = 0; 588 for (int bit = authAlgMask.nextSetBit(0); bit != -1; 589 bit = authAlgMask.nextSetBit(bit + 1)) { 590 switch (bit) { 591 case WifiConfiguration.AuthAlgorithm.OPEN: 592 mask |= ISupplicantStaNetwork.AuthAlgMask.OPEN; 593 break; 594 case WifiConfiguration.AuthAlgorithm.SHARED: 595 mask |= ISupplicantStaNetwork.AuthAlgMask.SHARED; 596 break; 597 case WifiConfiguration.AuthAlgorithm.LEAP: 598 mask |= ISupplicantStaNetwork.AuthAlgMask.LEAP; 599 break; 600 default: 601 throw new IllegalArgumentException( 602 "Invalid authAlgMask bit in wificonfig: " + bit); 603 } 604 } 605 return mask; 606 }; 607 608 private static int wifiConfigurationToSupplicantGroupCipherMask(BitSet groupCipherMask) { 609 int mask = 0; 610 for (int bit = groupCipherMask.nextSetBit(0); bit != -1; bit = 611 groupCipherMask.nextSetBit(bit + 1)) { 612 switch (bit) { 613 case WifiConfiguration.GroupCipher.WEP40: 614 mask |= ISupplicantStaNetwork.GroupCipherMask.WEP40; 615 break; 616 case WifiConfiguration.GroupCipher.WEP104: 617 mask |= ISupplicantStaNetwork.GroupCipherMask.WEP104; 618 break; 619 case WifiConfiguration.GroupCipher.TKIP: 620 mask |= ISupplicantStaNetwork.GroupCipherMask.TKIP; 621 break; 622 case WifiConfiguration.GroupCipher.CCMP: 623 mask |= ISupplicantStaNetwork.GroupCipherMask.CCMP; 624 break; 625 case WifiConfiguration.GroupCipher.GTK_NOT_USED: 626 mask |= ISupplicantStaNetwork.GroupCipherMask.GTK_NOT_USED; 627 break; 628 default: 629 throw new IllegalArgumentException( 630 "Invalid GroupCipherMask bit in wificonfig: " + bit); 631 } 632 } 633 return mask; 634 }; 635 636 private static int wifiConfigurationToSupplicantPairwiseCipherMask(BitSet pairwiseCipherMask) { 637 int mask = 0; 638 for (int bit = pairwiseCipherMask.nextSetBit(0); bit != -1; 639 bit = pairwiseCipherMask.nextSetBit(bit + 1)) { 640 switch (bit) { 641 case WifiConfiguration.PairwiseCipher.NONE: 642 mask |= ISupplicantStaNetwork.PairwiseCipherMask.NONE; 643 break; 644 case WifiConfiguration.PairwiseCipher.TKIP: 645 mask |= ISupplicantStaNetwork.PairwiseCipherMask.TKIP; 646 break; 647 case WifiConfiguration.PairwiseCipher.CCMP: 648 mask |= ISupplicantStaNetwork.PairwiseCipherMask.CCMP; 649 break; 650 default: 651 throw new IllegalArgumentException( 652 "Invalid pairwiseCipherMask bit in wificonfig: " + bit); 653 } 654 } 655 return mask; 656 }; 657 658 private static int supplicantToWifiConfigurationEapMethod(int value) { 659 switch (value) { 660 case ISupplicantStaNetwork.EapMethod.PEAP: 661 return WifiEnterpriseConfig.Eap.PEAP; 662 case ISupplicantStaNetwork.EapMethod.TLS: 663 return WifiEnterpriseConfig.Eap.TLS; 664 case ISupplicantStaNetwork.EapMethod.TTLS: 665 return WifiEnterpriseConfig.Eap.TTLS; 666 case ISupplicantStaNetwork.EapMethod.PWD: 667 return WifiEnterpriseConfig.Eap.PWD; 668 case ISupplicantStaNetwork.EapMethod.SIM: 669 return WifiEnterpriseConfig.Eap.SIM; 670 case ISupplicantStaNetwork.EapMethod.AKA: 671 return WifiEnterpriseConfig.Eap.AKA; 672 case ISupplicantStaNetwork.EapMethod.AKA_PRIME: 673 return WifiEnterpriseConfig.Eap.AKA_PRIME; 674 case ISupplicantStaNetwork.EapMethod.WFA_UNAUTH_TLS: 675 return WifiEnterpriseConfig.Eap.UNAUTH_TLS; 676 // WifiEnterpriseConfig.Eap.NONE: 677 default: 678 Log.e(TAG, "invalid eap method value from supplicant: " + value); 679 return -1; 680 } 681 }; 682 683 private static int supplicantToWifiConfigurationEapPhase2Method(int value) { 684 switch (value) { 685 case ISupplicantStaNetwork.EapPhase2Method.NONE: 686 return WifiEnterpriseConfig.Phase2.NONE; 687 case ISupplicantStaNetwork.EapPhase2Method.PAP: 688 return WifiEnterpriseConfig.Phase2.PAP; 689 case ISupplicantStaNetwork.EapPhase2Method.MSPAP: 690 return WifiEnterpriseConfig.Phase2.MSCHAP; 691 case ISupplicantStaNetwork.EapPhase2Method.MSPAPV2: 692 return WifiEnterpriseConfig.Phase2.MSCHAPV2; 693 case ISupplicantStaNetwork.EapPhase2Method.GTC: 694 return WifiEnterpriseConfig.Phase2.GTC; 695 default: 696 Log.e(TAG, "invalid eap phase2 method value from supplicant: " + value); 697 return -1; 698 } 699 }; 700 701 private static int supplicantMaskValueToWifiConfigurationBitSet(int supplicantMask, 702 int supplicantValue, BitSet bitset, 703 int bitSetPosition) { 704 bitset.set(bitSetPosition, (supplicantMask & supplicantValue) == supplicantValue); 705 int modifiedSupplicantMask = supplicantMask & ~supplicantValue; 706 return modifiedSupplicantMask; 707 } 708 709 private static BitSet supplicantToWifiConfigurationKeyMgmtMask(int mask) { 710 BitSet bitset = new BitSet(); 711 mask = supplicantMaskValueToWifiConfigurationBitSet( 712 mask, ISupplicantStaNetwork.KeyMgmtMask.NONE, bitset, 713 WifiConfiguration.KeyMgmt.NONE); 714 mask = supplicantMaskValueToWifiConfigurationBitSet( 715 mask, ISupplicantStaNetwork.KeyMgmtMask.WPA_PSK, bitset, 716 WifiConfiguration.KeyMgmt.WPA_PSK); 717 mask = supplicantMaskValueToWifiConfigurationBitSet( 718 mask, ISupplicantStaNetwork.KeyMgmtMask.WPA_EAP, bitset, 719 WifiConfiguration.KeyMgmt.WPA_EAP); 720 mask = supplicantMaskValueToWifiConfigurationBitSet( 721 mask, ISupplicantStaNetwork.KeyMgmtMask.IEEE8021X, bitset, 722 WifiConfiguration.KeyMgmt.IEEE8021X); 723 mask = supplicantMaskValueToWifiConfigurationBitSet( 724 mask, ISupplicantStaNetwork.KeyMgmtMask.OSEN, bitset, 725 WifiConfiguration.KeyMgmt.OSEN); 726 mask = supplicantMaskValueToWifiConfigurationBitSet( 727 mask, ISupplicantStaNetwork.KeyMgmtMask.FT_PSK, bitset, 728 WifiConfiguration.KeyMgmt.FT_PSK); 729 mask = supplicantMaskValueToWifiConfigurationBitSet( 730 mask, ISupplicantStaNetwork.KeyMgmtMask.FT_EAP, bitset, 731 WifiConfiguration.KeyMgmt.FT_EAP); 732 if (mask != 0) { 733 throw new IllegalArgumentException( 734 "invalid key mgmt mask from supplicant: " + mask); 735 } 736 return bitset; 737 } 738 739 private static BitSet supplicantToWifiConfigurationProtoMask(int mask) { 740 BitSet bitset = new BitSet(); 741 mask = supplicantMaskValueToWifiConfigurationBitSet( 742 mask, ISupplicantStaNetwork.ProtoMask.WPA, bitset, 743 WifiConfiguration.Protocol.WPA); 744 mask = supplicantMaskValueToWifiConfigurationBitSet( 745 mask, ISupplicantStaNetwork.ProtoMask.RSN, bitset, 746 WifiConfiguration.Protocol.RSN); 747 mask = supplicantMaskValueToWifiConfigurationBitSet( 748 mask, ISupplicantStaNetwork.ProtoMask.OSEN, bitset, 749 WifiConfiguration.Protocol.OSEN); 750 if (mask != 0) { 751 throw new IllegalArgumentException( 752 "invalid proto mask from supplicant: " + mask); 753 } 754 return bitset; 755 }; 756 757 private static BitSet supplicantToWifiConfigurationAuthAlgMask(int mask) { 758 BitSet bitset = new BitSet(); 759 mask = supplicantMaskValueToWifiConfigurationBitSet( 760 mask, ISupplicantStaNetwork.AuthAlgMask.OPEN, bitset, 761 WifiConfiguration.AuthAlgorithm.OPEN); 762 mask = supplicantMaskValueToWifiConfigurationBitSet( 763 mask, ISupplicantStaNetwork.AuthAlgMask.SHARED, bitset, 764 WifiConfiguration.AuthAlgorithm.SHARED); 765 mask = supplicantMaskValueToWifiConfigurationBitSet( 766 mask, ISupplicantStaNetwork.AuthAlgMask.LEAP, bitset, 767 WifiConfiguration.AuthAlgorithm.LEAP); 768 if (mask != 0) { 769 throw new IllegalArgumentException( 770 "invalid auth alg mask from supplicant: " + mask); 771 } 772 return bitset; 773 }; 774 775 private static BitSet supplicantToWifiConfigurationGroupCipherMask(int mask) { 776 BitSet bitset = new BitSet(); 777 mask = supplicantMaskValueToWifiConfigurationBitSet( 778 mask, ISupplicantStaNetwork.GroupCipherMask.WEP40, bitset, 779 WifiConfiguration.GroupCipher.WEP40); 780 mask = supplicantMaskValueToWifiConfigurationBitSet( 781 mask, ISupplicantStaNetwork.GroupCipherMask.WEP104, bitset, 782 WifiConfiguration.GroupCipher.WEP104); 783 mask = supplicantMaskValueToWifiConfigurationBitSet( 784 mask, ISupplicantStaNetwork.GroupCipherMask.TKIP, bitset, 785 WifiConfiguration.GroupCipher.TKIP); 786 mask = supplicantMaskValueToWifiConfigurationBitSet( 787 mask, ISupplicantStaNetwork.GroupCipherMask.CCMP, bitset, 788 WifiConfiguration.GroupCipher.CCMP); 789 mask = supplicantMaskValueToWifiConfigurationBitSet( 790 mask, ISupplicantStaNetwork.GroupCipherMask.GTK_NOT_USED, bitset, 791 WifiConfiguration.GroupCipher.GTK_NOT_USED); 792 if (mask != 0) { 793 throw new IllegalArgumentException( 794 "invalid group cipher mask from supplicant: " + mask); 795 } 796 return bitset; 797 }; 798 799 private static BitSet supplicantToWifiConfigurationPairwiseCipherMask(int mask) { 800 BitSet bitset = new BitSet(); 801 mask = supplicantMaskValueToWifiConfigurationBitSet( 802 mask, ISupplicantStaNetwork.PairwiseCipherMask.NONE, bitset, 803 WifiConfiguration.PairwiseCipher.NONE); 804 mask = supplicantMaskValueToWifiConfigurationBitSet( 805 mask, ISupplicantStaNetwork.PairwiseCipherMask.TKIP, bitset, 806 WifiConfiguration.PairwiseCipher.TKIP); 807 mask = supplicantMaskValueToWifiConfigurationBitSet( 808 mask, ISupplicantStaNetwork.PairwiseCipherMask.CCMP, bitset, 809 WifiConfiguration.PairwiseCipher.CCMP); 810 if (mask != 0) { 811 throw new IllegalArgumentException( 812 "invalid pairwise cipher mask from supplicant: " + mask); 813 } 814 return bitset; 815 }; 816 817 private static int wifiConfigurationToSupplicantEapMethod(int value) { 818 switch (value) { 819 case WifiEnterpriseConfig.Eap.PEAP: 820 return ISupplicantStaNetwork.EapMethod.PEAP; 821 case WifiEnterpriseConfig.Eap.TLS: 822 return ISupplicantStaNetwork.EapMethod.TLS; 823 case WifiEnterpriseConfig.Eap.TTLS: 824 return ISupplicantStaNetwork.EapMethod.TTLS; 825 case WifiEnterpriseConfig.Eap.PWD: 826 return ISupplicantStaNetwork.EapMethod.PWD; 827 case WifiEnterpriseConfig.Eap.SIM: 828 return ISupplicantStaNetwork.EapMethod.SIM; 829 case WifiEnterpriseConfig.Eap.AKA: 830 return ISupplicantStaNetwork.EapMethod.AKA; 831 case WifiEnterpriseConfig.Eap.AKA_PRIME: 832 return ISupplicantStaNetwork.EapMethod.AKA_PRIME; 833 case WifiEnterpriseConfig.Eap.UNAUTH_TLS: 834 return ISupplicantStaNetwork.EapMethod.WFA_UNAUTH_TLS; 835 // WifiEnterpriseConfig.Eap.NONE: 836 default: 837 Log.e(TAG, "invalid eap method value from WifiConfiguration: " + value); 838 return -1; 839 } 840 }; 841 842 private static int wifiConfigurationToSupplicantEapPhase2Method(int value) { 843 switch (value) { 844 case WifiEnterpriseConfig.Phase2.NONE: 845 return ISupplicantStaNetwork.EapPhase2Method.NONE; 846 case WifiEnterpriseConfig.Phase2.PAP: 847 return ISupplicantStaNetwork.EapPhase2Method.PAP; 848 case WifiEnterpriseConfig.Phase2.MSCHAP: 849 return ISupplicantStaNetwork.EapPhase2Method.MSPAP; 850 case WifiEnterpriseConfig.Phase2.MSCHAPV2: 851 return ISupplicantStaNetwork.EapPhase2Method.MSPAPV2; 852 case WifiEnterpriseConfig.Phase2.GTC: 853 return ISupplicantStaNetwork.EapPhase2Method.GTC; 854 default: 855 Log.e(TAG, "invalid eap phase2 method value from WifiConfiguration: " + value); 856 return -1; 857 } 858 }; 859 860 /** See ISupplicantNetwork.hal for documentation */ 861 private boolean getId() { 862 synchronized (mLock) { 863 final String methodStr = "getId"; 864 if (DBG) Log.i(TAG, methodStr); 865 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 866 try { 867 MutableBoolean statusOk = new MutableBoolean(false); 868 mISupplicantStaNetwork.getId((SupplicantStatus status, int idValue) -> { 869 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 870 if (statusOk.value) { 871 this.mNetworkId = idValue; 872 } else { 873 logFailureStatus(status, methodStr); 874 } 875 }); 876 return statusOk.value; 877 } catch (RemoteException e) { 878 handleRemoteException(e, methodStr); 879 return false; 880 } 881 } 882 } 883 884 /** See ISupplicantNetwork.hal for documentation */ 885 private boolean getInterfaceName() { 886 synchronized (mLock) { 887 final String methodStr = "getInterfaceName"; 888 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 889 try { 890 MutableBoolean statusOk = new MutableBoolean(false); 891 mISupplicantStaNetwork.getInterfaceName((SupplicantStatus status, 892 String nameValue) -> { 893 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 894 if (statusOk.value) { 895 this.mIfaceName = nameValue; 896 } else { 897 logFailureStatus(status, methodStr); 898 } 899 }); 900 return statusOk.value; 901 } catch (RemoteException e) { 902 handleRemoteException(e, methodStr); 903 return false; 904 } 905 } 906 } 907 908 /** See ISupplicantStaNetwork.hal for documentation */ 909 private boolean registerCallback(ISupplicantStaNetworkCallback callback) { 910 synchronized (mLock) { 911 final String methodStr = "registerCallback"; 912 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 913 try { 914 SupplicantStatus status = mISupplicantStaNetwork.registerCallback(callback); 915 return checkStatusAndLogFailure(status, methodStr); 916 } catch (RemoteException e) { 917 handleRemoteException(e, methodStr); 918 return false; 919 } 920 } 921 } 922 923 /** See ISupplicantStaNetwork.hal for documentation */ 924 private boolean setSsid(java.util.ArrayList<Byte> ssid) { 925 synchronized (mLock) { 926 final String methodStr = "setSsid"; 927 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 928 try { 929 SupplicantStatus status = mISupplicantStaNetwork.setSsid(ssid); 930 return checkStatusAndLogFailure(status, methodStr); 931 } catch (RemoteException e) { 932 handleRemoteException(e, methodStr); 933 return false; 934 } 935 } 936 } 937 938 /** 939 * Set the BSSID for this network. 940 * 941 * @param bssidStr MAC address in "XX:XX:XX:XX:XX:XX" form or "any" to reset the mac address. 942 * @return true if it succeeds, false otherwise. 943 */ 944 public boolean setBssid(String bssidStr) { 945 return setBssid(NativeUtil.macAddressToByteArray(bssidStr)); 946 } 947 948 /** See ISupplicantStaNetwork.hal for documentation */ 949 private boolean setBssid(byte[/* 6 */] bssid) { 950 synchronized (mLock) { 951 final String methodStr = "setBssid"; 952 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 953 try { 954 SupplicantStatus status = mISupplicantStaNetwork.setBssid(bssid); 955 return checkStatusAndLogFailure(status, methodStr); 956 } catch (RemoteException e) { 957 handleRemoteException(e, methodStr); 958 return false; 959 } 960 } 961 } 962 /** See ISupplicantStaNetwork.hal for documentation */ 963 private boolean setScanSsid(boolean enable) { 964 synchronized (mLock) { 965 final String methodStr = "setScanSsid"; 966 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 967 try { 968 SupplicantStatus status = mISupplicantStaNetwork.setScanSsid(enable); 969 return checkStatusAndLogFailure(status, methodStr); 970 } catch (RemoteException e) { 971 handleRemoteException(e, methodStr); 972 return false; 973 } 974 } 975 } 976 /** See ISupplicantStaNetwork.hal for documentation */ 977 private boolean setKeyMgmt(int keyMgmtMask) { 978 synchronized (mLock) { 979 final String methodStr = "setKeyMgmt"; 980 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 981 try { 982 SupplicantStatus status = mISupplicantStaNetwork.setKeyMgmt(keyMgmtMask); 983 return checkStatusAndLogFailure(status, methodStr); 984 } catch (RemoteException e) { 985 handleRemoteException(e, methodStr); 986 return false; 987 } 988 } 989 } 990 /** See ISupplicantStaNetwork.hal for documentation */ 991 private boolean setProto(int protoMask) { 992 synchronized (mLock) { 993 final String methodStr = "setProto"; 994 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 995 try { 996 SupplicantStatus status = mISupplicantStaNetwork.setProto(protoMask); 997 return checkStatusAndLogFailure(status, methodStr); 998 } catch (RemoteException e) { 999 handleRemoteException(e, methodStr); 1000 return false; 1001 } 1002 } 1003 } 1004 /** See ISupplicantStaNetwork.hal for documentation */ 1005 private boolean setAuthAlg(int authAlgMask) { 1006 synchronized (mLock) { 1007 final String methodStr = "setAuthAlg"; 1008 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1009 try { 1010 SupplicantStatus status = mISupplicantStaNetwork.setAuthAlg(authAlgMask); 1011 return checkStatusAndLogFailure(status, methodStr); 1012 } catch (RemoteException e) { 1013 handleRemoteException(e, methodStr); 1014 return false; 1015 } 1016 } 1017 } 1018 /** See ISupplicantStaNetwork.hal for documentation */ 1019 private boolean setGroupCipher(int groupCipherMask) { 1020 synchronized (mLock) { 1021 final String methodStr = "setGroupCipher"; 1022 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1023 try { 1024 SupplicantStatus status = mISupplicantStaNetwork.setGroupCipher(groupCipherMask); 1025 return checkStatusAndLogFailure(status, methodStr); 1026 } catch (RemoteException e) { 1027 handleRemoteException(e, methodStr); 1028 return false; 1029 } 1030 } 1031 } 1032 /** See ISupplicantStaNetwork.hal for documentation */ 1033 private boolean setPairwiseCipher(int pairwiseCipherMask) { 1034 synchronized (mLock) { 1035 final String methodStr = "setPairwiseCipher"; 1036 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1037 try { 1038 SupplicantStatus status = 1039 mISupplicantStaNetwork.setPairwiseCipher(pairwiseCipherMask); 1040 return checkStatusAndLogFailure(status, methodStr); 1041 } catch (RemoteException e) { 1042 handleRemoteException(e, methodStr); 1043 return false; 1044 } 1045 } 1046 } 1047 /** See ISupplicantStaNetwork.hal for documentation */ 1048 private boolean setPskPassphrase(String psk) { 1049 synchronized (mLock) { 1050 final String methodStr = "setPskPassphrase"; 1051 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1052 try { 1053 SupplicantStatus status = mISupplicantStaNetwork.setPskPassphrase(psk); 1054 return checkStatusAndLogFailure(status, methodStr); 1055 } catch (RemoteException e) { 1056 handleRemoteException(e, methodStr); 1057 return false; 1058 } 1059 } 1060 } 1061 /** See ISupplicantStaNetwork.hal for documentation */ 1062 private boolean setWepKey(int keyIdx, java.util.ArrayList<Byte> wepKey) { 1063 synchronized (mLock) { 1064 final String methodStr = "setWepKey"; 1065 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1066 try { 1067 SupplicantStatus status = mISupplicantStaNetwork.setWepKey(keyIdx, wepKey); 1068 return checkStatusAndLogFailure(status, methodStr); 1069 } catch (RemoteException e) { 1070 handleRemoteException(e, methodStr); 1071 return false; 1072 } 1073 } 1074 } 1075 /** See ISupplicantStaNetwork.hal for documentation */ 1076 private boolean setWepTxKeyIdx(int keyIdx) { 1077 synchronized (mLock) { 1078 final String methodStr = "setWepTxKeyIdx"; 1079 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1080 try { 1081 SupplicantStatus status = mISupplicantStaNetwork.setWepTxKeyIdx(keyIdx); 1082 return checkStatusAndLogFailure(status, methodStr); 1083 } catch (RemoteException e) { 1084 handleRemoteException(e, methodStr); 1085 return false; 1086 } 1087 } 1088 } 1089 /** See ISupplicantStaNetwork.hal for documentation */ 1090 private boolean setRequirePmf(boolean enable) { 1091 synchronized (mLock) { 1092 final String methodStr = "setRequirePmf"; 1093 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1094 try { 1095 SupplicantStatus status = mISupplicantStaNetwork.setRequirePmf(enable); 1096 return checkStatusAndLogFailure(status, methodStr); 1097 } catch (RemoteException e) { 1098 handleRemoteException(e, methodStr); 1099 return false; 1100 } 1101 } 1102 } 1103 /** See ISupplicantStaNetwork.hal for documentation */ 1104 private boolean setUpdateIdentifier(int identifier) { 1105 synchronized (mLock) { 1106 final String methodStr = "setUpdateIdentifier"; 1107 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1108 try { 1109 SupplicantStatus status = mISupplicantStaNetwork.setUpdateIdentifier(identifier); 1110 return checkStatusAndLogFailure(status, methodStr); 1111 } catch (RemoteException e) { 1112 handleRemoteException(e, methodStr); 1113 return false; 1114 } 1115 } 1116 } 1117 /** See ISupplicantStaNetwork.hal for documentation */ 1118 private boolean setEapMethod(int method) { 1119 synchronized (mLock) { 1120 final String methodStr = "setEapMethod"; 1121 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1122 try { 1123 SupplicantStatus status = mISupplicantStaNetwork.setEapMethod(method); 1124 return checkStatusAndLogFailure(status, methodStr); 1125 } catch (RemoteException e) { 1126 handleRemoteException(e, methodStr); 1127 return false; 1128 } 1129 } 1130 } 1131 /** See ISupplicantStaNetwork.hal for documentation */ 1132 private boolean setEapPhase2Method(int method) { 1133 synchronized (mLock) { 1134 final String methodStr = "setEapPhase2Method"; 1135 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1136 try { 1137 SupplicantStatus status = mISupplicantStaNetwork.setEapPhase2Method(method); 1138 return checkStatusAndLogFailure(status, methodStr); 1139 } catch (RemoteException e) { 1140 handleRemoteException(e, methodStr); 1141 return false; 1142 } 1143 } 1144 } 1145 /** See ISupplicantStaNetwork.hal for documentation */ 1146 private boolean setEapIdentity(java.util.ArrayList<Byte> identity) { 1147 synchronized (mLock) { 1148 final String methodStr = "setEapIdentity"; 1149 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1150 try { 1151 SupplicantStatus status = mISupplicantStaNetwork.setEapIdentity(identity); 1152 return checkStatusAndLogFailure(status, methodStr); 1153 } catch (RemoteException e) { 1154 handleRemoteException(e, methodStr); 1155 return false; 1156 } 1157 } 1158 } 1159 /** See ISupplicantStaNetwork.hal for documentation */ 1160 private boolean setEapAnonymousIdentity(java.util.ArrayList<Byte> identity) { 1161 synchronized (mLock) { 1162 final String methodStr = "setEapAnonymousIdentity"; 1163 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1164 try { 1165 SupplicantStatus status = mISupplicantStaNetwork.setEapAnonymousIdentity(identity); 1166 return checkStatusAndLogFailure(status, methodStr); 1167 } catch (RemoteException e) { 1168 handleRemoteException(e, methodStr); 1169 return false; 1170 } 1171 } 1172 } 1173 /** See ISupplicantStaNetwork.hal for documentation */ 1174 private boolean setEapPassword(java.util.ArrayList<Byte> password) { 1175 synchronized (mLock) { 1176 final String methodStr = "setEapPassword"; 1177 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1178 try { 1179 SupplicantStatus status = mISupplicantStaNetwork.setEapPassword(password); 1180 return checkStatusAndLogFailure(status, methodStr); 1181 } catch (RemoteException e) { 1182 handleRemoteException(e, methodStr); 1183 return false; 1184 } 1185 } 1186 } 1187 /** See ISupplicantStaNetwork.hal for documentation */ 1188 private boolean setEapCACert(String path) { 1189 synchronized (mLock) { 1190 final String methodStr = "setEapCACert"; 1191 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1192 try { 1193 SupplicantStatus status = mISupplicantStaNetwork.setEapCACert(path); 1194 return checkStatusAndLogFailure(status, methodStr); 1195 } catch (RemoteException e) { 1196 handleRemoteException(e, methodStr); 1197 return false; 1198 } 1199 } 1200 } 1201 /** See ISupplicantStaNetwork.hal for documentation */ 1202 private boolean setEapCAPath(String path) { 1203 synchronized (mLock) { 1204 final String methodStr = "setEapCAPath"; 1205 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1206 try { 1207 SupplicantStatus status = mISupplicantStaNetwork.setEapCAPath(path); 1208 return checkStatusAndLogFailure(status, methodStr); 1209 } catch (RemoteException e) { 1210 handleRemoteException(e, methodStr); 1211 return false; 1212 } 1213 } 1214 } 1215 /** See ISupplicantStaNetwork.hal for documentation */ 1216 private boolean setEapClientCert(String path) { 1217 synchronized (mLock) { 1218 final String methodStr = "setEapClientCert"; 1219 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1220 try { 1221 SupplicantStatus status = mISupplicantStaNetwork.setEapClientCert(path); 1222 return checkStatusAndLogFailure(status, methodStr); 1223 } catch (RemoteException e) { 1224 handleRemoteException(e, methodStr); 1225 return false; 1226 } 1227 } 1228 } 1229 /** See ISupplicantStaNetwork.hal for documentation */ 1230 private boolean setEapPrivateKey(String path) { 1231 synchronized (mLock) { 1232 final String methodStr = "setEapPrivateKey"; 1233 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1234 try { 1235 SupplicantStatus status = mISupplicantStaNetwork.setEapPrivateKey(path); 1236 return checkStatusAndLogFailure(status, methodStr); 1237 } catch (RemoteException e) { 1238 handleRemoteException(e, methodStr); 1239 return false; 1240 } 1241 } 1242 } 1243 /** See ISupplicantStaNetwork.hal for documentation */ 1244 private boolean setEapSubjectMatch(String match) { 1245 synchronized (mLock) { 1246 final String methodStr = "setEapSubjectMatch"; 1247 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1248 try { 1249 SupplicantStatus status = mISupplicantStaNetwork.setEapSubjectMatch(match); 1250 return checkStatusAndLogFailure(status, methodStr); 1251 } catch (RemoteException e) { 1252 handleRemoteException(e, methodStr); 1253 return false; 1254 } 1255 } 1256 } 1257 /** See ISupplicantStaNetwork.hal for documentation */ 1258 private boolean setEapAltSubjectMatch(String match) { 1259 synchronized (mLock) { 1260 final String methodStr = "setEapAltSubjectMatch"; 1261 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1262 try { 1263 SupplicantStatus status = mISupplicantStaNetwork.setEapAltSubjectMatch(match); 1264 return checkStatusAndLogFailure(status, methodStr); 1265 } catch (RemoteException e) { 1266 handleRemoteException(e, methodStr); 1267 return false; 1268 } 1269 } 1270 } 1271 /** See ISupplicantStaNetwork.hal for documentation */ 1272 private boolean setEapEngine(boolean enable) { 1273 synchronized (mLock) { 1274 final String methodStr = "setEapEngine"; 1275 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1276 try { 1277 SupplicantStatus status = mISupplicantStaNetwork.setEapEngine(enable); 1278 return checkStatusAndLogFailure(status, methodStr); 1279 } catch (RemoteException e) { 1280 handleRemoteException(e, methodStr); 1281 return false; 1282 } 1283 } 1284 } 1285 /** See ISupplicantStaNetwork.hal for documentation */ 1286 private boolean setEapEngineID(String id) { 1287 synchronized (mLock) { 1288 final String methodStr = "setEapEngineID"; 1289 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1290 try { 1291 SupplicantStatus status = mISupplicantStaNetwork.setEapEngineID(id); 1292 return checkStatusAndLogFailure(status, methodStr); 1293 } catch (RemoteException e) { 1294 handleRemoteException(e, methodStr); 1295 return false; 1296 } 1297 } 1298 } 1299 /** See ISupplicantStaNetwork.hal for documentation */ 1300 private boolean setEapDomainSuffixMatch(String match) { 1301 synchronized (mLock) { 1302 final String methodStr = "setEapDomainSuffixMatch"; 1303 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1304 try { 1305 SupplicantStatus status = mISupplicantStaNetwork.setEapDomainSuffixMatch(match); 1306 return checkStatusAndLogFailure(status, methodStr); 1307 } catch (RemoteException e) { 1308 handleRemoteException(e, methodStr); 1309 return false; 1310 } 1311 } 1312 } 1313 /** See ISupplicantStaNetwork.hal for documentation */ 1314 private boolean setEapProactiveKeyCaching(boolean enable) { 1315 synchronized (mLock) { 1316 final String methodStr = "setEapProactiveKeyCaching"; 1317 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1318 try { 1319 SupplicantStatus status = mISupplicantStaNetwork.setProactiveKeyCaching(enable); 1320 return checkStatusAndLogFailure(status, methodStr); 1321 } catch (RemoteException e) { 1322 handleRemoteException(e, methodStr); 1323 return false; 1324 } 1325 } 1326 } 1327 /** See ISupplicantStaNetwork.hal for documentation */ 1328 private boolean setIdStr(String idString) { 1329 synchronized (mLock) { 1330 final String methodStr = "setIdStr"; 1331 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1332 try { 1333 SupplicantStatus status = mISupplicantStaNetwork.setIdStr(idString); 1334 return checkStatusAndLogFailure(status, methodStr); 1335 } catch (RemoteException e) { 1336 handleRemoteException(e, methodStr); 1337 return false; 1338 } 1339 } 1340 } 1341 /** See ISupplicantStaNetwork.hal for documentation */ 1342 private boolean getSsid() { 1343 synchronized (mLock) { 1344 final String methodStr = "getSsid"; 1345 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1346 try { 1347 MutableBoolean statusOk = new MutableBoolean(false); 1348 mISupplicantStaNetwork.getSsid((SupplicantStatus status, 1349 java.util.ArrayList<Byte> ssidValue) -> { 1350 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1351 if (statusOk.value) { 1352 this.mSsid = ssidValue; 1353 } else { 1354 logFailureStatus(status, methodStr); 1355 } 1356 }); 1357 return statusOk.value; 1358 } catch (RemoteException e) { 1359 handleRemoteException(e, methodStr); 1360 return false; 1361 } 1362 } 1363 } 1364 /** See ISupplicantStaNetwork.hal for documentation */ 1365 private boolean getBssid() { 1366 synchronized (mLock) { 1367 final String methodStr = "getBssid"; 1368 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1369 try { 1370 MutableBoolean statusOk = new MutableBoolean(false); 1371 mISupplicantStaNetwork.getBssid((SupplicantStatus status, 1372 byte[/* 6 */] bssidValue) -> { 1373 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1374 if (statusOk.value) { 1375 this.mBssid = bssidValue; 1376 } else { 1377 logFailureStatus(status, methodStr); 1378 } 1379 }); 1380 return statusOk.value; 1381 } catch (RemoteException e) { 1382 handleRemoteException(e, methodStr); 1383 return false; 1384 } 1385 } 1386 } 1387 /** See ISupplicantStaNetwork.hal for documentation */ 1388 private boolean getScanSsid() { 1389 synchronized (mLock) { 1390 final String methodStr = "getScanSsid"; 1391 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1392 try { 1393 MutableBoolean statusOk = new MutableBoolean(false); 1394 mISupplicantStaNetwork.getScanSsid((SupplicantStatus status, 1395 boolean enabledValue) -> { 1396 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1397 if (statusOk.value) { 1398 this.mScanSsid = enabledValue; 1399 } else { 1400 logFailureStatus(status, methodStr); 1401 } 1402 }); 1403 return statusOk.value; 1404 } catch (RemoteException e) { 1405 handleRemoteException(e, methodStr); 1406 return false; 1407 } 1408 } 1409 } 1410 /** See ISupplicantStaNetwork.hal for documentation */ 1411 private boolean getKeyMgmt() { 1412 synchronized (mLock) { 1413 final String methodStr = "getKeyMgmt"; 1414 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1415 try { 1416 MutableBoolean statusOk = new MutableBoolean(false); 1417 mISupplicantStaNetwork.getKeyMgmt((SupplicantStatus status, 1418 int keyMgmtMaskValue) -> { 1419 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1420 if (statusOk.value) { 1421 this.mKeyMgmtMask = keyMgmtMaskValue; 1422 } else { 1423 logFailureStatus(status, methodStr); 1424 } 1425 }); 1426 return statusOk.value; 1427 } catch (RemoteException e) { 1428 handleRemoteException(e, methodStr); 1429 return false; 1430 } 1431 } 1432 } 1433 /** See ISupplicantStaNetwork.hal for documentation */ 1434 private boolean getProto() { 1435 synchronized (mLock) { 1436 final String methodStr = "getProto"; 1437 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1438 try { 1439 MutableBoolean statusOk = new MutableBoolean(false); 1440 mISupplicantStaNetwork.getProto((SupplicantStatus status, int protoMaskValue) -> { 1441 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1442 if (statusOk.value) { 1443 this.mProtoMask = protoMaskValue; 1444 } else { 1445 logFailureStatus(status, methodStr); 1446 } 1447 }); 1448 return statusOk.value; 1449 } catch (RemoteException e) { 1450 handleRemoteException(e, methodStr); 1451 return false; 1452 } 1453 } 1454 } 1455 /** See ISupplicantStaNetwork.hal for documentation */ 1456 private boolean getAuthAlg() { 1457 synchronized (mLock) { 1458 final String methodStr = "getAuthAlg"; 1459 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1460 try { 1461 MutableBoolean statusOk = new MutableBoolean(false); 1462 mISupplicantStaNetwork.getAuthAlg((SupplicantStatus status, 1463 int authAlgMaskValue) -> { 1464 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1465 if (statusOk.value) { 1466 this.mAuthAlgMask = authAlgMaskValue; 1467 } else { 1468 logFailureStatus(status, methodStr); 1469 } 1470 }); 1471 return statusOk.value; 1472 } catch (RemoteException e) { 1473 handleRemoteException(e, methodStr); 1474 return false; 1475 } 1476 } 1477 } 1478 /** See ISupplicantStaNetwork.hal for documentation */ 1479 private boolean getGroupCipher() { 1480 synchronized (mLock) { 1481 final String methodStr = "getGroupCipher"; 1482 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1483 try { 1484 MutableBoolean statusOk = new MutableBoolean(false); 1485 mISupplicantStaNetwork.getGroupCipher((SupplicantStatus status, 1486 int groupCipherMaskValue) -> { 1487 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1488 if (statusOk.value) { 1489 this.mGroupCipherMask = groupCipherMaskValue; 1490 } else { 1491 logFailureStatus(status, methodStr); 1492 } 1493 }); 1494 return statusOk.value; 1495 } catch (RemoteException e) { 1496 handleRemoteException(e, methodStr); 1497 return false; 1498 } 1499 } 1500 } 1501 /** See ISupplicantStaNetwork.hal for documentation */ 1502 private boolean getPairwiseCipher() { 1503 synchronized (mLock) { 1504 final String methodStr = "getPairwiseCipher"; 1505 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1506 try { 1507 MutableBoolean statusOk = new MutableBoolean(false); 1508 mISupplicantStaNetwork.getPairwiseCipher((SupplicantStatus status, 1509 int pairwiseCipherMaskValue) -> { 1510 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1511 if (statusOk.value) { 1512 this.mPairwiseCipherMask = pairwiseCipherMaskValue; 1513 } else { 1514 logFailureStatus(status, methodStr); 1515 } 1516 }); 1517 return statusOk.value; 1518 } catch (RemoteException e) { 1519 handleRemoteException(e, methodStr); 1520 return false; 1521 } 1522 } 1523 } 1524 /** See ISupplicantStaNetwork.hal for documentation */ 1525 private boolean getPskPassphrase() { 1526 synchronized (mLock) { 1527 final String methodStr = "getPskPassphrase"; 1528 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1529 try { 1530 MutableBoolean statusOk = new MutableBoolean(false); 1531 mISupplicantStaNetwork.getPskPassphrase((SupplicantStatus status, 1532 String pskValue) -> { 1533 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1534 if (statusOk.value) { 1535 this.mPskPassphrase = pskValue; 1536 } else { 1537 logFailureStatus(status, methodStr); 1538 } 1539 }); 1540 return statusOk.value; 1541 } catch (RemoteException e) { 1542 handleRemoteException(e, methodStr); 1543 return false; 1544 } 1545 } 1546 } 1547 /** See ISupplicantStaNetwork.hal for documentation */ 1548 private boolean getWepKey(int keyIdx) { 1549 synchronized (mLock) { 1550 final String methodStr = "keyIdx"; 1551 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1552 try { 1553 MutableBoolean statusOk = new MutableBoolean(false); 1554 mISupplicantStaNetwork.getWepKey(keyIdx, (SupplicantStatus status, 1555 java.util.ArrayList<Byte> wepKeyValue) -> { 1556 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1557 if (statusOk.value) { 1558 this.mWepKey = wepKeyValue; 1559 } else { 1560 Log.e(TAG, methodStr + ", failed: " + status.debugMessage); 1561 } 1562 }); 1563 return statusOk.value; 1564 } catch (RemoteException e) { 1565 handleRemoteException(e, methodStr); 1566 return false; 1567 } 1568 } 1569 } 1570 /** See ISupplicantStaNetwork.hal for documentation */ 1571 private boolean getWepTxKeyIdx() { 1572 synchronized (mLock) { 1573 final String methodStr = "getWepTxKeyIdx"; 1574 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1575 try { 1576 MutableBoolean statusOk = new MutableBoolean(false); 1577 mISupplicantStaNetwork.getWepTxKeyIdx((SupplicantStatus status, 1578 int keyIdxValue) -> { 1579 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1580 if (statusOk.value) { 1581 this.mWepTxKeyIdx = keyIdxValue; 1582 } else { 1583 logFailureStatus(status, methodStr); 1584 } 1585 }); 1586 return statusOk.value; 1587 } catch (RemoteException e) { 1588 handleRemoteException(e, methodStr); 1589 return false; 1590 } 1591 } 1592 } 1593 /** See ISupplicantStaNetwork.hal for documentation */ 1594 private boolean getRequirePmf() { 1595 synchronized (mLock) { 1596 final String methodStr = "getRequirePmf"; 1597 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1598 try { 1599 MutableBoolean statusOk = new MutableBoolean(false); 1600 mISupplicantStaNetwork.getRequirePmf((SupplicantStatus status, 1601 boolean enabledValue) -> { 1602 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1603 if (statusOk.value) { 1604 this.mRequirePmf = enabledValue; 1605 } else { 1606 logFailureStatus(status, methodStr); 1607 } 1608 }); 1609 return statusOk.value; 1610 } catch (RemoteException e) { 1611 handleRemoteException(e, methodStr); 1612 return false; 1613 } 1614 } 1615 } 1616 /** See ISupplicantStaNetwork.hal for documentation */ 1617 private boolean getEapMethod() { 1618 synchronized (mLock) { 1619 final String methodStr = "getEapMethod"; 1620 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1621 try { 1622 MutableBoolean statusOk = new MutableBoolean(false); 1623 mISupplicantStaNetwork.getEapMethod((SupplicantStatus status, 1624 int methodValue) -> { 1625 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1626 if (statusOk.value) { 1627 this.mEapMethod = methodValue; 1628 } else { 1629 logFailureStatus(status, methodStr); 1630 } 1631 }); 1632 return statusOk.value; 1633 } catch (RemoteException e) { 1634 handleRemoteException(e, methodStr); 1635 return false; 1636 } 1637 } 1638 } 1639 /** See ISupplicantStaNetwork.hal for documentation */ 1640 private boolean getEapPhase2Method() { 1641 synchronized (mLock) { 1642 final String methodStr = "getEapPhase2Method"; 1643 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1644 try { 1645 MutableBoolean statusOk = new MutableBoolean(false); 1646 mISupplicantStaNetwork.getEapPhase2Method((SupplicantStatus status, 1647 int methodValue) -> { 1648 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1649 if (statusOk.value) { 1650 this.mEapPhase2Method = methodValue; 1651 } else { 1652 logFailureStatus(status, methodStr); 1653 } 1654 }); 1655 return statusOk.value; 1656 } catch (RemoteException e) { 1657 handleRemoteException(e, methodStr); 1658 return false; 1659 } 1660 } 1661 } 1662 /** See ISupplicantStaNetwork.hal for documentation */ 1663 private boolean getEapIdentity() { 1664 synchronized (mLock) { 1665 final String methodStr = "getEapIdentity"; 1666 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1667 try { 1668 MutableBoolean statusOk = new MutableBoolean(false); 1669 mISupplicantStaNetwork.getEapIdentity((SupplicantStatus status, 1670 ArrayList<Byte> identityValue) -> { 1671 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1672 if (statusOk.value) { 1673 this.mEapIdentity = identityValue; 1674 } else { 1675 logFailureStatus(status, methodStr); 1676 } 1677 }); 1678 return statusOk.value; 1679 } catch (RemoteException e) { 1680 handleRemoteException(e, methodStr); 1681 return false; 1682 } 1683 } 1684 } 1685 /** See ISupplicantStaNetwork.hal for documentation */ 1686 private boolean getEapAnonymousIdentity() { 1687 synchronized (mLock) { 1688 final String methodStr = "getEapAnonymousIdentity"; 1689 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1690 try { 1691 MutableBoolean statusOk = new MutableBoolean(false); 1692 mISupplicantStaNetwork.getEapAnonymousIdentity((SupplicantStatus status, 1693 ArrayList<Byte> identityValue) -> { 1694 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1695 if (statusOk.value) { 1696 this.mEapAnonymousIdentity = identityValue; 1697 } else { 1698 logFailureStatus(status, methodStr); 1699 } 1700 }); 1701 return statusOk.value; 1702 } catch (RemoteException e) { 1703 handleRemoteException(e, methodStr); 1704 return false; 1705 } 1706 } 1707 } 1708 /** See ISupplicantStaNetwork.hal for documentation */ 1709 private boolean getEapPassword() { 1710 synchronized (mLock) { 1711 final String methodStr = "getEapPassword"; 1712 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1713 try { 1714 MutableBoolean statusOk = new MutableBoolean(false); 1715 mISupplicantStaNetwork.getEapPassword((SupplicantStatus status, 1716 ArrayList<Byte> passwordValue) -> { 1717 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1718 if (statusOk.value) { 1719 this.mEapPassword = passwordValue; 1720 } else { 1721 logFailureStatus(status, methodStr); 1722 } 1723 }); 1724 return statusOk.value; 1725 } catch (RemoteException e) { 1726 handleRemoteException(e, methodStr); 1727 return false; 1728 } 1729 } 1730 } 1731 /** See ISupplicantStaNetwork.hal for documentation */ 1732 private boolean getEapCACert() { 1733 synchronized (mLock) { 1734 final String methodStr = "getEapCACert"; 1735 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1736 try { 1737 MutableBoolean statusOk = new MutableBoolean(false); 1738 mISupplicantStaNetwork.getEapCACert((SupplicantStatus status, String pathValue) -> { 1739 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1740 if (statusOk.value) { 1741 this.mEapCACert = pathValue; 1742 } else { 1743 logFailureStatus(status, methodStr); 1744 } 1745 }); 1746 return statusOk.value; 1747 } catch (RemoteException e) { 1748 handleRemoteException(e, methodStr); 1749 return false; 1750 } 1751 } 1752 } 1753 /** See ISupplicantStaNetwork.hal for documentation */ 1754 private boolean getEapCAPath() { 1755 synchronized (mLock) { 1756 final String methodStr = "getEapCAPath"; 1757 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1758 try { 1759 MutableBoolean statusOk = new MutableBoolean(false); 1760 mISupplicantStaNetwork.getEapCAPath((SupplicantStatus status, String pathValue) -> { 1761 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1762 if (statusOk.value) { 1763 this.mEapCAPath = pathValue; 1764 } else { 1765 logFailureStatus(status, methodStr); 1766 } 1767 }); 1768 return statusOk.value; 1769 } catch (RemoteException e) { 1770 handleRemoteException(e, methodStr); 1771 return false; 1772 } 1773 } 1774 } 1775 /** See ISupplicantStaNetwork.hal for documentation */ 1776 private boolean getEapClientCert() { 1777 synchronized (mLock) { 1778 final String methodStr = "getEapClientCert"; 1779 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1780 try { 1781 MutableBoolean statusOk = new MutableBoolean(false); 1782 mISupplicantStaNetwork.getEapClientCert((SupplicantStatus status, 1783 String pathValue) -> { 1784 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1785 if (statusOk.value) { 1786 this.mEapClientCert = pathValue; 1787 } else { 1788 logFailureStatus(status, methodStr); 1789 } 1790 }); 1791 return statusOk.value; 1792 } catch (RemoteException e) { 1793 handleRemoteException(e, methodStr); 1794 return false; 1795 } 1796 } 1797 } 1798 /** See ISupplicantStaNetwork.hal for documentation */ 1799 private boolean getEapPrivateKey() { 1800 synchronized (mLock) { 1801 final String methodStr = "getEapPrivateKey"; 1802 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1803 try { 1804 MutableBoolean statusOk = new MutableBoolean(false); 1805 mISupplicantStaNetwork.getEapPrivateKey((SupplicantStatus status, 1806 String pathValue) -> { 1807 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1808 if (statusOk.value) { 1809 this.mEapPrivateKey = pathValue; 1810 } else { 1811 logFailureStatus(status, methodStr); 1812 } 1813 }); 1814 return statusOk.value; 1815 } catch (RemoteException e) { 1816 handleRemoteException(e, methodStr); 1817 return false; 1818 } 1819 } 1820 } 1821 /** See ISupplicantStaNetwork.hal for documentation */ 1822 private boolean getEapSubjectMatch() { 1823 synchronized (mLock) { 1824 final String methodStr = "getEapSubjectMatch"; 1825 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1826 try { 1827 MutableBoolean statusOk = new MutableBoolean(false); 1828 mISupplicantStaNetwork.getEapSubjectMatch((SupplicantStatus status, 1829 String matchValue) -> { 1830 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1831 if (statusOk.value) { 1832 this.mEapSubjectMatch = matchValue; 1833 } else { 1834 logFailureStatus(status, methodStr); 1835 } 1836 }); 1837 return statusOk.value; 1838 } catch (RemoteException e) { 1839 handleRemoteException(e, methodStr); 1840 return false; 1841 } 1842 } 1843 } 1844 /** See ISupplicantStaNetwork.hal for documentation */ 1845 private boolean getEapAltSubjectMatch() { 1846 synchronized (mLock) { 1847 final String methodStr = "getEapAltSubjectMatch"; 1848 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1849 try { 1850 MutableBoolean statusOk = new MutableBoolean(false); 1851 mISupplicantStaNetwork.getEapAltSubjectMatch((SupplicantStatus status, 1852 String matchValue) -> { 1853 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1854 if (statusOk.value) { 1855 this.mEapAltSubjectMatch = matchValue; 1856 } else { 1857 logFailureStatus(status, methodStr); 1858 } 1859 }); 1860 return statusOk.value; 1861 } catch (RemoteException e) { 1862 handleRemoteException(e, methodStr); 1863 return false; 1864 } 1865 } 1866 } 1867 /** See ISupplicantStaNetwork.hal for documentation */ 1868 private boolean getEapEngine() { 1869 synchronized (mLock) { 1870 final String methodStr = "getEapEngine"; 1871 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1872 try { 1873 MutableBoolean statusOk = new MutableBoolean(false); 1874 mISupplicantStaNetwork.getEapEngine((SupplicantStatus status, 1875 boolean enabledValue) -> { 1876 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1877 if (statusOk.value) { 1878 this.mEapEngine = enabledValue; 1879 } else { 1880 logFailureStatus(status, methodStr); 1881 } 1882 }); 1883 return statusOk.value; 1884 } catch (RemoteException e) { 1885 handleRemoteException(e, methodStr); 1886 return false; 1887 } 1888 } 1889 } 1890 /** See ISupplicantStaNetwork.hal for documentation */ 1891 private boolean getEapEngineID() { 1892 synchronized (mLock) { 1893 final String methodStr = "getEapEngineID"; 1894 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1895 try { 1896 MutableBoolean statusOk = new MutableBoolean(false); 1897 mISupplicantStaNetwork.getEapEngineID((SupplicantStatus status, String idValue) -> { 1898 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1899 if (statusOk.value) { 1900 this.mEapEngineID = idValue; 1901 } else { 1902 logFailureStatus(status, methodStr); 1903 } 1904 }); 1905 return statusOk.value; 1906 } catch (RemoteException e) { 1907 handleRemoteException(e, methodStr); 1908 return false; 1909 } 1910 } 1911 } 1912 /** See ISupplicantStaNetwork.hal for documentation */ 1913 private boolean getEapDomainSuffixMatch() { 1914 synchronized (mLock) { 1915 final String methodStr = "getEapDomainSuffixMatch"; 1916 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1917 try { 1918 MutableBoolean statusOk = new MutableBoolean(false); 1919 mISupplicantStaNetwork.getEapDomainSuffixMatch((SupplicantStatus status, 1920 String matchValue) -> { 1921 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1922 if (statusOk.value) { 1923 this.mEapDomainSuffixMatch = matchValue; 1924 } else { 1925 logFailureStatus(status, methodStr); 1926 } 1927 }); 1928 return statusOk.value; 1929 } catch (RemoteException e) { 1930 handleRemoteException(e, methodStr); 1931 return false; 1932 } 1933 } 1934 } 1935 /** See ISupplicantStaNetwork.hal for documentation */ 1936 private boolean getIdStr() { 1937 synchronized (mLock) { 1938 final String methodStr = "getIdStr"; 1939 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1940 try { 1941 MutableBoolean statusOk = new MutableBoolean(false); 1942 mISupplicantStaNetwork.getIdStr((SupplicantStatus status, String idString) -> { 1943 statusOk.value = status.code == SupplicantStatusCode.SUCCESS; 1944 if (statusOk.value) { 1945 this.mIdStr = idString; 1946 } else { 1947 logFailureStatus(status, methodStr); 1948 } 1949 }); 1950 return statusOk.value; 1951 } catch (RemoteException e) { 1952 handleRemoteException(e, methodStr); 1953 return false; 1954 } 1955 } 1956 } 1957 /** See ISupplicantStaNetwork.hal for documentation */ 1958 private boolean enable(boolean noConnect) { 1959 synchronized (mLock) { 1960 final String methodStr = "enable"; 1961 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1962 try { 1963 SupplicantStatus status = mISupplicantStaNetwork.enable(noConnect); 1964 return checkStatusAndLogFailure(status, methodStr); 1965 } catch (RemoteException e) { 1966 handleRemoteException(e, methodStr); 1967 return false; 1968 } 1969 } 1970 } 1971 /** See ISupplicantStaNetwork.hal for documentation */ 1972 private boolean disable() { 1973 synchronized (mLock) { 1974 final String methodStr = "disable"; 1975 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1976 try { 1977 SupplicantStatus status = mISupplicantStaNetwork.disable(); 1978 return checkStatusAndLogFailure(status, methodStr); 1979 } catch (RemoteException e) { 1980 handleRemoteException(e, methodStr); 1981 return false; 1982 } 1983 } 1984 } 1985 1986 /** 1987 * Trigger a connection to this network. 1988 * 1989 * @return true if it succeeds, false otherwise. 1990 */ 1991 public boolean select() { 1992 synchronized (mLock) { 1993 final String methodStr = "select"; 1994 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 1995 try { 1996 SupplicantStatus status = mISupplicantStaNetwork.select(); 1997 return checkStatusAndLogFailure(status, methodStr); 1998 } catch (RemoteException e) { 1999 handleRemoteException(e, methodStr); 2000 return false; 2001 } 2002 } 2003 } 2004 2005 /** 2006 * Send GSM auth response. 2007 * 2008 * @param paramsStr Response params as a string. 2009 * @return true if succeeds, false otherwise. 2010 */ 2011 public boolean sendNetworkEapSimGsmAuthResponse(String paramsStr) { 2012 Matcher match = GSM_AUTH_RESPONSE_PARAMS_PATTERN.matcher(paramsStr); 2013 ArrayList<ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams> params = 2014 new ArrayList<>(); 2015 while (match.find()) { 2016 if (match.groupCount() != 2) { 2017 Log.e(TAG, "Malformed gsm auth response params: " + paramsStr); 2018 return false; 2019 } 2020 ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams param = 2021 new ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams(); 2022 byte[] kc = NativeUtil.hexStringToByteArray(match.group(1)); 2023 if (kc == null || kc.length != param.kc.length) { 2024 Log.e(TAG, "Invalid kc value: " + match.group(1)); 2025 return false; 2026 } 2027 byte[] sres = NativeUtil.hexStringToByteArray(match.group(2)); 2028 if (sres == null || sres.length != param.sres.length) { 2029 Log.e(TAG, "Invalid sres value: " + match.group(2)); 2030 return false; 2031 } 2032 System.arraycopy(kc, 0, param.kc, 0, param.kc.length); 2033 System.arraycopy(sres, 0, param.sres, 0, param.sres.length); 2034 params.add(param); 2035 } 2036 // The number of kc/sres pairs can either be 2 or 3 depending on the request. 2037 if (params.size() > 3 || params.size() < 2) { 2038 Log.e(TAG, "Malformed gsm auth response params: " + paramsStr); 2039 return false; 2040 } 2041 return sendNetworkEapSimGsmAuthResponse(params); 2042 } 2043 2044 /** See ISupplicantStaNetwork.hal for documentation */ 2045 private boolean sendNetworkEapSimGsmAuthResponse( 2046 ArrayList<ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams> params) { 2047 synchronized (mLock) { 2048 final String methodStr = "sendNetworkEapSimGsmAuthResponse"; 2049 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 2050 try { 2051 SupplicantStatus status = 2052 mISupplicantStaNetwork.sendNetworkEapSimGsmAuthResponse(params); 2053 return checkStatusAndLogFailure(status, methodStr); 2054 } catch (RemoteException e) { 2055 handleRemoteException(e, methodStr); 2056 return false; 2057 } 2058 } 2059 } 2060 /** See ISupplicantStaNetwork.hal for documentation */ 2061 public boolean sendNetworkEapSimGsmAuthFailure() { 2062 synchronized (mLock) { 2063 final String methodStr = "sendNetworkEapSimGsmAuthFailure"; 2064 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 2065 try { 2066 SupplicantStatus status = mISupplicantStaNetwork.sendNetworkEapSimGsmAuthFailure(); 2067 return checkStatusAndLogFailure(status, methodStr); 2068 } catch (RemoteException e) { 2069 handleRemoteException(e, methodStr); 2070 return false; 2071 } 2072 } 2073 } 2074 /** 2075 * Send UMTS auth response. 2076 * 2077 * @param paramsStr Response params as a string. 2078 * @return true if succeeds, false otherwise. 2079 */ 2080 public boolean sendNetworkEapSimUmtsAuthResponse(String paramsStr) { 2081 Matcher match = UMTS_AUTH_RESPONSE_PARAMS_PATTERN.matcher(paramsStr); 2082 if (!match.find() || match.groupCount() != 3) { 2083 Log.e(TAG, "Malformed umts auth response params: " + paramsStr); 2084 return false; 2085 } 2086 ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams params = 2087 new ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams(); 2088 byte[] ik = NativeUtil.hexStringToByteArray(match.group(1)); 2089 if (ik == null || ik.length != params.ik.length) { 2090 Log.e(TAG, "Invalid ik value: " + match.group(1)); 2091 return false; 2092 } 2093 byte[] ck = NativeUtil.hexStringToByteArray(match.group(2)); 2094 if (ck == null || ck.length != params.ck.length) { 2095 Log.e(TAG, "Invalid ck value: " + match.group(2)); 2096 return false; 2097 } 2098 byte[] res = NativeUtil.hexStringToByteArray(match.group(3)); 2099 if (res == null || res.length == 0) { 2100 Log.e(TAG, "Invalid res value: " + match.group(3)); 2101 return false; 2102 } 2103 System.arraycopy(ik, 0, params.ik, 0, params.ik.length); 2104 System.arraycopy(ck, 0, params.ck, 0, params.ck.length); 2105 for (byte b : res) { 2106 params.res.add(b); 2107 } 2108 return sendNetworkEapSimUmtsAuthResponse(params); 2109 } 2110 /** See ISupplicantStaNetwork.hal for documentation */ 2111 private boolean sendNetworkEapSimUmtsAuthResponse( 2112 ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams params) { 2113 synchronized (mLock) { 2114 final String methodStr = "sendNetworkEapSimUmtsAuthResponse"; 2115 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 2116 try { 2117 SupplicantStatus status = 2118 mISupplicantStaNetwork.sendNetworkEapSimUmtsAuthResponse(params); 2119 return checkStatusAndLogFailure(status, methodStr); 2120 } catch (RemoteException e) { 2121 handleRemoteException(e, methodStr); 2122 return false; 2123 } 2124 } 2125 } 2126 /** 2127 * Send UMTS auts response. 2128 * 2129 * @param paramsStr Response params as a string. 2130 * @return true if succeeds, false otherwise. 2131 */ 2132 public boolean sendNetworkEapSimUmtsAutsResponse(String paramsStr) { 2133 Matcher match = UMTS_AUTS_RESPONSE_PARAMS_PATTERN.matcher(paramsStr); 2134 if (!match.find() || match.groupCount() != 1) { 2135 Log.e(TAG, "Malformed umts auts response params: " + paramsStr); 2136 return false; 2137 } 2138 byte[] auts = NativeUtil.hexStringToByteArray(match.group(1)); 2139 if (auts == null || auts.length != 14) { 2140 Log.e(TAG, "Invalid auts value: " + match.group(1)); 2141 return false; 2142 } 2143 return sendNetworkEapSimUmtsAutsResponse(auts); 2144 } 2145 /** See ISupplicantStaNetwork.hal for documentation */ 2146 private boolean sendNetworkEapSimUmtsAutsResponse(byte[/* 14 */] auts) { 2147 synchronized (mLock) { 2148 final String methodStr = "sendNetworkEapSimUmtsAutsResponse"; 2149 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 2150 try { 2151 SupplicantStatus status = 2152 mISupplicantStaNetwork.sendNetworkEapSimUmtsAutsResponse(auts); 2153 return checkStatusAndLogFailure(status, methodStr); 2154 } catch (RemoteException e) { 2155 handleRemoteException(e, methodStr); 2156 return false; 2157 } 2158 } 2159 } 2160 /** See ISupplicantStaNetwork.hal for documentation */ 2161 public boolean sendNetworkEapSimUmtsAuthFailure() { 2162 synchronized (mLock) { 2163 final String methodStr = "sendNetworkEapSimUmtsAuthFailure"; 2164 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 2165 try { 2166 SupplicantStatus status = mISupplicantStaNetwork.sendNetworkEapSimUmtsAuthFailure(); 2167 return checkStatusAndLogFailure(status, methodStr); 2168 } catch (RemoteException e) { 2169 handleRemoteException(e, methodStr); 2170 return false; 2171 } 2172 } 2173 } 2174 /** 2175 * Send eap identity response. 2176 * 2177 * @param identityStr Identity as a string. 2178 * @return true if succeeds, false otherwise. 2179 */ 2180 public boolean sendNetworkEapIdentityResponse(String identityStr) { 2181 ArrayList<Byte> identity = NativeUtil.stringToByteArrayList(identityStr); 2182 return sendNetworkEapIdentityResponse(identity); 2183 } 2184 /** See ISupplicantStaNetwork.hal for documentation */ 2185 private boolean sendNetworkEapIdentityResponse(ArrayList<Byte> identity) { 2186 synchronized (mLock) { 2187 final String methodStr = "sendNetworkEapIdentityResponse"; 2188 if (!checkISupplicantStaNetworkAndLogFailure(methodStr)) return false; 2189 try { 2190 SupplicantStatus status = 2191 mISupplicantStaNetwork.sendNetworkEapIdentityResponse(identity); 2192 return checkStatusAndLogFailure(status, methodStr); 2193 } catch (RemoteException e) { 2194 handleRemoteException(e, methodStr); 2195 return false; 2196 } 2197 } 2198 } 2199 2200 /** 2201 * Returns true if provided status code is SUCCESS, logs debug message and returns false 2202 * otherwise 2203 */ 2204 private boolean checkStatusAndLogFailure(SupplicantStatus status, final String methodStr) { 2205 if (DBG) Log.i(TAG, methodStr); 2206 if (status.code != SupplicantStatusCode.SUCCESS) { 2207 Log.e(TAG, methodStr + " failed: " 2208 + SupplicantStaIfaceHal.supplicantStatusCodeToString(status.code) + ", " 2209 + status.debugMessage); 2210 return false; 2211 } 2212 return true; 2213 } 2214 2215 /** 2216 * Returns false if ISupplicantStaNetwork is null, and logs failure of methodStr 2217 */ 2218 private boolean checkISupplicantStaNetworkAndLogFailure(final String methodStr) { 2219 if (mISupplicantStaNetwork == null) { 2220 Log.e(TAG, "Can't call " + methodStr + ", ISupplicantStaNetwork is null"); 2221 return false; 2222 } 2223 return true; 2224 } 2225 2226 private void handleRemoteException(RemoteException e, String methodStr) { 2227 mISupplicantStaNetwork = null; 2228 Log.e(TAG, "ISupplicantStaNetwork." + methodStr + ":exception: " + e); 2229 } 2230 2231 private void logFailureStatus(SupplicantStatus status, String methodStr) { 2232 Log.e(TAG, methodStr + " failed: " + status.debugMessage); 2233 } 2234} 2235