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

Commit c571b680 authored by Nick James's avatar Nick James Committed by Android (Google) Code Review
Browse files

Merge "Add feature flag to disable wifi AP on the watch." into pi-dev

parents e9a39e27 c52e8087
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@ endif
ifdef WIFI_HIDL_FEATURE_DUAL_INTERFACE
LOCAL_CPPFLAGS += -DWIFI_HIDL_FEATURE_DUAL_INTERFACE
endif
ifdef WIFI_HIDL_FEATURE_DISABLE_AP
LOCAL_CPPFLAGS += -DWIFI_HIDL_FEATURE_DISABLE_AP
endif
LOCAL_SRC_FILES := \
    hidl_struct_util.cpp \
    hidl_sync_util.cpp \
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ class MockWifiFeatureFlags : public WifiFeatureFlags {

    MOCK_METHOD0(isAwareSupported, bool());
    MOCK_METHOD0(isDualInterfaceSupported, bool());
    MOCK_METHOD0(isApDisabled, bool());
};

}  // namespace feature_flags
+57 −0
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ class WifiChipTest : public Test {
            .WillRepeatedly(testing::Return(false));
        EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
            .WillRepeatedly(testing::Return(false));
        EXPECT_CALL(*feature_flags_, isApDisabled())
            .WillRepeatedly(testing::Return(false));
    }

    void setupV1_AwareIfaceCombination() {
@@ -55,6 +57,17 @@ class WifiChipTest : public Test {
            .WillRepeatedly(testing::Return(true));
        EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
            .WillRepeatedly(testing::Return(false));
        EXPECT_CALL(*feature_flags_, isApDisabled())
            .WillRepeatedly(testing::Return(false));
    }

    void setupV1_AwareDisabledApIfaceCombination() {
        EXPECT_CALL(*feature_flags_, isAwareSupported())
            .WillRepeatedly(testing::Return(true));
        EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
            .WillRepeatedly(testing::Return(false));
        EXPECT_CALL(*feature_flags_, isApDisabled())
            .WillRepeatedly(testing::Return(true));
    }

    void setupV2_AwareIfaceCombination() {
@@ -62,6 +75,17 @@ class WifiChipTest : public Test {
            .WillRepeatedly(testing::Return(true));
        EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
            .WillRepeatedly(testing::Return(true));
        EXPECT_CALL(*feature_flags_, isApDisabled())
            .WillRepeatedly(testing::Return(false));
    }

    void setupV2_AwareDisabledApIfaceCombination() {
        EXPECT_CALL(*feature_flags_, isAwareSupported())
            .WillRepeatedly(testing::Return(true));
        EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
            .WillRepeatedly(testing::Return(true));
        EXPECT_CALL(*feature_flags_, isApDisabled())
            .WillRepeatedly(testing::Return(true));
    }

    void assertNumberOfModes(uint32_t num_modes) {
@@ -515,6 +539,39 @@ TEST_F(WifiChipV2_AwareIfaceCombinationTest,
    ASSERT_FALSE(ap_iface_name.empty());
    ASSERT_NE(sta_iface_name, ap_iface_name);
}

////////// V1 Iface Combinations when AP creation is disabled //////////
class WifiChipV1_AwareDisabledApIfaceCombinationTest : public WifiChipTest {
 public:
  void SetUp() override {
    setupV1_AwareDisabledApIfaceCombination();
    WifiChipTest::SetUp();
  }
};

TEST_F(WifiChipV1_AwareDisabledApIfaceCombinationTest,
       StaMode_CreateSta_ShouldSucceed) {
  findModeAndConfigureForIfaceType(IfaceType::STA);
  ASSERT_FALSE(createIface(IfaceType::STA).empty());
  ASSERT_TRUE(createIface(IfaceType::AP).empty());
}

////////// V2 Iface Combinations when AP creation is disabled //////////
class WifiChipV2_AwareDisabledApIfaceCombinationTest: public WifiChipTest {
 public:
  void SetUp() override {
    setupV2_AwareDisabledApIfaceCombination();
    WifiChipTest::SetUp();
  }
};

TEST_F(WifiChipV2_AwareDisabledApIfaceCombinationTest,
       CreateSta_ShouldSucceed) {
  findModeAndConfigureForIfaceType(IfaceType::STA);
  ASSERT_FALSE(createIface(IfaceType::STA).empty());
  ASSERT_TRUE(createIface(IfaceType::AP).empty());
}

}  // namespace implementation
}  // namespace V1_2
}  // namespace wifi
+14 −3
Original line number Diff line number Diff line
@@ -1211,10 +1211,17 @@ void WifiChip::populateModes() {
            {chip_iface_combination_limit_1, chip_iface_combination_limit_2}};
        const IWifiChip::ChipIfaceCombination chip_iface_combination_2 = {
            {chip_iface_combination_limit_1, chip_iface_combination_limit_3}};
        if (feature_flags_.lock()->isApDisabled()) {
          const IWifiChip::ChipMode chip_mode = {
              kV2ChipModeId,
              {chip_iface_combination_2}};
          modes_ = {chip_mode};
        } else {
          const IWifiChip::ChipMode chip_mode = {
            kV2ChipModeId,
            {chip_iface_combination_1, chip_iface_combination_2}};
          modes_ = {chip_mode};
        }
    } else {
        // V1 Iface combinations for Mode Id = 0. (STA Mode)
        const IWifiChip::ChipIfaceCombinationLimit
@@ -1238,9 +1245,13 @@ void WifiChip::populateModes() {
            {ap_chip_iface_combination_limit}};
        const IWifiChip::ChipMode ap_chip_mode = {kV1ApChipModeId,
                                                  {ap_chip_iface_combination}};
        if (feature_flags_.lock()->isApDisabled()) {
          modes_ = {sta_chip_mode};
        } else {
          modes_ = {sta_chip_mode, ap_chip_mode};
        }
    }
}

std::vector<IWifiChip::ChipIfaceCombination>
WifiChip::getCurrentModeIfaceCombinations() {
+9 −0
Original line number Diff line number Diff line
@@ -27,6 +27,12 @@ static const bool wifiHidlFeatureDualInterface = true;
#else
static const bool wifiHidlFeatureDualInterface = false;
#endif  // WIFI_HIDL_FEATURE_DUAL_INTERFACE
#ifdef WIFI_HIDL_FEATURE_DISABLE_AP
static const bool wifiHidlFeatureDisableAp = true;
#else
static const bool wifiHidlFeatureDisableAp = false;
#endif  // WIFI_HIDL_FEATURE_DISABLE_AP

}  // namespace

namespace android {
@@ -41,6 +47,9 @@ bool WifiFeatureFlags::isAwareSupported() { return wifiHidlFeatureAware; }
bool WifiFeatureFlags::isDualInterfaceSupported() {
    return wifiHidlFeatureDualInterface;
}
bool WifiFeatureFlags::isApDisabled() {
  return wifiHidlFeatureDisableAp;
}

}  // namespace feature_flags
}  // namespace implementation
Loading