Merge "wifi: add enable SAE PK only mode API"

This commit is contained in:
TreeHugger Robot
2020-11-06 20:04:15 +00:00
committed by Android (Google) Code Review
7 changed files with 123 additions and 6 deletions

View File

@@ -54,6 +54,7 @@ cc_test {
"android.hardware.wifi.supplicant@1.1",
"android.hardware.wifi.supplicant@1.2",
"android.hardware.wifi.supplicant@1.3",
"android.hardware.wifi.supplicant@1.4",
"android.hardware.wifi@1.0",
"android.hardware.wifi@1.1",
"libgmock",

View File

@@ -23,6 +23,8 @@
#include <android/hardware/wifi/supplicant/1.3/ISupplicantStaIfaceCallback.h>
#include <android/hardware/wifi/supplicant/1.3/ISupplicantStaNetwork.h>
#include <android/hardware/wifi/supplicant/1.3/types.h>
#include <android/hardware/wifi/supplicant/1.4/ISupplicantStaIface.h>
#include <android/hardware/wifi/supplicant/1.4/types.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/HidlSupport.h>
@@ -61,6 +63,10 @@ class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBaseV1_3 {
SupplicantHidlTestBaseV1_3::SetUp();
sta_iface_ = getSupplicantStaIface_1_3(supplicant_);
ASSERT_NE(sta_iface_.get(), nullptr);
/* Variable used to check the underlying HAL version. */
sta_iface_v1_4_ = ::android::hardware::wifi::supplicant::V1_4::
ISupplicantStaIface::castFrom(sta_iface_);
}
int64_t pmkCacheExpirationTimeInSec;
@@ -108,6 +114,8 @@ class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBaseV1_3 {
protected:
// ISupplicantStaIface object used for all tests in this fixture.
sp<ISupplicantStaIface> sta_iface_;
sp<::android::hardware::wifi::supplicant::V1_4::ISupplicantStaIface>
sta_iface_v1_4_ = nullptr;
bool isDppSupported() {
uint32_t keyMgmtMask = 0;
@@ -342,9 +350,12 @@ TEST_P(SupplicantStaIfaceHidlTest, GetConnectionCapabilities) {
* GetWpaDriverCapabilities
*/
TEST_P(SupplicantStaIfaceHidlTest, GetWpaDriverCapabilities) {
SupplicantStatusCode expectedCode =
(nullptr != sta_iface_v1_4_) ? SupplicantStatusCode::FAILURE_UNKNOWN
: SupplicantStatusCode::SUCCESS;
sta_iface_->getWpaDriverCapabilities(
[&](const SupplicantStatus& status, uint32_t) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
EXPECT_EQ(expectedCode, status.code);
});
}
@@ -355,12 +366,26 @@ TEST_P(SupplicantStaIfaceHidlTest, SetMboCellularDataStatus) {
uint32_t driverCapMask = 0;
// Get MBO support from the device.
sta_iface_->getWpaDriverCapabilities(
[&](const SupplicantStatus& status, uint32_t driverCapMaskInternal) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
if (nullptr != sta_iface_v1_4_) {
sta_iface_v1_4_->getWpaDriverCapabilities_1_4(
[&](const ::android::hardware::wifi::supplicant::V1_4::
SupplicantStatus& status,
uint32_t driverCapMaskInternal) {
EXPECT_EQ(::android::hardware::wifi::supplicant::V1_4::
SupplicantStatusCode::SUCCESS,
status.code);
driverCapMask = driverCapMaskInternal;
});
driverCapMask = driverCapMaskInternal;
});
} else {
sta_iface_->getWpaDriverCapabilities(
[&](const SupplicantStatus& status,
uint32_t driverCapMaskInternal) {
EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code);
driverCapMask = driverCapMaskInternal;
});
}
SupplicantStatusCode expectedStatusCode =
(driverCapMask & WpaDriverCapabilitiesMask::MBO)

View File

@@ -73,4 +73,15 @@ interface ISupplicantStaIface extends @1.3::ISupplicantStaIface {
*/
initiateVenueUrlAnqpQuery(MacAddress macAddress)
generates (SupplicantStatus status);
/**
* Get wpa driver capabilities.
*
* @return status Status of the operation, and a bitmap of wpa driver features.
* Possible status codes:
* |SupplicantStatusCode.SUCCESS|,
* |SupplicantStatusCode.FAILURE_UNKNOWN|,
*/
getWpaDriverCapabilities_1_4() generates (SupplicantStatus status,
bitfield<WpaDriverCapabilitiesMask> driverCapabilitiesMask);
};

View File

@@ -24,6 +24,16 @@ import @1.4::ISupplicantStaNetworkCallback;
* configuration it controls.
*/
interface ISupplicantStaNetwork extends @1.3::ISupplicantStaNetwork {
/**
* Possible mask of values for KeyMgmt param.
*/
enum KeyMgmtMask : @1.3::ISupplicantStaNetwork.KeyMgmtMask {
/**
* SAE PK mode
*/
SAE_PK,
};
/**
* Possible mask of values for PairwiseCipher param.
*/
@@ -160,4 +170,22 @@ interface ISupplicantStaNetwork extends @1.3::ISupplicantStaNetwork {
* |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
*/
enableSaeH2eOnlyMode(bool enable) generates (SupplicantStatus status);
/**
* Set whether to enable SAE PK (Public Key) only mode to enable public AP validation.
* When enabled, only SAE PK network is allowed; otherwise PK is optional.
* If this API is not called before connecting to an SAE
* network, SAE PK mode depends on SAE PK config in wpa_supplicant configuration.
* If SAE PK config of wpa_supplicant configuration is not set,
* the default mode is optional (support for both PK and standard mode).
*
* @param enable true to set, false otherwise.
* @return status Status of the operation.
* Possible status codes:
* |SupplicantStatusCode.SUCCESS|,
* |SupplicantStatusCode.FAILURE_UNKNOWN|,
* |SupplicantStatusCode.FAILURE_NETWORK_INVALID|,
* |SupplicantStatusCode.FAILURE_UNSUPPORTED|
*/
enableSaePkOnlyMode(bool enable) generates (SupplicantStatus status);
};

View File

@@ -18,6 +18,7 @@ package android.hardware.wifi.supplicant@1.4;
import @1.0::SupplicantStatusCode;
import @1.3::ConnectionCapabilities;
import @1.3::WpaDriverCapabilitiesMask;
/**
* Detailed network mode for legacy network
@@ -71,3 +72,13 @@ struct SupplicantStatus {
*/
string debugMessage;
};
/**
* WPA Driver capability.
*/
enum WpaDriverCapabilitiesMask : @1.3::WpaDriverCapabilitiesMask {
/**
*
*/
SAE_PK = 1 << 2,
};

View File

@@ -245,6 +245,16 @@ TEST_P(SupplicantStaIfaceHidlTest, InitiateVenueUrlAnqpQuery) {
});
}
/*
* GetWpaDriverCapabilities
*/
TEST_P(SupplicantStaIfaceHidlTest, GetWpaDriverCapabilities) {
sta_iface_->getWpaDriverCapabilities_1_4(
[&](const SupplicantStatusV1_4& status, uint32_t) {
EXPECT_EQ(SupplicantStatusCodeV1_4::SUCCESS, status.code);
});
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SupplicantStaIfaceHidlTest);
INSTANTIATE_TEST_CASE_P(
PerInstance, SupplicantStaIfaceHidlTest,

View File

@@ -46,11 +46,15 @@ using SupplicantStatusV1_4 =
::android::hardware::wifi::supplicant::V1_4::SupplicantStatus;
using SupplicantStatusCodeV1_4 =
::android::hardware::wifi::supplicant::V1_4::SupplicantStatusCode;
using WpaDriverCapabilitiesMaskV1_4 =
::android::hardware::wifi::supplicant::V1_4::WpaDriverCapabilitiesMask;
class SupplicantStaNetworkHidlTest : public SupplicantHidlTestBaseV1_4 {
public:
virtual void SetUp() override {
SupplicantHidlTestBaseV1_4::SetUp();
sta_iface_ = getSupplicantStaIface_1_4(supplicant_);
ASSERT_NE(nullptr, sta_iface_.get());
sta_network_ = createSupplicantStaNetwork(supplicant_);
ASSERT_NE(sta_network_.get(), nullptr);
/* variable used to check if the underlying HAL version is 1.4 or
@@ -61,10 +65,21 @@ class SupplicantStaNetworkHidlTest : public SupplicantHidlTestBaseV1_4 {
}
protected:
sp<::android::hardware::wifi::supplicant::V1_4::ISupplicantStaIface>
sta_iface_;
sp<::android::hardware::wifi::supplicant::V1_4::ISupplicantStaNetwork>
v1_4 = nullptr;
// ISupplicantStaNetwork object used for all tests in this fixture.
sp<ISupplicantStaNetwork> sta_network_;
bool isSaePkSupported() {
uint32_t caps;
sta_iface_->getWpaDriverCapabilities_1_4(
[&](const SupplicantStatusV1_4& status, uint32_t capsInternal) {
EXPECT_EQ(SupplicantStatusCodeV1_4::SUCCESS, status.code);
caps = capsInternal;
});
return !!(caps & WpaDriverCapabilitiesMaskV1_4::SAE_PK);
}
};
class NetworkCallback : public ISupplicantStaNetworkCallback {
@@ -106,6 +121,22 @@ TEST_P(SupplicantStaNetworkHidlTest, EnableSaeH2eOnlyMode) {
});
}
/*
* enable SAE PK only mode
*/
TEST_P(SupplicantStaNetworkHidlTest, EnableSaePkOnlyMode) {
LOG(INFO) << "SAE-PK Supported: " << isSaePkSupported();
SupplicantStatusCodeV1_4 expectedCode =
isSaePkSupported() ? SupplicantStatusCodeV1_4::SUCCESS
: SupplicantStatusCodeV1_4::FAILURE_UNSUPPORTED;
v1_4->enableSaePkOnlyMode(true, [&](const SupplicantStatusV1_4& status) {
EXPECT_EQ(expectedCode, status.code);
});
v1_4->enableSaePkOnlyMode(false, [&](const SupplicantStatusV1_4& status) {
EXPECT_EQ(expectedCode, status.code);
});
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SupplicantStaNetworkHidlTest);
INSTANTIATE_TEST_CASE_P(
PerInstance, SupplicantStaNetworkHidlTest,