Merge "Merge "Revert "[AccessPoint]Check AP state and restart."" am: 3eea2ffc1b am: 212c337d11 am: 23406bde5b Bug: 79856986 Change-Id: Ieafda4598283e52d8bcda5be435a305abed689a8 (cherry picked from commit b2c26d20a2932e8c7bcc33604acf52b4d20b14f4)" into pi-dev
diff --git a/acts/framework/acts/controllers/access_point.py b/acts/framework/acts/controllers/access_point.py
index a58c7dc..bf5b5f6 100755
--- a/acts/framework/acts/controllers/access_point.py
+++ b/acts/framework/acts/controllers/access_point.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3.4
+#!/usr/bin/env python3
 #
 #   Copyright 2016 - Google, Inc.
 #
@@ -16,16 +16,18 @@
 
 import collections
 import ipaddress
+import logging
 import time
 
-from acts import logger
 from acts.controllers.ap_lib import ap_get_interface
 from acts.controllers.ap_lib import bridge_interface
 from acts.controllers.ap_lib import dhcp_config
 from acts.controllers.ap_lib import dhcp_server
 from acts.controllers.ap_lib import hostapd
+from acts.controllers.ap_lib import hostapd_config
 from acts.controllers.utils_lib.commands import ip
 from acts.controllers.utils_lib.commands import route
+from acts.controllers.utils_lib.commands import shell
 from acts.controllers.utils_lib.ssh import connection
 from acts.controllers.utils_lib.ssh import settings
 from acts.libs.proc import job
@@ -104,12 +106,6 @@
             configs: configs for the access point from config file.
         """
         self.ssh_settings = settings.from_config(configs['ssh_config'])
-        self.ssh = connection.SshConnection(self.ssh_settings)
-        self.log = logger.create_logger(lambda msg: '[Access Point|%s] %s' % (
-            self.ssh_settings.hostname, msg))
-
-        self.check_state()
-
         if 'ap_subnet' in configs:
             self._AP_2G_SUBNET_STR = configs['ap_subnet']['2g']
             self._AP_5G_SUBNET_STR = configs['ap_subnet']['5g']
@@ -134,7 +130,7 @@
         self.bridge = bridge_interface.BridgeInterface(self)
         self.interfaces = ap_get_interface.ApInterfaces(self)
 
-        # Get needed interface names and initialize the unnecessary ones.
+        # Get needed interface names and initialize the unneccessary ones.
         self.wan = self.interfaces.get_wan_interface()
         self.wlan = self.interfaces.get_wlan_interface()
         self.wlan_2g = self.wlan[0]
@@ -142,30 +138,6 @@
         self.lan = self.interfaces.get_lan_interface()
         self.__initial_ap()
 
-    def check_state(self):
-        """Check what state the AP is in and reboot if required.
-
-        Check if the AP already has stale interfaces from the previous run.
-        If "yes", then reboot the AP and continue AP initialization.
-
-        """
-        self.log.debug("Checking AP state")
-        self.interfaces = ap_get_interface.ApInterfaces(self)
-        # Check if the AP has any virtual interfaces created.
-        interfaces = self.ssh.run('iw dev | grep -i "type ap" || true')
-        self.log.debug("AP interfaces = %s" % interfaces)
-        # The virtual interface will be of type "AP".
-        if 'AP' in interfaces.stdout:
-            self.log.debug("Found AP in stale state. Rebooting.")
-            try:
-                self.ssh.run('reboot')
-                # Wait for AP to shut down.
-                time.sleep(10)
-                self.ssh.run('echo connected', timeout=300)
-            except Exception as e:
-                self.log.exception("Error in rebooting AP: %s", e)
-                raise
-
     def __initial_ap(self):
         """Initial AP interfaces.
 
@@ -281,8 +253,9 @@
             counter = 1
             for bss in hostapd_config.bss_lookup:
                 if interface_mac_orig:
-                    hostapd_config.bss_lookup[bss].bssid = (
-                            interface_mac_orig.stdout[:-1] + str(counter))
+                    hostapd_config.bss_lookup[
+                        bss].bssid = interface_mac_orig.stdout[:-1] + str(
+                            counter)
                 self._route_cmd.clear_routes(net_interface=str(bss))
                 if interface is self.wlan_2g:
                     starting_ip_range = self._AP_2G_SUBNET_STR