wifi(interface): Add callbacks for indicating radio mode changes

Bug: 68349158
Test: Compiles
Change-Id: Id9dc5118e7595651cadf24676b66d4c0875396ba
This commit is contained in:
Roshan Pius
2018-01-22 16:12:19 -08:00
parent 84a51275b5
commit 1ce92cfb0f
5 changed files with 115 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ hidl_interface {
"types.hal",
"IWifi.hal",
"IWifiChip.hal",
"IWifiChipEventCallback.hal",
"IWifiNanIface.hal",
"IWifiNanIfaceEventCallback.hal",
],

View File

@@ -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);
};

View File

@@ -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<IfaceInfo> 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<RadioModeInfo> radioModeInfos);
};

View File

@@ -306,7 +306,7 @@ Return<void> WifiChip::getId(getId_cb hidl_status_cb) {
}
Return<void> WifiChip::registerEventCallback(
const sp<IWifiChipEventCallback>& event_callback,
const sp<V1_0::IWifiChipEventCallback>& event_callback,
registerEventCallback_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
&WifiChip::registerEventCallbackInternal,
@@ -520,6 +520,14 @@ Return<void> WifiChip::resetTxPowerScenario(
hidl_status_cb);
}
Return<void> WifiChip::registerEventCallback_1_2(
const sp<IWifiChipEventCallback>& 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<void> WifiChip::debug(const hidl_handle& handle,
const hidl_vec<hidl_string>&) {
if (handle != nullptr && handle->numFds >= 1) {
@@ -556,11 +564,9 @@ std::pair<WifiStatus, ChipId> WifiChip::getIdInternal() {
}
WifiStatus WifiChip::registerEventCallbackInternal(
const sp<IWifiChipEventCallback>& event_callback) {
if (!event_cb_handler_.addCallback(event_callback)) {
return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
}
return createWifiStatus(WifiStatusCode::SUCCESS);
const sp<V1_0::IWifiChipEventCallback>& /* event_callback */) {
// Deprecated support for this callback.
return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
}
std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal() {
@@ -997,6 +1003,14 @@ WifiStatus WifiChip::resetTxPowerScenarioInternal() {
return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiChip::registerEventCallbackInternal_1_2(
const sp<IWifiChipEventCallback>& 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<std::recursive_mutex>* lock,
ChipModeId mode_id) {

View File

@@ -74,7 +74,7 @@ class WifiChip : public V1_2::IWifiChip {
// HIDL methods exposed.
Return<void> getId(getId_cb hidl_status_cb) override;
Return<void> registerEventCallback(
const sp<IWifiChipEventCallback>& event_callback,
const sp<V1_0::IWifiChipEventCallback>& event_callback,
registerEventCallback_cb hidl_status_cb) override;
Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
Return<void> getAvailableModes(
@@ -138,6 +138,9 @@ class WifiChip : public V1_2::IWifiChip {
resetTxPowerScenario_cb hidl_status_cb) override;
Return<void> debug(const hidl_handle& handle,
const hidl_vec<hidl_string>& options) override;
Return<void> registerEventCallback_1_2(
const sp<IWifiChipEventCallback>& 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<WifiStatus, ChipId> getIdInternal();
WifiStatus registerEventCallbackInternal(
const sp<IWifiChipEventCallback>& event_callback);
const sp<V1_0::IWifiChipEventCallback>& event_callback);
std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
std::pair<WifiStatus, std::vector<ChipMode>> 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<IWifiChipEventCallback>& event_callback);
WifiStatus handleChipConfiguration(
std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id);