1 /*
2 * Copyright (C) 2019 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 <VtsCoreUtil.h>
18
19 #include <android-base/logging.h>
20 #include <cutils/properties.h>
21
22 #include <gtest/gtest.h>
23 #include <hidl/GtestPrinter.h>
24 #include <hidl/ServiceManagement.h>
25
26 #include <android/hardware/wifi/1.0/IWifi.h>
27 #include <android/hardware/wifi/hostapd/1.2/IHostapd.h>
28 #include <android/hardware/wifi/hostapd/1.3/IHostapd.h>
29
30 #include "hostapd_hidl_call_util.h"
31 #include "hostapd_hidl_test_utils.h"
32 #include "wifi_hidl_test_utils_1_4.h"
33
34 using ::android::sp;
35 using ::android::hardware::hidl_string;
36 using ::android::hardware::Return;
37 using ::android::hardware::Void;
38 using ::android::hardware::wifi::hostapd::V1_2::DebugLevel;
39 using ::android::hardware::wifi::hostapd::V1_2::HostapdStatusCode;
40 using ::android::hardware::wifi::hostapd::V1_2::Ieee80211ReasonCode;
41 using ::android::hardware::wifi::hostapd::V1_2::IHostapd;
42 using ::android::hardware::wifi::V1_0::IWifi;
43 using ::android::hardware::wifi::V1_0::WifiStatusCode;
44 using ::android::hardware::wifi::V1_4::IWifiApIface;
45 using ::android::hardware::wifi::V1_4::IWifiChip;
46
47 namespace {
48 constexpr unsigned char kNwSsid[] = {'t', 'e', 's', 't', '1',
49 '2', '3', '4', '5'};
50 constexpr char kNwPassphrase[] = "test12345";
51 constexpr char kInvalidMaxPskNwPassphrase[] =
52 "0123456789012345678901234567890123456789012345678901234567890123456789";
53 constexpr char kInvalidMinPskNwPassphrase[] = "test";
54 constexpr int kIfaceChannel = 6;
55 constexpr int kIfaceInvalidChannel = 567;
56 constexpr uint8_t kTestZeroMacAddr[] = {[0 ... 5] = 0x0};
57 constexpr Ieee80211ReasonCode kTestDisconnectReasonCode =
58 Ieee80211ReasonCode::WLAN_REASON_UNSPECIFIED;
59 } // namespace
60
61 class HostapdHidlTest
62 : public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
63 public:
SetUp()64 virtual void SetUp() override {
65 wifi_instance_name_ = std::get<0>(GetParam());
66 hostapd_instance_name_ = std::get<1>(GetParam());
67 stopSupplicantIfNeeded(wifi_instance_name_);
68 startHostapdAndWaitForHidlService(wifi_instance_name_,
69 hostapd_instance_name_);
70 hostapd_ = IHostapd::getService(hostapd_instance_name_);
71 ASSERT_NE(hostapd_.get(), nullptr);
72 setupApIfaceIfNeeded();
73 isAcsSupport_ = testing::checkSubstringInCommandOutput(
74 "/system/bin/cmd wifi get-softap-supported-features",
75 "wifi_softap_acs_supported");
76 isWpa3SaeSupport_ = testing::checkSubstringInCommandOutput(
77 "/system/bin/cmd wifi get-softap-supported-features",
78 "wifi_softap_wpa3_sae_supported");
79 }
80
TearDown()81 virtual void TearDown() override {
82 HIDL_INVOKE_VOID_WITHOUT_ARGUMENTS(hostapd_, terminate);
83 stopHostapd(wifi_instance_name_);
84 }
85
86 protected:
87 bool isWpa3SaeSupport_ = false;
88 bool isAcsSupport_ = false;
89
setupApIfaceIfNeeded()90 void setupApIfaceIfNeeded() {
91 sp<IWifiApIface> wifi_ap_iface;
92 wifi_ap_iface = getWifiApIface_1_4(wifi_instance_name_);
93 EXPECT_NE(nullptr, wifi_ap_iface.get());
94
95 const auto& status_and_name = HIDL_INVOKE(wifi_ap_iface, getName);
96 EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_name.first.code);
97 }
98
getPrimaryWlanIfaceName()99 std::string getPrimaryWlanIfaceName() {
100 std::array<char, PROPERTY_VALUE_MAX> buffer;
101 auto res = property_get("ro.vendor.wifi.sap.interface", buffer.data(), nullptr);
102 if (res > 0) return buffer.data();
103 property_get("wifi.interface", buffer.data(), "wlan0");
104 return buffer.data();
105 }
106
getIfaceParamsWithoutAcs(std::string iface_name)107 IHostapd::IfaceParams getIfaceParamsWithoutAcs(std::string iface_name) {
108 ::android::hardware::wifi::hostapd::V1_0::IHostapd::IfaceParams
109 iface_params;
110 ::android::hardware::wifi::hostapd::V1_1::IHostapd::IfaceParams
111 iface_params_1_1;
112 IHostapd::IfaceParams iface_params_1_2;
113
114 iface_params.ifaceName = iface_name;
115 iface_params.hwModeParams.enable80211N = true;
116 iface_params.hwModeParams.enable80211AC = false;
117 iface_params.channelParams.enableAcs = false;
118 iface_params.channelParams.acsShouldExcludeDfs = false;
119 iface_params.channelParams.channel = kIfaceChannel;
120 iface_params_1_1.V1_0 = iface_params;
121 iface_params_1_2.V1_1 = iface_params_1_1;
122 // Newly added attributes in V1_2
123 iface_params_1_2.hwModeParams.enable80211AX = false;
124 iface_params_1_2.hwModeParams.enable6GhzBand = false;
125 iface_params_1_2.channelParams.bandMask = 0;
126 iface_params_1_2.channelParams.bandMask |=
127 IHostapd::BandMask::BAND_2_GHZ;
128 return iface_params_1_2;
129 }
130
getIfaceParamsWithAcs(std::string iface_name)131 IHostapd::IfaceParams getIfaceParamsWithAcs(std::string iface_name) {
132 // First get the settings for WithoutAcs and then make changes
133 IHostapd::IfaceParams iface_params_1_2 =
134 getIfaceParamsWithoutAcs(iface_name);
135 iface_params_1_2.V1_1.V1_0.channelParams.enableAcs = true;
136 iface_params_1_2.V1_1.V1_0.channelParams.acsShouldExcludeDfs = true;
137 iface_params_1_2.V1_1.V1_0.channelParams.channel = 0;
138 iface_params_1_2.channelParams.bandMask |=
139 IHostapd::BandMask::BAND_5_GHZ;
140
141 return iface_params_1_2;
142 }
143
getIfaceParamsWithAcsAndFreqRange(std::string iface_name)144 IHostapd::IfaceParams getIfaceParamsWithAcsAndFreqRange(
145 std::string iface_name) {
146 IHostapd::IfaceParams iface_params_1_2 =
147 getIfaceParamsWithAcs(iface_name);
148 ::android::hardware::wifi::hostapd::V1_2::IHostapd::AcsFrequencyRange
149 acsFrequencyRange;
150 acsFrequencyRange.start = 2412;
151 acsFrequencyRange.end = 2462;
152 std::vector<::android::hardware::wifi::hostapd::V1_2::IHostapd::
153 AcsFrequencyRange>
154 vec_acsFrequencyRange;
155 vec_acsFrequencyRange.push_back(acsFrequencyRange);
156 iface_params_1_2.channelParams.acsChannelFreqRangesMhz =
157 vec_acsFrequencyRange;
158 return iface_params_1_2;
159 }
160
getIfaceParamsWithAcsAndInvalidFreqRange(std::string iface_name)161 IHostapd::IfaceParams getIfaceParamsWithAcsAndInvalidFreqRange(
162 std::string iface_name) {
163 IHostapd::IfaceParams iface_params_1_2 =
164 getIfaceParamsWithAcsAndFreqRange(iface_name);
165 iface_params_1_2.channelParams.acsChannelFreqRangesMhz[0].start = 222;
166 iface_params_1_2.channelParams.acsChannelFreqRangesMhz[0].end = 999;
167 return iface_params_1_2;
168 }
169
getOpenNwParams()170 IHostapd::NetworkParams getOpenNwParams() {
171 IHostapd::NetworkParams nw_params_1_2;
172 ::android::hardware::wifi::hostapd::V1_0::IHostapd::NetworkParams
173 nw_params_1_0;
174 nw_params_1_0.ssid =
175 std::vector<uint8_t>(kNwSsid, kNwSsid + sizeof(kNwSsid));
176 nw_params_1_0.isHidden = false;
177 nw_params_1_2.V1_0 = nw_params_1_0;
178 nw_params_1_2.encryptionType = IHostapd::EncryptionType::NONE;
179 return nw_params_1_2;
180 }
181
getPskNwParams()182 IHostapd::NetworkParams getPskNwParams() {
183 IHostapd::NetworkParams nw_params_1_2 = getOpenNwParams();
184 nw_params_1_2.encryptionType = IHostapd::EncryptionType::WPA2;
185 nw_params_1_2.passphrase = kNwPassphrase;
186 return nw_params_1_2;
187 }
188
getInvalidPskNwParams()189 IHostapd::NetworkParams getInvalidPskNwParams() {
190 IHostapd::NetworkParams nw_params_1_2 = getOpenNwParams();
191 nw_params_1_2.encryptionType = IHostapd::EncryptionType::WPA2;
192 nw_params_1_2.passphrase = kInvalidMaxPskNwPassphrase;
193
194 return nw_params_1_2;
195 }
196
getSaeTransitionNwParams()197 IHostapd::NetworkParams getSaeTransitionNwParams() {
198 IHostapd::NetworkParams nw_params_1_2 = getOpenNwParams();
199 nw_params_1_2.encryptionType =
200 IHostapd::EncryptionType::WPA3_SAE_TRANSITION;
201 nw_params_1_2.passphrase = kNwPassphrase;
202 return nw_params_1_2;
203 }
204
getInvalidSaeTransitionNwParams()205 IHostapd::NetworkParams getInvalidSaeTransitionNwParams() {
206 IHostapd::NetworkParams nw_params_1_2 = getOpenNwParams();
207 nw_params_1_2.encryptionType = IHostapd::EncryptionType::WPA2;
208 nw_params_1_2.passphrase = kInvalidMinPskNwPassphrase;
209 return nw_params_1_2;
210 }
211
getSaeNwParams()212 IHostapd::NetworkParams getSaeNwParams() {
213 IHostapd::NetworkParams nw_params_1_2 = getOpenNwParams();
214 nw_params_1_2.encryptionType = IHostapd::EncryptionType::WPA3_SAE;
215 nw_params_1_2.passphrase = kNwPassphrase;
216 return nw_params_1_2;
217 }
218
getInvalidSaeNwParams()219 IHostapd::NetworkParams getInvalidSaeNwParams() {
220 IHostapd::NetworkParams nw_params_1_2 = getOpenNwParams();
221 nw_params_1_2.encryptionType = IHostapd::EncryptionType::WPA3_SAE;
222 nw_params_1_2.passphrase = "";
223 return nw_params_1_2;
224 }
225
getIfaceParamsWithInvalidChannel(std::string iface_name)226 IHostapd::IfaceParams getIfaceParamsWithInvalidChannel(
227 std::string iface_name) {
228 IHostapd::IfaceParams iface_params_1_2 =
229 getIfaceParamsWithoutAcs(iface_name);
230 iface_params_1_2.V1_1.V1_0.channelParams.channel = kIfaceInvalidChannel;
231 return iface_params_1_2;
232 }
233
234 // IHostapd object used for all tests in this fixture.
235 sp<IHostapd> hostapd_;
236 std::string wifi_instance_name_;
237 std::string hostapd_instance_name_;
238 };
239
is_1_3(const sp<IHostapd> & hostapd)240 bool is_1_3(const sp<IHostapd>& hostapd) {
241 sp<::android::hardware::wifi::hostapd::V1_3::IHostapd> hostapd_1_3 =
242 ::android::hardware::wifi::hostapd::V1_3::IHostapd::castFrom(hostapd);
243 return hostapd_1_3.get() != nullptr;
244 }
245
246 /**
247 * Adds an access point with PSK network config & ACS enabled.
248 * Access point creation should pass.
249 */
TEST_P(HostapdHidlTest,AddPskAccessPointWithAcs)250 TEST_P(HostapdHidlTest, AddPskAccessPointWithAcs) {
251 if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
252 if (is_1_3(hostapd_))
253 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
254 std::string ifname = getPrimaryWlanIfaceName();
255 auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
256 getIfaceParamsWithAcs(ifname), getPskNwParams());
257 EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
258 }
259
260 /**
261 * Adds an access point with PSK network config, ACS enabled & frequency Range.
262 * Access point creation should pass.
263 */
TEST_P(HostapdHidlTest,AddPskAccessPointWithAcsAndFreqRange)264 TEST_P(HostapdHidlTest, AddPskAccessPointWithAcsAndFreqRange) {
265 if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
266 if (is_1_3(hostapd_))
267 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
268 std::string ifname = getPrimaryWlanIfaceName();
269 auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
270 getIfaceParamsWithAcsAndFreqRange(ifname),
271 getPskNwParams());
272 EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
273 }
274
275 /**
276 * Adds an access point with invalid channel range.
277 * Access point creation should fail.
278 */
TEST_P(HostapdHidlTest,AddPskAccessPointWithAcsAndInvalidFreqRange)279 TEST_P(HostapdHidlTest, AddPskAccessPointWithAcsAndInvalidFreqRange) {
280 if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
281 if (is_1_3(hostapd_))
282 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
283 std::string ifname = getPrimaryWlanIfaceName();
284 auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
285 getIfaceParamsWithAcsAndInvalidFreqRange(ifname),
286 getPskNwParams());
287 EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
288 }
289
290 /**
291 * Adds an access point with Open network config & ACS enabled.
292 * Access point creation should pass.
293 */
TEST_P(HostapdHidlTest,AddOpenAccessPointWithAcs)294 TEST_P(HostapdHidlTest, AddOpenAccessPointWithAcs) {
295 if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
296 if (is_1_3(hostapd_))
297 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
298 std::string ifname = getPrimaryWlanIfaceName();
299 auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
300 getIfaceParamsWithAcs(ifname), getOpenNwParams());
301 EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
302 }
303
304 /**
305 * Adds an access point with PSK network config & ACS disabled.
306 * Access point creation should pass.
307 */
TEST_P(HostapdHidlTest,AddPskAccessPointWithoutAcs)308 TEST_P(HostapdHidlTest, AddPskAccessPointWithoutAcs) {
309 if (is_1_3(hostapd_))
310 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
311 std::string ifname = getPrimaryWlanIfaceName();
312 auto status =
313 HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
314 getIfaceParamsWithoutAcs(ifname), getPskNwParams());
315 EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
316 }
317
318 /**
319 * Adds an access point with Open network config & ACS disabled.
320 * Access point creation should pass.
321 */
TEST_P(HostapdHidlTest,AddOpenAccessPointWithoutAcs)322 TEST_P(HostapdHidlTest, AddOpenAccessPointWithoutAcs) {
323 if (is_1_3(hostapd_))
324 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
325 std::string ifname = getPrimaryWlanIfaceName();
326 auto status =
327 HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
328 getIfaceParamsWithoutAcs(ifname), getOpenNwParams());
329 EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
330 }
331
332 /**
333 * Adds an access point with SAE Transition network config & ACS disabled.
334 * Access point creation should pass.
335 */
TEST_P(HostapdHidlTest,AddSaeTransitionAccessPointWithoutAcs)336 TEST_P(HostapdHidlTest, AddSaeTransitionAccessPointWithoutAcs) {
337 if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
338 if (is_1_3(hostapd_))
339 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
340 std::string ifname = getPrimaryWlanIfaceName();
341 auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
342 getIfaceParamsWithoutAcs(ifname),
343 getSaeTransitionNwParams());
344 EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
345 }
346
347 /**
348 * Adds an access point with SAE network config & ACS disabled.
349 * Access point creation should pass.
350 */
TEST_P(HostapdHidlTest,AddSAEAccessPointWithoutAcs)351 TEST_P(HostapdHidlTest, AddSAEAccessPointWithoutAcs) {
352 if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
353 if (is_1_3(hostapd_))
354 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
355 std::string ifname = getPrimaryWlanIfaceName();
356 auto status =
357 HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
358 getIfaceParamsWithoutAcs(ifname), getSaeNwParams());
359 EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
360 }
361
362 /**
363 * Adds & then removes an access point with PSK network config & ACS enabled.
364 * Access point creation & removal should pass.
365 */
TEST_P(HostapdHidlTest,RemoveAccessPointWithAcs)366 TEST_P(HostapdHidlTest, RemoveAccessPointWithAcs) {
367 if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
368 if (is_1_3(hostapd_))
369 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
370 std::string ifname = getPrimaryWlanIfaceName();
371 auto status_1_2 =
372 HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithAcs(ifname),
373 getPskNwParams());
374 EXPECT_EQ(HostapdStatusCode::SUCCESS, status_1_2.code);
375 auto status = HIDL_INVOKE(hostapd_, removeAccessPoint, ifname);
376 EXPECT_EQ(
377 android::hardware::wifi::hostapd::V1_0::HostapdStatusCode::SUCCESS,
378 status.code);
379 }
380
381 /**
382 * Adds & then removes an access point with PSK network config & ACS disabled.
383 * Access point creation & removal should pass.
384 */
TEST_P(HostapdHidlTest,RemoveAccessPointWithoutAcs)385 TEST_P(HostapdHidlTest, RemoveAccessPointWithoutAcs) {
386 if (is_1_3(hostapd_))
387 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
388 std::string ifname = getPrimaryWlanIfaceName();
389 auto status_1_2 =
390 HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
391 getIfaceParamsWithoutAcs(ifname), getPskNwParams());
392 EXPECT_EQ(HostapdStatusCode::SUCCESS, status_1_2.code);
393 auto status = HIDL_INVOKE(hostapd_, removeAccessPoint, ifname);
394 EXPECT_EQ(
395 android::hardware::wifi::hostapd::V1_0::HostapdStatusCode::SUCCESS,
396 status.code);
397 }
398
399 /**
400 * Adds an access point with invalid channel.
401 * Access point creation should fail.
402 */
TEST_P(HostapdHidlTest,AddPskAccessPointWithInvalidChannel)403 TEST_P(HostapdHidlTest, AddPskAccessPointWithInvalidChannel) {
404 if (is_1_3(hostapd_))
405 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
406 std::string ifname = getPrimaryWlanIfaceName();
407 auto status =
408 HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
409 getIfaceParamsWithInvalidChannel(ifname), getPskNwParams());
410 EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
411 }
412
413 /**
414 * Adds an access point with invalid PSK network config.
415 * Access point creation should fail.
416 */
TEST_P(HostapdHidlTest,AddInvalidPskAccessPointWithoutAcs)417 TEST_P(HostapdHidlTest, AddInvalidPskAccessPointWithoutAcs) {
418 if (is_1_3(hostapd_))
419 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
420 std::string ifname = getPrimaryWlanIfaceName();
421 auto status =
422 HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
423 getIfaceParamsWithoutAcs(ifname), getInvalidPskNwParams());
424 EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
425 }
426
427 /**
428 * Adds an access point with invalid SAE transition network config.
429 * Access point creation should fail.
430 */
TEST_P(HostapdHidlTest,AddInvalidSaeTransitionAccessPointWithoutAcs)431 TEST_P(HostapdHidlTest, AddInvalidSaeTransitionAccessPointWithoutAcs) {
432 if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
433 if (is_1_3(hostapd_))
434 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
435 std::string ifname = getPrimaryWlanIfaceName();
436 auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
437 getIfaceParamsWithoutAcs(ifname),
438 getInvalidSaeTransitionNwParams());
439 EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
440 }
441
442 /**
443 * Adds an access point with invalid SAE network config.
444 * Access point creation should fail.
445 */
TEST_P(HostapdHidlTest,AddInvalidSaeAccessPointWithoutAcs)446 TEST_P(HostapdHidlTest, AddInvalidSaeAccessPointWithoutAcs) {
447 if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
448 if (is_1_3(hostapd_))
449 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
450 std::string ifname = getPrimaryWlanIfaceName();
451 auto status =
452 HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
453 getIfaceParamsWithoutAcs(ifname), getInvalidSaeNwParams());
454 EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
455 }
456
457 /**
458 * forceClientDisconnect should return FAILURE_IFACE_UNKNOWN
459 * when hotspot interface doesn't init..
460 */
TEST_P(HostapdHidlTest,DisconnectClientWhenIfaceNotAvailable)461 TEST_P(HostapdHidlTest, DisconnectClientWhenIfaceNotAvailable) {
462 std::string ifname = getPrimaryWlanIfaceName();
463 auto status = HIDL_INVOKE(hostapd_, forceClientDisconnect, ifname,
464 kTestZeroMacAddr, kTestDisconnectReasonCode);
465 EXPECT_EQ(HostapdStatusCode::FAILURE_IFACE_UNKNOWN, status.code);
466 }
467
468 /**
469 * forceClientDisconnect should return FAILURE_CLIENT_UNKNOWN
470 * when hotspot interface available.
471 */
TEST_P(HostapdHidlTest,DisconnectClientWhenIfacAvailable)472 TEST_P(HostapdHidlTest, DisconnectClientWhenIfacAvailable) {
473 if (is_1_3(hostapd_))
474 GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
475 std::string ifname = getPrimaryWlanIfaceName();
476 auto status_1_2 =
477 HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
478 getIfaceParamsWithoutAcs(ifname), getOpenNwParams());
479 EXPECT_EQ(HostapdStatusCode::SUCCESS, status_1_2.code);
480
481 status_1_2 = HIDL_INVOKE(hostapd_, forceClientDisconnect, ifname,
482 kTestZeroMacAddr, kTestDisconnectReasonCode);
483 EXPECT_EQ(HostapdStatusCode::FAILURE_CLIENT_UNKNOWN, status_1_2.code);
484 }
485
486 /*
487 * SetDebugParams
488 */
TEST_P(HostapdHidlTest,SetDebugParams)489 TEST_P(HostapdHidlTest, SetDebugParams) {
490 auto status = HIDL_INVOKE(hostapd_, setDebugParams, DebugLevel::EXCESSIVE);
491 EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
492 }
493
494 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(HostapdHidlTest);
495 INSTANTIATE_TEST_CASE_P(
496 PerInstance, HostapdHidlTest,
497 testing::Combine(
498 testing::ValuesIn(
499 android::hardware::getAllHalInstanceNames(IWifi::descriptor)),
500 testing::ValuesIn(android::hardware::getAllHalInstanceNames(
501 android::hardware::wifi::hostapd::V1_2::IHostapd::descriptor))),
502 android::hardware::PrintInstanceTupleNameToString<>);
503