1 /*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <android-base/logging.h>
18 #include <android-base/macros.h>
19 #include <cutils/properties.h>
20 #include <gmock/gmock.h>
21
22 #include "wifi_chip.h"
23
24 #include "mock_interface_tool.h"
25 #include "mock_wifi_feature_flags.h"
26 #include "mock_wifi_iface_util.h"
27 #include "mock_wifi_legacy_hal.h"
28 #include "mock_wifi_mode_controller.h"
29
30 using testing::NiceMock;
31 using testing::Return;
32 using testing::Test;
33
34 namespace {
35 constexpr int kFakeChipId = 5;
36 } // namespace
37
38 namespace aidl {
39 namespace android {
40 namespace hardware {
41 namespace wifi {
42
43 class WifiChipTest : public Test {
44 protected:
setupV1IfaceCombination()45 void setupV1IfaceCombination() {
46 // clang-format off
47 // 1 STA + 1 P2P
48 const std::vector<IWifiChip::ChipConcurrencyCombination> combinationsSta =
49 {
50 {
51 {
52 {{IfaceConcurrencyType::STA}, 1},
53 {{IfaceConcurrencyType::P2P}, 1}
54 }
55 }
56 };
57 // 1 AP
58 const std::vector<IWifiChip::ChipConcurrencyCombination> combinationsAp =
59 {
60 {
61 {
62 {{IfaceConcurrencyType::AP}, 1}
63 }
64 }
65 };
66 const std::vector<IWifiChip::ChipMode> modes = {
67 {feature_flags::chip_mode_ids::kV1Sta, combinationsSta},
68 {feature_flags::chip_mode_ids::kV1Ap, combinationsAp}
69 };
70 // clang-format on
71 EXPECT_CALL(*feature_flags_, getChipModes(true)).WillRepeatedly(testing::Return(modes));
72 }
73
setupV1_AwareIfaceCombination()74 void setupV1_AwareIfaceCombination() {
75 // clang-format off
76 // 1 STA + 1 of (P2P or NAN)
77 const std::vector<IWifiChip::ChipConcurrencyCombination> combinationsSta =
78 {
79 {
80 {
81 {{IfaceConcurrencyType::STA}, 1},
82 {{IfaceConcurrencyType::P2P, IfaceConcurrencyType::NAN_IFACE}, 1}
83 }
84 }
85 };
86 // 1 AP
87 const std::vector<IWifiChip::ChipConcurrencyCombination> combinationsAp =
88 {
89 {
90 {
91 {{IfaceConcurrencyType::AP}, 1}
92 }
93 }
94 };
95 const std::vector<IWifiChip::ChipMode> modes = {
96 {feature_flags::chip_mode_ids::kV1Sta, combinationsSta},
97 {feature_flags::chip_mode_ids::kV1Ap, combinationsAp}
98 };
99 // clang-format on
100 EXPECT_CALL(*feature_flags_, getChipModes(true)).WillRepeatedly(testing::Return(modes));
101 }
102
setupV1_AwareDisabledApIfaceCombination()103 void setupV1_AwareDisabledApIfaceCombination() {
104 // clang-format off
105 // 1 STA + 1 of (P2P or NAN)
106 const std::vector<IWifiChip::ChipConcurrencyCombination> combinationsSta =
107 {
108 {
109 {
110 {{IfaceConcurrencyType::STA}, 1},
111 {{IfaceConcurrencyType::P2P, IfaceConcurrencyType::NAN_IFACE}, 1}
112 }
113 }
114 };
115 const std::vector<IWifiChip::ChipMode> modes = {
116 {feature_flags::chip_mode_ids::kV1Sta, combinationsSta}
117 };
118 // clang-format on
119 EXPECT_CALL(*feature_flags_, getChipModes(true)).WillRepeatedly(testing::Return(modes));
120 }
121
setupV2_AwareIfaceCombination()122 void setupV2_AwareIfaceCombination() {
123 // clang-format off
124 // (1 STA + 1 AP) or (1 STA + 1 of (P2P or NAN))
125 const std::vector<IWifiChip::ChipConcurrencyCombination> combinations =
126 {
127 {
128 {
129 {{IfaceConcurrencyType::STA}, 1},
130 {{IfaceConcurrencyType::AP}, 1}
131 }
132 },
133 {
134 {
135 {{IfaceConcurrencyType::STA}, 1},
136 {{IfaceConcurrencyType::P2P, IfaceConcurrencyType::NAN_IFACE}, 1}
137 }
138 }
139 };
140 const std::vector<IWifiChip::ChipMode> modes = {
141 {feature_flags::chip_mode_ids::kV3, combinations}
142 };
143 // clang-format on
144 EXPECT_CALL(*feature_flags_, getChipModes(true)).WillRepeatedly(testing::Return(modes));
145 }
146
setupV2_AwareDisabledApIfaceCombination()147 void setupV2_AwareDisabledApIfaceCombination() {
148 // clang-format off
149 // 1 STA + 1 of (P2P or NAN)
150 const std::vector<IWifiChip::ChipConcurrencyCombination> combinations =
151 {
152 {
153 {
154 {{IfaceConcurrencyType::STA}, 1},
155 {{IfaceConcurrencyType::P2P, IfaceConcurrencyType::NAN_IFACE}, 1}
156 }
157 }
158 };
159 const std::vector<IWifiChip::ChipMode> modes = {
160 {feature_flags::chip_mode_ids::kV3, combinations}
161 };
162 // clang-format on
163 EXPECT_CALL(*feature_flags_, getChipModes(true)).WillRepeatedly(testing::Return(modes));
164 }
165
setup_MultiIfaceCombination()166 void setup_MultiIfaceCombination() {
167 // clang-format off
168 // 3 STA + 1 AP
169 const std::vector<IWifiChip::ChipConcurrencyCombination> combinations =
170 {
171 {
172 {
173 {{IfaceConcurrencyType::STA}, 3},
174 {{IfaceConcurrencyType::AP}, 1}
175 }
176 }
177 };
178 const std::vector<IWifiChip::ChipMode> modes = {
179 {feature_flags::chip_mode_ids::kV3, combinations}
180 };
181 // clang-format on
182 EXPECT_CALL(*feature_flags_, getChipModes(true)).WillRepeatedly(testing::Return(modes));
183 }
184
assertNumberOfModes(uint32_t num_modes)185 void assertNumberOfModes(uint32_t num_modes) {
186 std::vector<IWifiChip::ChipMode> modes;
187 ASSERT_TRUE(chip_->getAvailableModes(&modes).isOk());
188 // V2_Aware has 1 mode of operation.
189 ASSERT_EQ(num_modes, modes.size());
190 }
191
findModeAndConfigureForIfaceType(const IfaceConcurrencyType & type)192 void findModeAndConfigureForIfaceType(const IfaceConcurrencyType& type) {
193 // This should be aligned with kInvalidModeId in wifi_chip.cpp
194 int32_t mode_id = INT32_MAX;
195 std::vector<IWifiChip::ChipMode> modes;
196 ASSERT_TRUE(chip_->getAvailableModes(&modes).isOk());
197
198 for (const auto& mode : modes) {
199 for (const auto& combination : mode.availableCombinations) {
200 for (const auto& limit : combination.limits) {
201 if (limit.types.end() !=
202 std::find(limit.types.begin(), limit.types.end(), type)) {
203 mode_id = mode.id;
204 }
205 }
206 }
207 }
208
209 ASSERT_NE(INT32_MAX, mode_id);
210 ASSERT_TRUE(chip_->configureChip(mode_id).isOk());
211 }
212
213 // Returns an empty string on error.
createIface(const IfaceType & type)214 std::string createIface(const IfaceType& type) {
215 std::string iface_name;
216 if (type == IfaceType::AP) {
217 std::shared_ptr<IWifiApIface> iface;
218 if (!chip_->createApIface(&iface).isOk()) {
219 return "";
220 }
221 EXPECT_NE(iface.get(), nullptr);
222 EXPECT_TRUE(iface->getName(&iface_name).isOk());
223 } else if (type == IfaceType::NAN_IFACE) {
224 std::shared_ptr<IWifiNanIface> iface;
225 if (!chip_->createNanIface(&iface).isOk()) {
226 return "";
227 }
228 EXPECT_NE(iface.get(), nullptr);
229 EXPECT_TRUE(iface->getName(&iface_name).isOk());
230 } else if (type == IfaceType::P2P) {
231 std::shared_ptr<IWifiP2pIface> iface;
232 if (!chip_->createP2pIface(&iface).isOk()) {
233 return "";
234 }
235 EXPECT_NE(iface.get(), nullptr);
236 EXPECT_TRUE(iface->getName(&iface_name).isOk());
237 } else if (type == IfaceType::STA) {
238 std::shared_ptr<IWifiStaIface> iface;
239 if (!chip_->createStaIface(&iface).isOk()) {
240 return "";
241 }
242 EXPECT_NE(iface.get(), nullptr);
243 EXPECT_TRUE(iface->getName(&iface_name).isOk());
244 }
245 return iface_name;
246 }
247
removeIface(const IfaceType & type,const std::string & iface_name)248 void removeIface(const IfaceType& type, const std::string& iface_name) {
249 if (type == IfaceType::AP) {
250 ASSERT_TRUE(chip_->removeApIface(iface_name).isOk());
251 } else if (type == IfaceType::NAN_IFACE) {
252 ASSERT_TRUE(chip_->removeNanIface(iface_name).isOk());
253 } else if (type == IfaceType::P2P) {
254 ASSERT_TRUE(chip_->removeP2pIface(iface_name).isOk());
255 } else if (type == IfaceType::STA) {
256 ASSERT_TRUE(chip_->removeStaIface(iface_name).isOk());
257 }
258 }
259
createRttController()260 bool createRttController() {
261 std::shared_ptr<IWifiRttController> rtt_controller;
262 auto status = chip_->createRttController(nullptr, &rtt_controller);
263 return status.isOk();
264 }
265
subsystemRestartHandler(const std::string &)266 static void subsystemRestartHandler(const std::string& /*error*/) {}
267
268 std::shared_ptr<WifiChip> chip_;
269 int chip_id_ = kFakeChipId;
270 legacy_hal::wifi_hal_fn fake_func_table_;
271 std::shared_ptr<NiceMock<::android::wifi_system::MockInterfaceTool>> iface_tool_{
272 new NiceMock<::android::wifi_system::MockInterfaceTool>};
273 std::shared_ptr<NiceMock<legacy_hal::MockWifiLegacyHal>> legacy_hal_{
274 new NiceMock<legacy_hal::MockWifiLegacyHal>(iface_tool_, fake_func_table_, true)};
275 std::shared_ptr<NiceMock<mode_controller::MockWifiModeController>> mode_controller_{
276 new NiceMock<mode_controller::MockWifiModeController>};
277 std::shared_ptr<NiceMock<iface_util::MockWifiIfaceUtil>> iface_util_{
278 new NiceMock<iface_util::MockWifiIfaceUtil>(iface_tool_, legacy_hal_)};
279 std::shared_ptr<NiceMock<feature_flags::MockWifiFeatureFlags>> feature_flags_{
280 new NiceMock<feature_flags::MockWifiFeatureFlags>};
281
282 public:
SetUp()283 void SetUp() override {
284 chip_ = WifiChip::create(chip_id_, true, legacy_hal_, mode_controller_, iface_util_,
285 feature_flags_, subsystemRestartHandler, true);
286
287 EXPECT_CALL(*mode_controller_, changeFirmwareMode(testing::_))
288 .WillRepeatedly(testing::Return(true));
289 EXPECT_CALL(*legacy_hal_, start())
290 .WillRepeatedly(testing::Return(legacy_hal::WIFI_SUCCESS));
291 // Vendor HAL does not override the name by default.
292 EXPECT_CALL(*legacy_hal_, getSupportedIfaceName(testing::_, testing::_))
293 .WillRepeatedly(testing::Return(legacy_hal::WIFI_ERROR_UNKNOWN));
294 }
295
TearDown()296 void TearDown() override {
297 // Restore default system iface names (This should ideally be using a
298 // mock).
299 property_set("wifi.interface", "wlan0");
300 property_set("wifi.concurrent.interface", "wlan1");
301 property_set("wifi.aware.interface", nullptr);
302 }
303 };
304
305 ////////// V1 Iface Combinations ////////////
306 // Mode 1 - STA + P2P
307 // Mode 2 - AP
308 class WifiChipV1IfaceCombinationTest : public WifiChipTest {
309 public:
SetUp()310 void SetUp() override {
311 setupV1IfaceCombination();
312 WifiChipTest::SetUp();
313 // V1 has 2 modes of operation.
314 assertNumberOfModes(2);
315 }
316 };
317
TEST_F(WifiChipV1IfaceCombinationTest,StaMode_CreateSta_ShouldSucceed)318 TEST_F(WifiChipV1IfaceCombinationTest, StaMode_CreateSta_ShouldSucceed) {
319 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
320 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
321 }
322
TEST_F(WifiChipV1IfaceCombinationTest,StaMode_CreateP2p_ShouldSucceed)323 TEST_F(WifiChipV1IfaceCombinationTest, StaMode_CreateP2p_ShouldSucceed) {
324 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
325 ASSERT_FALSE(createIface(IfaceType::P2P).empty());
326 }
327
TEST_F(WifiChipV1IfaceCombinationTest,StaMode_CreateNan_ShouldFail)328 TEST_F(WifiChipV1IfaceCombinationTest, StaMode_CreateNan_ShouldFail) {
329 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
330 ASSERT_TRUE(createIface(IfaceType::NAN_IFACE).empty());
331 }
332
TEST_F(WifiChipV1IfaceCombinationTest,StaMode_CreateAp_ShouldFail)333 TEST_F(WifiChipV1IfaceCombinationTest, StaMode_CreateAp_ShouldFail) {
334 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
335 ASSERT_TRUE(createIface(IfaceType::AP).empty());
336 }
337
TEST_F(WifiChipV1IfaceCombinationTest,StaMode_CreateStaP2p_ShouldSucceed)338 TEST_F(WifiChipV1IfaceCombinationTest, StaMode_CreateStaP2p_ShouldSucceed) {
339 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
340 ASSERT_FALSE(createIface(IfaceType::STA).empty());
341 ASSERT_FALSE(createIface(IfaceType::P2P).empty());
342 }
343
TEST_F(WifiChipV1IfaceCombinationTest,ApMode_CreateAp_ShouldSucceed)344 TEST_F(WifiChipV1IfaceCombinationTest, ApMode_CreateAp_ShouldSucceed) {
345 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
346 ASSERT_EQ(createIface(IfaceType::AP), "wlan0");
347 }
348
TEST_F(WifiChipV1IfaceCombinationTest,ApMode_CreateSta_ShouldFail)349 TEST_F(WifiChipV1IfaceCombinationTest, ApMode_CreateSta_ShouldFail) {
350 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
351 ASSERT_TRUE(createIface(IfaceType::STA).empty());
352 }
353
TEST_F(WifiChipV1IfaceCombinationTest,ApMode_CreateP2p_ShouldFail)354 TEST_F(WifiChipV1IfaceCombinationTest, ApMode_CreateP2p_ShouldFail) {
355 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
356 ASSERT_TRUE(createIface(IfaceType::STA).empty());
357 }
358
TEST_F(WifiChipV1IfaceCombinationTest,ApMode_CreateNan_ShouldFail)359 TEST_F(WifiChipV1IfaceCombinationTest, ApMode_CreateNan_ShouldFail) {
360 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
361 ASSERT_TRUE(createIface(IfaceType::NAN_IFACE).empty());
362 }
363
364 ////////// V1 + Aware Iface Combinations ////////////
365 // Mode 1 - STA + P2P/NAN
366 // Mode 2 - AP
367 class WifiChipV1_AwareIfaceCombinationTest : public WifiChipTest {
368 public:
SetUp()369 void SetUp() override {
370 setupV1_AwareIfaceCombination();
371 WifiChipTest::SetUp();
372 // V1_Aware has 2 modes of operation.
373 assertNumberOfModes(2u);
374 }
375 };
376
TEST_F(WifiChipV1_AwareIfaceCombinationTest,StaMode_CreateSta_ShouldSucceed)377 TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateSta_ShouldSucceed) {
378 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
379 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
380 }
381
TEST_F(WifiChipV1_AwareIfaceCombinationTest,StaMode_CreateP2p_ShouldSucceed)382 TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateP2p_ShouldSucceed) {
383 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
384 ASSERT_FALSE(createIface(IfaceType::P2P).empty());
385 }
386
TEST_F(WifiChipV1_AwareIfaceCombinationTest,StaMode_CreateNan_ShouldSucceed)387 TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateNan_ShouldSucceed) {
388 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
389 ASSERT_FALSE(createIface(IfaceType::NAN_IFACE).empty());
390 }
391
TEST_F(WifiChipV1_AwareIfaceCombinationTest,StaMode_CreateAp_ShouldFail)392 TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateAp_ShouldFail) {
393 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
394 ASSERT_TRUE(createIface(IfaceType::AP).empty());
395 }
396
TEST_F(WifiChipV1_AwareIfaceCombinationTest,StaMode_CreateStaP2p_ShouldSucceed)397 TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateStaP2p_ShouldSucceed) {
398 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
399 ASSERT_FALSE(createIface(IfaceType::STA).empty());
400 ASSERT_FALSE(createIface(IfaceType::P2P).empty());
401 }
402
TEST_F(WifiChipV1_AwareIfaceCombinationTest,StaMode_CreateStaNan_ShouldSucceed)403 TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateStaNan_ShouldSucceed) {
404 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
405 ASSERT_FALSE(createIface(IfaceType::STA).empty());
406 ASSERT_FALSE(createIface(IfaceType::NAN_IFACE).empty());
407 }
408
TEST_F(WifiChipV1_AwareIfaceCombinationTest,StaMode_CreateStaP2PNan_ShouldFail)409 TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateStaP2PNan_ShouldFail) {
410 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
411 ASSERT_FALSE(createIface(IfaceType::STA).empty());
412 ASSERT_FALSE(createIface(IfaceType::P2P).empty());
413 ASSERT_TRUE(createIface(IfaceType::NAN_IFACE).empty());
414 }
415
TEST_F(WifiChipV1_AwareIfaceCombinationTest,StaMode_CreateStaNan_AfterP2pRemove_ShouldSucceed)416 TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateStaNan_AfterP2pRemove_ShouldSucceed) {
417 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
418 ASSERT_FALSE(createIface(IfaceType::STA).empty());
419 std::string p2p_iface_name = createIface(IfaceType::P2P);
420 ASSERT_FALSE(p2p_iface_name.empty());
421 ASSERT_TRUE(createIface(IfaceType::NAN_IFACE).empty());
422
423 // After removing P2P iface, NAN iface creation should succeed.
424 removeIface(IfaceType::P2P, p2p_iface_name);
425 ASSERT_FALSE(createIface(IfaceType::NAN_IFACE).empty());
426 }
427
TEST_F(WifiChipV1_AwareIfaceCombinationTest,StaMode_CreateStaP2p_AfterNanRemove_ShouldSucceed)428 TEST_F(WifiChipV1_AwareIfaceCombinationTest, StaMode_CreateStaP2p_AfterNanRemove_ShouldSucceed) {
429 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
430 ASSERT_FALSE(createIface(IfaceType::STA).empty());
431 std::string nan_iface_name = createIface(IfaceType::NAN_IFACE);
432 ASSERT_FALSE(nan_iface_name.empty());
433 ASSERT_TRUE(createIface(IfaceType::P2P).empty());
434
435 // After removing NAN iface, P2P iface creation should succeed.
436 removeIface(IfaceType::NAN_IFACE, nan_iface_name);
437 ASSERT_FALSE(createIface(IfaceType::P2P).empty());
438 }
439
TEST_F(WifiChipV1_AwareIfaceCombinationTest,ApMode_CreateAp_ShouldSucceed)440 TEST_F(WifiChipV1_AwareIfaceCombinationTest, ApMode_CreateAp_ShouldSucceed) {
441 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
442 ASSERT_EQ(createIface(IfaceType::AP), "wlan0");
443 }
444
TEST_F(WifiChipV1_AwareIfaceCombinationTest,ApMode_CreateSta_ShouldFail)445 TEST_F(WifiChipV1_AwareIfaceCombinationTest, ApMode_CreateSta_ShouldFail) {
446 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
447 ASSERT_TRUE(createIface(IfaceType::STA).empty());
448 }
449
TEST_F(WifiChipV1_AwareIfaceCombinationTest,ApMode_CreateP2p_ShouldFail)450 TEST_F(WifiChipV1_AwareIfaceCombinationTest, ApMode_CreateP2p_ShouldFail) {
451 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
452 ASSERT_TRUE(createIface(IfaceType::STA).empty());
453 }
454
TEST_F(WifiChipV1_AwareIfaceCombinationTest,ApMode_CreateNan_ShouldFail)455 TEST_F(WifiChipV1_AwareIfaceCombinationTest, ApMode_CreateNan_ShouldFail) {
456 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
457 ASSERT_TRUE(createIface(IfaceType::NAN_IFACE).empty());
458 }
459
TEST_F(WifiChipV1_AwareIfaceCombinationTest,RttControllerFlowStaModeNoSta)460 TEST_F(WifiChipV1_AwareIfaceCombinationTest, RttControllerFlowStaModeNoSta) {
461 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
462 ASSERT_TRUE(createRttController());
463 }
464
TEST_F(WifiChipV1_AwareIfaceCombinationTest,RttControllerFlowStaModeWithSta)465 TEST_F(WifiChipV1_AwareIfaceCombinationTest, RttControllerFlowStaModeWithSta) {
466 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
467 ASSERT_FALSE(createIface(IfaceType::STA).empty());
468 ASSERT_TRUE(createRttController());
469 }
470
TEST_F(WifiChipV1_AwareIfaceCombinationTest,RttControllerFlowApToSta)471 TEST_F(WifiChipV1_AwareIfaceCombinationTest, RttControllerFlowApToSta) {
472 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
473 std::string ap_iface_name = createIface(IfaceType::AP);
474 ASSERT_FALSE(ap_iface_name.empty());
475 ASSERT_FALSE(createRttController());
476
477 removeIface(IfaceType::AP, ap_iface_name);
478
479 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
480 ASSERT_TRUE(createRttController());
481 }
482
TEST_F(WifiChipV1_AwareIfaceCombinationTest,SelectTxScenarioWithOnlySta)483 TEST_F(WifiChipV1_AwareIfaceCombinationTest, SelectTxScenarioWithOnlySta) {
484 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
485 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
486 EXPECT_CALL(*legacy_hal_, selectTxPowerScenario("wlan0", testing::_))
487 .WillOnce(testing::Return(legacy_hal::WIFI_SUCCESS));
488 ASSERT_TRUE(chip_->selectTxPowerScenario(IWifiChip::TxPowerScenario::ON_HEAD_CELL_OFF).isOk());
489 }
490
TEST_F(WifiChipV1_AwareIfaceCombinationTest,SelectTxScenarioWithOnlyAp)491 TEST_F(WifiChipV1_AwareIfaceCombinationTest, SelectTxScenarioWithOnlyAp) {
492 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
493 ASSERT_EQ(createIface(IfaceType::AP), "wlan0");
494 EXPECT_CALL(*legacy_hal_, selectTxPowerScenario("wlan0", testing::_))
495 .WillOnce(testing::Return(legacy_hal::WIFI_SUCCESS));
496 ASSERT_TRUE(chip_->selectTxPowerScenario(IWifiChip::TxPowerScenario::ON_HEAD_CELL_OFF).isOk());
497 }
498
499 ////////// V2 + Aware Iface Combinations ////////////
500 // Mode 1 - STA + STA/AP
501 // - STA + P2P/NAN
502 class WifiChipV2_AwareIfaceCombinationTest : public WifiChipTest {
503 public:
SetUp()504 void SetUp() override {
505 setupV2_AwareIfaceCombination();
506 WifiChipTest::SetUp();
507 // V2_Aware has 1 mode of operation.
508 assertNumberOfModes(1u);
509 }
510 };
511
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateSta_ShouldSucceed)512 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateSta_ShouldSucceed) {
513 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
514 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
515 }
516
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateP2p_ShouldSucceed)517 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateP2p_ShouldSucceed) {
518 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
519 ASSERT_FALSE(createIface(IfaceType::P2P).empty());
520 }
521
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateNan_ShouldSucceed)522 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateNan_ShouldSucceed) {
523 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
524 ASSERT_FALSE(createIface(IfaceType::NAN_IFACE).empty());
525 }
526
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateAp_ShouldSucceed)527 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateAp_ShouldSucceed) {
528 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
529 ASSERT_EQ(createIface(IfaceType::AP), "wlan1");
530 }
531
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateStaSta_ShouldFail)532 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaSta_ShouldFail) {
533 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
534 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
535 ASSERT_TRUE(createIface(IfaceType::STA).empty());
536 }
537
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateStaAp_ShouldSucceed)538 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaAp_ShouldSucceed) {
539 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
540 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
541 ASSERT_EQ(createIface(IfaceType::AP), "wlan1");
542 }
543
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateApSta_ShouldSucceed)544 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateApSta_ShouldSucceed) {
545 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
546 ASSERT_EQ(createIface(IfaceType::AP), "wlan1");
547 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
548 }
549
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateSta_AfterStaApRemove_ShouldSucceed)550 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateSta_AfterStaApRemove_ShouldSucceed) {
551 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
552 std::string sta_iface_name = createIface(IfaceType::STA);
553 ASSERT_FALSE(sta_iface_name.empty());
554 std::string ap_iface_name = createIface(IfaceType::AP);
555 ASSERT_FALSE(ap_iface_name.empty());
556
557 ASSERT_TRUE(createIface(IfaceType::STA).empty());
558
559 // After removing AP & STA iface, STA iface creation should succeed.
560 removeIface(IfaceType::STA, sta_iface_name);
561 removeIface(IfaceType::AP, ap_iface_name);
562 ASSERT_FALSE(createIface(IfaceType::STA).empty());
563 }
564
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateStaP2p_ShouldSucceed)565 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaP2p_ShouldSucceed) {
566 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
567 ASSERT_FALSE(createIface(IfaceType::STA).empty());
568 ASSERT_FALSE(createIface(IfaceType::P2P).empty());
569 }
570
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateStaNan_ShouldSucceed)571 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaNan_ShouldSucceed) {
572 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
573 ASSERT_FALSE(createIface(IfaceType::STA).empty());
574 ASSERT_FALSE(createIface(IfaceType::NAN_IFACE).empty());
575 }
576
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateStaP2PNan_ShouldFail)577 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaP2PNan_ShouldFail) {
578 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
579 ASSERT_FALSE(createIface(IfaceType::STA).empty());
580 ASSERT_FALSE(createIface(IfaceType::P2P).empty());
581 ASSERT_TRUE(createIface(IfaceType::NAN_IFACE).empty());
582 }
583
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateStaNan_AfterP2pRemove_ShouldSucceed)584 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaNan_AfterP2pRemove_ShouldSucceed) {
585 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
586 ASSERT_FALSE(createIface(IfaceType::STA).empty());
587 std::string p2p_iface_name = createIface(IfaceType::P2P);
588 ASSERT_FALSE(p2p_iface_name.empty());
589 ASSERT_TRUE(createIface(IfaceType::NAN_IFACE).empty());
590
591 // After removing P2P iface, NAN iface creation should succeed.
592 removeIface(IfaceType::P2P, p2p_iface_name);
593 ASSERT_FALSE(createIface(IfaceType::NAN_IFACE).empty());
594 }
595
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateStaP2p_AfterNanRemove_ShouldSucceed)596 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaP2p_AfterNanRemove_ShouldSucceed) {
597 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
598 ASSERT_FALSE(createIface(IfaceType::STA).empty());
599 std::string nan_iface_name = createIface(IfaceType::NAN_IFACE);
600 ASSERT_FALSE(nan_iface_name.empty());
601 ASSERT_TRUE(createIface(IfaceType::P2P).empty());
602
603 // After removing NAN iface, P2P iface creation should succeed.
604 removeIface(IfaceType::NAN_IFACE, nan_iface_name);
605 ASSERT_FALSE(createIface(IfaceType::P2P).empty());
606 }
607
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateApNan_ShouldFail)608 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateApNan_ShouldFail) {
609 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
610 ASSERT_FALSE(createIface(IfaceType::AP).empty());
611 ASSERT_TRUE(createIface(IfaceType::NAN_IFACE).empty());
612 }
613
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateApP2p_ShouldFail)614 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateApP2p_ShouldFail) {
615 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
616 ASSERT_FALSE(createIface(IfaceType::AP).empty());
617 ASSERT_TRUE(createIface(IfaceType::P2P).empty());
618 }
619
TEST_F(WifiChipV2_AwareIfaceCombinationTest,StaMode_CreateStaNan_AfterP2pRemove_ShouldSucceed)620 TEST_F(WifiChipV2_AwareIfaceCombinationTest, StaMode_CreateStaNan_AfterP2pRemove_ShouldSucceed) {
621 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
622 ASSERT_FALSE(createIface(IfaceType::STA).empty());
623 std::string p2p_iface_name = createIface(IfaceType::P2P);
624 ASSERT_FALSE(p2p_iface_name.empty());
625 ASSERT_TRUE(createIface(IfaceType::NAN_IFACE).empty());
626
627 // After removing P2P iface, NAN iface creation should succeed.
628 removeIface(IfaceType::P2P, p2p_iface_name);
629 ASSERT_FALSE(createIface(IfaceType::NAN_IFACE).empty());
630 }
631
TEST_F(WifiChipV2_AwareIfaceCombinationTest,StaMode_CreateStaP2p_AfterNanRemove_ShouldSucceed)632 TEST_F(WifiChipV2_AwareIfaceCombinationTest, StaMode_CreateStaP2p_AfterNanRemove_ShouldSucceed) {
633 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
634 ASSERT_FALSE(createIface(IfaceType::STA).empty());
635 std::string nan_iface_name = createIface(IfaceType::NAN_IFACE);
636 ASSERT_FALSE(nan_iface_name.empty());
637 ASSERT_TRUE(createIface(IfaceType::P2P).empty());
638
639 // After removing NAN iface, P2P iface creation should succeed.
640 removeIface(IfaceType::NAN_IFACE, nan_iface_name);
641 ASSERT_FALSE(createIface(IfaceType::P2P).empty());
642 }
643
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateStaAp_EnsureDifferentIfaceNames)644 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateStaAp_EnsureDifferentIfaceNames) {
645 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
646 std::string sta_iface_name = createIface(IfaceType::STA);
647 std::string ap_iface_name = createIface(IfaceType::AP);
648 ASSERT_FALSE(sta_iface_name.empty());
649 ASSERT_FALSE(ap_iface_name.empty());
650 ASSERT_NE(sta_iface_name, ap_iface_name);
651 }
652
TEST_F(WifiChipV2_AwareIfaceCombinationTest,RttControllerFlowStaModeNoSta)653 TEST_F(WifiChipV2_AwareIfaceCombinationTest, RttControllerFlowStaModeNoSta) {
654 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
655 ASSERT_TRUE(createRttController());
656 }
657
TEST_F(WifiChipV2_AwareIfaceCombinationTest,RttControllerFlowStaModeWithSta)658 TEST_F(WifiChipV2_AwareIfaceCombinationTest, RttControllerFlowStaModeWithSta) {
659 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
660 ASSERT_FALSE(createIface(IfaceType::STA).empty());
661 ASSERT_TRUE(createRttController());
662 }
663
TEST_F(WifiChipV2_AwareIfaceCombinationTest,RttControllerFlow)664 TEST_F(WifiChipV2_AwareIfaceCombinationTest, RttControllerFlow) {
665 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
666 ASSERT_FALSE(createIface(IfaceType::STA).empty());
667 ASSERT_FALSE(createIface(IfaceType::AP).empty());
668 ASSERT_TRUE(createRttController());
669 }
670
TEST_F(WifiChipV2_AwareIfaceCombinationTest,SelectTxScenarioWithOnlySta)671 TEST_F(WifiChipV2_AwareIfaceCombinationTest, SelectTxScenarioWithOnlySta) {
672 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
673 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
674 EXPECT_CALL(*legacy_hal_, selectTxPowerScenario("wlan0", testing::_))
675 .WillOnce(testing::Return(legacy_hal::WIFI_SUCCESS));
676 ASSERT_TRUE(chip_->selectTxPowerScenario(IWifiChip::TxPowerScenario::ON_HEAD_CELL_OFF).isOk());
677 }
678
TEST_F(WifiChipV2_AwareIfaceCombinationTest,SelectTxScenarioWithOnlyAp)679 TEST_F(WifiChipV2_AwareIfaceCombinationTest, SelectTxScenarioWithOnlyAp) {
680 findModeAndConfigureForIfaceType(IfaceConcurrencyType::AP);
681 ASSERT_EQ(createIface(IfaceType::AP), "wlan1");
682 EXPECT_CALL(*legacy_hal_, selectTxPowerScenario("wlan1", testing::_))
683 .WillOnce(testing::Return(legacy_hal::WIFI_SUCCESS));
684 ASSERT_TRUE(chip_->selectTxPowerScenario(IWifiChip::TxPowerScenario::ON_HEAD_CELL_OFF).isOk());
685 }
686
TEST_F(WifiChipV2_AwareIfaceCombinationTest,InvalidateAndRemoveNanOnStaRemove)687 TEST_F(WifiChipV2_AwareIfaceCombinationTest, InvalidateAndRemoveNanOnStaRemove) {
688 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
689 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
690
691 // Create NAN iface
692 ASSERT_EQ(createIface(IfaceType::NAN_IFACE), "wlan0");
693
694 // We should have 1 nan iface.
695 std::vector<std::string> iface_names;
696 ASSERT_TRUE(chip_->getNanIfaceNames(&iface_names).isOk());
697 ASSERT_EQ(iface_names.size(), 1u);
698 ASSERT_EQ(iface_names[0], "wlan0");
699
700 // Retrieve the nan iface object.
701 std::shared_ptr<IWifiNanIface> nan_iface;
702 ASSERT_TRUE(chip_->getNanIface("wlan0", &nan_iface).isOk());
703 ASSERT_NE(nan_iface.get(), nullptr);
704
705 // Remove the STA iface. We should have 0 nan ifaces now.
706 removeIface(IfaceType::STA, "wlan0");
707 ASSERT_TRUE(chip_->getNanIfaceNames(&iface_names).isOk());
708 ASSERT_EQ(iface_names.size(), 0u);
709
710 // Any operation on the nan iface object should now return an error.
711 std::string name;
712 auto status = nan_iface->getName(&name);
713 ASSERT_EQ(status.getServiceSpecificError(),
714 static_cast<int32_t>(WifiStatusCode::ERROR_WIFI_IFACE_INVALID));
715 }
716
TEST_F(WifiChipV2_AwareIfaceCombinationTest,InvalidateAndRemoveRttControllerOnStaRemove)717 TEST_F(WifiChipV2_AwareIfaceCombinationTest, InvalidateAndRemoveRttControllerOnStaRemove) {
718 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
719 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
720
721 // Create RTT controller
722 std::shared_ptr<IWifiRttController> rtt_controller;
723 ASSERT_TRUE(chip_->createRttController(nullptr, &rtt_controller).isOk());
724
725 // Remove the STA iface.
726 removeIface(IfaceType::STA, "wlan0");
727
728 // Any operation on the rtt controller object should now return an error.
729 std::shared_ptr<IWifiStaIface> bound_iface;
730 auto status = rtt_controller->getBoundIface(&bound_iface);
731 ASSERT_EQ(status.getServiceSpecificError(),
732 static_cast<int32_t>(WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID));
733 }
734
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateNanWithSharedNanIface)735 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateNanWithSharedNanIface) {
736 property_set("wifi.aware.interface", nullptr);
737 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
738 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
739 ASSERT_EQ(createIface(IfaceType::NAN_IFACE), "wlan0");
740 removeIface(IfaceType::NAN_IFACE, "wlan0");
741 EXPECT_CALL(*iface_util_, setUpState(testing::_, testing::_)).Times(0);
742 }
743
TEST_F(WifiChipV2_AwareIfaceCombinationTest,CreateNanWithDedicatedNanIface)744 TEST_F(WifiChipV2_AwareIfaceCombinationTest, CreateNanWithDedicatedNanIface) {
745 property_set("wifi.aware.interface", "aware0");
746 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
747 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
748 EXPECT_CALL(*iface_util_, ifNameToIndex("aware0")).WillOnce(testing::Return(4));
749 EXPECT_CALL(*iface_util_, setUpState("aware0", true)).WillOnce(testing::Return(true));
750 ASSERT_EQ(createIface(IfaceType::NAN_IFACE), "aware0");
751
752 EXPECT_CALL(*iface_util_, setUpState("aware0", false)).WillOnce(testing::Return(true));
753 removeIface(IfaceType::NAN_IFACE, "aware0");
754 }
755
756 ////////// V1 Iface Combinations when AP creation is disabled //////////
757 class WifiChipV1_AwareDisabledApIfaceCombinationTest : public WifiChipTest {
758 public:
SetUp()759 void SetUp() override {
760 setupV1_AwareDisabledApIfaceCombination();
761 WifiChipTest::SetUp();
762 }
763 };
764
TEST_F(WifiChipV1_AwareDisabledApIfaceCombinationTest,StaMode_CreateSta_ShouldSucceed)765 TEST_F(WifiChipV1_AwareDisabledApIfaceCombinationTest, StaMode_CreateSta_ShouldSucceed) {
766 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
767 ASSERT_FALSE(createIface(IfaceType::STA).empty());
768 ASSERT_TRUE(createIface(IfaceType::AP).empty());
769 }
770
771 ////////// V2 Iface Combinations when AP creation is disabled //////////
772 class WifiChipV2_AwareDisabledApIfaceCombinationTest : public WifiChipTest {
773 public:
SetUp()774 void SetUp() override {
775 setupV2_AwareDisabledApIfaceCombination();
776 WifiChipTest::SetUp();
777 }
778 };
779
TEST_F(WifiChipV2_AwareDisabledApIfaceCombinationTest,CreateSta_ShouldSucceed)780 TEST_F(WifiChipV2_AwareDisabledApIfaceCombinationTest, CreateSta_ShouldSucceed) {
781 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
782 ASSERT_FALSE(createIface(IfaceType::STA).empty());
783 ASSERT_TRUE(createIface(IfaceType::AP).empty());
784 }
785
786 ////////// Hypothetical Iface Combination with multiple ifaces //////////
787 class WifiChip_MultiIfaceTest : public WifiChipTest {
788 public:
SetUp()789 void SetUp() override {
790 setup_MultiIfaceCombination();
791 WifiChipTest::SetUp();
792 }
793 };
794
TEST_F(WifiChip_MultiIfaceTest,Create3Sta)795 TEST_F(WifiChip_MultiIfaceTest, Create3Sta) {
796 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
797 ASSERT_FALSE(createIface(IfaceType::STA).empty());
798 ASSERT_FALSE(createIface(IfaceType::STA).empty());
799 ASSERT_FALSE(createIface(IfaceType::STA).empty());
800 ASSERT_TRUE(createIface(IfaceType::STA).empty());
801 }
802
TEST_F(WifiChip_MultiIfaceTest,CreateStaWithDefaultNames)803 TEST_F(WifiChip_MultiIfaceTest, CreateStaWithDefaultNames) {
804 property_set("wifi.interface.0", "");
805 property_set("wifi.interface.1", "");
806 property_set("wifi.interface.2", "");
807 property_set("wifi.interface", "");
808 property_set("wifi.concurrent.interface", "");
809 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
810 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
811 ASSERT_EQ(createIface(IfaceType::STA), "wlan1");
812 ASSERT_EQ(createIface(IfaceType::STA), "wlan2");
813 }
814
TEST_F(WifiChip_MultiIfaceTest,CreateStaWithCustomNames)815 TEST_F(WifiChip_MultiIfaceTest, CreateStaWithCustomNames) {
816 property_set("wifi.interface.0", "test0");
817 property_set("wifi.interface.1", "test1");
818 property_set("wifi.interface.2", "test2");
819 property_set("wifi.interface", "bad0");
820 property_set("wifi.concurrent.interface", "bad1");
821 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
822 ASSERT_EQ(createIface(IfaceType::STA), "bad0");
823 ASSERT_EQ(createIface(IfaceType::STA), "bad1");
824 ASSERT_EQ(createIface(IfaceType::STA), "test2");
825 }
826
TEST_F(WifiChip_MultiIfaceTest,CreateStaWithCustomAltNames)827 TEST_F(WifiChip_MultiIfaceTest, CreateStaWithCustomAltNames) {
828 property_set("wifi.interface.0", "");
829 property_set("wifi.interface.1", "");
830 property_set("wifi.interface.2", "");
831 property_set("wifi.interface", "testA0");
832 property_set("wifi.concurrent.interface", "testA1");
833 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
834 ASSERT_EQ(createIface(IfaceType::STA), "testA0");
835 ASSERT_EQ(createIface(IfaceType::STA), "testA1");
836 ASSERT_EQ(createIface(IfaceType::STA), "wlan2");
837 }
838
TEST_F(WifiChip_MultiIfaceTest,CreateApStartsWithIdx1)839 TEST_F(WifiChip_MultiIfaceTest, CreateApStartsWithIdx1) {
840 // WifiChip_MultiIfaceTest iface combo: STAx3 + APx1
841 // When the HAL support dual STAs, AP should start with idx 2.
842 findModeAndConfigureForIfaceType(IfaceConcurrencyType::STA);
843 // First AP will be slotted to wlan1.
844 ASSERT_EQ(createIface(IfaceType::AP), "wlan2");
845 // First STA will be slotted to wlan0.
846 ASSERT_EQ(createIface(IfaceType::STA), "wlan0");
847 // All further STA will be slotted to the remaining free indices.
848 ASSERT_EQ(createIface(IfaceType::STA), "wlan1");
849 ASSERT_EQ(createIface(IfaceType::STA), "wlan3");
850 }
851
852 } // namespace wifi
853 } // namespace hardware
854 } // namespace android
855 } // namespace aidl
856