Loading wifi/1.5/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ hidl_interface { "types.hal", "IWifi.hal", "IWifiChip.hal", "IWifiApIface.hal", "IWifiNanIface.hal", "IWifiNanIfaceEventCallback.hal", "IWifiStaIface.hal", Loading wifi/1.5/IWifiApIface.hal 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright 2020 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.5; import @1.4::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.5. */ interface IWifiApIface extends @1.4::IWifiApIface { /** * Reset all of the AP interfaces MAC address to the factory MAC address. * * @return status WifiStatus of the operation * Possible status codes: * |WifiStatusCode.SUCCESS|, * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|, * |WifiStatusCode.ERROR_UNKNOWN| */ resetToFactoryMacAddress() generates (WifiStatus status); }; wifi/1.5/IWifiChip.hal +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package android.hardware.wifi@1.5; import @1.0::WifiStatus; import @1.0::IWifiApIface; import @1.5::IWifiApIface; import @1.0::IWifiIface; import @1.3::IWifiChip; import @1.4::IWifiChip; Loading wifi/1.5/default/wifi_ap_iface.cpp +55 −7 Original line number Diff line number Diff line Loading @@ -29,10 +29,11 @@ namespace implementation { using hidl_return_util::validateAndCall; WifiApIface::WifiApIface( const std::string& ifname, const std::string& ifname, const std::vector<std::string>& instances, const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util) : ifname_(ifname), instances_(instances), legacy_hal_(legacy_hal), iface_util_(iface_util), is_valid_(true) {} Loading Loading @@ -81,6 +82,14 @@ Return<void> WifiApIface::getFactoryMacAddress( getFactoryMacAddress_cb hidl_status_cb) { return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, &WifiApIface::getFactoryMacAddressInternal, hidl_status_cb, instances_.size() > 0 ? instances_[0] : ifname_); } Return<void> WifiApIface::resetToFactoryMacAddress( resetToFactoryMacAddress_cb hidl_status_cb) { return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, &WifiApIface::resetToFactoryMacAddressInternal, hidl_status_cb); } Loading @@ -94,8 +103,8 @@ std::pair<WifiStatus, IfaceType> WifiApIface::getTypeInternal() { WifiStatus WifiApIface::setCountryCodeInternal( const std::array<int8_t, 2>& code) { legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->setCountryCode(ifname_, code); legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->setCountryCode( instances_.size() > 0 ? instances_[0] : ifname_, code); return createWifiStatusFromLegacyError(legacy_status); } Loading @@ -107,13 +116,30 @@ WifiApIface::getValidFrequenciesForBandInternal(V1_0::WifiBand band) { std::vector<uint32_t> valid_frequencies; std::tie(legacy_status, valid_frequencies) = legacy_hal_.lock()->getValidFrequenciesForBand( ifname_, hidl_struct_util::convertHidlWifiBandToLegacy(band)); instances_.size() > 0 ? instances_[0] : 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); bool status; // Support random MAC up to 2 interfaces if (instances_.size() == 2) { int rbyte = 1; for (auto const& intf : instances_) { std::array<uint8_t, 6> rmac = mac; // reverse the bits to avoid clision rmac[rbyte] = 0xff - rmac[rbyte]; status = iface_util_.lock()->setMacAddress(intf, rmac); if (!status) { LOG(INFO) << "Failed to set random mac address on " << intf; } rbyte++; } } else { status = iface_util_.lock()->setMacAddress(ifname_, mac); } if (!status) { return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); } Loading @@ -121,15 +147,37 @@ WifiStatus WifiApIface::setMacAddressInternal( } std::pair<WifiStatus, std::array<uint8_t, 6>> WifiApIface::getFactoryMacAddressInternal() { WifiApIface::getFactoryMacAddressInternal(const std::string& ifaceName) { std::array<uint8_t, 6> mac = iface_util_.lock()->getFactoryMacAddress(ifname_); iface_util_.lock()->getFactoryMacAddress(ifaceName); 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}; } WifiStatus WifiApIface::resetToFactoryMacAddressInternal() { std::pair<WifiStatus, std::array<uint8_t, 6>> getMacResult; if (instances_.size() == 2) { for (auto const& intf : instances_) { getMacResult = getFactoryMacAddressInternal(intf); LOG(DEBUG) << "Reset MAC to factory MAC on " << intf; if (getMacResult.first.code != WifiStatusCode::SUCCESS || !iface_util_.lock()->setMacAddress(intf, getMacResult.second)) { return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); } } } else { getMacResult = getFactoryMacAddressInternal(ifname_); LOG(DEBUG) << "Reset MAC to factory MAC on " << ifname_; if (getMacResult.first.code != WifiStatusCode::SUCCESS || !iface_util_.lock()->setMacAddress(ifname_, getMacResult.second)) { return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); } } return createWifiStatus(WifiStatusCode::SUCCESS); } } // namespace implementation } // namespace V1_5 } // namespace wifi Loading wifi/1.5/default/wifi_ap_iface.h +9 −4 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.4/IWifiApIface.h> #include <android/hardware/wifi/1.5/IWifiApIface.h> #include "wifi_iface_util.h" #include "wifi_legacy_hal.h" Loading @@ -33,9 +33,10 @@ using namespace android::hardware::wifi::V1_0; /** * HIDL interface object used to control a AP Iface instance. */ class WifiApIface : public V1_4::IWifiApIface { class WifiApIface : public V1_5::IWifiApIface { public: WifiApIface(const std::string& ifname, const std::vector<std::string>& instances, const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util); // Refer to |WifiChip::invalidate()|. Loading @@ -55,6 +56,8 @@ class WifiApIface : public V1_4::IWifiApIface { setMacAddress_cb hidl_status_cb) override; Return<void> getFactoryMacAddress( getFactoryMacAddress_cb hidl_status_cb) override; Return<void> resetToFactoryMacAddress( resetToFactoryMacAddress_cb hidl_status_cb) override; private: // Corresponding worker functions for the HIDL methods. Loading @@ -64,10 +67,12 @@ class WifiApIface : public V1_4::IWifiApIface { std::pair<WifiStatus, std::vector<WifiChannelInMhz>> getValidFrequenciesForBandInternal(V1_0::WifiBand band); WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); std::pair<WifiStatus, std::array<uint8_t, 6>> getFactoryMacAddressInternal(); std::pair<WifiStatus, std::array<uint8_t, 6>> getFactoryMacAddressInternal( const std::string& ifaceName); WifiStatus resetToFactoryMacAddressInternal(); std::string ifname_; std::vector<std::string> instances_; std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_; bool is_valid_; Loading Loading
wifi/1.5/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ hidl_interface { "types.hal", "IWifi.hal", "IWifiChip.hal", "IWifiApIface.hal", "IWifiNanIface.hal", "IWifiNanIfaceEventCallback.hal", "IWifiStaIface.hal", Loading
wifi/1.5/IWifiApIface.hal 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright 2020 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.5; import @1.4::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.5. */ interface IWifiApIface extends @1.4::IWifiApIface { /** * Reset all of the AP interfaces MAC address to the factory MAC address. * * @return status WifiStatus of the operation * Possible status codes: * |WifiStatusCode.SUCCESS|, * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|, * |WifiStatusCode.ERROR_UNKNOWN| */ resetToFactoryMacAddress() generates (WifiStatus status); };
wifi/1.5/IWifiChip.hal +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package android.hardware.wifi@1.5; import @1.0::WifiStatus; import @1.0::IWifiApIface; import @1.5::IWifiApIface; import @1.0::IWifiIface; import @1.3::IWifiChip; import @1.4::IWifiChip; Loading
wifi/1.5/default/wifi_ap_iface.cpp +55 −7 Original line number Diff line number Diff line Loading @@ -29,10 +29,11 @@ namespace implementation { using hidl_return_util::validateAndCall; WifiApIface::WifiApIface( const std::string& ifname, const std::string& ifname, const std::vector<std::string>& instances, const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util) : ifname_(ifname), instances_(instances), legacy_hal_(legacy_hal), iface_util_(iface_util), is_valid_(true) {} Loading Loading @@ -81,6 +82,14 @@ Return<void> WifiApIface::getFactoryMacAddress( getFactoryMacAddress_cb hidl_status_cb) { return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, &WifiApIface::getFactoryMacAddressInternal, hidl_status_cb, instances_.size() > 0 ? instances_[0] : ifname_); } Return<void> WifiApIface::resetToFactoryMacAddress( resetToFactoryMacAddress_cb hidl_status_cb) { return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID, &WifiApIface::resetToFactoryMacAddressInternal, hidl_status_cb); } Loading @@ -94,8 +103,8 @@ std::pair<WifiStatus, IfaceType> WifiApIface::getTypeInternal() { WifiStatus WifiApIface::setCountryCodeInternal( const std::array<int8_t, 2>& code) { legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->setCountryCode(ifname_, code); legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->setCountryCode( instances_.size() > 0 ? instances_[0] : ifname_, code); return createWifiStatusFromLegacyError(legacy_status); } Loading @@ -107,13 +116,30 @@ WifiApIface::getValidFrequenciesForBandInternal(V1_0::WifiBand band) { std::vector<uint32_t> valid_frequencies; std::tie(legacy_status, valid_frequencies) = legacy_hal_.lock()->getValidFrequenciesForBand( ifname_, hidl_struct_util::convertHidlWifiBandToLegacy(band)); instances_.size() > 0 ? instances_[0] : 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); bool status; // Support random MAC up to 2 interfaces if (instances_.size() == 2) { int rbyte = 1; for (auto const& intf : instances_) { std::array<uint8_t, 6> rmac = mac; // reverse the bits to avoid clision rmac[rbyte] = 0xff - rmac[rbyte]; status = iface_util_.lock()->setMacAddress(intf, rmac); if (!status) { LOG(INFO) << "Failed to set random mac address on " << intf; } rbyte++; } } else { status = iface_util_.lock()->setMacAddress(ifname_, mac); } if (!status) { return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); } Loading @@ -121,15 +147,37 @@ WifiStatus WifiApIface::setMacAddressInternal( } std::pair<WifiStatus, std::array<uint8_t, 6>> WifiApIface::getFactoryMacAddressInternal() { WifiApIface::getFactoryMacAddressInternal(const std::string& ifaceName) { std::array<uint8_t, 6> mac = iface_util_.lock()->getFactoryMacAddress(ifname_); iface_util_.lock()->getFactoryMacAddress(ifaceName); 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}; } WifiStatus WifiApIface::resetToFactoryMacAddressInternal() { std::pair<WifiStatus, std::array<uint8_t, 6>> getMacResult; if (instances_.size() == 2) { for (auto const& intf : instances_) { getMacResult = getFactoryMacAddressInternal(intf); LOG(DEBUG) << "Reset MAC to factory MAC on " << intf; if (getMacResult.first.code != WifiStatusCode::SUCCESS || !iface_util_.lock()->setMacAddress(intf, getMacResult.second)) { return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); } } } else { getMacResult = getFactoryMacAddressInternal(ifname_); LOG(DEBUG) << "Reset MAC to factory MAC on " << ifname_; if (getMacResult.first.code != WifiStatusCode::SUCCESS || !iface_util_.lock()->setMacAddress(ifname_, getMacResult.second)) { return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); } } return createWifiStatus(WifiStatusCode::SUCCESS); } } // namespace implementation } // namespace V1_5 } // namespace wifi Loading
wifi/1.5/default/wifi_ap_iface.h +9 −4 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.4/IWifiApIface.h> #include <android/hardware/wifi/1.5/IWifiApIface.h> #include "wifi_iface_util.h" #include "wifi_legacy_hal.h" Loading @@ -33,9 +33,10 @@ using namespace android::hardware::wifi::V1_0; /** * HIDL interface object used to control a AP Iface instance. */ class WifiApIface : public V1_4::IWifiApIface { class WifiApIface : public V1_5::IWifiApIface { public: WifiApIface(const std::string& ifname, const std::vector<std::string>& instances, const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util); // Refer to |WifiChip::invalidate()|. Loading @@ -55,6 +56,8 @@ class WifiApIface : public V1_4::IWifiApIface { setMacAddress_cb hidl_status_cb) override; Return<void> getFactoryMacAddress( getFactoryMacAddress_cb hidl_status_cb) override; Return<void> resetToFactoryMacAddress( resetToFactoryMacAddress_cb hidl_status_cb) override; private: // Corresponding worker functions for the HIDL methods. Loading @@ -64,10 +67,12 @@ class WifiApIface : public V1_4::IWifiApIface { std::pair<WifiStatus, std::vector<WifiChannelInMhz>> getValidFrequenciesForBandInternal(V1_0::WifiBand band); WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); std::pair<WifiStatus, std::array<uint8_t, 6>> getFactoryMacAddressInternal(); std::pair<WifiStatus, std::array<uint8_t, 6>> getFactoryMacAddressInternal( const std::string& ifaceName); WifiStatus resetToFactoryMacAddressInternal(); std::string ifname_; std::vector<std::string> instances_; std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_; bool is_valid_; Loading