Merge "[WIFI][HIDL] Add device-based feature flag support" am: 48b4ce2e99

am: d15376f05c

Change-Id: If13d2a7e8993d93f23082fcd4ccf2732aaacba6f
This commit is contained in:
Etan Cohen 2017-03-11 19:08:08 +00:00 committed by android-build-merger
commit 733015b56e
3 changed files with 68 additions and 14 deletions

View file

@ -18,6 +18,9 @@ LOCAL_MODULE := android.hardware.wifi@1.0-service
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_PROPRIETARY_MODULE := true
LOCAL_CPPFLAGS := -Wall -Werror -Wextra
ifdef WIFI_HIDL_FEATURE_AWARE
LOCAL_CPPFLAGS += -DWIFI_HIDL_FEATURE_AWARE
endif
LOCAL_SRC_FILES := \
hidl_struct_util.cpp \
hidl_sync_util.cpp \

View file

@ -19,6 +19,7 @@
#include "hidl_return_util.h"
#include "hidl_struct_util.h"
#include "wifi_chip.h"
#include "wifi_feature_flags.h"
#include "wifi_status_util.h"
namespace {
@ -388,16 +389,21 @@ WifiChip::getAvailableModesInternal() {
// The chip combination supported for current devices is fixed for now with
// 2 separate modes of operation:
// Mode 1 (STA mode): Will support 1 STA and 1 P2P or NAN iface operations
// concurrently.
// concurrently [NAN conditional on wifiHidlFeatureAware]
// Mode 2 (AP mode): Will support 1 AP iface operations.
// TODO (b/32997844): Read this from some device specific flags in the
// makefile.
// STA mode iface combinations.
const IWifiChip::ChipIfaceCombinationLimit
sta_chip_iface_combination_limit_1 = {{IfaceType::STA}, 1};
const IWifiChip::ChipIfaceCombinationLimit
sta_chip_iface_combination_limit_2 = {{IfaceType::P2P, IfaceType::NAN},
1};
IWifiChip::ChipIfaceCombinationLimit sta_chip_iface_combination_limit_2;
if (WifiFeatureFlags::wifiHidlFeatureAware) {
sta_chip_iface_combination_limit_2 = {{IfaceType::P2P, IfaceType::NAN},
1};
} else {
sta_chip_iface_combination_limit_2 = {{IfaceType::P2P},
1};
}
const IWifiChip::ChipIfaceCombination sta_chip_iface_combination = {
{sta_chip_iface_combination_limit_1, sta_chip_iface_combination_limit_2}};
const IWifiChip::ChipMode sta_chip_mode = {kStaChipModeId,
@ -552,18 +558,22 @@ WifiStatus WifiChip::removeApIfaceInternal(const std::string& ifname) {
std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::createNanIfaceInternal() {
// Only 1 of NAN or P2P iface can be active at a time.
if (current_mode_id_ != kStaChipModeId || nan_iface_.get() ||
p2p_iface_.get()) {
if (WifiFeatureFlags::wifiHidlFeatureAware) {
if (current_mode_id_ != kStaChipModeId || nan_iface_.get() ||
p2p_iface_.get()) {
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
std::string ifname = legacy_hal_.lock()->getNanIfaceName();
nan_iface_ = new WifiNanIface(ifname, legacy_hal_);
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onIfaceAdded(IfaceType::NAN, ifname).isOk()) {
LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
}
}
return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_};
} else {
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
std::string ifname = legacy_hal_.lock()->getNanIfaceName();
nan_iface_ = new WifiNanIface(ifname, legacy_hal_);
for (const auto& callback : event_cb_handler_.getCallbacks()) {
if (!callback->onIfaceAdded(IfaceType::NAN, ifname).isOk()) {
LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
}
}
return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_};
}
std::pair<WifiStatus, std::vector<hidl_string>>

View file

@ -0,0 +1,41 @@
/*
* Copyright (C) 2016 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 WIFI_FEATURE_FLAGS_H_
#define WIFI_FEATURE_FLAGS_H_
namespace android {
namespace hardware {
namespace wifi {
namespace V1_0 {
namespace implementation {
class WifiFeatureFlags {
public:
#ifdef WIFI_HIDL_FEATURE_AWARE
static const bool wifiHidlFeatureAware = true;
#else
static const bool wifiHidlFeatureAware = false;
#endif // WIFI_HIDL_FEATURE_AWARE
};
} // namespace implementation
} // namespace V1_0
} // namespace wifi
} // namespace hardware
} // namespace android
#endif // WIFI_FEATURE_FLAGS_H_