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 <android-base/logging.h>
18 
19 #include "supplicant_hidl_test_utils.h"
20 #include "supplicant_hidl_test_utils_1_3.h"
21 
22 using ::android::sp;
23 using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
24 using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
25 using ::android::hardware::wifi::supplicant::V1_3::ISupplicant;
26 using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaIface;
27 using ::android::hardware::wifi::supplicant::V1_3::ISupplicantStaNetwork;
28 
getSupplicantStaIface_1_3(const android::sp<android::hardware::wifi::supplicant::V1_3::ISupplicant> & supplicant)29 sp<ISupplicantStaIface> getSupplicantStaIface_1_3(
30     const android::sp<android::hardware::wifi::supplicant::V1_3::ISupplicant>&
31         supplicant) {
32     return ISupplicantStaIface::castFrom(getSupplicantStaIface(supplicant));
33 }
34 
createSupplicantStaNetwork_1_3(const android::sp<android::hardware::wifi::supplicant::V1_3::ISupplicant> & supplicant)35 sp<ISupplicantStaNetwork> createSupplicantStaNetwork_1_3(
36     const android::sp<android::hardware::wifi::supplicant::V1_3::ISupplicant>&
37         supplicant) {
38     return ISupplicantStaNetwork::castFrom(
39         createSupplicantStaNetwork(supplicant));
40 }
41 
getSupplicant_1_3(const std::string & supplicant_instance_name,bool isP2pOn)42 sp<ISupplicant> getSupplicant_1_3(const std::string& supplicant_instance_name,
43                                   bool isP2pOn) {
44     return ISupplicant::castFrom(
45         getSupplicant(supplicant_instance_name, isP2pOn));
46 }
47 
isFilsSupported(sp<ISupplicantStaIface> sta_iface)48 bool isFilsSupported(sp<ISupplicantStaIface> sta_iface) {
49     uint32_t keyMgmtMask = 0;
50     sta_iface->getKeyMgmtCapabilities_1_3(
51         [&](const SupplicantStatus& status, uint32_t keyMgmtMaskInternal) {
52             EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
53             keyMgmtMask = keyMgmtMaskInternal;
54         });
55 
56     return (keyMgmtMask & (ISupplicantStaNetwork::KeyMgmtMask::FILS_SHA256 |
57                            ISupplicantStaNetwork::KeyMgmtMask::FILS_SHA384));
58 }
59