hostapd_config: Add check to prevent generating ill-formed config.

The attribute `_vht_oper_centr_freq_seg0_idx` is used without checking,
so something like `vht_oper_centr_freq_seg0_idx=None` will appear in
hostapd config in those testcases which are 80211ac without setting a
center channel.

The config is ill-formed; however, it is ignored by hostapd parser. Thus,
this CL only prevents generating a eventually ignored config, and does not
change the behaviors of APs.

BUG=None
TEST=test_that --fast --debug -b ${BOARD} ${DUT} network_WiFi_SimpleConnect.wifi_check5VHT20

Change-Id: I3b8925ad73d21df968732f80675f2293af897c61
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2006849
Reviewed-by: Shuo-Peng Liao <deanliao@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Tested-by: Hsin-chen Chuang <chharry@google.com>
Commit-Queue: Brian Norris <briannorris@chromium.org>
diff --git a/server/cros/network/hostap_config.py b/server/cros/network/hostap_config.py
index 2b8553e..a27314b 100644
--- a/server/cros/network/hostap_config.py
+++ b/server/cros/network/hostap_config.py
@@ -775,8 +775,9 @@
         if self.is_11ac:
             conf['ieee80211ac'] = 1
             conf['vht_oper_chwidth'] = self._vht_oper_chwidth
-            conf['vht_oper_centr_freq_seg0_idx'] = \
-                    self._vht_oper_centr_freq_seg0_idx
+            if self._vht_oper_centr_freq_seg0_idx is not None:
+                conf['vht_oper_centr_freq_seg0_idx'] = \
+                        self._vht_oper_centr_freq_seg0_idx
             conf['vht_capab'] = self._hostapd_vht_capabilities
         if self._wmm_enabled:
             conf['wmm_enabled'] = 1