From 1ce92cfb0f6246c0d767ac97b3d87e1c4db8766d Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Mon, 22 Jan 2018 16:12:19 -0800 Subject: [PATCH] wifi(interface): Add callbacks for indicating radio mode changes Bug: 68349158 Test: Compiles Change-Id: Id9dc5118e7595651cadf24676b66d4c0875396ba --- wifi/1.2/Android.bp | 1 + wifi/1.2/IWifiChip.hal | 16 +++++++ wifi/1.2/IWifiChipEventCallback.hal | 71 +++++++++++++++++++++++++++++ wifi/1.2/default/wifi_chip.cpp | 26 ++++++++--- wifi/1.2/default/wifi_chip.h | 9 +++- 5 files changed, 115 insertions(+), 8 deletions(-) create mode 100644 wifi/1.2/IWifiChipEventCallback.hal diff --git a/wifi/1.2/Android.bp b/wifi/1.2/Android.bp index 100b36bfdb..f41324ed1d 100644 --- a/wifi/1.2/Android.bp +++ b/wifi/1.2/Android.bp @@ -10,6 +10,7 @@ hidl_interface { "types.hal", "IWifi.hal", "IWifiChip.hal", + "IWifiChipEventCallback.hal", "IWifiNanIface.hal", "IWifiNanIfaceEventCallback.hal", ], diff --git a/wifi/1.2/IWifiChip.hal b/wifi/1.2/IWifiChip.hal index 72cbf811ab..d336a337c6 100644 --- a/wifi/1.2/IWifiChip.hal +++ b/wifi/1.2/IWifiChip.hal @@ -16,7 +16,9 @@ package android.hardware.wifi@1.2; +import @1.0::WifiStatus; import @1.1::IWifiChip; +import IWifiChipEventCallback; /** * Interface that represents a chip that must be configured as a single unit. @@ -24,4 +26,18 @@ import @1.1::IWifiChip; * to perform operations like NAN, RTT, etc. */ interface IWifiChip extends @1.1::IWifiChip { + /** + * Requests notifications of significant events on this chip. Multiple calls + * to this must register multiple callbacks each of which must receive all + * events. + * + * @param callback An instance of the |IWifiChipEventCallback| HIDL interface + * object. + * @return status WifiStatus of the operation. + * Possible status codes: + * |WifiStatusCode.SUCCESS|, + * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID| + */ + registerEventCallback_1_2(IWifiChipEventCallback callback) + generates (WifiStatus status); }; diff --git a/wifi/1.2/IWifiChipEventCallback.hal b/wifi/1.2/IWifiChipEventCallback.hal new file mode 100644 index 0000000000..5d2e7e9c8d --- /dev/null +++ b/wifi/1.2/IWifiChipEventCallback.hal @@ -0,0 +1,71 @@ +/* + * Copyright 2017 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.2; + +import @1.0::IWifiChipEventCallback; +import @1.0::WifiBand; + +/** + * Wifi chip event callbacks. + */ +interface IWifiChipEventCallback extends @1.0::IWifiChipEventCallback { + /** + * Struct describing the state of each iface operating on the radio chain + * (hardware MAC) on the device. + */ + struct IfaceInfo { + /** Name of the interface (For ex: "wlan0"). */ + string name; + /** Wifi channel on which this interface is operating. */ + uint32_t channel; + }; + + /** + * Struct describing the state of each hardware radio chain (hardware MAC) + * on the device. + */ + struct RadioModeInfo { + /** + * Identifier for this radio chain. This is vendor dependent & used + * only for debugging purposes. + */ + uint32_t radioId; + /** + * List of bands on which this radio chain is operating. + * Can be one of: + * a) WifiBand.BAND_24GHZ => 2.4Ghz. + * b) WifiBand.BAND_5GHZ => 5Ghz. + * c) WifiBand.BAND_24GHZ_5GHZ = 2.4Ghz + 5Ghz (Radio is time sharing + * across the 2 bands). + */ + WifiBand bandInfo; + /** List of interfaces on this radio chain (hardware MAC). */ + vec ifaceInfos; + }; + + /** + * Asynchronous callback indicating a radio mode change. + * Radio mode change could be a result of: + * a) Bringing up concurrent interfaces (For ex: STA + AP). + * b) Change in operating band of one of the concurrent interfaces (For ex: + * STA connection moved from 2.4G to 5G) + * + * @param radioModeInfos List of RadioModeInfo structures for each + * radio chain (hardware MAC) on the device. + */ + oneway onRadioModeChange(vec radioModeInfos); +}; diff --git a/wifi/1.2/default/wifi_chip.cpp b/wifi/1.2/default/wifi_chip.cpp index bc3404a819..a4b52b9b75 100644 --- a/wifi/1.2/default/wifi_chip.cpp +++ b/wifi/1.2/default/wifi_chip.cpp @@ -306,7 +306,7 @@ Return WifiChip::getId(getId_cb hidl_status_cb) { } Return WifiChip::registerEventCallback( - const sp& event_callback, + const sp& event_callback, registerEventCallback_cb hidl_status_cb) { return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID, &WifiChip::registerEventCallbackInternal, @@ -520,6 +520,14 @@ Return WifiChip::resetTxPowerScenario( hidl_status_cb); } +Return WifiChip::registerEventCallback_1_2( + const sp& event_callback, + registerEventCallback_cb hidl_status_cb) { + return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID, + &WifiChip::registerEventCallbackInternal_1_2, + hidl_status_cb, event_callback); +} + Return WifiChip::debug(const hidl_handle& handle, const hidl_vec&) { if (handle != nullptr && handle->numFds >= 1) { @@ -556,11 +564,9 @@ std::pair WifiChip::getIdInternal() { } WifiStatus WifiChip::registerEventCallbackInternal( - const sp& event_callback) { - if (!event_cb_handler_.addCallback(event_callback)) { - return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); - } - return createWifiStatus(WifiStatusCode::SUCCESS); + const sp& /* event_callback */) { + // Deprecated support for this callback. + return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); } std::pair WifiChip::getCapabilitiesInternal() { @@ -997,6 +1003,14 @@ WifiStatus WifiChip::resetTxPowerScenarioInternal() { return createWifiStatusFromLegacyError(legacy_status); } +WifiStatus WifiChip::registerEventCallbackInternal_1_2( + const sp& event_callback) { + if (!event_cb_handler_.addCallback(event_callback)) { + return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); + } + return createWifiStatus(WifiStatusCode::SUCCESS); +} + WifiStatus WifiChip::handleChipConfiguration( /* NONNULL */ std::unique_lock* lock, ChipModeId mode_id) { diff --git a/wifi/1.2/default/wifi_chip.h b/wifi/1.2/default/wifi_chip.h index 4ffa8da138..c51f6b1e27 100644 --- a/wifi/1.2/default/wifi_chip.h +++ b/wifi/1.2/default/wifi_chip.h @@ -74,7 +74,7 @@ class WifiChip : public V1_2::IWifiChip { // HIDL methods exposed. Return getId(getId_cb hidl_status_cb) override; Return registerEventCallback( - const sp& event_callback, + const sp& event_callback, registerEventCallback_cb hidl_status_cb) override; Return getCapabilities(getCapabilities_cb hidl_status_cb) override; Return getAvailableModes( @@ -138,6 +138,9 @@ class WifiChip : public V1_2::IWifiChip { resetTxPowerScenario_cb hidl_status_cb) override; Return debug(const hidl_handle& handle, const hidl_vec& options) override; + Return registerEventCallback_1_2( + const sp& event_callback, + registerEventCallback_1_2_cb hidl_status_cb) override; private: void invalidateAndRemoveAllIfaces(); @@ -145,7 +148,7 @@ class WifiChip : public V1_2::IWifiChip { // Corresponding worker functions for the HIDL methods. std::pair getIdInternal(); WifiStatus registerEventCallbackInternal( - const sp& event_callback); + const sp& event_callback); std::pair getCapabilitiesInternal(); std::pair> getAvailableModesInternal(); WifiStatus configureChipInternal( @@ -192,6 +195,8 @@ class WifiChip : public V1_2::IWifiChip { WifiStatus enableDebugErrorAlertsInternal(bool enable); WifiStatus selectTxPowerScenarioInternal(TxPowerScenario scenario); WifiStatus resetTxPowerScenarioInternal(); + WifiStatus registerEventCallbackInternal_1_2( + const sp& event_callback); WifiStatus handleChipConfiguration( std::unique_lock* lock, ChipModeId mode_id);