Add Wifi HAL supplicant AIDL interface definitions.
Converted from android.hardware.wifi.supplicant@1.4 HIDL interface.
Bug: 196235436
Test: m android.hardware.wifi.supplicant-update-api
BYPASS_INCLUSIVE_LANGUAGE_REASON=HE refers to High Efficiency
Change-Id: I9872f297450457c347fb5fe8cf4005b01d3ab1f6
diff --git a/wifi/supplicant/aidl/vts/functional/Android.bp b/wifi/supplicant/aidl/vts/functional/Android.bp
new file mode 100644
index 0000000..65f9652
--- /dev/null
+++ b/wifi/supplicant/aidl/vts/functional/Android.bp
@@ -0,0 +1,90 @@
+//
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_test {
+ name: "VtsHalWifiSupplicantStaIfaceTargetTest",
+ defaults: [
+ "VtsHalTargetTestDefaults",
+ "use_libaidlvintf_gtest_helper_static",
+ ],
+ srcs: ["supplicant_sta_iface_aidl_test.cpp"],
+ shared_libs: [
+ "libbinder",
+ "libbinder_ndk",
+ ],
+ static_libs: [
+ "android.hardware.wifi.supplicant-V1-ndk",
+ "libwifi-system",
+ "libwifi-system-iface",
+ ],
+ test_suites: [
+ "general-tests",
+ "vts",
+ ],
+}
+
+cc_test {
+ name: "VtsHalWifiSupplicantStaNetworkTargetTest",
+ defaults: [
+ "VtsHalTargetTestDefaults",
+ "use_libaidlvintf_gtest_helper_static",
+ ],
+ srcs: ["supplicant_sta_network_aidl_test.cpp"],
+ shared_libs: [
+ "libbinder",
+ "libbinder_ndk",
+ ],
+ static_libs: [
+ "android.hardware.wifi.supplicant-V1-ndk",
+ "libwifi-system",
+ "libwifi-system-iface",
+ ],
+ test_suites: [
+ "general-tests",
+ "vts",
+ ],
+}
+
+cc_test {
+ name: "VtsHalWifiSupplicantP2pIfaceTargetTest",
+ defaults: [
+ "VtsHalTargetTestDefaults",
+ "use_libaidlvintf_gtest_helper_static",
+ ],
+ srcs: ["supplicant_p2p_iface_aidl_test.cpp"],
+ shared_libs: [
+ "libbinder",
+ "libbinder_ndk",
+ ],
+ static_libs: [
+ "android.hardware.wifi.supplicant-V1-ndk",
+ "libwifi-system",
+ "libwifi-system-iface",
+ ],
+ test_suites: [
+ "general-tests",
+ "vts",
+ ],
+}
diff --git a/wifi/supplicant/aidl/vts/functional/supplicant_p2p_iface_aidl_test.cpp b/wifi/supplicant/aidl/vts/functional/supplicant_p2p_iface_aidl_test.cpp
new file mode 100644
index 0000000..2f4f06d
--- /dev/null
+++ b/wifi/supplicant/aidl/vts/functional/supplicant_p2p_iface_aidl_test.cpp
@@ -0,0 +1,633 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <VtsCoreUtil.h>
+#include <aidl/Gtest.h>
+#include <aidl/Vintf.h>
+#include <aidl/android/hardware/wifi/supplicant/BnSupplicant.h>
+#include <aidl/android/hardware/wifi/supplicant/BnSupplicantP2pIfaceCallback.h>
+#include <android/binder_manager.h>
+#include <android/binder_status.h>
+#include <binder/IServiceManager.h>
+#include <binder/ProcessState.h>
+#include <cutils/properties.h>
+
+#include "supplicant_test_utils.h"
+
+using aidl::android::hardware::wifi::supplicant::BnSupplicantP2pIfaceCallback;
+using aidl::android::hardware::wifi::supplicant::DebugLevel;
+using aidl::android::hardware::wifi::supplicant::FreqRange;
+using aidl::android::hardware::wifi::supplicant::IfaceType;
+using aidl::android::hardware::wifi::supplicant::ISupplicant;
+using aidl::android::hardware::wifi::supplicant::ISupplicantP2pIface;
+using aidl::android::hardware::wifi::supplicant::MiracastMode;
+using aidl::android::hardware::wifi::supplicant::P2pGroupCapabilityMask;
+using aidl::android::hardware::wifi::supplicant::P2pProvDiscStatusCode;
+using aidl::android::hardware::wifi::supplicant::P2pStatusCode;
+using aidl::android::hardware::wifi::supplicant::WpsConfigMethods;
+using aidl::android::hardware::wifi::supplicant::WpsDevPasswordId;
+using aidl::android::hardware::wifi::supplicant::WpsProvisionMethod;
+using android::ProcessState;
+
+namespace {
+const std::string kTestSsidStr = "TestSsid1234";
+const std::vector<uint8_t> kTestSsid =
+ std::vector<uint8_t>(kTestSsidStr.begin(), kTestSsidStr.end());
+const std::vector<uint8_t> kTestMacAddr = {0x56, 0x67, 0x67, 0xf4, 0x56, 0x92};
+const std::vector<uint8_t> kTestPeerMacAddr = {0x56, 0x67, 0x55,
+ 0xf4, 0x56, 0x92};
+const std::vector<uint8_t> kTestZeroMacAddr = std::vector<uint8_t>(6, 0);
+const std::string kTestPassphrase = "P2pWorld1234";
+const std::string kTestConnectPin = "34556665";
+const std::string kTestGroupIfName = "TestGroup";
+const uint32_t kTestFindTimeout = 5;
+const uint32_t kTestConnectGoIntent = 6;
+const uint32_t kTestNetworkId = 7;
+const uint32_t kTestGroupFreq = 0;
+const bool kTestGroupPersistent = false;
+const bool kTestGroupIsJoin = false;
+
+} // namespace
+
+class SupplicantP2pIfaceCallback : public BnSupplicantP2pIfaceCallback {
+ public:
+ SupplicantP2pIfaceCallback() = default;
+
+ ::ndk::ScopedAStatus onDeviceFound(
+ const std::vector<uint8_t>& /* srcAddress */,
+ const std::vector<uint8_t>& /* p2pDeviceAddress */,
+ const std::vector<uint8_t>& /* primaryDeviceType */,
+ const std::string& /* deviceName */,
+ WpsConfigMethods /* configMethods */, int8_t /* deviceCapabilities */,
+ P2pGroupCapabilityMask /* groupCapabilities */,
+ const std::vector<uint8_t>& /* wfdDeviceInfo */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onDeviceLost(
+ const std::vector<uint8_t>& /* p2pDeviceAddress */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onFindStopped() override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onGoNegotiationCompleted(
+ P2pStatusCode /* status */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onGoNegotiationRequest(
+ const std::vector<uint8_t>& /* srcAddress */,
+ WpsDevPasswordId /* passwordId */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onGroupFormationFailure(
+ const std::string& /* failureReason */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onGroupFormationSuccess() override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onGroupRemoved(const std::string& /* groupIfname */,
+ bool /* isGroupOwner */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onGroupStarted(
+ const std::string& /* groupIfname */, bool /* isGroupOwner */,
+ const std::vector<uint8_t>& /* ssid */, int32_t /* frequency */,
+ const std::vector<uint8_t>& /* psk */,
+ const std::string& /* passphrase */,
+ const std::vector<uint8_t>& /* goDeviceAddress */,
+ bool /* isPersistent */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onInvitationReceived(
+ const std::vector<uint8_t>& /* srcAddress */,
+ const std::vector<uint8_t>& /* goDeviceAddress */,
+ const std::vector<uint8_t>& /* bssid */,
+ int32_t /* persistentNetworkId */,
+ int32_t /* operatingFrequency */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onInvitationResult(
+ const std::vector<uint8_t>& /* bssid */,
+ P2pStatusCode /* status */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onProvisionDiscoveryCompleted(
+ const std::vector<uint8_t>& /* p2pDeviceAddress */,
+ bool /* isRequest */, P2pProvDiscStatusCode /* status */,
+ WpsConfigMethods /* configMethods */,
+ const std::string& /* generatedPin */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onR2DeviceFound(
+ const std::vector<uint8_t>& /* srcAddress */,
+ const std::vector<uint8_t>& /* p2pDeviceAddress */,
+ const std::vector<uint8_t>& /* primaryDeviceType */,
+ const std::string& /* deviceName */,
+ WpsConfigMethods /* configMethods */, int8_t /* deviceCapabilities */,
+ P2pGroupCapabilityMask /* groupCapabilities */,
+ const std::vector<uint8_t>& /* wfdDeviceInfo */,
+ const std::vector<uint8_t>& /* wfdR2DeviceInfo */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onServiceDiscoveryResponse(
+ const std::vector<uint8_t>& /* srcAddress */,
+ char16_t /* updateIndicator */,
+ const std::vector<uint8_t>& /* tlvs */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onStaAuthorized(
+ const std::vector<uint8_t>& /* srcAddress */,
+ const std::vector<uint8_t>& /* p2pDeviceAddress */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onStaDeauthorized(
+ const std::vector<uint8_t>& /* srcAddress */,
+ const std::vector<uint8_t>& /* p2pDeviceAddress */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+};
+
+class SupplicantP2pIfaceAidlTest : public testing::TestWithParam<std::string> {
+ public:
+ void SetUp() override {
+ initializeService();
+ supplicant_ = ISupplicant::fromBinder(ndk::SpAIBinder(
+ AServiceManager_waitForService(GetParam().c_str())));
+ ASSERT_NE(supplicant_, nullptr);
+ ASSERT_TRUE(supplicant_
+ ->setDebugParams(DebugLevel::EXCESSIVE,
+ true, // show timestamps
+ true)
+ .isOk());
+
+ bool p2pEnabled =
+ testing::deviceSupportsFeature("android.hardware.wifi.direct");
+ if (!p2pEnabled) {
+ GTEST_SKIP() << "Wi-Fi Direct is not supported, skip this test.";
+ }
+
+ EXPECT_TRUE(supplicant_->addP2pInterface(getP2pIfaceName(), &p2p_iface_)
+ .isOk());
+ ASSERT_NE(p2p_iface_, nullptr);
+ }
+
+ void TearDown() override {
+ stopSupplicant();
+ startWifiFramework();
+ }
+
+ protected:
+ std::shared_ptr<ISupplicant> supplicant_;
+ std::shared_ptr<ISupplicantP2pIface> p2p_iface_;
+};
+
+/*
+ * RegisterCallback
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, RegisterCallback) {
+ std::shared_ptr<SupplicantP2pIfaceCallback> callback =
+ ndk::SharedRefBase::make<SupplicantP2pIfaceCallback>();
+ ASSERT_NE(callback, nullptr);
+ EXPECT_TRUE(p2p_iface_->registerCallback(callback).isOk());
+}
+
+/*
+ * GetName
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, GetName) {
+ std::string name;
+ EXPECT_TRUE(p2p_iface_->getName(&name).isOk());
+ EXPECT_NE(name.size(), 0);
+}
+
+/*
+ * GetType
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, GetType) {
+ IfaceType type;
+ EXPECT_TRUE(p2p_iface_->getType(&type).isOk());
+ EXPECT_EQ(type, IfaceType::P2P);
+}
+
+/*
+ * GetDeviceAddress
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, GetDeviceAddress) {
+ std::vector<uint8_t> macAddr;
+ EXPECT_TRUE(p2p_iface_->getDeviceAddress(&macAddr).isOk());
+ EXPECT_EQ(macAddr.size(), 6);
+}
+
+/*
+ * GetSsid
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, GetSsid) {
+ // This will fail with fake values.
+ std::vector<uint8_t> ssid;
+ EXPECT_FALSE(p2p_iface_->getSsid(kTestMacAddr, &ssid).isOk());
+}
+
+/*
+ * GetGroupCapability
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, GetGroupCapability) {
+ // This will fail with fake values.
+ P2pGroupCapabilityMask cap;
+ EXPECT_FALSE(p2p_iface_->getGroupCapability(kTestMacAddr, &cap).isOk());
+}
+
+/*
+ * Set/Get Edmg
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetGetEdmg) {
+ bool emdg = false;
+ EXPECT_TRUE(p2p_iface_->setEdmg(true).isOk());
+ EXPECT_TRUE(p2p_iface_->getEdmg(&emdg).isOk());
+ EXPECT_EQ(emdg, true);
+
+ EXPECT_TRUE(p2p_iface_->setEdmg(false).isOk());
+ EXPECT_TRUE(p2p_iface_->getEdmg(&emdg).isOk());
+ EXPECT_EQ(emdg, false);
+}
+
+/*
+ * SetWpsDeviceName
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetWpsDeviceName) {
+ const std::string deviceName = "TestWpsDeviceName";
+ EXPECT_TRUE(p2p_iface_->setWpsDeviceName(deviceName).isOk());
+}
+
+/*
+ * SetWpsDeviceType
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetWpsDeviceType) {
+ const std::vector<uint8_t> deviceType = std::vector<uint8_t>(8, 0x01);
+ EXPECT_TRUE(p2p_iface_->setWpsDeviceType(deviceType).isOk());
+}
+
+/*
+ * SetWpsManufacturer
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetWpsManufacturer) {
+ const std::string deviceManufacturer = "TestManufacturer";
+ EXPECT_TRUE(p2p_iface_->setWpsManufacturer(deviceManufacturer).isOk());
+}
+
+/*
+ * SetWpsModelName
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetWpsModelName) {
+ const std::string modelName = "TestModelName";
+ EXPECT_TRUE(p2p_iface_->setWpsModelName(modelName).isOk());
+}
+
+/*
+ * SetWpsModelNumber
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetWpsModelNumber) {
+ const std::string modelNumber = "TestModelNumber";
+ EXPECT_TRUE(p2p_iface_->setWpsModelName(modelNumber).isOk());
+}
+
+/*
+ * SetWpsSerialNumber
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetWpsSerialNumber) {
+ const std::string serialNumber = "TestSerialNumber";
+ EXPECT_TRUE(p2p_iface_->setWpsSerialNumber(serialNumber).isOk());
+}
+
+/*
+ * SetWpsConfigMethods
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetWpsConfigMethods) {
+ const WpsConfigMethods config = WpsConfigMethods::DISPLAY;
+ EXPECT_TRUE(p2p_iface_->setWpsConfigMethods(config).isOk());
+}
+
+/*
+ * SetSsidPostfix
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetSsidPostfix) {
+ const std::vector<uint8_t> ssidPostfix = {'t', 'e', 's', 't'};
+ EXPECT_TRUE(p2p_iface_->setSsidPostfix(ssidPostfix).isOk());
+}
+
+/*
+ * SetWfdDeviceInfo
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetWfdDeviceInfo) {
+ const std::vector<uint8_t> wfdDeviceInfo = std::vector<uint8_t>(6, 0x01);
+ EXPECT_TRUE(p2p_iface_->setWfdDeviceInfo(wfdDeviceInfo).isOk());
+}
+
+/*
+ * SetWfdR2DeviceInfo
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetWfdR2DeviceInfo) {
+ const std::vector<uint8_t> wfdR2DeviceInfo = std::vector<uint8_t>(4, 0x01);
+ EXPECT_TRUE(p2p_iface_->setWfdR2DeviceInfo(wfdR2DeviceInfo).isOk());
+}
+
+/*
+ * SetGroupIdle
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetGroupIdle) {
+ // This will fail with fake values.
+ const uint32_t groupIdleTimeout = 8;
+ EXPECT_FALSE(
+ p2p_iface_->setGroupIdle(kTestGroupIfName, groupIdleTimeout).isOk());
+}
+
+/*
+ * SetPowerSave
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetPowerSave) {
+ // This will fail with fake values.
+ EXPECT_FALSE(p2p_iface_->setPowerSave(kTestGroupIfName, true).isOk());
+ EXPECT_FALSE(p2p_iface_->setPowerSave(kTestGroupIfName, false).isOk());
+}
+
+/*
+ * SetMiracastMode
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetMiracastMode) {
+ EXPECT_TRUE(p2p_iface_->setMiracastMode(MiracastMode::DISABLED).isOk());
+ EXPECT_TRUE(p2p_iface_->setMiracastMode(MiracastMode::SOURCE).isOk());
+ EXPECT_TRUE(p2p_iface_->setMiracastMode(MiracastMode::SINK).isOk());
+}
+
+/*
+ * SetDisallowedFrequencies
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetDisallowedFrequencies) {
+ FreqRange range1;
+ range1.min = 2412;
+ range1.max = 2432;
+ const std::vector<FreqRange> ranges = {range1};
+ EXPECT_TRUE(p2p_iface_->setDisallowedFrequencies(ranges).isOk());
+}
+
+/*
+ * SetListenChannel
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, SetListenChannel) {
+ const uint32_t testChannel = 1;
+ const uint32_t testOperatingClass = 81;
+ EXPECT_TRUE(
+ p2p_iface_->setListenChannel(testChannel, testOperatingClass).isOk());
+}
+
+/*
+ * SetMacRandomization
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, EnableMacRandomization) {
+ // Enable twice
+ EXPECT_TRUE(p2p_iface_->setMacRandomization(true).isOk());
+ EXPECT_TRUE(p2p_iface_->setMacRandomization(true).isOk());
+
+ // Disable twice
+ EXPECT_TRUE(p2p_iface_->setMacRandomization(false).isOk());
+ EXPECT_TRUE(p2p_iface_->setMacRandomization(false).isOk());
+}
+
+/*
+ * AddGroup
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, AddGroup) {
+ EXPECT_TRUE(p2p_iface_->addGroup(false, kTestNetworkId).isOk());
+}
+
+/*
+ * RemoveGroup
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, RemoveGroup) {
+ // This will fail with fake values.
+ EXPECT_FALSE(p2p_iface_->removeGroup(kTestGroupIfName).isOk());
+}
+
+/*
+ * AddGroupWithConfig - success.
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, AddGroupWithConfig_Success) {
+ EXPECT_TRUE(p2p_iface_
+ ->addGroupWithConfig(kTestSsid, kTestPassphrase,
+ kTestGroupPersistent, kTestGroupFreq,
+ kTestZeroMacAddr, kTestGroupIsJoin)
+ .isOk());
+}
+
+/*
+ * AddGroupWithConfig - failure due to invalid SSID.
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, AddGroupWithConfig_FailureInvalidSsid) {
+ const std::vector<uint8_t> ssid;
+ EXPECT_FALSE(p2p_iface_
+ ->addGroupWithConfig(ssid, kTestPassphrase,
+ kTestGroupPersistent, kTestGroupFreq,
+ kTestZeroMacAddr, kTestGroupIsJoin)
+ .isOk());
+}
+
+/*
+ * AddGroupWithConfig - failure due to invalid passphrase.
+ */
+TEST_P(SupplicantP2pIfaceAidlTest,
+ AddGroupWithConfig_FailureInvalidPassphrase) {
+ const std::string passphrase = "1234";
+ EXPECT_FALSE(p2p_iface_
+ ->addGroupWithConfig(kTestSsid, passphrase,
+ kTestGroupPersistent, kTestGroupFreq,
+ kTestZeroMacAddr, kTestGroupIsJoin)
+ .isOk());
+}
+
+/*
+ * AddGroupWithConfig - failure due to invalid frequency.
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, AddGroupWithConfig_FailureInvalidFrequency) {
+ const int freq = 9999;
+ EXPECT_FALSE(p2p_iface_
+ ->addGroupWithConfig(kTestSsid, kTestPassphrase,
+ kTestGroupPersistent, freq,
+ kTestZeroMacAddr, kTestGroupIsJoin)
+ .isOk());
+}
+
+/*
+ * Find
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, Find) {
+ EXPECT_TRUE(p2p_iface_->find(kTestFindTimeout).isOk());
+}
+
+/*
+ * StopFind
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, StopFind) {
+ EXPECT_TRUE(p2p_iface_->find(kTestFindTimeout).isOk());
+ EXPECT_TRUE(p2p_iface_->stopFind().isOk());
+}
+
+/*
+ * Flush
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, Flush) {
+ EXPECT_TRUE(p2p_iface_->flush().isOk());
+}
+
+/*
+ * Connect
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, Connect) {
+ /*
+ * Auto-join is not enabled before R. After enabling auto-join,
+ * this should always succeed.
+ */
+ std::string pin;
+ EXPECT_TRUE(p2p_iface_
+ ->connect(kTestMacAddr, WpsProvisionMethod::PBC,
+ kTestConnectPin, false, false,
+ kTestConnectGoIntent, &pin)
+ .isOk());
+}
+
+/*
+ * CancelConnect
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, CancelConnect) {
+ std::string pin;
+ EXPECT_TRUE(p2p_iface_
+ ->connect(kTestMacAddr, WpsProvisionMethod::PBC,
+ kTestConnectPin, false, false,
+ kTestConnectGoIntent, &pin)
+ .isOk());
+ EXPECT_TRUE(p2p_iface_->cancelConnect().isOk());
+}
+
+/*
+ * ProvisionDiscovery
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, ProvisionDiscovery) {
+ // This will fail with fake values.
+ EXPECT_FALSE(
+ p2p_iface_->provisionDiscovery(kTestMacAddr, WpsProvisionMethod::PBC)
+ .isOk());
+}
+
+/*
+ * Reject
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, Reject) {
+ // This will fail with fake values.
+ ASSERT_FALSE(p2p_iface_->reject(kTestMacAddr).isOk());
+}
+
+/*
+ * Invite
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, Invite) {
+ // This will fail with fake values.
+ EXPECT_FALSE(
+ p2p_iface_->invite(kTestGroupIfName, kTestMacAddr, kTestPeerMacAddr)
+ .isOk());
+}
+
+/*
+ * Reinvoke
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, Reinvoke) {
+ // This will fail with fake values.
+ EXPECT_FALSE(p2p_iface_->reinvoke(kTestNetworkId, kTestMacAddr).isOk());
+}
+
+/*
+ * ConfigureExtListen
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, ConfigureExtListen) {
+ const uint32_t extListenPeriod = 400;
+ const uint32_t extListenInterval = 400;
+ EXPECT_TRUE(
+ p2p_iface_->configureExtListen(extListenPeriod, extListenInterval)
+ .isOk());
+}
+
+/*
+ * FlushServices
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, FlushServices) {
+ EXPECT_TRUE(p2p_iface_->flushServices().isOk());
+}
+
+/*
+ * EnableWfd
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, EnableWfd) {
+ EXPECT_TRUE(p2p_iface_->enableWfd(true).isOk());
+ EXPECT_TRUE(p2p_iface_->enableWfd(false).isOk());
+}
+
+/*
+ * Add/Remove BonjourService
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, AddAndRemoveBonjourService) {
+ const std::string serviceQueryStr = "testquery";
+ const std::string serviceResponseStr = "testresponse";
+ const std::vector<uint8_t> bonjourServiceQuery =
+ std::vector<uint8_t>(serviceQueryStr.begin(), serviceQueryStr.end());
+ const std::vector<uint8_t> bonjourServiceResponse = std::vector<uint8_t>(
+ serviceResponseStr.begin(), serviceResponseStr.end());
+
+ EXPECT_TRUE(
+ p2p_iface_
+ ->addBonjourService(bonjourServiceQuery, bonjourServiceResponse)
+ .isOk());
+ EXPECT_TRUE(p2p_iface_->removeBonjourService(bonjourServiceQuery).isOk());
+
+ // This will fail because the boujour service with
+ // bonjourServiceQuery was already removed.
+ EXPECT_FALSE(p2p_iface_->removeBonjourService(bonjourServiceQuery).isOk());
+}
+
+/*
+ * Add/Remove UpnpService
+ */
+TEST_P(SupplicantP2pIfaceAidlTest, AddAndRemoveUpnpService) {
+ const std::string upnpServiceName = "TestServiceName";
+ EXPECT_TRUE(
+ p2p_iface_->addUpnpService(0 /* version */, upnpServiceName).isOk());
+ EXPECT_TRUE(
+ p2p_iface_->removeUpnpService(0 /* version */, upnpServiceName).isOk());
+
+ // This will fail because Upnp service with
+ // upnpServiceName was already removed.
+ EXPECT_FALSE(
+ p2p_iface_->removeUpnpService(0 /* version */, upnpServiceName).isOk());
+}
+
+INSTANTIATE_TEST_SUITE_P(Supplicant, SupplicantP2pIfaceAidlTest,
+ testing::ValuesIn(android::getAidlHalInstanceNames(
+ ISupplicant::descriptor)),
+ android::PrintInstanceNameToString);
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ProcessState::self()->setThreadPoolMaxThreadCount(1);
+ ProcessState::self()->startThreadPool();
+ return RUN_ALL_TESTS();
+}
diff --git a/wifi/supplicant/aidl/vts/functional/supplicant_sta_iface_aidl_test.cpp b/wifi/supplicant/aidl/vts/functional/supplicant_sta_iface_aidl_test.cpp
new file mode 100644
index 0000000..f51c07f
--- /dev/null
+++ b/wifi/supplicant/aidl/vts/functional/supplicant_sta_iface_aidl_test.cpp
@@ -0,0 +1,782 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <VtsCoreUtil.h>
+#include <aidl/Gtest.h>
+#include <aidl/Vintf.h>
+#include <aidl/android/hardware/wifi/supplicant/BnSupplicant.h>
+#include <aidl/android/hardware/wifi/supplicant/BnSupplicantStaIfaceCallback.h>
+#include <android/binder_manager.h>
+#include <android/binder_status.h>
+#include <binder/IServiceManager.h>
+#include <binder/ProcessState.h>
+#include <cutils/properties.h>
+
+#include "supplicant_test_utils.h"
+
+using aidl::android::hardware::wifi::supplicant::AnqpInfoId;
+using aidl::android::hardware::wifi::supplicant::BnSupplicantStaIfaceCallback;
+using aidl::android::hardware::wifi::supplicant::BtCoexistenceMode;
+using aidl::android::hardware::wifi::supplicant::ConnectionCapabilities;
+using aidl::android::hardware::wifi::supplicant::DebugLevel;
+using aidl::android::hardware::wifi::supplicant::DppAkm;
+using aidl::android::hardware::wifi::supplicant::DppCurve;
+using aidl::android::hardware::wifi::supplicant::DppNetRole;
+using aidl::android::hardware::wifi::supplicant::DppResponderBootstrapInfo;
+using aidl::android::hardware::wifi::supplicant::Hs20AnqpSubtypes;
+using aidl::android::hardware::wifi::supplicant::IfaceType;
+using aidl::android::hardware::wifi::supplicant::ISupplicant;
+using aidl::android::hardware::wifi::supplicant::ISupplicantStaIface;
+using aidl::android::hardware::wifi::supplicant::ISupplicantStaNetwork;
+using aidl::android::hardware::wifi::supplicant::KeyMgmtMask;
+using aidl::android::hardware::wifi::supplicant::RxFilterType;
+using aidl::android::hardware::wifi::supplicant::WpaDriverCapabilitiesMask;
+using aidl::android::hardware::wifi::supplicant::WpsConfigMethods;
+using android::ProcessState;
+
+static constexpr int TIMEOUT_PERIOD = 60;
+class IfaceDppCallback;
+
+namespace {
+const std::vector<uint8_t> kTestMacAddr = {0x56, 0x67, 0x67, 0xf4, 0x56, 0x92};
+const std::string kTestUri =
+ "DPP:C:81/1,117/"
+ "40;M:48d6d5bd1de1;I:G1197843;K:MDkwEwYHKoZIzj0CAQYIKoZIzj"
+ "0DAQcDIgAD0edY4X3N//HhMFYsZfMbQJTiNFtNIWF/cIwMB/gzqOM=;;";
+} // namespace
+
+class SupplicantStaIfaceCallback : public BnSupplicantStaIfaceCallback {
+ public:
+ SupplicantStaIfaceCallback() = default;
+
+ ::ndk::ScopedAStatus onAnqpQueryDone(
+ const std::vector<uint8_t>& /* bssid */,
+ const ::aidl::android::hardware::wifi::supplicant::AnqpData& /* data */,
+ const ::aidl::android::hardware::wifi::supplicant::
+ Hs20AnqpData& /* hs20Data */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onAssociationRejected(
+ const ::aidl::android::hardware::wifi::supplicant::
+ AssociationRejectionData& /* assocRejectData */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onAuthenticationTimeout(
+ const std::vector<uint8_t>& /* bssid */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onBssTmHandlingDone(
+ const ::aidl::android::hardware::wifi::supplicant::
+ BssTmData& /* tmData */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onBssidChanged(
+ ::aidl::android::hardware::wifi::supplicant::
+ BssidChangeReason /* reason */,
+ const std::vector<uint8_t>& /* bssid */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onDisconnected(
+ const std::vector<uint8_t>& /* bssid */, bool /* locallyGenerated */,
+ ::aidl::android::hardware::wifi::supplicant::
+ StaIfaceReasonCode /* reasonCode */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onDppFailure(
+ ::aidl::android::hardware::wifi::supplicant::DppFailureCode /* code */,
+ const std::string& /* ssid */, const std::string& /* channelList */,
+ const std::vector<char16_t>& /* bandList */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onDppProgress(
+ ::aidl::android::hardware::wifi::supplicant::DppProgressCode /* code */)
+ override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onDppSuccess(
+ ::aidl::android::hardware::wifi::supplicant::DppEventType /* type */)
+ override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onDppSuccessConfigReceived(
+ const std::vector<uint8_t>& /* ssid */,
+ const std::string& /* password */,
+ const std::vector<uint8_t>& /* psk */,
+ ::aidl::android::hardware::wifi::supplicant::DppAkm /* securityAkm */)
+ override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onDppSuccessConfigSent() override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onEapFailure(int32_t /* errorCode */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onExtRadioWorkStart(int32_t /* id */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onExtRadioWorkTimeout(int32_t /* id */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onHs20DeauthImminentNotice(
+ const std::vector<uint8_t>& /* bssid */, int32_t /* reasonCode */,
+ int32_t /* reAuthDelayInSec */, const std::string& /* url */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onHs20IconQueryDone(
+ const std::vector<uint8_t>& /* bssid */,
+ const std::string& /* fileName */,
+ const std::vector<uint8_t>& /* data */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onHs20SubscriptionRemediation(
+ const std::vector<uint8_t>& /* bssid */,
+ ::aidl::android::hardware::wifi::supplicant::OsuMethod /* osuMethod */,
+ const std::string& /* url */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus
+ onHs20TermsAndConditionsAcceptanceRequestedNotification(
+ const std::vector<uint8_t>& /* bssid */,
+ const std::string& /* url */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onNetworkAdded(int32_t /* id */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onNetworkNotFound(
+ const std::vector<uint8_t>& /* ssid */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onNetworkRemoved(int32_t /* id */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onPmkCacheAdded(
+ int64_t /* expirationTimeInSec */,
+ const std::vector<uint8_t>& /* serializedEntry */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onStateChanged(
+ ::aidl::android::hardware::wifi::supplicant::
+ StaIfaceCallbackState /* newState */,
+ const std::vector<uint8_t>& /* bssid */, int32_t /* id */,
+ const std::vector<uint8_t>& /* ssid */,
+ bool /* filsHlpSent */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onWpsEventFail(
+ const std::vector<uint8_t>& /* bssid */,
+ ::aidl::android::hardware::wifi::supplicant::
+ WpsConfigError /* configError */,
+ ::aidl::android::hardware::wifi::supplicant::
+ WpsErrorIndication /* errorInd */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onWpsEventPbcOverlap() override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onWpsEventSuccess() override {
+ return ndk::ScopedAStatus::ok();
+ }
+};
+
+class SupplicantStaIfaceAidlTest : public testing::TestWithParam<std::string> {
+ public:
+ void SetUp() override {
+ initializeService();
+ supplicant_ = ISupplicant::fromBinder(ndk::SpAIBinder(
+ AServiceManager_waitForService(GetParam().c_str())));
+ ASSERT_NE(supplicant_, nullptr);
+ ASSERT_TRUE(supplicant_
+ ->setDebugParams(DebugLevel::EXCESSIVE,
+ true, // show timestamps
+ true)
+ .isOk());
+ EXPECT_TRUE(supplicant_->addStaInterface(getStaIfaceName(), &sta_iface_)
+ .isOk());
+ ASSERT_NE(sta_iface_, nullptr);
+ }
+
+ void TearDown() override {
+ stopSupplicant();
+ startWifiFramework();
+ }
+
+ enum DppCallbackType {
+ ANY_CALLBACK = -2,
+ INVALID = -1,
+ EVENT_SUCCESS = 0,
+ EVENT_PROGRESS,
+ EVENT_FAILURE,
+ };
+
+ DppCallbackType dppCallbackType;
+ uint32_t code;
+
+ // Used as a mechanism to inform the test about data/event callback
+ inline void notify() {
+ std::unique_lock<std::mutex> lock(mtx_);
+ cv_.notify_one();
+ }
+
+ // Test code calls this function to wait for data/event callback
+ inline std::cv_status wait(DppCallbackType waitForCallbackType) {
+ std::unique_lock<std::mutex> lock(mtx_);
+ EXPECT_NE(INVALID, waitForCallbackType); // can't ASSERT in a
+ // non-void-returning method
+ auto now = std::chrono::system_clock::now();
+ std::cv_status status =
+ cv_.wait_until(lock, now + std::chrono::seconds(TIMEOUT_PERIOD));
+ return status;
+ }
+
+ protected:
+ std::shared_ptr<ISupplicant> supplicant_;
+ std::shared_ptr<ISupplicantStaIface> sta_iface_;
+
+ private:
+ // synchronization objects
+ std::mutex mtx_;
+ std::condition_variable cv_;
+};
+
+/*
+ * RegisterCallback
+ */
+TEST_P(SupplicantStaIfaceAidlTest, RegisterCallback) {
+ std::shared_ptr<SupplicantStaIfaceCallback> callback =
+ ndk::SharedRefBase::make<SupplicantStaIfaceCallback>();
+ ASSERT_NE(callback, nullptr);
+ EXPECT_TRUE(sta_iface_->registerCallback(callback).isOk());
+}
+
+/*
+ * GetConnectionCapabilities
+ */
+TEST_P(SupplicantStaIfaceAidlTest, GetConnectionCapabilities) {
+ ConnectionCapabilities cap;
+ EXPECT_TRUE(sta_iface_->getConnectionCapabilities(&cap).isOk());
+}
+
+/*
+ * GetWpaDriverCapabilities
+ */
+TEST_P(SupplicantStaIfaceAidlTest, GetWpaDriverCapabilities) {
+ WpaDriverCapabilitiesMask cap;
+ EXPECT_TRUE(sta_iface_->getWpaDriverCapabilities(&cap).isOk());
+}
+
+/*
+ * GetKeyMgmtCapabilities
+ */
+TEST_P(SupplicantStaIfaceAidlTest, GetKeyMgmtCapabilities) {
+ KeyMgmtMask cap;
+ EXPECT_TRUE(sta_iface_->getKeyMgmtCapabilities(&cap).isOk());
+
+ // Even though capabilities vary, these two are always set.
+ EXPECT_TRUE(!!(static_cast<uint32_t>(cap) &
+ static_cast<uint32_t>(KeyMgmtMask::NONE)));
+ EXPECT_TRUE(!!(static_cast<uint32_t>(cap) &
+ static_cast<uint32_t>(KeyMgmtMask::IEEE8021X)));
+}
+
+/*
+ * GetName
+ */
+TEST_P(SupplicantStaIfaceAidlTest, GetName) {
+ std::string name;
+ EXPECT_TRUE(sta_iface_->getName(&name).isOk());
+ EXPECT_NE(name.size(), 0);
+}
+
+/*
+ * GetType
+ */
+TEST_P(SupplicantStaIfaceAidlTest, GetType) {
+ IfaceType type;
+ EXPECT_TRUE(sta_iface_->getType(&type).isOk());
+ EXPECT_EQ(type, IfaceType::STA);
+}
+
+/*
+ * GetMacAddress
+ */
+TEST_P(SupplicantStaIfaceAidlTest, GetMacAddress) {
+ std::vector<uint8_t> macAddr;
+ EXPECT_TRUE(sta_iface_->getMacAddress(&macAddr).isOk());
+ EXPECT_EQ(macAddr.size(), 6);
+}
+
+/*
+ * ListNetworks
+ */
+TEST_P(SupplicantStaIfaceAidlTest, ListNetworks) {
+ std::vector<int32_t> networks;
+ EXPECT_TRUE(sta_iface_->listNetworks(&networks).isOk());
+}
+
+/*
+ * SetBtCoexistenceMode
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetBtCoexistenceMode) {
+ EXPECT_TRUE(
+ sta_iface_->setBtCoexistenceMode(BtCoexistenceMode::ENABLED).isOk());
+ EXPECT_TRUE(
+ sta_iface_->setBtCoexistenceMode(BtCoexistenceMode::DISABLED).isOk());
+ EXPECT_TRUE(
+ sta_iface_->setBtCoexistenceMode(BtCoexistenceMode::SENSE).isOk());
+}
+
+/*
+ * SetBtCoexistenceScanModeEnabled
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetBtCoexistenceScanModeEnabled) {
+ EXPECT_TRUE(sta_iface_->setBtCoexistenceScanModeEnabled(true).isOk());
+ EXPECT_TRUE(sta_iface_->setBtCoexistenceScanModeEnabled(false).isOk());
+}
+
+/*
+ * SetSuspendModeEnabled
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetSuspendModeEnabled) {
+ EXPECT_TRUE(sta_iface_->setSuspendModeEnabled(true).isOk());
+ EXPECT_TRUE(sta_iface_->setSuspendModeEnabled(false).isOk());
+}
+
+/*
+ * SetCountryCode
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetCountryCode) {
+ const std::vector<uint8_t> countryCode = {'M', 'X'};
+ EXPECT_TRUE(sta_iface_->setCountryCode(countryCode).isOk());
+}
+
+/*
+ * SetWpsDeviceName
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetWpsDeviceName) {
+ const std::string deviceName = "TestWpsDeviceName";
+ EXPECT_TRUE(sta_iface_->setWpsDeviceName(deviceName).isOk());
+}
+
+/*
+ * SetWpsDeviceType
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetWpsDeviceType) {
+ const std::vector<uint8_t> deviceType = {8, 0x1};
+ EXPECT_TRUE(sta_iface_->setWpsDeviceType(deviceType).isOk());
+}
+
+/*
+ * SetWpsManufacturer
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetWpsManufacturer) {
+ const std::string wpsManufacturer = "TestManufacturer";
+ EXPECT_TRUE(sta_iface_->setWpsManufacturer(wpsManufacturer).isOk());
+}
+
+/*
+ * SetWpsModelName
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetWpsModelName) {
+ const std::string modelName = "TestModelName";
+ EXPECT_TRUE(sta_iface_->setWpsModelName(modelName).isOk());
+}
+
+/*
+ * SetWpsModelNumber
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetWpsModelNumber) {
+ const std::string modelNumber = "TestModelNumber";
+ EXPECT_TRUE(sta_iface_->setWpsModelNumber(modelNumber).isOk());
+}
+
+/*
+ * SetWpsSerialNumber
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetWpsSerialNumber) {
+ const std::string serialNumber = "TestSerialNumber";
+ EXPECT_TRUE(sta_iface_->setWpsSerialNumber(serialNumber).isOk());
+}
+
+/*
+ * SetWpsConfigMethods
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetWpsConfigMethods) {
+ const WpsConfigMethods configMethods = WpsConfigMethods::KEYPAD;
+ EXPECT_TRUE(sta_iface_->setWpsConfigMethods(configMethods).isOk());
+}
+
+/*
+ * SetExternalSim
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetExternalSim) {
+ EXPECT_TRUE(sta_iface_->setExternalSim(true).isOk());
+ EXPECT_TRUE(sta_iface_->setExternalSim(false).isOk());
+}
+
+/*
+ * SetMboCellularDataStatus
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetMboCellularDataStatus) {
+ WpaDriverCapabilitiesMask cap;
+ EXPECT_TRUE(sta_iface_->getWpaDriverCapabilities(&cap).isOk());
+
+ // Operation should succeed if MBO is supported, or fail if it's not.
+ bool mboSupported =
+ !!(static_cast<uint32_t>(cap) &
+ static_cast<uint32_t>(WpaDriverCapabilitiesMask::MBO));
+ EXPECT_EQ(mboSupported, sta_iface_->setMboCellularDataStatus(true).isOk());
+}
+
+/*
+ * InitiateTdlsDiscover
+ */
+TEST_P(SupplicantStaIfaceAidlTest, InitiateTdlsDiscover) {
+ EXPECT_TRUE(sta_iface_->initiateTdlsDiscover(kTestMacAddr).isOk());
+}
+
+/*
+ * InitiateTdlsSetup
+ */
+TEST_P(SupplicantStaIfaceAidlTest, InitiateTdlsSetup) {
+ EXPECT_TRUE(sta_iface_->initiateTdlsSetup(kTestMacAddr).isOk());
+}
+
+/*
+ * InitiateTdlsTeardown
+ */
+TEST_P(SupplicantStaIfaceAidlTest, InitiateTdlsTeardown) {
+ EXPECT_TRUE(sta_iface_->initiateTdlsTeardown(kTestMacAddr).isOk());
+}
+
+/*
+ * InitiateAnqpQuery
+ */
+TEST_P(SupplicantStaIfaceAidlTest, InitiateAnqpQuery) {
+ const std::vector<AnqpInfoId> anqpIds = {
+ AnqpInfoId::VENUE_NAME, AnqpInfoId::NAI_REALM, AnqpInfoId::DOMAIN_NAME};
+ const std::vector<Hs20AnqpSubtypes> hsTypes = {
+ Hs20AnqpSubtypes::WAN_METRICS,
+ Hs20AnqpSubtypes::OPERATOR_FRIENDLY_NAME};
+
+ // Request should fail since the BSSID mentioned
+ // is not present in the scan results
+ EXPECT_FALSE(
+ sta_iface_->initiateAnqpQuery(kTestMacAddr, anqpIds, hsTypes).isOk());
+}
+
+/*
+ * InitiateHs20IconQuery
+ */
+TEST_P(SupplicantStaIfaceAidlTest, InitiateHs20IconQuery) {
+ // Request should fail since the BSSID mentioned
+ // is not present in the scan results
+ const std::string hs20IconFile = "TestFile";
+ EXPECT_FALSE(
+ sta_iface_->initiateHs20IconQuery(kTestMacAddr, hs20IconFile).isOk());
+}
+
+/*
+ * InitiateVenueUrlAnqpQuery.
+ */
+TEST_P(SupplicantStaIfaceAidlTest, InitiateVenueUrlAnqpQuery) {
+ // Request should fail since the BSSID mentioned
+ // is not present in the scan results
+ EXPECT_FALSE(sta_iface_->initiateVenueUrlAnqpQuery(kTestMacAddr).isOk());
+}
+
+/*
+ * Reassociate
+ */
+TEST_P(SupplicantStaIfaceAidlTest, Reassociate) {
+ EXPECT_TRUE(sta_iface_->reassociate().isOk());
+}
+
+/*
+ * Reconnect
+ */
+TEST_P(SupplicantStaIfaceAidlTest, Reconnect) {
+ EXPECT_FALSE(sta_iface_->reconnect().isOk());
+}
+
+/*
+ * Disconnect
+ */
+TEST_P(SupplicantStaIfaceAidlTest, Disconnect) {
+ EXPECT_TRUE(sta_iface_->disconnect().isOk());
+}
+
+/*
+ * SetPowerSave
+ */
+TEST_P(SupplicantStaIfaceAidlTest, SetPowerSave) {
+ EXPECT_TRUE(sta_iface_->setPowerSave(true).isOk());
+ EXPECT_TRUE(sta_iface_->setPowerSave(false).isOk());
+}
+
+/*
+ * StartRxFilter
+ */
+TEST_P(SupplicantStaIfaceAidlTest, StartRxFilter) {
+ EXPECT_TRUE(sta_iface_->startRxFilter().isOk());
+}
+
+/*
+ * StopRxFilter
+ */
+TEST_P(SupplicantStaIfaceAidlTest, StopRxFilter) {
+ EXPECT_TRUE(sta_iface_->stopRxFilter().isOk());
+}
+
+/*
+ * AddRxFilter
+ */
+TEST_P(SupplicantStaIfaceAidlTest, AddRxFilter) {
+ EXPECT_TRUE(sta_iface_->addRxFilter(RxFilterType::V4_MULTICAST).isOk());
+ EXPECT_TRUE(sta_iface_->addRxFilter(RxFilterType::V6_MULTICAST).isOk());
+}
+
+/*
+ * RemoveRxFilter
+ */
+TEST_P(SupplicantStaIfaceAidlTest, RemoveRxFilter) {
+ EXPECT_TRUE(sta_iface_->removeRxFilter(RxFilterType::V4_MULTICAST).isOk());
+ EXPECT_TRUE(sta_iface_->removeRxFilter(RxFilterType::V6_MULTICAST).isOk());
+}
+
+/*
+ * AddExtRadioWork
+ */
+TEST_P(SupplicantStaIfaceAidlTest, AddExtRadioWork) {
+ const std::string radioWorkName = "TestRadioWork";
+ const int32_t radioWorkFreq = 2412;
+ const int32_t radioWorkTimeout = 8;
+ int32_t radioWorkId;
+ EXPECT_TRUE(sta_iface_
+ ->addExtRadioWork(radioWorkName, radioWorkFreq,
+ radioWorkTimeout, &radioWorkId)
+ .isOk());
+ // removeExtRadio only succeeds if the added radio work hasn't started yet,
+ // so there is no guaranteed result from calling removeExtRadioWork here.
+ // Given that, we can't currently test removeExtRadioWork following
+ // a call to addExtRadioWork.
+}
+
+/*
+ * RemoveExtRadioWork
+ */
+TEST_P(SupplicantStaIfaceAidlTest, RemoveExtRadioWork) {
+ // This fails because there is no ongoing radio work with radioWorkId
+ const int32_t radioWorkId = 16;
+ EXPECT_FALSE(sta_iface_->removeExtRadioWork(radioWorkId).isOk());
+}
+
+/*
+ * Add/Remove DppPeerUri
+ */
+TEST_P(SupplicantStaIfaceAidlTest, AddRemoveDppPeerUri) {
+ if (!keyMgmtSupported(sta_iface_, KeyMgmtMask::DPP)) {
+ GTEST_SKIP() << "Missing DPP support";
+ }
+ // Add a peer URI and then remove it.
+ int32_t peerId;
+ EXPECT_TRUE(sta_iface_->addDppPeerUri(kTestUri, &peerId).isOk());
+ EXPECT_TRUE(sta_iface_->removeDppUri(peerId).isOk());
+}
+
+/*
+ * FilsHlpAddRequest
+ */
+TEST_P(SupplicantStaIfaceAidlTest, FilsHlpAddRequest) {
+ if (!isFilsSupported(sta_iface_)) {
+ GTEST_SKIP()
+ << "Skipping test since driver/supplicant doesn't support FILS";
+ }
+ const std::vector<uint8_t> destMacAddr = {0x00, 0x11, 0x22,
+ 0x33, 0x44, 0x55};
+ const std::vector<uint8_t> pktBuffer = std::vector<uint8_t>(300, 0x3a);
+ EXPECT_TRUE(sta_iface_->filsHlpAddRequest(destMacAddr, pktBuffer).isOk());
+}
+
+/*
+ * FilsHlpFlushRequest
+ */
+TEST_P(SupplicantStaIfaceAidlTest, FilsHlpFlushRequest) {
+ if (!isFilsSupported(sta_iface_)) {
+ GTEST_SKIP()
+ << "Skipping test since driver/supplicant doesn't support FILS";
+ }
+ EXPECT_TRUE(sta_iface_->filsHlpFlushRequest().isOk());
+}
+
+/*
+ * StartDppEnrolleeResponder
+ */
+TEST_P(SupplicantStaIfaceAidlTest, StartDppEnrolleeResponder) {
+ if (!keyMgmtSupported(sta_iface_, KeyMgmtMask::DPP)) {
+ GTEST_SKIP() << "Missing DPP support";
+ }
+
+ const std::string deviceInfo = "DPP_Responder_Mode_VTS_Test";
+ const std::vector<uint8_t> mac_address = {0x22, 0x33, 0x44,
+ 0x55, 0x66, 0x77};
+
+ // Generate DPP bootstrap information.
+ DppResponderBootstrapInfo bootstrapInfo;
+ EXPECT_TRUE(
+ sta_iface_
+ ->generateDppBootstrapInfoForResponder(
+ mac_address, deviceInfo, DppCurve::PRIME256V1, &bootstrapInfo)
+ .isOk());
+ EXPECT_NE(-1, bootstrapInfo.bootstrapId);
+ EXPECT_NE(0, bootstrapInfo.bootstrapId);
+ EXPECT_NE(0, bootstrapInfo.listenChannel);
+ const uint32_t bootstrap_id = bootstrapInfo.bootstrapId;
+ const uint32_t listen_channel = bootstrapInfo.listenChannel;
+
+ // Start DPP as Enrollee-Responder.
+ EXPECT_TRUE(sta_iface_->startDppEnrolleeResponder(listen_channel).isOk());
+
+ // Stop DPP Enrollee-Responder mode, ie remove the URI and stop listen.
+ EXPECT_TRUE(sta_iface_->stopDppResponder(bootstrap_id).isOk());
+}
+
+class IfaceDppCallback : public SupplicantStaIfaceCallback {
+ SupplicantStaIfaceAidlTest& parent_;
+ ::ndk::ScopedAStatus onDppSuccess(
+ ::aidl::android::hardware::wifi::supplicant::DppEventType event)
+ override {
+ parent_.code = (uint32_t)event;
+ parent_.dppCallbackType =
+ SupplicantStaIfaceAidlTest::DppCallbackType::EVENT_SUCCESS;
+ parent_.notify();
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onDppProgress(
+ aidl::android::hardware::wifi::supplicant::DppProgressCode code)
+ override {
+ parent_.code = (uint32_t)code;
+ parent_.dppCallbackType =
+ SupplicantStaIfaceAidlTest::DppCallbackType::EVENT_PROGRESS;
+ parent_.notify();
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onDppFailure(
+ aidl::android::hardware::wifi::supplicant::DppFailureCode code,
+ const std::string& ssid __attribute__((unused)),
+ const std::string& channelList __attribute__((unused)),
+ const std::vector<char16_t>& bandList
+ __attribute__((unused))) override {
+ parent_.code = (uint32_t)code;
+ parent_.dppCallbackType =
+ SupplicantStaIfaceAidlTest::DppCallbackType::EVENT_FAILURE;
+ parent_.notify();
+ return ndk::ScopedAStatus::ok();
+ }
+
+ public:
+ IfaceDppCallback(SupplicantStaIfaceAidlTest& parent) : parent_(parent){};
+};
+
+/*
+ * StartDppEnrolleeInitiator
+ */
+TEST_P(SupplicantStaIfaceAidlTest, StartDppEnrolleeInitiator) {
+ if (!keyMgmtSupported(sta_iface_, KeyMgmtMask::DPP)) {
+ GTEST_SKIP() << "Missing DPP support";
+ }
+
+ // Register callback
+ std::shared_ptr<IfaceDppCallback> callback =
+ ndk::SharedRefBase::make<IfaceDppCallback>(*this);
+ EXPECT_NE(callback, nullptr);
+ EXPECT_TRUE(sta_iface_->registerCallback(callback).isOk());
+
+ // Add a peer URI
+ int32_t peer_id = 0;
+ EXPECT_TRUE(sta_iface_->addDppPeerUri(kTestUri, &peer_id).isOk());
+ EXPECT_NE(0, peer_id);
+ EXPECT_NE(-1, peer_id);
+
+ // Start DPP as Enrollee-Initiator. Since this operation requires two
+ // devices, we start the operation and expect a timeout.
+ EXPECT_TRUE(sta_iface_->startDppEnrolleeInitiator(peer_id, 0).isOk());
+
+ // Wait for the timeout callback
+ EXPECT_EQ(std::cv_status::no_timeout,
+ wait(SupplicantStaIfaceAidlTest::DppCallbackType::EVENT_FAILURE));
+ EXPECT_EQ(SupplicantStaIfaceAidlTest::DppCallbackType::EVENT_FAILURE,
+ dppCallbackType);
+
+ // ...and then remove the peer URI.
+ EXPECT_TRUE(sta_iface_->removeDppUri(peer_id).isOk());
+}
+
+/*
+ * StartDppConfiguratorInitiator
+ */
+TEST_P(SupplicantStaIfaceAidlTest, StartDppConfiguratorInitiator) {
+ if (!keyMgmtSupported(sta_iface_, KeyMgmtMask::DPP)) {
+ GTEST_SKIP() << "Missing DPP support";
+ }
+
+ // Register callback
+ std::shared_ptr<IfaceDppCallback> callback =
+ ndk::SharedRefBase::make<IfaceDppCallback>(*this);
+ EXPECT_NE(callback, nullptr);
+ EXPECT_TRUE(sta_iface_->registerCallback(callback).isOk());
+
+ // Add a peer URI
+ int32_t peer_id = 0;
+ EXPECT_TRUE(sta_iface_->addDppPeerUri(kTestUri, &peer_id).isOk());
+ EXPECT_NE(0, peer_id);
+ EXPECT_NE(-1, peer_id);
+
+ const std::string ssid =
+ "6D795F746573745F73736964"; // 'my_test_ssid' encoded in hex
+ const std::string password =
+ "746F70736563726574"; // 'topsecret' encoded in hex
+
+ // Start DPP as Configurator-Initiator. Since this operation requires two
+ // devices, we start the operation and expect a timeout.
+ EXPECT_TRUE(sta_iface_
+ ->startDppConfiguratorInitiator(peer_id, 0, ssid, password,
+ "", DppNetRole::STA,
+ DppAkm::PSK)
+ .isOk());
+
+ // Wait for the timeout callback
+ ASSERT_EQ(std::cv_status::no_timeout,
+ wait(SupplicantStaIfaceAidlTest::DppCallbackType::EVENT_FAILURE));
+ ASSERT_EQ(SupplicantStaIfaceAidlTest::DppCallbackType::EVENT_FAILURE,
+ dppCallbackType);
+
+ // ...and then remove the peer URI.
+ EXPECT_TRUE(sta_iface_->removeDppUri(peer_id).isOk());
+}
+
+INSTANTIATE_TEST_SUITE_P(Supplicant, SupplicantStaIfaceAidlTest,
+ testing::ValuesIn(android::getAidlHalInstanceNames(
+ ISupplicant::descriptor)),
+ android::PrintInstanceNameToString);
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ProcessState::self()->setThreadPoolMaxThreadCount(1);
+ ProcessState::self()->startThreadPool();
+ return RUN_ALL_TESTS();
+}
diff --git a/wifi/supplicant/aidl/vts/functional/supplicant_sta_network_aidl_test.cpp b/wifi/supplicant/aidl/vts/functional/supplicant_sta_network_aidl_test.cpp
new file mode 100644
index 0000000..66c8807
--- /dev/null
+++ b/wifi/supplicant/aidl/vts/functional/supplicant_sta_network_aidl_test.cpp
@@ -0,0 +1,791 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <VtsCoreUtil.h>
+#include <aidl/Gtest.h>
+#include <aidl/Vintf.h>
+#include <aidl/android/hardware/wifi/supplicant/BnSupplicant.h>
+#include <aidl/android/hardware/wifi/supplicant/BnSupplicantStaNetworkCallback.h>
+#include <android/binder_manager.h>
+#include <android/binder_status.h>
+#include <binder/IServiceManager.h>
+#include <binder/ProcessState.h>
+#include <cutils/properties.h>
+
+#include "supplicant_test_utils.h"
+
+using aidl::android::hardware::wifi::supplicant::AuthAlgMask;
+using aidl::android::hardware::wifi::supplicant::BnSupplicantStaNetworkCallback;
+using aidl::android::hardware::wifi::supplicant::DebugLevel;
+using aidl::android::hardware::wifi::supplicant::EapMethod;
+using aidl::android::hardware::wifi::supplicant::EapPhase2Method;
+using aidl::android::hardware::wifi::supplicant::GroupCipherMask;
+using aidl::android::hardware::wifi::supplicant::GroupMgmtCipherMask;
+using aidl::android::hardware::wifi::supplicant::IfaceType;
+using aidl::android::hardware::wifi::supplicant::ISupplicant;
+using aidl::android::hardware::wifi::supplicant::ISupplicantStaIface;
+using aidl::android::hardware::wifi::supplicant::ISupplicantStaNetwork;
+using aidl::android::hardware::wifi::supplicant::KeyMgmtMask;
+using aidl::android::hardware::wifi::supplicant::
+ NetworkRequestEapSimGsmAuthParams;
+using aidl::android::hardware::wifi::supplicant::
+ NetworkRequestEapSimUmtsAuthParams;
+using aidl::android::hardware::wifi::supplicant::
+ NetworkResponseEapSimGsmAuthParams;
+using aidl::android::hardware::wifi::supplicant::
+ NetworkResponseEapSimUmtsAuthParams;
+using aidl::android::hardware::wifi::supplicant::OcspType;
+using aidl::android::hardware::wifi::supplicant::PairwiseCipherMask;
+using aidl::android::hardware::wifi::supplicant::ProtoMask;
+using aidl::android::hardware::wifi::supplicant::SaeH2eMode;
+using aidl::android::hardware::wifi::supplicant::TransitionDisableIndication;
+using aidl::android::hardware::wifi::supplicant::WpaDriverCapabilitiesMask;
+using android::ProcessState;
+
+namespace {
+const std::vector<uint8_t> kTestIdentity = {0x45, 0x67, 0x98, 0x67, 0x56};
+const std::vector<uint8_t> kTestEncryptedIdentity = {0x35, 0x37, 0x58, 0x57,
+ 0x26};
+const std::string kTestSsidStr = "TestSsid1234";
+const std::vector<uint8_t> kTestSsid =
+ std::vector<uint8_t>(kTestSsidStr.begin(), kTestSsidStr.end());
+const std::vector<uint8_t> kTestBssid = {0x56, 0x67, 0x67, 0xf4, 0x56, 0x92};
+const std::string kTestPskPassphrase =
+ "\"123456780abcdef0123456780abcdef0deadbeef\"";
+const std::string kTestEapCert = "keystore://CERT";
+const std::string kTestEapMatch = "match";
+const KeyMgmtMask kTestKeyMgmt =
+ static_cast<KeyMgmtMask>(static_cast<uint32_t>(KeyMgmtMask::WPA_PSK) |
+ static_cast<uint32_t>(KeyMgmtMask::WPA_EAP));
+
+} // namespace
+
+class SupplicantStaNetworkCallback : public BnSupplicantStaNetworkCallback {
+ public:
+ SupplicantStaNetworkCallback() = default;
+
+ ::ndk::ScopedAStatus onNetworkEapIdentityRequest() override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onNetworkEapSimGsmAuthRequest(
+ const NetworkRequestEapSimGsmAuthParams& /* params */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onNetworkEapSimUmtsAuthRequest(
+ const NetworkRequestEapSimUmtsAuthParams& /* params */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+ ::ndk::ScopedAStatus onTransitionDisable(
+ TransitionDisableIndication /* ind */) override {
+ return ndk::ScopedAStatus::ok();
+ }
+};
+
+class SupplicantStaNetworkAidlTest
+ : public testing::TestWithParam<std::string> {
+ public:
+ void SetUp() override {
+ initializeService();
+ supplicant_ = ISupplicant::fromBinder(ndk::SpAIBinder(
+ AServiceManager_waitForService(GetParam().c_str())));
+ ASSERT_NE(supplicant_, nullptr);
+ ASSERT_TRUE(supplicant_
+ ->setDebugParams(DebugLevel::EXCESSIVE,
+ true, // show timestamps
+ true)
+ .isOk());
+ EXPECT_TRUE(supplicant_->addStaInterface(getStaIfaceName(), &sta_iface_)
+ .isOk());
+ ASSERT_NE(sta_iface_, nullptr);
+ EXPECT_TRUE(sta_iface_->addNetwork(&sta_network_).isOk());
+ ASSERT_NE(sta_network_, nullptr);
+ }
+
+ void TearDown() override {
+ stopSupplicant();
+ startWifiFramework();
+ }
+
+ protected:
+ std::shared_ptr<ISupplicant> supplicant_;
+ std::shared_ptr<ISupplicantStaIface> sta_iface_;
+ std::shared_ptr<ISupplicantStaNetwork> sta_network_;
+
+ void removeNetwork() {
+ ASSERT_NE(sta_iface_, nullptr);
+ int32_t net_id;
+ EXPECT_TRUE(sta_network_->getId(&net_id).isOk());
+ EXPECT_TRUE(sta_iface_->removeNetwork(net_id).isOk());
+ }
+};
+
+/*
+ * RegisterCallback
+ */
+TEST_P(SupplicantStaNetworkAidlTest, RegisterCallback) {
+ std::shared_ptr<SupplicantStaNetworkCallback> callback =
+ ndk::SharedRefBase::make<SupplicantStaNetworkCallback>();
+ ASSERT_NE(callback, nullptr);
+ EXPECT_TRUE(sta_network_->registerCallback(callback).isOk());
+}
+
+/*
+ * GetInterfaceName
+ */
+TEST_P(SupplicantStaNetworkAidlTest, GetInterfaceName) {
+ std::string name;
+ EXPECT_TRUE(sta_network_->getInterfaceName(&name).isOk());
+ EXPECT_NE(name.size(), 0);
+}
+
+/*
+ * GetType
+ */
+TEST_P(SupplicantStaNetworkAidlTest, GetType) {
+ IfaceType type;
+ EXPECT_TRUE(sta_network_->getType(&type).isOk());
+ EXPECT_EQ(type, IfaceType::STA);
+}
+
+/*
+ * Set/Get ScanSsid
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetScanSsid) {
+ bool scanSsid = false;
+ EXPECT_TRUE(sta_network_->setScanSsid(true).isOk());
+ EXPECT_TRUE(sta_network_->getScanSsid(&scanSsid).isOk());
+ EXPECT_TRUE(scanSsid);
+}
+
+/*
+ * Set/Get RequirePmf
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetRequirePmf) {
+ bool requirePmf = false;
+ EXPECT_TRUE(sta_network_->setRequirePmf(true).isOk());
+ EXPECT_TRUE(sta_network_->getRequirePmf(&requirePmf).isOk());
+ EXPECT_TRUE(requirePmf);
+}
+
+/*
+ * Set/Get IdStr
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetIdStr) {
+ const std::string savedIdStr = "TestIdstr";
+ EXPECT_TRUE(sta_network_->setIdStr(savedIdStr).isOk());
+
+ std::string retrievedIdStr;
+ EXPECT_TRUE(sta_network_->getIdStr(&retrievedIdStr).isOk());
+ EXPECT_EQ(retrievedIdStr, savedIdStr);
+}
+
+/*
+ * Set/Get EapMethod
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapMethod) {
+ const EapMethod savedMethod = EapMethod::PEAP;
+ EXPECT_TRUE(sta_network_->setEapMethod(savedMethod).isOk());
+
+ EapMethod retrievedMethod;
+ EXPECT_TRUE(sta_network_->getEapMethod(&retrievedMethod).isOk());
+ EXPECT_EQ(retrievedMethod, savedMethod);
+}
+
+/*
+ * Set/Get EapPhase2Method
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapPhase2Method) {
+ const EapMethod savedEapMethod = EapMethod::PEAP;
+ EXPECT_TRUE(sta_network_->setEapMethod(savedEapMethod).isOk());
+
+ const EapPhase2Method savedPhase2Method = EapPhase2Method::NONE;
+ EXPECT_TRUE(sta_network_->setEapPhase2Method(savedPhase2Method).isOk());
+
+ EapPhase2Method retrievedMethod;
+ EXPECT_TRUE(sta_network_->getEapPhase2Method(&retrievedMethod).isOk());
+ EXPECT_EQ(retrievedMethod, savedPhase2Method);
+}
+
+/*
+ * Set/Get EapIdentity
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapIdentity) {
+ EXPECT_TRUE(sta_network_->setEapIdentity(kTestIdentity).isOk());
+
+ std::vector<uint8_t> retrievedIdentity;
+ EXPECT_TRUE(sta_network_->getEapIdentity(&retrievedIdentity).isOk());
+ EXPECT_EQ(retrievedIdentity, kTestIdentity);
+}
+
+/*
+ * Set/Get EapAnonymousIdentity
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapAnonymousIdentity) {
+ EXPECT_TRUE(sta_network_->setEapAnonymousIdentity(kTestIdentity).isOk());
+
+ std::vector<uint8_t> retrievedIdentity;
+ EXPECT_TRUE(
+ sta_network_->getEapAnonymousIdentity(&retrievedIdentity).isOk());
+ EXPECT_EQ(retrievedIdentity, kTestIdentity);
+}
+
+/*
+ * Set/Get EapPassword
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapPassword) {
+ const std::string eapPasswdStr = "TestEapPasswd1234";
+ const std::vector<uint8_t> savedEapPasswd =
+ std::vector<uint8_t>(eapPasswdStr.begin(), eapPasswdStr.end());
+ ASSERT_TRUE(sta_network_->setEapPassword(savedEapPasswd).isOk());
+
+ std::vector<uint8_t> retrievedEapPasswd;
+ ASSERT_TRUE(sta_network_->getEapPassword(&retrievedEapPasswd).isOk());
+ ASSERT_EQ(retrievedEapPasswd, savedEapPasswd);
+}
+
+/*
+ * Set/Get EapCACert
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapCACert) {
+ EXPECT_TRUE(sta_network_->setEapCACert(kTestEapCert).isOk());
+
+ std::string retrievedCert;
+ EXPECT_TRUE(sta_network_->getEapCACert(&retrievedCert).isOk());
+ EXPECT_EQ(retrievedCert, kTestEapCert);
+}
+
+/*
+ * Set/Get EapCAPath
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapCAPath) {
+ EXPECT_TRUE(sta_network_->setEapCAPath(kTestEapCert).isOk());
+
+ std::string retrievedCert;
+ EXPECT_TRUE(sta_network_->getEapCAPath(&retrievedCert).isOk());
+ EXPECT_EQ(retrievedCert, kTestEapCert);
+}
+
+/*
+ * Set/Get EapClientCert
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapClientCert) {
+ EXPECT_TRUE(sta_network_->setEapClientCert(kTestEapCert).isOk());
+
+ std::string retrievedCert;
+ EXPECT_TRUE(sta_network_->getEapClientCert(&retrievedCert).isOk());
+ EXPECT_EQ(retrievedCert, kTestEapCert);
+}
+
+/*
+ * Set/Get EapPrivateKeyId
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapPrivateKeyId) {
+ std::string savedKeyId = "key_id";
+ EXPECT_TRUE(sta_network_->setEapPrivateKeyId(savedKeyId).isOk());
+
+ std::string retrievedKeyId;
+ EXPECT_TRUE(sta_network_->getEapPrivateKeyId(&retrievedKeyId).isOk());
+ EXPECT_EQ(retrievedKeyId, savedKeyId);
+}
+
+/*
+ * Set/Get EapAltSubjectMatch
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapAltSubjectMatch) {
+ EXPECT_TRUE(sta_network_->setEapAltSubjectMatch(kTestEapMatch).isOk());
+
+ std::string retrievedMatch;
+ EXPECT_TRUE(sta_network_->getEapAltSubjectMatch(&retrievedMatch).isOk());
+ EXPECT_EQ(retrievedMatch, kTestEapMatch);
+}
+
+/*
+ * Set/Get EapSubjectMatch
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapSubjectMatch) {
+ EXPECT_TRUE(sta_network_->setEapSubjectMatch(kTestEapMatch).isOk());
+
+ std::string retrievedMatch;
+ EXPECT_TRUE(sta_network_->getEapSubjectMatch(&retrievedMatch).isOk());
+ EXPECT_EQ(retrievedMatch, kTestEapMatch);
+}
+
+/*
+ * Set/Get EapDomainSuffixMatch
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapDomainSuffixMatch) {
+ EXPECT_TRUE(sta_network_->setEapDomainSuffixMatch(kTestEapMatch).isOk());
+
+ std::string retrievedMatch;
+ EXPECT_TRUE(sta_network_->getEapDomainSuffixMatch(&retrievedMatch).isOk());
+ EXPECT_EQ(retrievedMatch, kTestEapMatch);
+}
+
+/*
+ * Set/Get EapEngine
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapEngine) {
+ bool retrievedEapEngine = false;
+ EXPECT_TRUE(sta_network_->setEapEngine(true).isOk());
+ EXPECT_TRUE(sta_network_->getEapEngine(&retrievedEapEngine).isOk());
+ EXPECT_TRUE(retrievedEapEngine);
+}
+
+/*
+ * Set/Get EapEngineID
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetEapEngineId) {
+ const std::string savedEngineId = "engine_id";
+ EXPECT_TRUE(sta_network_->setEapEngineID(savedEngineId).isOk());
+
+ std::string retrievedId;
+ EXPECT_TRUE(sta_network_->getEapEngineId(&retrievedId).isOk());
+ EXPECT_EQ(retrievedId, savedEngineId);
+}
+
+/*
+ * Set/Get Ocsp
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetOcsp) {
+ const OcspType savedOcspType = OcspType::REQUEST_CERT_STATUS;
+ EXPECT_TRUE(sta_network_->setOcsp(savedOcspType).isOk());
+
+ const OcspType invalidOcspType = static_cast<OcspType>(-1);
+ EXPECT_FALSE(sta_network_->setOcsp(invalidOcspType).isOk());
+
+ OcspType retrievedOcspType;
+ EXPECT_TRUE(sta_network_->getOcsp(&retrievedOcspType).isOk());
+ EXPECT_EQ(retrievedOcspType, savedOcspType);
+}
+
+/*
+ * Set/Get KeyMgmt
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetKeyMgmt) {
+ KeyMgmtMask savedKeyMgmt = KeyMgmtMask::WAPI_PSK;
+ EXPECT_TRUE(sta_network_->setKeyMgmt(savedKeyMgmt).isOk());
+
+ KeyMgmtMask retrievedKeyMgmt;
+ EXPECT_TRUE(sta_network_->getKeyMgmt(&retrievedKeyMgmt).isOk());
+ EXPECT_EQ(retrievedKeyMgmt, savedKeyMgmt);
+
+ savedKeyMgmt = KeyMgmtMask::WAPI_CERT;
+ EXPECT_TRUE(sta_network_->setKeyMgmt(savedKeyMgmt).isOk());
+
+ EXPECT_TRUE(sta_network_->getKeyMgmt(&retrievedKeyMgmt).isOk());
+ EXPECT_EQ(retrievedKeyMgmt, savedKeyMgmt);
+}
+
+/*
+ * Set/Get Proto
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetProto) {
+ const ProtoMask savedProto = ProtoMask::WAPI;
+ EXPECT_TRUE(sta_network_->setProto(savedProto).isOk());
+
+ ProtoMask retrievedProto;
+ EXPECT_TRUE(sta_network_->getProto(&retrievedProto).isOk());
+ EXPECT_EQ(retrievedProto, savedProto);
+}
+
+/*
+ * Set/Get GroupCipher
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetGroupCipher) {
+ const GroupCipherMask savedCipher = GroupCipherMask::SMS4;
+ EXPECT_TRUE(sta_network_->setGroupCipher(savedCipher).isOk());
+
+ GroupCipherMask retrievedCipher;
+ EXPECT_TRUE(sta_network_->getGroupCipher(&retrievedCipher).isOk());
+ EXPECT_EQ(retrievedCipher, savedCipher);
+}
+
+/*
+ * Set/Get PairwiseCipher
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetPairwiseCipher) {
+ const PairwiseCipherMask savedCipher = PairwiseCipherMask::SMS4;
+ EXPECT_TRUE(sta_network_->setPairwiseCipher(savedCipher).isOk());
+
+ PairwiseCipherMask retrievedCipher;
+ EXPECT_TRUE(sta_network_->getPairwiseCipher(&retrievedCipher).isOk());
+ EXPECT_EQ(retrievedCipher, savedCipher);
+}
+
+/*
+ * Set/Get WapiCertSuite
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetWapiCertSuite) {
+ if (!keyMgmtSupported(sta_iface_, KeyMgmtMask::WAPI_PSK)) {
+ GTEST_SKIP() << "Skipping test since WAPI is not supported.";
+ }
+
+ const std::string savedCertSuite = "suite";
+ EXPECT_TRUE(sta_network_->setWapiCertSuite(savedCertSuite).isOk());
+
+ std::string retrievedCertSuite;
+ EXPECT_TRUE(sta_network_->getWapiCertSuite(&retrievedCertSuite).isOk());
+ EXPECT_EQ(retrievedCertSuite, savedCertSuite);
+}
+
+/*
+ * Set/Get WapiPsk
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetWapiPsk) {
+ if (!keyMgmtSupported(sta_iface_, KeyMgmtMask::WAPI_PSK)) {
+ GTEST_SKIP() << "Skipping test since WAPI is not supported.";
+ }
+
+ EXPECT_TRUE(sta_network_->setKeyMgmt(KeyMgmtMask::WAPI_PSK).isOk());
+ EXPECT_TRUE(sta_network_->setPskPassphrase(kTestPskPassphrase).isOk());
+
+ std::string retrievedPassphrase;
+ EXPECT_TRUE(sta_network_->getPskPassphrase(&retrievedPassphrase).isOk());
+ EXPECT_EQ(retrievedPassphrase, kTestPskPassphrase);
+
+ const std::string pskHex = "12345678";
+ EXPECT_TRUE(sta_network_->setPskPassphrase(pskHex).isOk());
+
+ EXPECT_TRUE(sta_network_->getPskPassphrase(&retrievedPassphrase).isOk());
+ EXPECT_EQ(retrievedPassphrase, pskHex);
+}
+
+/*
+ * Set/Get SaePassword
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetSaePassword) {
+ const std::string savedPassword = "topsecret";
+ EXPECT_TRUE(sta_network_->setSaePassword(savedPassword).isOk());
+
+ std::string retrievedPassword;
+ EXPECT_TRUE(sta_network_->getSaePassword(&retrievedPassword).isOk());
+ EXPECT_EQ(retrievedPassword, savedPassword);
+}
+
+/*
+ * Set/Get SaePasswordId
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetSaePasswordId) {
+ const std::string savedPasswdId = "id1";
+ EXPECT_TRUE(sta_network_->setSaePasswordId(savedPasswdId).isOk());
+
+ std::string retrievedPasswdId;
+ EXPECT_TRUE(sta_network_->getSaePasswordId(&retrievedPasswdId).isOk());
+ EXPECT_EQ(retrievedPasswdId, savedPasswdId);
+}
+
+/*
+ * Set/Get GroupMgmtCipher
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetGroupMgmtCipher) {
+ const GroupMgmtCipherMask savedCipher = GroupMgmtCipherMask::BIP_GMAC_256;
+ EXPECT_TRUE(sta_network_->setGroupMgmtCipher(savedCipher).isOk());
+
+ GroupMgmtCipherMask retrievedCipher;
+ EXPECT_TRUE(sta_network_->getGroupMgmtCipher(&retrievedCipher).isOk());
+ EXPECT_EQ(retrievedCipher, savedCipher);
+}
+
+/*
+ * Set/Get Ssid
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetSsid) {
+ EXPECT_TRUE(sta_network_->setSsid(kTestSsid).isOk());
+
+ std::vector<uint8_t> retrievedSsid;
+ EXPECT_TRUE(sta_network_->getSsid(&retrievedSsid).isOk());
+ EXPECT_EQ(retrievedSsid, kTestSsid);
+}
+
+/*
+ * Set/Get Bssid
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetBssid) {
+ EXPECT_TRUE(sta_network_->setBssid(kTestBssid).isOk());
+
+ std::vector<uint8_t> retrievedBssid;
+ EXPECT_TRUE(sta_network_->getBssid(&retrievedBssid).isOk());
+ EXPECT_EQ(retrievedBssid, kTestBssid);
+}
+
+/*
+ * Set/Get KeyAuthAlg
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetAuthAlg) {
+ const AuthAlgMask savedAlg =
+ static_cast<AuthAlgMask>(static_cast<uint32_t>(AuthAlgMask::OPEN) |
+ static_cast<uint32_t>(AuthAlgMask::SHARED));
+ EXPECT_TRUE(sta_network_->setAuthAlg(savedAlg).isOk());
+
+ AuthAlgMask retrievedAlg;
+ EXPECT_TRUE(sta_network_->getAuthAlg(&retrievedAlg).isOk());
+ EXPECT_EQ(retrievedAlg, savedAlg);
+}
+
+/*
+ * Set/Get WepTxKeyIdx
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetWepTxKeyIdx) {
+ const int32_t savedKeyIdx = 2;
+ EXPECT_TRUE(sta_network_->setWepTxKeyIdx(savedKeyIdx).isOk());
+
+ int32_t retrievedKeyIdx;
+ EXPECT_TRUE(sta_network_->getWepTxKeyIdx(&retrievedKeyIdx).isOk());
+ EXPECT_EQ(retrievedKeyIdx, savedKeyIdx);
+}
+
+/*
+ * Set SAE H2E (Hash-to-Element) mode
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetSaeH2eMode) {
+ EXPECT_TRUE(sta_network_->setSaeH2eMode(SaeH2eMode::DISABLED).isOk());
+ EXPECT_TRUE(sta_network_->setSaeH2eMode(SaeH2eMode::H2E_MANDATORY).isOk());
+ EXPECT_TRUE(sta_network_->setSaeH2eMode(SaeH2eMode::H2E_OPTIONAL).isOk());
+}
+
+/*
+ * Set/Get Psk
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetPsk) {
+ const std::vector<uint8_t> savedPsk = std::vector<uint8_t>(32, 0x12);
+ EXPECT_TRUE(sta_network_->setPsk(savedPsk).isOk());
+
+ std::vector<uint8_t> retrievedPsk;
+ EXPECT_TRUE(sta_network_->getPsk(&retrievedPsk).isOk());
+ EXPECT_EQ(retrievedPsk, savedPsk);
+}
+
+/*
+ * Set/Get WepKeys
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetGetWepKeys) {
+ const uint32_t maxKeys = 4;
+ const std::vector<uint8_t> testWepKey = {0x56, 0x67, 0x67, 0xf4, 0x56};
+
+ for (uint32_t i = 0; i < maxKeys; i++) {
+ std::vector<uint8_t> retrievedKey;
+ EXPECT_TRUE(sta_network_->setWepKey(i, testWepKey).isOk());
+ EXPECT_TRUE(sta_network_->getWepKey(i, &retrievedKey).isOk());
+ EXPECT_EQ(retrievedKey, testWepKey);
+ }
+}
+
+/*
+ * SetPmkCacheEntry
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetPmkCache) {
+ const std::vector<uint8_t> serializedEntry(128, 0);
+ EXPECT_TRUE(sta_network_->setPmkCache(serializedEntry).isOk());
+}
+
+/*
+ * SetEapErp
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetEapErp) {
+ if (!isFilsSupported(sta_iface_)) {
+ GTEST_SKIP()
+ << "Skipping test since driver/supplicant doesn't support FILS";
+ }
+ EXPECT_TRUE(sta_network_->setEapErp(true).isOk());
+}
+
+/*
+ * SetUpdateIdentifier
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetUpdateIdentifier) {
+ const uint32_t updateIdentifier = 21;
+ EXPECT_TRUE(sta_network_->setUpdateIdentifier(updateIdentifier).isOk());
+}
+
+/*
+ * SetProactiveKeyCaching
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetProactiveKeyCaching) {
+ EXPECT_TRUE(sta_network_->setProactiveKeyCaching(true).isOk());
+ EXPECT_TRUE(sta_network_->setProactiveKeyCaching(false).isOk());
+}
+
+/*
+ * EnableSuiteBEapOpenSslCiphers
+ */
+TEST_P(SupplicantStaNetworkAidlTest, EnableSuiteBEapOpenSslCiphers) {
+ EXPECT_TRUE(sta_network_->enableSuiteBEapOpenSslCiphers().isOk());
+}
+
+/*
+ * EnableTlsSuiteBEapPhase1Param
+ */
+TEST_P(SupplicantStaNetworkAidlTest, EnableTlsSuiteBEapPhase1Param) {
+ EXPECT_TRUE(sta_network_->enableTlsSuiteBEapPhase1Param(true).isOk());
+ EXPECT_TRUE(sta_network_->enableTlsSuiteBEapPhase1Param(false).isOk());
+}
+
+/*
+ * SetEapEncryptedImsiIdentity
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SetEapEncryptedImsiIdentity) {
+ EXPECT_TRUE(
+ sta_network_->setEapEncryptedImsiIdentity(kTestEncryptedIdentity)
+ .isOk());
+}
+
+/*
+ * SendNetworkEapIdentityResponse
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SendNetworkEapIdentityResponse) {
+ EXPECT_TRUE(sta_network_
+ ->sendNetworkEapIdentityResponse(kTestIdentity,
+ kTestEncryptedIdentity)
+ .isOk());
+}
+
+/*
+ * Enable SAE PK only mode
+ */
+TEST_P(SupplicantStaNetworkAidlTest, EnableSaePkOnlyMode) {
+ // Check for SAE PK support
+ WpaDriverCapabilitiesMask caps;
+ EXPECT_TRUE(sta_iface_->getWpaDriverCapabilities(&caps).isOk());
+ const bool saePkSupported =
+ !!(static_cast<uint32_t>(caps) &
+ static_cast<uint32_t>(WpaDriverCapabilitiesMask::SAE_PK));
+ LOG(INFO) << "SAE-PK Supported: " << saePkSupported;
+
+ // Operation will succeed if SAE PK is supported, or fail otherwise.
+ EXPECT_EQ(sta_network_->enableSaePkOnlyMode(true).isOk(), saePkSupported);
+ EXPECT_EQ(sta_network_->enableSaePkOnlyMode(false).isOk(), saePkSupported);
+}
+
+/*
+ * Enable
+ */
+TEST_P(SupplicantStaNetworkAidlTest, Enable) {
+ // wpa_supplicant won't perform any connection initiation
+ // unless at least the SSID and key mgmt params are set.
+ EXPECT_TRUE(sta_network_->setSsid(kTestSsid).isOk());
+ EXPECT_TRUE(sta_network_->setKeyMgmt(kTestKeyMgmt).isOk());
+
+ EXPECT_TRUE(sta_network_->enable(false).isOk());
+ EXPECT_TRUE(sta_network_->enable(true).isOk());
+
+ // Now remove the network and ensure that the call fails.
+ removeNetwork();
+ ASSERT_FALSE(sta_network_->enable(true).isOk());
+}
+
+/*
+ * Disable
+ */
+TEST_P(SupplicantStaNetworkAidlTest, Disable) {
+ // wpa_supplicant won't perform any connection initiation
+ // unless at least the SSID and key mgmt params are set.
+ EXPECT_TRUE(sta_network_->setSsid(kTestSsid).isOk());
+ EXPECT_TRUE(sta_network_->setKeyMgmt(kTestKeyMgmt).isOk());
+
+ EXPECT_TRUE(sta_network_->disable().isOk());
+
+ // Now remove the network and ensure that the call fails.
+ removeNetwork();
+ EXPECT_FALSE(sta_network_->disable().isOk());
+}
+
+/*
+ * Select
+ */
+TEST_P(SupplicantStaNetworkAidlTest, Select) {
+ // wpa_supplicant won't perform any connection initiation
+ // unless at least the SSID and key mgmt params are set.
+ EXPECT_TRUE(sta_network_->setSsid(kTestSsid).isOk());
+ EXPECT_TRUE(sta_network_->setKeyMgmt(kTestKeyMgmt).isOk());
+
+ EXPECT_TRUE(sta_network_->select().isOk());
+
+ // Now remove the network and ensure that the call fails.
+ removeNetwork();
+ EXPECT_FALSE(sta_network_->select().isOk());
+}
+
+/*
+ * SendNetworkEapSimGsmAuthResponse
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SendNetworkEapSimGsmAuthResponse) {
+ NetworkResponseEapSimGsmAuthParams param;
+ param.kc =
+ std::vector<uint8_t>({0x56, 0x67, 0x67, 0xf4, 0x76, 0x87, 0x98, 0x12});
+ param.sres = std::vector<uint8_t>({0x56, 0x67, 0x67, 0xf4});
+ const std::vector<NetworkResponseEapSimGsmAuthParams> params = {param};
+ EXPECT_TRUE(sta_network_->sendNetworkEapSimGsmAuthResponse(params).isOk());
+}
+
+/*
+ * SendNetworkEapSimGsmAuthFailure
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SendNetworkEapSimGsmAuthFailure) {
+ EXPECT_TRUE(sta_network_->sendNetworkEapSimGsmAuthFailure().isOk());
+}
+
+/*
+ * SendNetworkEapSimUmtsAuthResponse
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SendNetworkEapSimUmtsAuthResponse) {
+ NetworkResponseEapSimUmtsAuthParams params;
+ params.res = std::vector<uint8_t>({0x56, 0x67, 0x67, 0xf4, 0x67});
+ params.ik = std::vector<uint8_t>(16, 0x65);
+ params.ck = std::vector<uint8_t>(16, 0x45);
+ EXPECT_TRUE(sta_network_->sendNetworkEapSimUmtsAuthResponse(params).isOk());
+}
+
+/*
+ * SendNetworkEapSimUmtsAuthFailure
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SendNetworkEapSimUmtsAuthFailure) {
+ EXPECT_TRUE(sta_network_->sendNetworkEapSimUmtsAuthFailure().isOk());
+}
+
+/*
+ * SendNetworkEapSimUmtsAutsResponse
+ */
+TEST_P(SupplicantStaNetworkAidlTest, SendNetworkEapSimUmtsAutsResponse) {
+ const std::vector<uint8_t> testAutParam = std::vector<uint8_t>(14, 0xe1);
+ EXPECT_TRUE(
+ sta_network_->sendNetworkEapSimUmtsAutsResponse(testAutParam).isOk());
+}
+
+/*
+ * GetWpsNfcConfigurationToken
+ */
+TEST_P(SupplicantStaNetworkAidlTest, GetWpsNfcConfigurationToken) {
+ EXPECT_TRUE(sta_network_->setSsid(kTestSsid).isOk());
+ EXPECT_TRUE(sta_network_->setKeyMgmt(kTestKeyMgmt).isOk());
+ EXPECT_TRUE(sta_network_->setPskPassphrase(kTestPskPassphrase).isOk());
+
+ std::vector<uint8_t> retrievedToken;
+ EXPECT_TRUE(
+ sta_network_->getWpsNfcConfigurationToken(&retrievedToken).isOk());
+ EXPECT_NE(retrievedToken.size(), 0);
+}
+
+INSTANTIATE_TEST_SUITE_P(Supplicant, SupplicantStaNetworkAidlTest,
+ testing::ValuesIn(android::getAidlHalInstanceNames(
+ ISupplicant::descriptor)),
+ android::PrintInstanceNameToString);
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ProcessState::self()->setThreadPoolMaxThreadCount(1);
+ ProcessState::self()->startThreadPool();
+ return RUN_ALL_TESTS();
+}
diff --git a/wifi/supplicant/aidl/vts/functional/supplicant_test_utils.h b/wifi/supplicant/aidl/vts/functional/supplicant_test_utils.h
new file mode 100644
index 0000000..b7e1a80
--- /dev/null
+++ b/wifi/supplicant/aidl/vts/functional/supplicant_test_utils.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SUPPLICANT_TEST_UTILS_H
+#define SUPPLICANT_TEST_UTILS_H
+
+#include <VtsCoreUtil.h>
+#include <android-base/logging.h>
+#include <wifi_system/supplicant_manager.h>
+
+using aidl::android::hardware::wifi::supplicant::ISupplicantStaIface;
+using aidl::android::hardware::wifi::supplicant::KeyMgmtMask;
+using android::wifi_system::SupplicantManager;
+
+std::string getStaIfaceName() {
+ std::array<char, PROPERTY_VALUE_MAX> buffer;
+ property_get("wifi.interface", buffer.data(), "wlan0");
+ return std::string(buffer.data());
+}
+
+std::string getP2pIfaceName() {
+ std::array<char, PROPERTY_VALUE_MAX> buffer;
+ property_get("wifi.direct.interface", buffer.data(), "p2p0");
+ return std::string(buffer.data());
+}
+
+bool keyMgmtSupported(std::shared_ptr<ISupplicantStaIface> iface,
+ KeyMgmtMask expected) {
+ KeyMgmtMask caps;
+ if (!iface->getKeyMgmtCapabilities(&caps).isOk()) {
+ return false;
+ }
+ return !!(static_cast<uint32_t>(caps) & static_cast<uint32_t>(expected));
+}
+
+bool isFilsSupported(std::shared_ptr<ISupplicantStaIface> iface) {
+ KeyMgmtMask filsMask = static_cast<KeyMgmtMask>(
+ static_cast<uint32_t>(KeyMgmtMask::FILS_SHA256) |
+ static_cast<uint32_t>(KeyMgmtMask::FILS_SHA384));
+ return keyMgmtSupported(iface, filsMask);
+}
+
+bool waitForSupplicantState(bool is_running) {
+ SupplicantManager supplicant_manager;
+ int count = 50; /* wait at most 5 seconds for completion */
+ while (count-- > 0) {
+ if (supplicant_manager.IsSupplicantRunning() == is_running) {
+ return true;
+ }
+ usleep(100000);
+ }
+ LOG(ERROR) << "Supplicant not " << (is_running ? "running" : "stopped");
+ return false;
+}
+
+bool waitForFrameworkReady() {
+ int waitCount = 15;
+ do {
+ // Check whether package service is ready or not.
+ if (!testing::checkSubstringInCommandOutput(
+ "/system/bin/service check package", ": not found")) {
+ return true;
+ }
+ LOG(INFO) << "Framework is not ready";
+ sleep(1);
+ } while (waitCount-- > 0);
+ return false;
+}
+
+bool waitForSupplicantStart() { return waitForSupplicantState(true); }
+
+bool waitForSupplicantStop() { return waitForSupplicantState(false); }
+
+void stopSupplicant() {
+ SupplicantManager supplicant_manager;
+ ASSERT_TRUE(supplicant_manager.StopSupplicant());
+ ASSERT_FALSE(supplicant_manager.IsSupplicantRunning());
+}
+
+bool startWifiFramework() {
+ std::system("svc wifi enable");
+ std::system("cmd wifi set-scan-always-available enabled");
+ return waitForSupplicantStart();
+}
+
+bool stopWifiFramework() {
+ std::system("svc wifi disable");
+ std::system("cmd wifi set-scan-always-available disabled");
+ return waitForSupplicantStop();
+}
+
+void initializeService() {
+ ASSERT_TRUE(stopWifiFramework());
+ std::system("/system/bin/start");
+ ASSERT_TRUE(waitForFrameworkReady());
+ stopSupplicant();
+}
+
+#endif // SUPPLICANT_TEST_UTILS_H
\ No newline at end of file