Merge "Ability to register controller without starting vts services. Enable HwBinderBinerizePerformanceAdbTest."
diff --git a/runners/host/test_runner.py b/runners/host/test_runner.py
index 68df2b9..5a8f67b 100644
--- a/runners/host/test_runner.py
+++ b/runners/host/test_runner.py
@@ -243,7 +243,7 @@
                     ("Controller interface %s in %s "
                      "cannot be null.") % (attr, module.__name__))
 
-    def registerController(self, module):
+    def registerController(self, module, start_services=True):
         """Registers a controller module for a test run.
 
         This declares a controller dependency of this test class. If the target
@@ -253,6 +253,8 @@
 
         Params:
             module: A module that follows the controller module interface.
+            start_services: boolean, controls whether services (e.g VTS agent)
+                            are started on the target.
 
         Returns:
             A list of controller objects instantiated from controller_module.
@@ -283,7 +285,7 @@
             controller_config = copy.deepcopy(original_config)
             logging.info("controller_config: %s", controller_config)
             if "use_vts_agent" not in self.testbed_configs:
-                objects = create(controller_config)
+                objects = create(controller_config, start_services)
             else:
                 objects = create(controller_config,
                                  self.testbed_configs["use_vts_agent"])
diff --git a/tools/vts-tradefed/res/config/vts-serving-staging-hal-hidl.xml b/tools/vts-tradefed/res/config/vts-serving-staging-hal-hidl.xml
index 6c4813b..6c87b4b 100644
--- a/tools/vts-tradefed/res/config/vts-serving-staging-hal-hidl.xml
+++ b/tools/vts-tradefed/res/config/vts-serving-staging-hal-hidl.xml
@@ -22,6 +22,7 @@
     <option name="compatibility:include-filter" value="HwBinderPassthroughThroughputTest" />
     <option name="compatibility:include-filter" value="HwBinderBinderizePerformanceTest" />
     <option name="compatibility:include-filter" value="HwBinderPassthroughPerformanceTest" />
+    <option name="compatibility:include-filter" value="HwBinderBinderizePerformanceAdbTest" />
     <option name="compatibility:include-filter" value="NfcHidlBinderizeBasicTest" />
     <option name="compatibility:include-filter" value="NfcHidlPassthroughBasicTest" />
     <option name="compatibility:include-filter" value="HalNfcHidlTargetBasicTest" />
diff --git a/utils/python/controllers/android_device.py b/utils/python/controllers/android_device.py
index 1b31091..31e89e9 100644
--- a/utils/python/controllers/android_device.py
+++ b/utils/python/controllers/android_device.py
@@ -62,12 +62,13 @@
     pass
 
 
-def create(configs):
+def create(configs, start_services=True):
     """Creates AndroidDevice controller objects.
 
     Args:
         configs: A list of dicts, each representing a configuration for an
                  Android device.
+        start_services: boolean, controls whether services will be started.
 
     Returns:
         A list of AndroidDevice objects.
@@ -89,7 +90,8 @@
         if ad.serial not in connected_ads:
             raise DoesNotExistError(("Android device %s is specified in config"
                                      " but is not attached.") % ad.serial)
-    _startServicesOnAds(ads)
+    if start_services:
+        _startServicesOnAds(ads)
     return ads
 
 
@@ -590,7 +592,7 @@
         self.adb.shell("start")
         self.waitForBootCompletion()
 
-    def reboot(self):
+    def reboot(self, restart_services=True):
         """Reboots the device and wait for device to complete booting.
 
         This is probably going to print some error messages in console. Only
@@ -603,19 +605,24 @@
         if self.isBootloaderMode:
             self.fastboot.reboot()
             return
-        has_adb_log = self.isAdbLogcatOn
-        has_vts_agent = True if self.vts_agent_process else False
-        if has_adb_log:
-            self.stopAdbLogcat()
-        if has_vts_agent:
-            self.stopVtsAgent()
+
+        if restart_services:
+            has_adb_log = self.isAdbLogcatOn
+            has_vts_agent = True if self.vts_agent_process else False
+            if has_adb_log:
+                self.stopAdbLogcat()
+            if has_vts_agent:
+                self.stopVtsAgent()
+
         self.adb.reboot()
         self.waitForBootCompletion()
         self.rootAdb()
-        if has_adb_log:
-            self.startAdbLogcat()
-        if has_vts_agent:
-            self.startVtsAgent()
+
+        if restart_services:
+            if has_adb_log:
+                self.startAdbLogcat()
+            if has_vts_agent:
+                self.startVtsAgent()
 
     def startServices(self):
         """Starts long running services on the android device.