diff --git a/wifi/supplicant/1.4/Android.bp b/wifi/supplicant/1.4/Android.bp index 0a039de722..2867629d4c 100644 --- a/wifi/supplicant/1.4/Android.bp +++ b/wifi/supplicant/1.4/Android.bp @@ -10,6 +10,7 @@ hidl_interface { "ISupplicantStaIface.hal", "ISupplicantStaNetwork.hal", "ISupplicantStaNetworkCallback.hal", + "ISupplicantStaIfaceCallback.hal", ], interfaces: [ "android.hardware.wifi.supplicant@1.0", diff --git a/wifi/supplicant/1.4/ISupplicantStaIface.hal b/wifi/supplicant/1.4/ISupplicantStaIface.hal index 28ef912eae..68fd01d12e 100644 --- a/wifi/supplicant/1.4/ISupplicantStaIface.hal +++ b/wifi/supplicant/1.4/ISupplicantStaIface.hal @@ -17,6 +17,7 @@ package android.hardware.wifi.supplicant@1.4; import @1.0::SupplicantStatus; +import ISupplicantStaIfaceCallback; import @1.3::ISupplicantStaIface; /** @@ -36,4 +37,22 @@ interface ISupplicantStaIface extends @1.3::ISupplicantStaIface { getConnectionCapabilities_1_4() generates (SupplicantStatus status, ConnectionCapabilities capabilities); + /** + * Register for callbacks from this interface. + * + * These callbacks are invoked for events that are specific to this interface. + * Registration of multiple callback objects is supported. These objects must + * be automatically deleted when the corresponding client process is dead or + * if this interface is removed. + * + * @param callback An instance of the |ISupplicantStaIfaceCallback| HIDL + * interface object. + * @return status Status of the operation. + * Possible status codes: + * |SupplicantStatusCode.SUCCESS|, + * |SupplicantStatusCode.FAILURE_UNKNOWN|, + * |SupplicantStatusCode.FAILURE_IFACE_INVALID| + */ + registerCallback_1_4(ISupplicantStaIfaceCallback callback) + generates (SupplicantStatus status); }; diff --git a/wifi/supplicant/1.4/ISupplicantStaIfaceCallback.hal b/wifi/supplicant/1.4/ISupplicantStaIfaceCallback.hal new file mode 100644 index 0000000000..20bce34dd7 --- /dev/null +++ b/wifi/supplicant/1.4/ISupplicantStaIfaceCallback.hal @@ -0,0 +1,40 @@ +/* + * Copyright 2020 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 android.hardware.wifi.supplicant@1.4; + +import @1.3::ISupplicantStaIfaceCallback; +import @1.0::ISupplicantStaIfaceCallback.State; +import @1.0::Bssid; + +/** + * Callback Interface exposed by the supplicant service + * for each station mode interface (ISupplicantStaIface). + * + * Clients need to host an instance of this HIDL interface object and + * pass a reference of the object to the supplicant via the + * corresponding |ISupplicantStaIface.registerCallback_1_4| method. + */ +interface ISupplicantStaIfaceCallback extends @1.3::ISupplicantStaIfaceCallback { + /** + * Used to indicate a Hotspot 2.0 terms and conditions acceptance is requested from the user + * before allowing the device to get internet access. + * + * @param bssid BSSID of the access point. + * @param url URL of the T&C server. + */ + oneway onHs20TermsAndConditionsAcceptanceRequestedNotification(Bssid bssid, string url); +}; diff --git a/wifi/supplicant/1.4/vts/functional/supplicant_sta_iface_hidl_test.cpp b/wifi/supplicant/1.4/vts/functional/supplicant_sta_iface_hidl_test.cpp index 5b9c750c4e..fbf6445217 100644 --- a/wifi/supplicant/1.4/vts/functional/supplicant_sta_iface_hidl_test.cpp +++ b/wifi/supplicant/1.4/vts/functional/supplicant_sta_iface_hidl_test.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -32,13 +33,22 @@ #include "supplicant_hidl_test_utils_1_4.h" using ::android::sp; +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; using ::android::hardware::Void; using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus; using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode; - +using ::android::hardware::wifi::supplicant::V1_2::DppAkm; +using ::android::hardware::wifi::supplicant::V1_2::DppFailureCode; +using ::android::hardware::wifi::supplicant::V1_2::DppNetRole; +using ::android::hardware::wifi::supplicant::V1_2::DppProgressCode; +using ::android::hardware::wifi::supplicant::V1_3::DppSuccessCode; using ::android::hardware::wifi::supplicant::V1_4::ConnectionCapabilities; using ::android::hardware::wifi::supplicant::V1_4::ISupplicant; using ::android::hardware::wifi::supplicant::V1_4::ISupplicantStaIface; +using ::android::hardware::wifi::supplicant::V1_4::ISupplicantStaIfaceCallback; class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBaseV1_4 { public: @@ -53,6 +63,133 @@ class SupplicantStaIfaceHidlTest : public SupplicantHidlTestBaseV1_4 { sp sta_iface_; }; +class IfaceCallback : public ISupplicantStaIfaceCallback { + Return onNetworkAdded(uint32_t /* id */) override { return Void(); } + Return onNetworkRemoved(uint32_t /* id */) override { return Void(); } + Return onStateChanged( + ISupplicantStaIfaceCallback::State /* newState */, + const hidl_array& /*bssid */, uint32_t /* id */, + const hidl_vec& /* ssid */) override { + return Void(); + } + Return onAnqpQueryDone( + const hidl_array& /* bssid */, + const ISupplicantStaIfaceCallback::AnqpData& /* data */, + const ISupplicantStaIfaceCallback::Hs20AnqpData& /* hs20Data */) + override { + return Void(); + } + virtual Return onHs20IconQueryDone( + const hidl_array& /* bssid */, + const hidl_string& /* fileName */, + const hidl_vec& /* data */) override { + return Void(); + } + virtual Return onHs20SubscriptionRemediation( + const hidl_array& /* bssid */, + ISupplicantStaIfaceCallback::OsuMethod /* osuMethod */, + const hidl_string& /* url*/) override { + return Void(); + } + Return onHs20TermsAndConditionsAcceptanceRequestedNotification( + const hidl_array& /* bssid */, + const hidl_string& /* url */) override { + return Void(); + } + Return onHs20DeauthImminentNotice( + const hidl_array& /* bssid */, uint32_t /* reasonCode */, + uint32_t /* reAuthDelayInSec */, + const hidl_string& /* url */) override { + return Void(); + } + Return onDisconnected(const hidl_array& /* bssid */, + bool /* locallyGenerated */, + ISupplicantStaIfaceCallback::ReasonCode + /* reasonCode */) override { + return Void(); + } + Return onAssociationRejected( + const hidl_array& /* bssid */, + ISupplicantStaIfaceCallback::StatusCode /* statusCode */, + bool /*timedOut */) override { + return Void(); + } + Return onAuthenticationTimeout( + const hidl_array& /* bssid */) override { + return Void(); + } + Return onBssidChanged( + ISupplicantStaIfaceCallback::BssidChangeReason /* reason */, + const hidl_array& /* bssid */) override { + return Void(); + } + Return onEapFailure() override { return Void(); } + Return onEapFailure_1_1( + ISupplicantStaIfaceCallback::EapErrorCode /* eapErrorCode */) override { + return Void(); + } + Return onEapFailure_1_3(uint32_t /* eapErrorCode */) override { + return Void(); + } + Return onWpsEventSuccess() override { return Void(); } + Return onWpsEventFail( + const hidl_array& /* bssid */, + ISupplicantStaIfaceCallback::WpsConfigError /* configError */, + ISupplicantStaIfaceCallback::WpsErrorIndication /* errorInd */) + override { + return Void(); + } + Return onWpsEventPbcOverlap() override { return Void(); } + Return onExtRadioWorkStart(uint32_t /* id */) override { + return Void(); + } + Return onExtRadioWorkTimeout(uint32_t /* id*/) override { + return Void(); + } + Return onDppSuccessConfigReceived( + const hidl_vec& /* ssid */, const hidl_string& /* password */, + const hidl_array& /* psk */, + DppAkm /* securityAkm */) override { + return Void(); + } + Return onDppSuccessConfigSent() override { return Void(); } + Return onDppProgress(DppProgressCode /* code */) override { + return Void(); + } + Return onDppFailure(DppFailureCode /* code */) override { + return Void(); + } + Return onDppSuccess(DppSuccessCode /* code */) override { + return Void(); + } + Return onDppProgress_1_3( + ::android::hardware::wifi::supplicant::V1_3::DppProgressCode /* code */) + override { + return Void(); + } + Return onDppFailure_1_3( + ::android::hardware::wifi::supplicant::V1_3::DppFailureCode /* code */, + const hidl_string& /* ssid */, const hidl_string& /* channelList */, + const hidl_vec& /* bandList */) override { + return Void(); + } + Return onPmkCacheAdded( + int64_t /* expirationTimeInSec */, + const hidl_vec& /* serializedEntry */) override { + return Void(); + } + Return onBssTmHandlingDone( + const ISupplicantStaIfaceCallback::BssTmData& /* data */) override { + return Void(); + } + Return onStateChanged_1_3( + ISupplicantStaIfaceCallback::State /* newState */, + const hidl_array& /*bssid */, uint32_t /* id */, + const hidl_vec& /* ssid */, bool /* filsHlpSent */) override { + return Void(); + } +}; + /* * getConnectionCapabilities_1_4 */ @@ -64,6 +201,16 @@ TEST_P(SupplicantStaIfaceHidlTest, GetConnectionCapabilities) { }); } +/* + * RegisterCallback_1_4 + */ +TEST_P(SupplicantStaIfaceHidlTest, RegisterCallback_1_4) { + sta_iface_->registerCallback_1_4( + new IfaceCallback(), [](const SupplicantStatus& status) { + EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code); + }); +} + GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SupplicantStaIfaceHidlTest); INSTANTIATE_TEST_CASE_P( PerInstance, SupplicantStaIfaceHidlTest,