SupplicantStaNetworkHalTest.java revision 2104cc5eaf4ed7b9047ca1de460838a8ca6d0fe1
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 static org.junit.Assert.*; 19import static org.mockito.Mockito.any; 20import static org.mockito.Mockito.doAnswer; 21import static org.mockito.Mockito.when; 22 23import android.app.test.MockAnswerUtil.AnswerWithArguments; 24import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetwork; 25import android.hardware.wifi.supplicant.V1_0.SupplicantStatus; 26import android.hardware.wifi.supplicant.V1_0.SupplicantStatusCode; 27import android.net.wifi.WifiConfiguration; 28import android.net.wifi.WifiEnterpriseConfig; 29import android.os.HandlerThread; 30import android.os.RemoteException; 31import android.os.test.TestLooper; 32import android.text.TextUtils; 33 34import com.android.server.wifi.util.NativeUtil; 35 36import org.junit.Before; 37import org.junit.Test; 38import org.mockito.Mock; 39import org.mockito.MockitoAnnotations; 40 41import java.util.ArrayList; 42import java.util.HashMap; 43import java.util.Map; 44 45/** 46 * Unit tests for SupplicantStaNetworkHal 47 */ 48public class SupplicantStaNetworkHalTest { 49 private static final String TAG = "SupplicantStaNetworkHalTest"; 50 51 private SupplicantStaNetworkHal mSupplicantNetwork; 52 private SupplicantStatus mStatusSuccess; 53 private SupplicantStatus mStatusFailure; 54 @Mock private ISupplicantStaNetwork mISupplicantStaNetworkMock; 55 @Mock private HandlerThread mHandlerThread; 56 private TestLooper mTestLooper; 57 private SupplicantNetworkVariables mSupplicantVariables; 58 59 @Before 60 public void setUp() throws Exception { 61 MockitoAnnotations.initMocks(this); 62 mTestLooper = new TestLooper(); 63 mStatusSuccess = createSupplicantStatus(SupplicantStatusCode.SUCCESS); 64 mStatusFailure = createSupplicantStatus(SupplicantStatusCode.FAILURE_UNKNOWN); 65 when(mHandlerThread.getLooper()).thenReturn(mTestLooper.getLooper()); 66 mSupplicantVariables = new SupplicantNetworkVariables(); 67 setupISupplicantNetworkMock(); 68 69 mSupplicantNetwork = 70 new SupplicantStaNetworkHal(mISupplicantStaNetworkMock, mHandlerThread); 71 } 72 73 /** 74 * Tests the saving of WifiConfiguration to wpa_supplicant. 75 */ 76 @Test 77 public void testOpenNetworkWifiConfigurationSaveLoad() throws Exception { 78 WifiConfiguration config = WifiConfigurationTestUtil.createOpenHiddenNetwork(); 79 config.updateIdentifier = "45"; 80 testWifiConfigurationSaveLoad(config); 81 } 82 83 /** 84 * Tests the saving/loading of WifiConfiguration to wpa_supplicant. 85 */ 86 @Test 87 public void testPskNetworkWifiConfigurationSaveLoad() throws Exception { 88 WifiConfiguration config = WifiConfigurationTestUtil.createPskNetwork(); 89 config.requirePMF = true; 90 testWifiConfigurationSaveLoad(config); 91 } 92 93 /** 94 * Tests the saving/loading of WifiConfiguration to wpa_supplicant. 95 */ 96 @Test 97 public void testWepNetworkWifiConfigurationSaveLoad() throws Exception { 98 WifiConfiguration config = WifiConfigurationTestUtil.createWepHiddenNetwork(); 99 config.BSSID = "34:45:19:09:45"; 100 testWifiConfigurationSaveLoad(config); 101 } 102 103 /** 104 * Tests the saving of WifiConfiguration to wpa_supplicant. 105 */ 106 @Test 107 public void testEapPeapGtcNetworkWifiConfigurationSaveLoad() throws Exception { 108 WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(); 109 config.enterpriseConfig = 110 WifiConfigurationTestUtil.createPEAPWifiEnterpriseConfigWithGTCPhase2(); 111 testWifiConfigurationSaveLoad(config); 112 } 113 114 /** 115 * Tests the saving of WifiConfiguration to wpa_supplicant. 116 */ 117 @Test 118 public void testEapTlsNoneNetworkWifiConfigurationSaveLoad() throws Exception { 119 WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(); 120 config.enterpriseConfig = 121 WifiConfigurationTestUtil.createTLSWifiEnterpriseConfigWithNonePhase2(); 122 testWifiConfigurationSaveLoad(config); 123 } 124 125 /** 126 * Tests the saving of WifiConfiguration to wpa_supplicant. 127 */ 128 @Test 129 public void testEapTlsNoneClientCertNetworkWifiConfigurationSaveLoad() throws Exception { 130 WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(); 131 config.enterpriseConfig = 132 WifiConfigurationTestUtil.createTLSWifiEnterpriseConfigWithNonePhase2(); 133 config.enterpriseConfig.setClientCertificateAlias("test_alias"); 134 testWifiConfigurationSaveLoad(config); 135 } 136 137 /** 138 * Tests the failure to load ssid aborts the loading of network variables. 139 */ 140 @Test 141 public void testSsidLoadFailure() throws Exception { 142 WifiConfiguration config = WifiConfigurationTestUtil.createWepHiddenNetwork(); 143 assertTrue(mSupplicantNetwork.saveWifiConfiguration(config)); 144 145 doAnswer(new AnswerWithArguments() { 146 public void answer(ISupplicantStaNetwork.getSsidCallback cb) throws RemoteException { 147 cb.onValues(mStatusFailure, mSupplicantVariables.ssid); 148 } 149 }).when(mISupplicantStaNetworkMock) 150 .getSsid(any(ISupplicantStaNetwork.getSsidCallback.class)); 151 152 WifiConfiguration loadConfig = new WifiConfiguration(); 153 Map<String, String> networkExtras = new HashMap<>(); 154 assertFalse(mSupplicantNetwork.loadWifiConfiguration(loadConfig, networkExtras)); 155 } 156 157 /** 158 * Tests the failure to save ssid. 159 */ 160 @Test 161 public void testSsidSaveFailure() throws Exception { 162 WifiConfiguration config = WifiConfigurationTestUtil.createWepHiddenNetwork(); 163 164 doAnswer(new AnswerWithArguments() { 165 public SupplicantStatus answer(ArrayList<Byte> ssid) throws RemoteException { 166 return mStatusFailure; 167 } 168 }).when(mISupplicantStaNetworkMock).setSsid(any(ArrayList.class)); 169 170 assertFalse(mSupplicantNetwork.saveWifiConfiguration(config)); 171 } 172 173 /** 174 * Tests the failure to save invalid key mgmt (unknown bit set in the 175 * {@link WifiConfiguration#allowedKeyManagement} being saved). 176 */ 177 @Test 178 public void testInvalidKeyMgmtSaveFailure() throws Exception { 179 WifiConfiguration config = WifiConfigurationTestUtil.createWepHiddenNetwork(); 180 config.allowedKeyManagement.set(10); 181 try { 182 assertFalse(mSupplicantNetwork.saveWifiConfiguration(config)); 183 } catch (IllegalArgumentException e) { 184 return; 185 } 186 assertTrue(false); 187 } 188 189 /** 190 * Tests the failure to load invalid key mgmt (unkown bit set in the supplicant network key_mgmt 191 * variable read). 192 */ 193 @Test 194 public void testInvalidKeyMgmtLoadFailure() throws Exception { 195 WifiConfiguration config = WifiConfigurationTestUtil.createWepHiddenNetwork(); 196 assertTrue(mSupplicantNetwork.saveWifiConfiguration(config)); 197 198 // Modify the supplicant variable directly. 199 mSupplicantVariables.keyMgmtMask = 0xFFFFF; 200 WifiConfiguration loadConfig = new WifiConfiguration(); 201 Map<String, String> networkExtras = new HashMap<>(); 202 try { 203 assertFalse(mSupplicantNetwork.loadWifiConfiguration(loadConfig, networkExtras)); 204 } catch (IllegalArgumentException e) { 205 return; 206 } 207 assertTrue(false); 208 } 209 210 /** 211 * Tests the failure to save invalid bssid (less than 6 bytes in the 212 * {@link WifiConfiguration#BSSID} being saved). 213 */ 214 @Test 215 public void testInvalidBssidSaveFailure() throws Exception { 216 WifiConfiguration config = WifiConfigurationTestUtil.createWepHiddenNetwork(); 217 config.getNetworkSelectionStatus().setNetworkSelectionBSSID("45:34:23:12"); 218 try { 219 assertFalse(mSupplicantNetwork.saveWifiConfiguration(config)); 220 } catch (IllegalArgumentException e) { 221 return; 222 } 223 assertTrue(false); 224 } 225 226 /** 227 * Tests the failure to load invalid bssid (less than 6 bytes in the supplicant bssid variable 228 * read). 229 */ 230 @Test 231 public void testInvalidBssidLoadFailure() throws Exception { 232 WifiConfiguration config = WifiConfigurationTestUtil.createWepHiddenNetwork(); 233 assertTrue(mSupplicantNetwork.saveWifiConfiguration(config)); 234 235 // Modify the supplicant variable directly. 236 mSupplicantVariables.bssid = new byte[3]; 237 WifiConfiguration loadConfig = new WifiConfiguration(); 238 Map<String, String> networkExtras = new HashMap<>(); 239 try { 240 assertFalse(mSupplicantNetwork.loadWifiConfiguration(loadConfig, networkExtras)); 241 } catch (IllegalArgumentException e) { 242 return; 243 } 244 assertTrue(false); 245 } 246 247 /** 248 * Tests the loading of invalid ssid from wpa_supplicant. 249 */ 250 @Test 251 public void testInvalidSsidLoadFailure() throws Exception { 252 WifiConfiguration config = WifiConfigurationTestUtil.createWepHiddenNetwork(); 253 assertTrue(mSupplicantNetwork.saveWifiConfiguration(config)); 254 255 // Modify the supplicant variable directly. 256 mSupplicantVariables.ssid = null; 257 258 WifiConfiguration loadConfig = new WifiConfiguration(); 259 Map<String, String> networkExtras = new HashMap<>(); 260 assertFalse(mSupplicantNetwork.loadWifiConfiguration(loadConfig, networkExtras)); 261 } 262 263 /** 264 * Tests the loading of invalid eap method from wpa_supplicant. 265 * Invalid eap method is assumed to be a non enterprise network. So, the loading should 266 * succeed as a non-enterprise network. 267 */ 268 @Test 269 public void testInvalidEapMethodLoadFailure() throws Exception { 270 WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(); 271 config.enterpriseConfig = 272 WifiConfigurationTestUtil.createPEAPWifiEnterpriseConfigWithGTCPhase2(); 273 assertTrue(mSupplicantNetwork.saveWifiConfiguration(config)); 274 275 // Modify the supplicant variable directly. 276 mSupplicantVariables.eapMethod = -1; 277 278 WifiConfiguration loadConfig = new WifiConfiguration(); 279 Map<String, String> networkExtras = new HashMap<>(); 280 assertTrue(mSupplicantNetwork.loadWifiConfiguration(loadConfig, networkExtras)); 281 } 282 283 /** 284 * Tests the loading of invalid eap phase2 method from wpa_supplicant. 285 */ 286 @Test 287 public void testInvalidEapPhase2MethodLoadFailure() throws Exception { 288 WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(); 289 config.enterpriseConfig = 290 WifiConfigurationTestUtil.createPEAPWifiEnterpriseConfigWithGTCPhase2(); 291 assertTrue(mSupplicantNetwork.saveWifiConfiguration(config)); 292 293 // Modify the supplicant variable directly. 294 mSupplicantVariables.eapPhase2Method = -1; 295 296 WifiConfiguration loadConfig = new WifiConfiguration(); 297 Map<String, String> networkExtras = new HashMap<>(); 298 assertFalse(mSupplicantNetwork.loadWifiConfiguration(loadConfig, networkExtras)); 299 } 300 301 /** 302 * Tests the parsing of GSM auth response parameters. 303 */ 304 @Test 305 public void testSendNetworkEapSimGsmAuthResponseWith2KcSresPair() throws Exception { 306 final byte[] kc = new byte[]{0x45, 0x45, 0x32, 0x34, 0x45, 0x10, 0x34, 0x12}; 307 final byte[] sres = new byte[]{0x12, 0x10, 0x32, 0x23}; 308 // Send 2 kc/sres pair for this request. 309 String paramsStr = ":kc:" + NativeUtil.hexStringFromByteArray(kc) 310 + ":sres:" + NativeUtil.hexStringFromByteArray(sres) 311 + ":kc:" + NativeUtil.hexStringFromByteArray(kc) 312 + ":sres:" + NativeUtil.hexStringFromByteArray(sres); 313 314 doAnswer(new AnswerWithArguments() { 315 public SupplicantStatus answer( 316 ArrayList<ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams> params) 317 throws RemoteException { 318 assertEquals(2, params.size()); 319 assertArrayEquals(kc, params.get(0).kc); 320 assertArrayEquals(sres, params.get(0).sres); 321 assertArrayEquals(kc, params.get(1).kc); 322 assertArrayEquals(sres, params.get(1).sres); 323 return mStatusSuccess; 324 } 325 }).when(mISupplicantStaNetworkMock).sendNetworkEapSimGsmAuthResponse(any(ArrayList.class)); 326 327 assertTrue(mSupplicantNetwork.sendNetworkEapSimGsmAuthResponse(paramsStr)); 328 } 329 330 /** 331 * Tests the parsing of GSM auth response parameters. 332 */ 333 @Test 334 public void testSendNetworkEapSimGsmAuthResponseWith3KcSresPair() throws Exception { 335 final byte[] kc1 = new byte[]{0x45, 0x45, 0x32, 0x34, 0x45, 0x10, 0x34, 0x12}; 336 final byte[] sres1 = new byte[]{0x12, 0x10, 0x32, 0x23}; 337 final byte[] kc2 = new byte[]{0x45, 0x34, 0x12, 0x34, 0x45, 0x10, 0x34, 0x12}; 338 final byte[] sres2 = new byte[]{0x12, 0x23, 0x12, 0x23}; 339 final byte[] kc3 = new byte[]{0x25, 0x34, 0x12, 0x14, 0x45, 0x10, 0x34, 0x12}; 340 final byte[] sres3 = new byte[]{0x42, 0x23, 0x22, 0x23}; 341 // Send 3 kc/sres pair for this request. 342 String paramsStr = ":kc:" + NativeUtil.hexStringFromByteArray(kc1) 343 + ":sres:" + NativeUtil.hexStringFromByteArray(sres1) 344 + ":kc:" + NativeUtil.hexStringFromByteArray(kc2) 345 + ":sres:" + NativeUtil.hexStringFromByteArray(sres2) 346 + ":kc:" + NativeUtil.hexStringFromByteArray(kc3) 347 + ":sres:" + NativeUtil.hexStringFromByteArray(sres3); 348 349 doAnswer(new AnswerWithArguments() { 350 public SupplicantStatus answer( 351 ArrayList<ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams> params) 352 throws RemoteException { 353 assertEquals(3, params.size()); 354 assertArrayEquals(kc1, params.get(0).kc); 355 assertArrayEquals(sres1, params.get(0).sres); 356 assertArrayEquals(kc2, params.get(1).kc); 357 assertArrayEquals(sres2, params.get(1).sres); 358 assertArrayEquals(kc3, params.get(2).kc); 359 assertArrayEquals(sres3, params.get(2).sres); 360 return mStatusSuccess; 361 } 362 }).when(mISupplicantStaNetworkMock).sendNetworkEapSimGsmAuthResponse(any(ArrayList.class)); 363 364 assertTrue(mSupplicantNetwork.sendNetworkEapSimGsmAuthResponse(paramsStr)); 365 } 366 367 /** 368 * Tests the parsing of invalid GSM auth response parameters (invalid kc & sres lengths). 369 */ 370 @Test 371 public void testSendInvalidKcSresLenNetworkEapSimGsmAuthResponse() throws Exception { 372 final byte[] kc1 = new byte[]{0x45, 0x45, 0x32, 0x34, 0x45, 0x10, 0x34}; 373 final byte[] sres1 = new byte[]{0x12, 0x10, 0x23}; 374 final byte[] kc2 = new byte[]{0x45, 0x34, 0x12, 0x34, 0x45, 0x10, 0x34, 0x12}; 375 final byte[] sres2 = new byte[]{0x12, 0x23, 0x12, 0x23}; 376 // Send 2 kc/sres pair for this request. 377 String paramsStr = ":kc:" + NativeUtil.hexStringFromByteArray(kc1) 378 + ":sres:" + NativeUtil.hexStringFromByteArray(sres1) 379 + ":kc:" + NativeUtil.hexStringFromByteArray(kc2) 380 + ":sres:" + NativeUtil.hexStringFromByteArray(sres2); 381 382 doAnswer(new AnswerWithArguments() { 383 public SupplicantStatus answer( 384 ArrayList<ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams> params) 385 throws RemoteException { 386 return mStatusSuccess; 387 } 388 }).when(mISupplicantStaNetworkMock).sendNetworkEapSimGsmAuthResponse(any(ArrayList.class)); 389 390 assertFalse(mSupplicantNetwork.sendNetworkEapSimGsmAuthResponse(paramsStr)); 391 } 392 393 /** 394 * Tests the parsing of invalid GSM auth response parameters (invalid number of kc/sres pairs). 395 */ 396 @Test 397 public void testSendInvalidKcSresPairNumNetworkEapSimGsmAuthResponse() throws Exception { 398 final byte[] kc = new byte[]{0x45, 0x34, 0x12, 0x34, 0x45, 0x10, 0x34, 0x12}; 399 final byte[] sres = new byte[]{0x12, 0x23, 0x12, 0x23}; 400 // Send 1 kc/sres pair for this request. 401 String paramsStr = ":kc:" + NativeUtil.hexStringFromByteArray(kc) 402 + ":sres:" + NativeUtil.hexStringFromByteArray(sres); 403 404 doAnswer(new AnswerWithArguments() { 405 public SupplicantStatus answer( 406 ArrayList<ISupplicantStaNetwork.NetworkResponseEapSimGsmAuthParams> params) 407 throws RemoteException { 408 return mStatusSuccess; 409 } 410 }).when(mISupplicantStaNetworkMock).sendNetworkEapSimGsmAuthResponse(any(ArrayList.class)); 411 412 assertFalse(mSupplicantNetwork.sendNetworkEapSimGsmAuthResponse(paramsStr)); 413 } 414 415 /** 416 * Tests the parsing of UMTS auth response parameters. 417 */ 418 @Test 419 public void testSendNetworkEapSimUmtsAuthResponse() throws Exception { 420 final byte[] ik = new byte[]{0x45, 0x45, 0x32, 0x34, 0x45, 0x10, 0x34, 0x12, 0x23, 0x34, 421 0x33, 0x23, 0x34, 0x10, 0x40, 0x34}; 422 final byte[] ck = new byte[]{0x12, 0x10, 0x32, 0x23, 0x45, 0x10, 0x34, 0x12, 0x23, 0x34, 423 0x33, 0x23, 0x34, 0x10, 0x40, 0x34}; 424 final byte[] res = new byte[]{0x12, 0x10, 0x32, 0x23, 0x45, 0x10, 0x34, 0x12, 0x23, 0x34}; 425 String paramsStr = ":ik:" + NativeUtil.hexStringFromByteArray(ik) 426 + ":ck:" + NativeUtil.hexStringFromByteArray(ck) 427 + ":res:" + NativeUtil.hexStringFromByteArray(res); 428 429 doAnswer(new AnswerWithArguments() { 430 public SupplicantStatus answer( 431 ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams params) 432 throws RemoteException { 433 assertArrayEquals(ik, params.ik); 434 assertArrayEquals(ck, params.ck); 435 // Convert to arraylist before comparison. 436 ArrayList<Byte> resList = new ArrayList<>(); 437 for (byte b : res) { 438 resList.add(b); 439 } 440 assertEquals(resList, params.res); 441 return mStatusSuccess; 442 } 443 }).when(mISupplicantStaNetworkMock).sendNetworkEapSimUmtsAuthResponse( 444 any(ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams.class)); 445 446 assertTrue(mSupplicantNetwork.sendNetworkEapSimUmtsAuthResponse(paramsStr)); 447 } 448 449 /** 450 * Tests the parsing of invalid UMTS auth response parameters (invalid ik, ck lengths). 451 */ 452 @Test 453 public void testSendInvalidNetworkEapSimUmtsAuthResponse() throws Exception { 454 final byte[] ik = new byte[]{0x45, 0x45, 0x32, 0x34, 0x45, 0x10, 0x34, 0x12}; 455 final byte[] ck = new byte[]{0x12, 0x10, 0x32, 0x23, 0x45, 0x10, 0x34, 0x12, 0x23, 0x34, 456 0x33, 0x23, 0x34, 0x10, 0x40}; 457 final byte[] res = new byte[]{0x12, 0x10, 0x32, 0x23, 0x45, 0x10, 0x34, 0x12, 0x23, 0x34}; 458 String paramsStr = ":ik:" + NativeUtil.hexStringFromByteArray(ik) 459 + ":ck:" + NativeUtil.hexStringFromByteArray(ck) 460 + ":res:" + NativeUtil.hexStringFromByteArray(res); 461 462 doAnswer(new AnswerWithArguments() { 463 public SupplicantStatus answer( 464 ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams params) 465 throws RemoteException { 466 return mStatusSuccess; 467 } 468 }).when(mISupplicantStaNetworkMock).sendNetworkEapSimUmtsAuthResponse( 469 any(ISupplicantStaNetwork.NetworkResponseEapSimUmtsAuthParams.class)); 470 471 assertFalse(mSupplicantNetwork.sendNetworkEapSimUmtsAuthResponse(paramsStr)); 472 } 473 474 /** 475 * Tests the parsing of UMTS auts response parameters. 476 */ 477 @Test 478 public void testSendNetworkEapSimUmtsAutsResponse() throws Exception { 479 final byte[] auts = new byte[]{0x45, 0x45, 0x32, 0x34, 0x45, 0x10, 0x34, 0x12, 0x23, 0x34, 480 0x33, 0x23, 0x34, 0x10}; 481 String paramsStr = ":" + NativeUtil.hexStringFromByteArray(auts); 482 483 doAnswer(new AnswerWithArguments() { 484 public SupplicantStatus answer(byte[] params) 485 throws RemoteException { 486 assertArrayEquals(auts, params); 487 return mStatusSuccess; 488 } 489 }).when(mISupplicantStaNetworkMock).sendNetworkEapSimUmtsAutsResponse(any(byte[].class)); 490 491 assertTrue(mSupplicantNetwork.sendNetworkEapSimUmtsAutsResponse(paramsStr)); 492 } 493 494 /** 495 * Tests the parsing of invalid UMTS auts response parameters (invalid auts length). 496 */ 497 @Test 498 public void testSendInvalidNetworkEapSimUmtsAutsResponse() throws Exception { 499 final byte[] auts = new byte[]{0x45, 0x45, 0x32, 0x34, 0x45, 0x10, 0x34, 0x12, 0x23}; 500 String paramsStr = ":" + NativeUtil.hexStringFromByteArray(auts); 501 502 doAnswer(new AnswerWithArguments() { 503 public SupplicantStatus answer(byte[] params) 504 throws RemoteException { 505 assertArrayEquals(auts, params); 506 return mStatusSuccess; 507 } 508 }).when(mISupplicantStaNetworkMock).sendNetworkEapSimUmtsAutsResponse(any(byte[].class)); 509 510 assertFalse(mSupplicantNetwork.sendNetworkEapSimUmtsAutsResponse(paramsStr)); 511 } 512 513 /** 514 * Tests the parsing of identity string. 515 */ 516 @Test 517 public void testSendNetworkEapIdentityResponse() throws Exception { 518 final String identityStr = "test@test.com"; 519 520 doAnswer(new AnswerWithArguments() { 521 public SupplicantStatus answer(ArrayList<Byte> identity) 522 throws RemoteException { 523 assertEquals(identityStr, NativeUtil.stringFromByteArrayList(identity)); 524 return mStatusSuccess; 525 } 526 }).when(mISupplicantStaNetworkMock).sendNetworkEapIdentityResponse(any(ArrayList.class)); 527 528 assertTrue(mSupplicantNetwork.sendNetworkEapIdentityResponse(identityStr)); 529 } 530 531 private void testWifiConfigurationSaveLoad(WifiConfiguration config) { 532 assertTrue(mSupplicantNetwork.saveWifiConfiguration(config)); 533 WifiConfiguration loadConfig = new WifiConfiguration(); 534 Map<String, String> networkExtras = new HashMap<>(); 535 assertTrue(mSupplicantNetwork.loadWifiConfiguration(loadConfig, networkExtras)); 536 WifiConfigurationTestUtil.assertConfigurationEqualForSupplicant(config, loadConfig); 537 assertEquals(config.configKey(), 538 networkExtras.get(SupplicantStaNetworkHal.ID_STRING_KEY_CONFIG_KEY)); 539 assertEquals( 540 config.creatorUid, 541 Integer.parseInt(networkExtras.get( 542 SupplicantStaNetworkHal.ID_STRING_KEY_CREATOR_UID))); 543 // There is no getter for this one, so check the supplicant variable. 544 if (!TextUtils.isEmpty(config.updateIdentifier)) { 545 assertEquals(Integer.parseInt(config.updateIdentifier), 546 mSupplicantVariables.updateIdentifier); 547 } 548 // There is no getter for this one, so check the supplicant variable. 549 String oppKeyCaching = 550 config.enterpriseConfig.getFieldValue(WifiEnterpriseConfig.OPP_KEY_CACHING); 551 if (!TextUtils.isEmpty(oppKeyCaching)) { 552 assertEquals( 553 Integer.parseInt(oppKeyCaching) == 1 ? true : false, 554 mSupplicantVariables.eapProactiveKeyCaching); 555 } 556 } 557 558 /** 559 * Sets up the HIDL interface mock with all the setters/getter values. 560 * Note: This only sets up the mock to return success on all methods. 561 */ 562 private void setupISupplicantNetworkMock() throws Exception { 563 /** SSID */ 564 doAnswer(new AnswerWithArguments() { 565 public SupplicantStatus answer(ArrayList<Byte> ssid) throws RemoteException { 566 mSupplicantVariables.ssid = ssid; 567 return mStatusSuccess; 568 } 569 }).when(mISupplicantStaNetworkMock).setSsid(any(ArrayList.class)); 570 doAnswer(new AnswerWithArguments() { 571 public void answer(ISupplicantStaNetwork.getSsidCallback cb) throws RemoteException { 572 cb.onValues(mStatusSuccess, mSupplicantVariables.ssid); 573 } 574 }).when(mISupplicantStaNetworkMock) 575 .getSsid(any(ISupplicantStaNetwork.getSsidCallback.class)); 576 577 /** BSSID */ 578 doAnswer(new AnswerWithArguments() { 579 public SupplicantStatus answer(byte[] bssid) throws RemoteException { 580 mSupplicantVariables.bssid = bssid; 581 return mStatusSuccess; 582 } 583 }).when(mISupplicantStaNetworkMock).setBssid(any(byte[].class)); 584 doAnswer(new AnswerWithArguments() { 585 public void answer(ISupplicantStaNetwork.getBssidCallback cb) throws RemoteException { 586 cb.onValues(mStatusSuccess, mSupplicantVariables.bssid); 587 } 588 }).when(mISupplicantStaNetworkMock) 589 .getBssid(any(ISupplicantStaNetwork.getBssidCallback.class)); 590 591 /** Scan SSID (Is Hidden Network?) */ 592 doAnswer(new AnswerWithArguments() { 593 public SupplicantStatus answer(boolean enable) throws RemoteException { 594 mSupplicantVariables.scanSsid = enable; 595 return mStatusSuccess; 596 } 597 }).when(mISupplicantStaNetworkMock).setScanSsid(any(boolean.class)); 598 doAnswer(new AnswerWithArguments() { 599 public void answer(ISupplicantStaNetwork.getScanSsidCallback cb) 600 throws RemoteException { 601 cb.onValues(mStatusSuccess, mSupplicantVariables.scanSsid); 602 } 603 }).when(mISupplicantStaNetworkMock) 604 .getScanSsid(any(ISupplicantStaNetwork.getScanSsidCallback.class)); 605 606 /** Require PMF*/ 607 doAnswer(new AnswerWithArguments() { 608 public SupplicantStatus answer(boolean enable) throws RemoteException { 609 mSupplicantVariables.requirePmf = enable; 610 return mStatusSuccess; 611 } 612 }).when(mISupplicantStaNetworkMock).setRequirePmf(any(boolean.class)); 613 doAnswer(new AnswerWithArguments() { 614 public void answer(ISupplicantStaNetwork.getRequirePmfCallback cb) 615 throws RemoteException { 616 cb.onValues(mStatusSuccess, mSupplicantVariables.requirePmf); 617 } 618 }).when(mISupplicantStaNetworkMock) 619 .getRequirePmf(any(ISupplicantStaNetwork.getRequirePmfCallback.class)); 620 621 /** PSK pass phrase*/ 622 doAnswer(new AnswerWithArguments() { 623 public SupplicantStatus answer(String pskPassphrase) throws RemoteException { 624 mSupplicantVariables.pskPassphrase = pskPassphrase; 625 return mStatusSuccess; 626 } 627 }).when(mISupplicantStaNetworkMock).setPskPassphrase(any(String.class)); 628 doAnswer(new AnswerWithArguments() { 629 public void answer(ISupplicantStaNetwork.getPskPassphraseCallback cb) 630 throws RemoteException { 631 cb.onValues(mStatusSuccess, mSupplicantVariables.pskPassphrase); 632 } 633 }).when(mISupplicantStaNetworkMock) 634 .getPskPassphrase(any(ISupplicantStaNetwork.getPskPassphraseCallback.class)); 635 636 /** WEP keys **/ 637 doAnswer(new AnswerWithArguments() { 638 public SupplicantStatus answer(int keyIdx, ArrayList<Byte> key) throws RemoteException { 639 mSupplicantVariables.wepKey[keyIdx] = key; 640 return mStatusSuccess; 641 } 642 }).when(mISupplicantStaNetworkMock).setWepKey(any(int.class), any(ArrayList.class)); 643 doAnswer(new AnswerWithArguments() { 644 public void answer(int keyIdx, ISupplicantStaNetwork.getWepKeyCallback cb) 645 throws RemoteException { 646 cb.onValues(mStatusSuccess, mSupplicantVariables.wepKey[keyIdx]); 647 } 648 }).when(mISupplicantStaNetworkMock) 649 .getWepKey(any(int.class), any(ISupplicantStaNetwork.getWepKeyCallback.class)); 650 651 doAnswer(new AnswerWithArguments() { 652 public SupplicantStatus answer(int keyIdx) throws RemoteException { 653 mSupplicantVariables.wepTxKeyIdx = keyIdx; 654 return mStatusSuccess; 655 } 656 }).when(mISupplicantStaNetworkMock).setWepTxKeyIdx(any(int.class)); 657 doAnswer(new AnswerWithArguments() { 658 public void answer(ISupplicantStaNetwork.getWepTxKeyIdxCallback cb) 659 throws RemoteException { 660 cb.onValues(mStatusSuccess, mSupplicantVariables.wepTxKeyIdx); 661 } 662 }).when(mISupplicantStaNetworkMock) 663 .getWepTxKeyIdx(any(ISupplicantStaNetwork.getWepTxKeyIdxCallback.class)); 664 665 /** allowedKeyManagement */ 666 doAnswer(new AnswerWithArguments() { 667 public SupplicantStatus answer(int mask) throws RemoteException { 668 mSupplicantVariables.keyMgmtMask = mask; 669 return mStatusSuccess; 670 } 671 }).when(mISupplicantStaNetworkMock).setKeyMgmt(any(int.class)); 672 doAnswer(new AnswerWithArguments() { 673 public void answer(ISupplicantStaNetwork.getKeyMgmtCallback cb) throws RemoteException { 674 cb.onValues(mStatusSuccess, mSupplicantVariables.keyMgmtMask); 675 } 676 }).when(mISupplicantStaNetworkMock) 677 .getKeyMgmt(any(ISupplicantStaNetwork.getKeyMgmtCallback.class)); 678 679 /** allowedProtocols */ 680 doAnswer(new AnswerWithArguments() { 681 public SupplicantStatus answer(int mask) throws RemoteException { 682 mSupplicantVariables.protoMask = mask; 683 return mStatusSuccess; 684 } 685 }).when(mISupplicantStaNetworkMock).setProto(any(int.class)); 686 doAnswer(new AnswerWithArguments() { 687 public void answer(ISupplicantStaNetwork.getProtoCallback cb) throws RemoteException { 688 cb.onValues(mStatusSuccess, mSupplicantVariables.protoMask); 689 } 690 }).when(mISupplicantStaNetworkMock) 691 .getProto(any(ISupplicantStaNetwork.getProtoCallback.class)); 692 693 /** allowedAuthAlgorithms */ 694 doAnswer(new AnswerWithArguments() { 695 public SupplicantStatus answer(int mask) throws RemoteException { 696 mSupplicantVariables.authAlgMask = mask; 697 return mStatusSuccess; 698 } 699 }).when(mISupplicantStaNetworkMock).setAuthAlg(any(int.class)); 700 doAnswer(new AnswerWithArguments() { 701 public void answer(ISupplicantStaNetwork.getAuthAlgCallback cb) throws RemoteException { 702 cb.onValues(mStatusSuccess, mSupplicantVariables.authAlgMask); 703 } 704 }).when(mISupplicantStaNetworkMock) 705 .getAuthAlg(any(ISupplicantStaNetwork.getAuthAlgCallback.class)); 706 707 /** allowedGroupCiphers */ 708 doAnswer(new AnswerWithArguments() { 709 public SupplicantStatus answer(int mask) throws RemoteException { 710 mSupplicantVariables.groupCipherMask = mask; 711 return mStatusSuccess; 712 } 713 }).when(mISupplicantStaNetworkMock).setGroupCipher(any(int.class)); 714 doAnswer(new AnswerWithArguments() { 715 public void answer(ISupplicantStaNetwork.getGroupCipherCallback cb) 716 throws RemoteException { 717 cb.onValues(mStatusSuccess, mSupplicantVariables.groupCipherMask); 718 } 719 }).when(mISupplicantStaNetworkMock) 720 .getGroupCipher(any(ISupplicantStaNetwork.getGroupCipherCallback.class)); 721 722 /** allowedPairwiseCiphers */ 723 doAnswer(new AnswerWithArguments() { 724 public SupplicantStatus answer(int mask) throws RemoteException { 725 mSupplicantVariables.pairwiseCipherMask = mask; 726 return mStatusSuccess; 727 } 728 }).when(mISupplicantStaNetworkMock).setPairwiseCipher(any(int.class)); 729 doAnswer(new AnswerWithArguments() { 730 public void answer(ISupplicantStaNetwork.getPairwiseCipherCallback cb) 731 throws RemoteException { 732 cb.onValues(mStatusSuccess, mSupplicantVariables.pairwiseCipherMask); 733 } 734 }).when(mISupplicantStaNetworkMock) 735 .getPairwiseCipher(any(ISupplicantStaNetwork.getPairwiseCipherCallback.class)); 736 737 /** metadata: idstr */ 738 doAnswer(new AnswerWithArguments() { 739 public SupplicantStatus answer(String idStr) throws RemoteException { 740 mSupplicantVariables.idStr = idStr; 741 return mStatusSuccess; 742 } 743 }).when(mISupplicantStaNetworkMock).setIdStr(any(String.class)); 744 doAnswer(new AnswerWithArguments() { 745 public void answer(ISupplicantStaNetwork.getIdStrCallback cb) throws RemoteException { 746 cb.onValues(mStatusSuccess, mSupplicantVariables.idStr); 747 } 748 }).when(mISupplicantStaNetworkMock) 749 .getIdStr(any(ISupplicantStaNetwork.getIdStrCallback.class)); 750 751 /** UpdateIdentifier */ 752 doAnswer(new AnswerWithArguments() { 753 public SupplicantStatus answer(int identifier) throws RemoteException { 754 mSupplicantVariables.updateIdentifier = identifier; 755 return mStatusSuccess; 756 } 757 }).when(mISupplicantStaNetworkMock).setUpdateIdentifier(any(int.class)); 758 759 /** EAP method */ 760 doAnswer(new AnswerWithArguments() { 761 public SupplicantStatus answer(int method) throws RemoteException { 762 mSupplicantVariables.eapMethod = method; 763 return mStatusSuccess; 764 } 765 }).when(mISupplicantStaNetworkMock).setEapMethod(any(int.class)); 766 doAnswer(new AnswerWithArguments() { 767 public void answer(ISupplicantStaNetwork.getEapMethodCallback cb) 768 throws RemoteException { 769 // When not set, return failure. 770 if (mSupplicantVariables.eapMethod == -1) { 771 cb.onValues(mStatusFailure, mSupplicantVariables.eapMethod); 772 } else { 773 cb.onValues(mStatusSuccess, mSupplicantVariables.eapMethod); 774 } 775 } 776 }).when(mISupplicantStaNetworkMock) 777 .getEapMethod(any(ISupplicantStaNetwork.getEapMethodCallback.class)); 778 779 /** EAP Phase 2 method */ 780 doAnswer(new AnswerWithArguments() { 781 public SupplicantStatus answer(int method) throws RemoteException { 782 mSupplicantVariables.eapPhase2Method = method; 783 return mStatusSuccess; 784 } 785 }).when(mISupplicantStaNetworkMock).setEapPhase2Method(any(int.class)); 786 doAnswer(new AnswerWithArguments() { 787 public void answer(ISupplicantStaNetwork.getEapPhase2MethodCallback cb) 788 throws RemoteException { 789 // When not set, return failure. 790 if (mSupplicantVariables.eapPhase2Method == -1) { 791 cb.onValues(mStatusFailure, mSupplicantVariables.eapPhase2Method); 792 } else { 793 cb.onValues(mStatusSuccess, mSupplicantVariables.eapPhase2Method); 794 } 795 } 796 }).when(mISupplicantStaNetworkMock) 797 .getEapPhase2Method(any(ISupplicantStaNetwork.getEapPhase2MethodCallback.class)); 798 799 /** EAP Identity */ 800 doAnswer(new AnswerWithArguments() { 801 public SupplicantStatus answer(ArrayList<Byte> identity) throws RemoteException { 802 mSupplicantVariables.eapIdentity = identity; 803 return mStatusSuccess; 804 } 805 }).when(mISupplicantStaNetworkMock).setEapIdentity(any(ArrayList.class)); 806 doAnswer(new AnswerWithArguments() { 807 public void answer(ISupplicantStaNetwork.getEapIdentityCallback cb) 808 throws RemoteException { 809 cb.onValues(mStatusSuccess, mSupplicantVariables.eapIdentity); 810 } 811 }).when(mISupplicantStaNetworkMock) 812 .getEapIdentity(any(ISupplicantStaNetwork.getEapIdentityCallback.class)); 813 814 /** EAP Anonymous Identity */ 815 doAnswer(new AnswerWithArguments() { 816 public SupplicantStatus answer(ArrayList<Byte> identity) throws RemoteException { 817 mSupplicantVariables.eapAnonymousIdentity = identity; 818 return mStatusSuccess; 819 } 820 }).when(mISupplicantStaNetworkMock).setEapAnonymousIdentity(any(ArrayList.class)); 821 doAnswer(new AnswerWithArguments() { 822 public void answer(ISupplicantStaNetwork.getEapAnonymousIdentityCallback cb) 823 throws RemoteException { 824 cb.onValues(mStatusSuccess, mSupplicantVariables.eapAnonymousIdentity); 825 } 826 }).when(mISupplicantStaNetworkMock) 827 .getEapAnonymousIdentity( 828 any(ISupplicantStaNetwork.getEapAnonymousIdentityCallback.class)); 829 830 /** EAP Password */ 831 doAnswer(new AnswerWithArguments() { 832 public SupplicantStatus answer(ArrayList<Byte> password) throws RemoteException { 833 mSupplicantVariables.eapPassword = password; 834 return mStatusSuccess; 835 } 836 }).when(mISupplicantStaNetworkMock).setEapPassword(any(ArrayList.class)); 837 doAnswer(new AnswerWithArguments() { 838 public void answer(ISupplicantStaNetwork.getEapPasswordCallback cb) 839 throws RemoteException { 840 cb.onValues(mStatusSuccess, mSupplicantVariables.eapPassword); 841 } 842 }).when(mISupplicantStaNetworkMock) 843 .getEapPassword(any(ISupplicantStaNetwork.getEapPasswordCallback.class)); 844 845 /** EAP Client Cert */ 846 doAnswer(new AnswerWithArguments() { 847 public SupplicantStatus answer(String cert) throws RemoteException { 848 mSupplicantVariables.eapClientCert = cert; 849 return mStatusSuccess; 850 } 851 }).when(mISupplicantStaNetworkMock).setEapClientCert(any(String.class)); 852 doAnswer(new AnswerWithArguments() { 853 public void answer(ISupplicantStaNetwork.getEapClientCertCallback cb) 854 throws RemoteException { 855 cb.onValues(mStatusSuccess, mSupplicantVariables.eapClientCert); 856 } 857 }).when(mISupplicantStaNetworkMock) 858 .getEapClientCert(any(ISupplicantStaNetwork.getEapClientCertCallback.class)); 859 860 /** EAP CA Cert */ 861 doAnswer(new AnswerWithArguments() { 862 public SupplicantStatus answer(String cert) throws RemoteException { 863 mSupplicantVariables.eapCACert = cert; 864 return mStatusSuccess; 865 } 866 }).when(mISupplicantStaNetworkMock).setEapCACert(any(String.class)); 867 doAnswer(new AnswerWithArguments() { 868 public void answer(ISupplicantStaNetwork.getEapCACertCallback cb) 869 throws RemoteException { 870 cb.onValues(mStatusSuccess, mSupplicantVariables.eapCACert); 871 } 872 }).when(mISupplicantStaNetworkMock) 873 .getEapCACert(any(ISupplicantStaNetwork.getEapCACertCallback.class)); 874 875 /** EAP Subject Match */ 876 doAnswer(new AnswerWithArguments() { 877 public SupplicantStatus answer(String match) throws RemoteException { 878 mSupplicantVariables.eapSubjectMatch = match; 879 return mStatusSuccess; 880 } 881 }).when(mISupplicantStaNetworkMock).setEapSubjectMatch(any(String.class)); 882 doAnswer(new AnswerWithArguments() { 883 public void answer(ISupplicantStaNetwork.getEapSubjectMatchCallback cb) 884 throws RemoteException { 885 cb.onValues(mStatusSuccess, mSupplicantVariables.eapSubjectMatch); 886 } 887 }).when(mISupplicantStaNetworkMock) 888 .getEapSubjectMatch(any(ISupplicantStaNetwork.getEapSubjectMatchCallback.class)); 889 890 /** EAP Engine */ 891 doAnswer(new AnswerWithArguments() { 892 public SupplicantStatus answer(boolean enable) throws RemoteException { 893 mSupplicantVariables.eapEngine = enable; 894 return mStatusSuccess; 895 } 896 }).when(mISupplicantStaNetworkMock).setEapEngine(any(boolean.class)); 897 doAnswer(new AnswerWithArguments() { 898 public void answer(ISupplicantStaNetwork.getEapEngineCallback cb) 899 throws RemoteException { 900 cb.onValues(mStatusSuccess, mSupplicantVariables.eapEngine); 901 } 902 }).when(mISupplicantStaNetworkMock) 903 .getEapEngine(any(ISupplicantStaNetwork.getEapEngineCallback.class)); 904 905 /** EAP Engine ID */ 906 doAnswer(new AnswerWithArguments() { 907 public SupplicantStatus answer(String id) throws RemoteException { 908 mSupplicantVariables.eapEngineID = id; 909 return mStatusSuccess; 910 } 911 }).when(mISupplicantStaNetworkMock).setEapEngineID(any(String.class)); 912 doAnswer(new AnswerWithArguments() { 913 public void answer(ISupplicantStaNetwork.getEapEngineIDCallback cb) 914 throws RemoteException { 915 cb.onValues(mStatusSuccess, mSupplicantVariables.eapEngineID); 916 } 917 }).when(mISupplicantStaNetworkMock) 918 .getEapEngineID(any(ISupplicantStaNetwork.getEapEngineIDCallback.class)); 919 920 /** EAP Private Key */ 921 doAnswer(new AnswerWithArguments() { 922 public SupplicantStatus answer(String key) throws RemoteException { 923 mSupplicantVariables.eapPrivateKey = key; 924 return mStatusSuccess; 925 } 926 }).when(mISupplicantStaNetworkMock).setEapPrivateKey(any(String.class)); 927 doAnswer(new AnswerWithArguments() { 928 public void answer(ISupplicantStaNetwork.getEapPrivateKeyCallback cb) 929 throws RemoteException { 930 cb.onValues(mStatusSuccess, mSupplicantVariables.eapPrivateKey); 931 } 932 }).when(mISupplicantStaNetworkMock) 933 .getEapPrivateKey(any(ISupplicantStaNetwork.getEapPrivateKeyCallback.class)); 934 935 /** EAP Alt Subject Match */ 936 doAnswer(new AnswerWithArguments() { 937 public SupplicantStatus answer(String match) throws RemoteException { 938 mSupplicantVariables.eapAltSubjectMatch = match; 939 return mStatusSuccess; 940 } 941 }).when(mISupplicantStaNetworkMock).setEapAltSubjectMatch(any(String.class)); 942 doAnswer(new AnswerWithArguments() { 943 public void answer(ISupplicantStaNetwork.getEapAltSubjectMatchCallback cb) 944 throws RemoteException { 945 cb.onValues(mStatusSuccess, mSupplicantVariables.eapAltSubjectMatch); 946 } 947 }).when(mISupplicantStaNetworkMock) 948 .getEapAltSubjectMatch( 949 any(ISupplicantStaNetwork.getEapAltSubjectMatchCallback.class)); 950 951 /** EAP Domain Suffix Match */ 952 doAnswer(new AnswerWithArguments() { 953 public SupplicantStatus answer(String match) throws RemoteException { 954 mSupplicantVariables.eapDomainSuffixMatch = match; 955 return mStatusSuccess; 956 } 957 }).when(mISupplicantStaNetworkMock).setEapDomainSuffixMatch(any(String.class)); 958 doAnswer(new AnswerWithArguments() { 959 public void answer(ISupplicantStaNetwork.getEapDomainSuffixMatchCallback cb) 960 throws RemoteException { 961 cb.onValues(mStatusSuccess, mSupplicantVariables.eapDomainSuffixMatch); 962 } 963 }).when(mISupplicantStaNetworkMock) 964 .getEapDomainSuffixMatch( 965 any(ISupplicantStaNetwork.getEapDomainSuffixMatchCallback.class)); 966 967 /** EAP CA Path*/ 968 doAnswer(new AnswerWithArguments() { 969 public SupplicantStatus answer(String path) throws RemoteException { 970 mSupplicantVariables.eapCAPath = path; 971 return mStatusSuccess; 972 } 973 }).when(mISupplicantStaNetworkMock).setEapCAPath(any(String.class)); 974 doAnswer(new AnswerWithArguments() { 975 public void answer(ISupplicantStaNetwork.getEapCAPathCallback cb) 976 throws RemoteException { 977 cb.onValues(mStatusSuccess, mSupplicantVariables.eapCAPath); 978 } 979 }).when(mISupplicantStaNetworkMock) 980 .getEapCAPath(any(ISupplicantStaNetwork.getEapCAPathCallback.class)); 981 982 /** EAP Proactive Key Caching */ 983 doAnswer(new AnswerWithArguments() { 984 public SupplicantStatus answer(boolean enable) throws RemoteException { 985 mSupplicantVariables.eapProactiveKeyCaching = enable; 986 return mStatusSuccess; 987 } 988 }).when(mISupplicantStaNetworkMock).setProactiveKeyCaching(any(boolean.class)); 989 } 990 991 private SupplicantStatus createSupplicantStatus(int code) { 992 SupplicantStatus status = new SupplicantStatus(); 993 status.code = code; 994 return status; 995 } 996 997 // Private class to to store/inspect values set via the HIDL mock. 998 private class SupplicantNetworkVariables { 999 public ArrayList<Byte> ssid; 1000 public byte[/* 6 */] bssid; 1001 public int keyMgmtMask; 1002 public int protoMask; 1003 public int authAlgMask; 1004 public int groupCipherMask; 1005 public int pairwiseCipherMask; 1006 public boolean scanSsid; 1007 public boolean requirePmf; 1008 public String idStr; 1009 public int updateIdentifier; 1010 public String pskPassphrase; 1011 public ArrayList<Byte>[] wepKey = new ArrayList[4]; 1012 public int wepTxKeyIdx; 1013 public int eapMethod = -1; 1014 public int eapPhase2Method = -1; 1015 public ArrayList<Byte> eapIdentity; 1016 public ArrayList<Byte> eapAnonymousIdentity; 1017 public ArrayList<Byte> eapPassword; 1018 public String eapCACert; 1019 public String eapCAPath; 1020 public String eapClientCert; 1021 public String eapPrivateKey; 1022 public String eapSubjectMatch; 1023 public String eapAltSubjectMatch; 1024 public boolean eapEngine; 1025 public String eapEngineID; 1026 public String eapDomainSuffixMatch; 1027 public boolean eapProactiveKeyCaching; 1028 } 1029} 1030