use lazy android device registration

Bug: 79166173
Test: run vts-selftest
Change-Id: Ieb32f4897e7c92668d7123bb10f5fdf20a687563
Merged-In: Ieb32f4897e7c92668d7123bb10f5fdf20a687563
(cherry picked from commit cff463b1e7de86dc8e63e350dc3138f5fe9a1aef)
diff --git a/audio_loopback_test/AudioLoopbackTest.py b/audio_loopback_test/AudioLoopbackTest.py
index 10c1b51..358a774 100644
--- a/audio_loopback_test/AudioLoopbackTest.py
+++ b/audio_loopback_test/AudioLoopbackTest.py
@@ -41,8 +41,7 @@
     ITERATION = 100
 
     def setUpClass(self):
-        self.dut = self.registerController(android_device)[0]
-        self.dut.shell.InvokeTerminal("one")
+        self.dut = self.android_devices[0]
         self.dut.adb.shell("mkdir -p %s" % self.FULL_DATA_DIR_PATH)
         # install Loopback.apk
         self.dut.adb.shell("pm install -r -g /data/local/tmp/Loopback.apk")
@@ -96,23 +95,23 @@
         latencies = []
         confidences = []
         for i in range(0, self.ITERATION):
-            self.dut.shell.one.Execute(
+            self.dut.shell.Execute(
                 ["rm -f %s/*" % self.FULL_DATA_DIR_PATH])
-            self.dut.shell.one.Execute([
+            self.dut.shell.Execute([
                 "am start -n org.drrickorang.loopback/.LoopbackActivity "
                 "--es FileName %s/%s --ei AudioLevel 11 --ei TestType 222;" %
                 (self.TEST_DATA_DIR, self.TEST_FILE_PREFIX)
             ])
             # wait until the test finished.
-            results = self.dut.shell.one.Execute(
+            results = self.dut.shell.Execute(
                 ["ls %s" % self.TEST_FILE_NAME])
             while results[const.EXIT_CODE][0]:
                 logging.info("Test is running...")
                 sleep(1)
-                results = self.dut.shell.one.Execute(
+                results = self.dut.shell.Execute(
                     ["ls %s" % self.TEST_FILE_NAME])
 
-            results = self.dut.shell.one.Execute(
+            results = self.dut.shell.Execute(
                 ["cat %s" % self.TEST_FILE_NAME])
             asserts.assertFalse(results[const.EXIT_CODE][0],
                                 "Fail to get the test output")
diff --git a/binder_benchmark/BinderPerformanceTest.py b/binder_benchmark/BinderPerformanceTest.py
index 8003512..638aa16 100644
--- a/binder_benchmark/BinderPerformanceTest.py
+++ b/binder_benchmark/BinderPerformanceTest.py
@@ -72,10 +72,9 @@
     }
 
     def setUpClass(self):
-        self.dut = self.registerController(android_device)[0]
-        self.dut.shell.InvokeTerminal("one")
-        self.dut.shell.one.Execute("stop")
-        self.dut.shell.one.Execute("setprop sys.boot_completed 0")
+        self.dut = self.android_devices[0]
+        self.dut.shell.Execute("stop")
+        self.dut.shell.Execute("setprop sys.boot_completed 0")
         self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(self.dut)
         self._cpu_freq.DisableCpuScaling()
 
@@ -87,7 +86,7 @@
 
     def tearDownClass(self):
         self._cpu_freq.EnableCpuScaling()
-        self.dut.shell.one.Execute("start")
+        self.dut.shell.Execute("start")
         self.dut.waitForBootCompletion()
 
     def testRunBenchmark32Bit(self):
@@ -109,7 +108,7 @@
         logging.info("Start to run the benchmark (%s bit mode)", bits)
         binary = "/data/local/tmp/%s/libbinder_benchmark%s" % (bits, bits)
 
-        results = self.dut.shell.one.Execute([
+        results = self.dut.shell.Execute([
             "chmod 755 %s" % binary, "LD_LIBRARY_PATH=/data/local/tmp/%s/hw:"
             "/data/local/tmp/%s:$LD_LIBRARY_PATH "
             "%s --benchmark_format=json" % (bits, bits, binary)
diff --git a/binder_throughput_test/BinderThroughputBenchmark.py b/binder_throughput_test/BinderThroughputBenchmark.py
index 8402613..3afee54 100644
--- a/binder_throughput_test/BinderThroughputBenchmark.py
+++ b/binder_throughput_test/BinderThroughputBenchmark.py
@@ -39,8 +39,7 @@
     """A test case for the binder throughput benchmarking."""
 
     def setUpClass(self):
-        self.dut = self.registerController(android_device)[0]
-        self.dut.shell.InvokeTerminal("one")
+        self.dut = self.android_devices[0]
         self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(self.dut)
         self._cpu_freq.DisableCpuScaling()
 
@@ -150,7 +149,7 @@
         logging.info("Start to run the benchmark (%s bit mode)", bits)
         binary = "/data/local/tmp/%s/binderThroughputTest%s" % (bits, bits)
 
-        results = self.dut.shell.one.Execute(
+        results = self.dut.shell.Execute(
             ["chmod 755 %s" % binary,
              "LD_LIBRARY_PATH=/data/local/tmp/%s/hw:"
              "/data/local/tmp/%s:"
diff --git a/fmq_benchmark/FmqPerformanceTest.py b/fmq_benchmark/FmqPerformanceTest.py
index d8032f1..9c86942 100644
--- a/fmq_benchmark/FmqPerformanceTest.py
+++ b/fmq_benchmark/FmqPerformanceTest.py
@@ -49,8 +49,7 @@
     }
 
     def setUpClass(self):
-        self.dut = self.registerController(android_device)[0]
-        self.dut.shell.InvokeTerminal("one")
+        self.dut = self.android_devices[0]
         self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(
             self.dut)
         self._cpu_freq.DisableCpuScaling()
@@ -82,7 +81,7 @@
         # Start the benchmark service.
         logging.info("Start the benchmark service(%s bit mode)", bits)
         binary = "/data/local/tmp/%s/mq_benchmark_service%s" % (bits, bits)
-        results = self.dut.shell.one.Execute([
+        results = self.dut.shell.Execute([
             "chmod 755 %s" % binary,
             "VTS_ROOT_PATH=/data/local/tmp TREBLE_TESTING_OVERRIDE=true " \
             "LD_LIBRARY_PATH=/data/local/tmp/%s:"
@@ -97,14 +96,14 @@
         logging.info("Start to run the benchmark (%s bit mode)", bits)
         binary = "/data/local/tmp/%s/mq_benchmark_client%s" % (bits, bits)
 
-        results = self.dut.shell.one.Execute([
+        results = self.dut.shell.Execute([
             "chmod 755 %s" % binary,
             "TREBLE_TESTING_OVERRIDE=true LD_LIBRARY_PATH=/data/local/tmp/%s:"
             "$LD_LIBRARY_PATH %s" % (bits, binary)
         ])
 
         # Stop the benchmark service.
-        self.dut.shell.one.Execute("kill -9 `pidof mq_benchmark_service%s`" %
+        self.dut.shell.Execute("kill -9 `pidof mq_benchmark_service%s`" %
                                    bits)
 
         # Parses the result.
diff --git a/hwbinder_benchmark/HwBinderPerformanceTest.py b/hwbinder_benchmark/HwBinderPerformanceTest.py
index 4fc0842..3fa5f9f 100644
--- a/hwbinder_benchmark/HwBinderPerformanceTest.py
+++ b/hwbinder_benchmark/HwBinderPerformanceTest.py
@@ -74,10 +74,9 @@
     def setUpClass(self):
         required_params = ["hidl_hal_mode"]
         self.getUserParams(required_params)
-        self.dut = self.registerController(android_device)[0]
-        self.dut.shell.InvokeTerminal("one")
-        self.dut.shell.one.Execute("stop")
-        self.dut.shell.one.Execute("setprop sys.boot_completed 0")
+        self.dut = self.android_devices[0]
+        self.dut.shell.Execute("stop")
+        self.dut.shell.Execute("setprop sys.boot_completed 0")
         self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(self.dut)
         self._cpu_freq.DisableCpuScaling()
 
@@ -89,7 +88,7 @@
 
     def tearDownClass(self):
         self._cpu_freq.EnableCpuScaling()
-        self.dut.shell.one.Execute("start")
+        self.dut.shell.Execute("start")
         self.dut.waitForBootCompletion()
 
     def testRunBenchmark32Bit(self):
@@ -113,7 +112,7 @@
             self.hidl_hal_mode, bits)
         binary = "/data/local/tmp/%s/libhwbinder_benchmark%s" % (bits, bits)
 
-        results = self.dut.shell.one.Execute([
+        results = self.dut.shell.Execute([
             "chmod 755 %s" % binary,
             "VTS_ROOT_PATH=/data/local/tmp " \
             "LD_LIBRARY_PATH=/system/lib%s:/data/local/tmp/%s/hw:"
diff --git a/hwbinder_latency_test/HwBinderLatencyTest.py b/hwbinder_latency_test/HwBinderLatencyTest.py
index 0cb2f0b..953d2cd 100644
--- a/hwbinder_latency_test/HwBinderLatencyTest.py
+++ b/hwbinder_latency_test/HwBinderLatencyTest.py
@@ -63,8 +63,7 @@
     def setUpClass(self):
         required_params = ["hidl_hal_mode"]
         self.getUserParams(required_params)
-        self.dut = self.registerController(android_device)[0]
-        self.dut.shell.InvokeTerminal("one")
+        self.dut = self.android_devices[0]
         self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(self.dut)
         self._cpu_freq.DisableCpuScaling()
 
@@ -102,7 +101,7 @@
         binary = "/data/local/tmp/%s/libhwbinder_latency%s" % (bits, bits)
         min_cpu, max_cpu = self._cpu_freq.GetMinAndMaxCpuNo()
         iterations = 1000 // (max_cpu - min_cpu)
-        results = self.dut.shell.one.Execute([
+        results = self.dut.shell.Execute([
             "chmod 755 %s" % binary,
             "VTS_ROOT_PATH=/data/local/tmp " \
             "LD_LIBRARY_PATH=/system/lib%s:/data/local/tmp/%s/hw:"
diff --git a/hwbinder_throughput_test/HwBinderThroughputBenchmark.py b/hwbinder_throughput_test/HwBinderThroughputBenchmark.py
index 588c37f..5fd950e 100644
--- a/hwbinder_throughput_test/HwBinderThroughputBenchmark.py
+++ b/hwbinder_throughput_test/HwBinderThroughputBenchmark.py
@@ -41,8 +41,7 @@
     def setUpClass(self):
         required_params = ["hidl_hal_mode"]
         self.getUserParams(required_params)
-        self.dut = self.registerController(android_device)[0]
-        self.dut.shell.InvokeTerminal("one")
+        self.dut = self.android_devices[0]
         self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(self.dut)
         self._cpu_freq.DisableCpuScaling()
 
@@ -153,7 +152,7 @@
                      self.hidl_hal_mode, bits)
         binary = "/data/local/tmp/%s/hwbinderThroughputTest%s" % (bits, bits)
 
-        results = self.dut.shell.one.Execute(
+        results = self.dut.shell.Execute(
             ["chmod 755 %s" % binary,
              "VTS_ROOT_PATH=/data/local/tmp " \
              "LD_LIBRARY_PATH=/system/lib%s:/data/local/tmp/%s/hw:"