diff options
-rw-r--r-- | wifi/1.5/Android.bp | 1 | ||||
-rw-r--r-- | wifi/1.5/IWifi.hal | 21 | ||||
-rw-r--r-- | wifi/1.5/IWifiEventCallback.hal | 21 | ||||
-rw-r--r-- | wifi/1.5/default/wifi.cpp | 18 | ||||
-rw-r--r-- | wifi/1.5/default/wifi.h | 11 |
5 files changed, 66 insertions, 6 deletions
diff --git a/wifi/1.5/Android.bp b/wifi/1.5/Android.bp index 7c04c6967a..0887c6b5c1 100644 --- a/wifi/1.5/Android.bp +++ b/wifi/1.5/Android.bp @@ -20,6 +20,7 @@ hidl_interface { "IWifiNanIface.hal", "IWifiNanIfaceEventCallback.hal", "IWifiStaIface.hal", + "IWifiEventCallback.hal", ], interfaces: [ "android.hardware.wifi@1.0", diff --git a/wifi/1.5/IWifi.hal b/wifi/1.5/IWifi.hal index 66d0a9c2f9..28b808ed32 100644 --- a/wifi/1.5/IWifi.hal +++ b/wifi/1.5/IWifi.hal @@ -17,6 +17,8 @@ package android.hardware.wifi@1.5; import @1.4::IWifi; +import IWifiEventCallback; +import @1.0::WifiStatus; /** * This is the root of the HAL module and is the interface returned when @@ -24,4 +26,21 @@ import @1.4::IWifi; * module loaded in the system. * IWifi.getChip() must return @1.5::IWifiChip */ -interface IWifi extends @1.4::IWifi {}; +interface IWifi extends @1.4::IWifi { + /** + * Requests notifications of significant events for the HAL. Multiple calls to + * this must register multiple callbacks each of which must receive all + * events. |IWifiEventCallback| object registration must be independent of the + * state of the rest of the HAL and must persist though stops/starts. These + * objects must be deleted when the corresponding client process is dead. + * + * @param callback An instance of the |IWifiEventCallback| HIDL interface + * object. + * @return status WifiStatus of the operation. + * Possible status codes: + * |WifiStatusCode.SUCCESS|, + * |WifiStatusCode.UNKNOWN| + */ + registerEventCallback_1_5(IWifiEventCallback callback) + generates (WifiStatus status); +}; diff --git a/wifi/1.5/IWifiEventCallback.hal b/wifi/1.5/IWifiEventCallback.hal new file mode 100644 index 0000000000..17dce39950 --- /dev/null +++ b/wifi/1.5/IWifiEventCallback.hal @@ -0,0 +1,21 @@ +/* + * Copyright 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 android.hardware.wifi@1.5; + +import @1.0::IWifiEventCallback; + +interface IWifiEventCallback extends @1.0::IWifiEventCallback {}; diff --git a/wifi/1.5/default/wifi.cpp b/wifi/1.5/default/wifi.cpp index da98db8296..b4037e9907 100644 --- a/wifi/1.5/default/wifi.cpp +++ b/wifi/1.5/default/wifi.cpp @@ -50,13 +50,21 @@ bool Wifi::isValid() { } Return<void> Wifi::registerEventCallback( - const sp<IWifiEventCallback>& event_callback, + const sp<V1_0::IWifiEventCallback>& event_callback, registerEventCallback_cb hidl_status_cb) { return validateAndCall(this, WifiStatusCode::ERROR_UNKNOWN, &Wifi::registerEventCallbackInternal, hidl_status_cb, event_callback); } +Return<void> Wifi::registerEventCallback_1_5( + const sp<V1_5::IWifiEventCallback>& event_callback, + registerEventCallback_1_5_cb hidl_status_cb) { + return validateAndCall(this, WifiStatusCode::ERROR_UNKNOWN, + &Wifi::registerEventCallbackInternal_1_5, + hidl_status_cb, event_callback); +} + Return<bool> Wifi::isStarted() { return run_state_ != RunState::STOPPED; } Return<void> Wifi::start(start_cb hidl_status_cb) { @@ -95,7 +103,13 @@ Return<void> Wifi::debug(const hidl_handle& handle, } WifiStatus Wifi::registerEventCallbackInternal( - const sp<IWifiEventCallback>& event_callback) { + const sp<V1_0::IWifiEventCallback>& event_callback __unused) { + // Deprecated support for this callback. + return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); +} + +WifiStatus Wifi::registerEventCallbackInternal_1_5( + const sp<V1_5::IWifiEventCallback>& event_callback) { if (!event_cb_handler_.addCallback(event_callback)) { return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); } diff --git a/wifi/1.5/default/wifi.h b/wifi/1.5/default/wifi.h index 825c0bc182..840bdfd927 100644 --- a/wifi/1.5/default/wifi.h +++ b/wifi/1.5/default/wifi.h @@ -52,8 +52,11 @@ class Wifi : public V1_5::IWifi { // HIDL methods exposed. Return<void> registerEventCallback( - const sp<IWifiEventCallback>& event_callback, + const sp<V1_0::IWifiEventCallback>& event_callback, registerEventCallback_cb hidl_status_cb) override; + Return<void> registerEventCallback_1_5( + const sp<V1_5::IWifiEventCallback>& event_callback, + registerEventCallback_1_5_cb hidl_status_cb) override; Return<bool> isStarted() override; Return<void> start(start_cb hidl_status_cb) override; Return<void> stop(stop_cb hidl_status_cb) override; @@ -67,7 +70,9 @@ class Wifi : public V1_5::IWifi { // Corresponding worker functions for the HIDL methods. WifiStatus registerEventCallbackInternal( - const sp<IWifiEventCallback>& event_callback); + const sp<V1_0::IWifiEventCallback>& event_callback __unused); + WifiStatus registerEventCallbackInternal_1_5( + const sp<V1_5::IWifiEventCallback>& event_callback); WifiStatus startInternal(); WifiStatus stopInternal(std::unique_lock<std::recursive_mutex>* lock); std::pair<WifiStatus, std::vector<ChipId>> getChipIdsInternal(); @@ -87,7 +92,7 @@ class Wifi : public V1_5::IWifi { std::shared_ptr<feature_flags::WifiFeatureFlags> feature_flags_; RunState run_state_; std::vector<sp<WifiChip>> chips_; - hidl_callback_util::HidlCallbackHandler<IWifiEventCallback> + hidl_callback_util::HidlCallbackHandler<V1_5::IWifiEventCallback> event_cb_handler_; DISALLOW_COPY_AND_ASSIGN(Wifi); |