From 073d5b9fdc67bc3ffda7fa3b895d7a51497ab2d0 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Thu, 8 Dec 2016 19:10:06 -0800 Subject: [PATCH] wifi: Disallow iface creation based on mode Based on the mode configured, limit the iface creation. Note: Support for iface removal will be added in a follow up CL which should help us use P2P or NAN iface dynamically. Bug: 31997422 Test: Compiles Change-Id: Idde2f3b749264d542d5d6608b0b2c5aa8103ade6 --- wifi/1.0/default/wifi_chip.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp index 4f3c192c1a..af194912a3 100644 --- a/wifi/1.0/default/wifi_chip.cpp +++ b/wifi/1.0/default/wifi_chip.cpp @@ -465,7 +465,9 @@ WifiChip::requestFirmwareDebugDumpInternal() { } std::pair> WifiChip::createApIfaceInternal() { - // TODO(b/31997422): Disallow this based on the chip combination. + if (current_mode_id_ != kApChipModeId || ap_iface_.get()) { + return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; + } std::string ifname = legacy_hal_.lock()->getApIfaceName(); ap_iface_ = new WifiApIface(ifname, legacy_hal_); return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_}; @@ -490,7 +492,11 @@ std::pair> WifiChip::getApIfaceInternal( } std::pair> WifiChip::createNanIfaceInternal() { - // TODO(b/31997422): Disallow this based on the chip combination. + // Only 1 of NAN or P2P iface can be active at a time. + 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_); return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_}; @@ -515,7 +521,11 @@ std::pair> WifiChip::getNanIfaceInternal( } std::pair> WifiChip::createP2pIfaceInternal() { - // TODO(b/31997422): Disallow this based on the chip combination. + // Only 1 of NAN or P2P iface can be active at a time. + if (current_mode_id_ != kStaChipModeId || p2p_iface_.get() || + nan_iface_.get()) { + return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; + } std::string ifname = legacy_hal_.lock()->getP2pIfaceName(); p2p_iface_ = new WifiP2pIface(ifname, legacy_hal_); return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_}; @@ -540,7 +550,9 @@ std::pair> WifiChip::getP2pIfaceInternal( } std::pair> WifiChip::createStaIfaceInternal() { - // TODO(b/31997422): Disallow this based on the chip combination. + if (current_mode_id_ != kStaChipModeId || sta_iface_.get()) { + return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; + } std::string ifname = legacy_hal_.lock()->getStaIfaceName(); sta_iface_ = new WifiStaIface(ifname, legacy_hal_); return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_};