Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c99ea88f authored by Roshan Pius's avatar Roshan Pius Committed by Android (Google) Code Review
Browse files

Merge "Notify scan-only mode to driver for power saving"

parents 2a396aad c6b5f89b
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -41,4 +41,17 @@ interface IWifiStaIface extends @1.3::IWifiStaIface {
     * @return stats Instance of |LinkLayerStats|.
     */
    getLinkLayerStats_1_5() generates (WifiStatus status, StaLinkLayerStats stats);

    /**
     * Turn on/off scan only mode for the interface.
     *
     * @param enable Indicate if scan only mode is to be turned on/off.
     * @return status Status of the operation.
     *         Possible status codes:
     *         |WifiStatusCode.SUCCESS|,
     *         |WifiStatusCode.ERROR_NOT_SUPPORTED|,
     *         |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|,
     *         |WifiStatusCode.FAILURE_UNKNOWN|
     */
    setScanMode(bool enable) generates (WifiStatus status);
};
+13 −0
Original line number Diff line number Diff line
@@ -273,6 +273,13 @@ Return<void> WifiStaIface::getFactoryMacAddress(
                           hidl_status_cb);
}

Return<void> WifiStaIface::setScanMode(bool enable,
                                       setScanMode_cb hidl_status_cb) {
    return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
                           &WifiStaIface::setScanModeInternal, hidl_status_cb,
                           enable);
}

std::pair<WifiStatus, std::string> WifiStaIface::getNameInternal() {
    return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
}
@@ -655,6 +662,12 @@ WifiStaIface::getFactoryMacAddressInternal() {
    return {createWifiStatus(WifiStatusCode::SUCCESS), mac};
}

WifiStatus WifiStaIface::setScanModeInternal(bool enable) {
    // OEM's need to implement this on their devices if needed.
    LOG(WARNING) << "setScanModeInternal(" << enable << ") not supported";
    return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
}

}  // namespace implementation
}  // namespace V1_5
}  // namespace wifi
+3 −0
Original line number Diff line number Diff line
@@ -114,6 +114,8 @@ class WifiStaIface : public V1_5::IWifiStaIface {
                               setMacAddress_cb hidl_status_cb) override;
    Return<void> getFactoryMacAddress(
        getFactoryMacAddress_cb hidl_status_cb) override;
    Return<void> setScanMode(bool enable,
                             setScanMode_cb hidl_status_cb) override;

   private:
    // Corresponding worker functions for the HIDL methods.
@@ -164,6 +166,7 @@ class WifiStaIface : public V1_5::IWifiStaIface {
    WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac);
    std::pair<WifiStatus, std::array<uint8_t, 6>>
    getFactoryMacAddressInternal();
    WifiStatus setScanModeInternal(bool enable);

    std::string ifname_;
    std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
+13 −0
Original line number Diff line number Diff line
@@ -108,6 +108,19 @@ TEST_P(WifiStaIfaceHidlTest, GetLinkLayerStats_1_5) {
        WifiStatusCode::SUCCESS,
        HIDL_INVOKE(wifi_sta_iface_, disableLinkLayerStatsCollection).code);
}
/**
 * SetScanMode
 */
TEST_P(WifiStaIfaceHidlTest, SetScanMode) {
    auto statusCode =
        HIDL_INVOKE(wifi_sta_iface_, setScanMode, true).code;
    EXPECT_TRUE(statusCode == WifiStatusCode::SUCCESS ||
                statusCode == WifiStatusCode::ERROR_NOT_SUPPORTED);

    statusCode = HIDL_INVOKE(wifi_sta_iface_, setScanMode, false).code;
    EXPECT_TRUE(statusCode == WifiStatusCode::SUCCESS ||
                statusCode == WifiStatusCode::ERROR_NOT_SUPPORTED);
}

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(WifiStaIfaceHidlTest);
INSTANTIATE_TEST_SUITE_P(