Loading wifi/1.4/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ hidl_interface { }, srcs: [ "IWifi.hal", "IWifiApIface.hal", ], interfaces: [ "android.hardware.wifi@1.0", Loading wifi/1.4/IWifiApIface.hal 0 → 100644 +53 −0 Original line number Diff line number Diff line /* * Copyright 2019 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.4; import @1.0::IWifiApIface; import @1.0::MacAddress; import @1.0::WifiStatus; /** * Represents a network interface in AP mode. * * This can be obtained through @1.0::IWifiChip.getApIface() and casting * IWifiApIface up to 1.4. */ interface IWifiApIface extends @1.0::IWifiApIface { /** * Changes the MAC address of the interface to the given MAC address. * * @param mac MAC address to change to. * @return status WifiStatus of the operation. * Possible status codes: * |WifiStatusCode.SUCCESS|, * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|, * |WifiStatusCode.ERROR_UNKNOWN| */ setMacAddress(MacAddress mac) generates (WifiStatus status); /** * Gets the factory MAC address of the interface. * * @return status WifiStatus of the operation * Possible status codes: * |WifiStatusCode.SUCCESS|, * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|, * |WifiStatusCode.ERROR_UNKNOWN| * @return mac factory MAC address of the interface */ getFactoryMacAddress() generates (WifiStatus status, MacAddress mac); }; wifi/1.4/default/tests/wifi_chip_unit_tests.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -173,8 +173,9 @@ class WifiChipTest : public Test { std::string createIface(const IfaceType& type) { std::string iface_name; if (type == IfaceType::AP) { chip_->createApIface([&iface_name](const WifiStatus& status, const sp<IWifiApIface>& iface) { chip_->createApIface([&iface_name]( const WifiStatus& status, const sp<V1_0::IWifiApIface>& iface) { if (WifiStatusCode::SUCCESS == status.code) { ASSERT_NE(iface.get(), nullptr); iface->getName([&iface_name](const WifiStatus& status, Loading wifi/1.4/default/wifi_ap_iface.cpp +34 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,20 @@ Return<void> WifiApIface::getValidFrequenciesForBand( hidl_status_cb, band); } Return<void> WifiApIface::setMacAddress(const hidl_array<uint8_t, 6>& mac, setMacAddress_cb hidl_status_cb) { return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, &WifiApIface::setMacAddressInternal, hidl_status_cb, mac); } Return<void> WifiApIface::getFactoryMacAddress( getFactoryMacAddress_cb hidl_status_cb) { return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, &WifiApIface::getFactoryMacAddressInternal, hidl_status_cb); } std::pair<WifiStatus, std::string> WifiApIface::getNameInternal() { return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_}; } Loading @@ -111,6 +125,26 @@ WifiApIface::getValidFrequenciesForBandInternal(WifiBand band) { ifname_, hidl_struct_util::convertHidlWifiBandToLegacy(band)); return {createWifiStatusFromLegacyError(legacy_status), valid_frequencies}; } WifiStatus WifiApIface::setMacAddressInternal( const std::array<uint8_t, 6>& mac) { bool status = iface_util_.lock()->setMacAddress(ifname_, mac); if (!status) { return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); } return createWifiStatus(WifiStatusCode::SUCCESS); } std::pair<WifiStatus, std::array<uint8_t, 6>> WifiApIface::getFactoryMacAddressInternal() { std::array<uint8_t, 6> mac = iface_util_.lock()->getFactoryMacAddress(ifname_); if (mac[0] == 0 && mac[1] == 0 && mac[2] == 0 && mac[3] == 0 && mac[4] == 0 && mac[5] == 0) { return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), mac}; } return {createWifiStatus(WifiStatusCode::SUCCESS), mac}; } } // namespace implementation } // namespace V1_4 } // namespace wifi Loading wifi/1.4/default/wifi_ap_iface.h +9 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ #define WIFI_AP_IFACE_H_ #include <android-base/macros.h> #include <android/hardware/wifi/1.0/IWifiApIface.h> #include <android/hardware/wifi/1.4/IWifiApIface.h> #include "wifi_feature_flags.h" #include "wifi_iface_util.h" Loading @@ -34,7 +34,7 @@ using namespace android::hardware::wifi::V1_0; /** * HIDL interface object used to control a AP Iface instance. */ class WifiApIface : public V1_0::IWifiApIface { class WifiApIface : public V1_4::IWifiApIface { public: WifiApIface( const std::string& ifname, Loading @@ -53,6 +53,10 @@ class WifiApIface : public V1_0::IWifiApIface { setCountryCode_cb hidl_status_cb) override; Return<void> getValidFrequenciesForBand( WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override; Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac, setMacAddress_cb hidl_status_cb) override; Return<void> getFactoryMacAddress( getFactoryMacAddress_cb hidl_status_cb) override; private: // Corresponding worker functions for the HIDL methods. Loading @@ -61,6 +65,9 @@ class WifiApIface : public V1_0::IWifiApIface { WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code); std::pair<WifiStatus, std::vector<WifiChannelInMhz>> getValidFrequenciesForBandInternal(WifiBand band); WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); std::pair<WifiStatus, std::array<uint8_t, 6>> getFactoryMacAddressInternal(); std::string ifname_; std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; Loading Loading
wifi/1.4/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ hidl_interface { }, srcs: [ "IWifi.hal", "IWifiApIface.hal", ], interfaces: [ "android.hardware.wifi@1.0", Loading
wifi/1.4/IWifiApIface.hal 0 → 100644 +53 −0 Original line number Diff line number Diff line /* * Copyright 2019 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.4; import @1.0::IWifiApIface; import @1.0::MacAddress; import @1.0::WifiStatus; /** * Represents a network interface in AP mode. * * This can be obtained through @1.0::IWifiChip.getApIface() and casting * IWifiApIface up to 1.4. */ interface IWifiApIface extends @1.0::IWifiApIface { /** * Changes the MAC address of the interface to the given MAC address. * * @param mac MAC address to change to. * @return status WifiStatus of the operation. * Possible status codes: * |WifiStatusCode.SUCCESS|, * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|, * |WifiStatusCode.ERROR_UNKNOWN| */ setMacAddress(MacAddress mac) generates (WifiStatus status); /** * Gets the factory MAC address of the interface. * * @return status WifiStatus of the operation * Possible status codes: * |WifiStatusCode.SUCCESS|, * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|, * |WifiStatusCode.ERROR_UNKNOWN| * @return mac factory MAC address of the interface */ getFactoryMacAddress() generates (WifiStatus status, MacAddress mac); };
wifi/1.4/default/tests/wifi_chip_unit_tests.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -173,8 +173,9 @@ class WifiChipTest : public Test { std::string createIface(const IfaceType& type) { std::string iface_name; if (type == IfaceType::AP) { chip_->createApIface([&iface_name](const WifiStatus& status, const sp<IWifiApIface>& iface) { chip_->createApIface([&iface_name]( const WifiStatus& status, const sp<V1_0::IWifiApIface>& iface) { if (WifiStatusCode::SUCCESS == status.code) { ASSERT_NE(iface.get(), nullptr); iface->getName([&iface_name](const WifiStatus& status, Loading
wifi/1.4/default/wifi_ap_iface.cpp +34 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,20 @@ Return<void> WifiApIface::getValidFrequenciesForBand( hidl_status_cb, band); } Return<void> WifiApIface::setMacAddress(const hidl_array<uint8_t, 6>& mac, setMacAddress_cb hidl_status_cb) { return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, &WifiApIface::setMacAddressInternal, hidl_status_cb, mac); } Return<void> WifiApIface::getFactoryMacAddress( getFactoryMacAddress_cb hidl_status_cb) { return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, &WifiApIface::getFactoryMacAddressInternal, hidl_status_cb); } std::pair<WifiStatus, std::string> WifiApIface::getNameInternal() { return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_}; } Loading @@ -111,6 +125,26 @@ WifiApIface::getValidFrequenciesForBandInternal(WifiBand band) { ifname_, hidl_struct_util::convertHidlWifiBandToLegacy(band)); return {createWifiStatusFromLegacyError(legacy_status), valid_frequencies}; } WifiStatus WifiApIface::setMacAddressInternal( const std::array<uint8_t, 6>& mac) { bool status = iface_util_.lock()->setMacAddress(ifname_, mac); if (!status) { return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); } return createWifiStatus(WifiStatusCode::SUCCESS); } std::pair<WifiStatus, std::array<uint8_t, 6>> WifiApIface::getFactoryMacAddressInternal() { std::array<uint8_t, 6> mac = iface_util_.lock()->getFactoryMacAddress(ifname_); if (mac[0] == 0 && mac[1] == 0 && mac[2] == 0 && mac[3] == 0 && mac[4] == 0 && mac[5] == 0) { return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), mac}; } return {createWifiStatus(WifiStatusCode::SUCCESS), mac}; } } // namespace implementation } // namespace V1_4 } // namespace wifi Loading
wifi/1.4/default/wifi_ap_iface.h +9 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ #define WIFI_AP_IFACE_H_ #include <android-base/macros.h> #include <android/hardware/wifi/1.0/IWifiApIface.h> #include <android/hardware/wifi/1.4/IWifiApIface.h> #include "wifi_feature_flags.h" #include "wifi_iface_util.h" Loading @@ -34,7 +34,7 @@ using namespace android::hardware::wifi::V1_0; /** * HIDL interface object used to control a AP Iface instance. */ class WifiApIface : public V1_0::IWifiApIface { class WifiApIface : public V1_4::IWifiApIface { public: WifiApIface( const std::string& ifname, Loading @@ -53,6 +53,10 @@ class WifiApIface : public V1_0::IWifiApIface { setCountryCode_cb hidl_status_cb) override; Return<void> getValidFrequenciesForBand( WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override; Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac, setMacAddress_cb hidl_status_cb) override; Return<void> getFactoryMacAddress( getFactoryMacAddress_cb hidl_status_cb) override; private: // Corresponding worker functions for the HIDL methods. Loading @@ -61,6 +65,9 @@ class WifiApIface : public V1_0::IWifiApIface { WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code); std::pair<WifiStatus, std::vector<WifiChannelInMhz>> getValidFrequenciesForBandInternal(WifiBand band); WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); std::pair<WifiStatus, std::array<uint8_t, 6>> getFactoryMacAddressInternal(); std::string ifname_; std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; Loading