Refactor test scripts.

Test: atest -v CtsSeekerDiscoverProviderTest
BUG: 214015364
Change-Id: I13d127cfdaa3ca7436a815b312ef4abc00b0406f
diff --git a/nearby/tests/multidevices/host/seeker_discover_provider_test.py b/nearby/tests/multidevices/host/seeker_discover_provider_test.py
index 03f3661..11304cc 100644
--- a/nearby/tests/multidevices/host/seeker_discover_provider_test.py
+++ b/nearby/tests/multidevices/host/seeker_discover_provider_test.py
@@ -16,23 +16,26 @@
 
 import logging
 import sys
+from typing import List
 
 from mobly import base_test
 from mobly import test_runner
 from mobly.controllers import android_device
 
+from test_helper import constants
 from test_helper import fast_pair_provider_simulator
 from test_helper import fast_pair_seeker
 
-# Default model ID to simulate on provider side.
-DEFAULT_MODEL_ID = '00000C'
-# Default public key to simulate as registered headsets.
-DEFAULT_ANTI_SPOOFING_KEY = 'Cbj9eCJrTdDgSYxLkqtfADQi86vIaMvxJsQ298sZYWE='
+# The model ID to simulate on provider side.
+PROVIDER_SIMULATOR_MODEL_ID = constants.DEFAULT_MODEL_ID
+# The public key to simulate as registered headsets.
+PROVIDER_SIMULATOR_ANTI_SPOOFING_KEY = constants.DEFAULT_ANTI_SPOOFING_KEY
+
 # Time in seconds for events waiting.
-SETUP_TIMEOUT_SEC = 5
-BECOME_DISCOVERABLE_TIMEOUT_SEC = 10
-START_ADVERTISING_TIMEOUT_SEC = 5
-SCAN_TIMEOUT_SEC = 30
+SETUP_TIMEOUT_SEC = constants.SETUP_TIMEOUT_SEC
+BECOME_DISCOVERABLE_TIMEOUT_SEC = constants.BECOME_DISCOVERABLE_TIMEOUT_SEC
+START_ADVERTISING_TIMEOUT_SEC = constants.START_ADVERTISING_TIMEOUT_SEC
+SCAN_TIMEOUT_SEC = constants.SCAN_TIMEOUT_SEC
 
 # Abbreviations for common use type.
 FastPairProviderSimulator = fast_pair_provider_simulator.FastPairProviderSimulator
@@ -42,17 +45,16 @@
 class SeekerDiscoverProviderTest(base_test.BaseTestClass):
     """Fast Pair seeker discover provider test."""
 
+    _duts: List[android_device.AndroidDevice]
     _provider: FastPairProviderSimulator
     _seeker: FastPairSeeker
 
     def setup_class(self) -> None:
         super().setup_class()
-        self.duts = self.register_controller(android_device)
+        self._duts = self.register_controller(android_device)
 
         # Assume the 1st phone is provider, the 2nd is seeker.
-        provider_ad, seeker_ad = self.duts
-        provider_ad.debug_tag = 'FastPairProviderSimulator'
-        seeker_ad.debug_tag = 'MainlineFastPairSeeker'
+        provider_ad, seeker_ad = self._duts
         self._provider = FastPairProviderSimulator(provider_ad)
         self._seeker = FastPairSeeker(seeker_ad)
         self._provider.load_snippet()
@@ -61,7 +63,8 @@
     def setup_test(self) -> None:
         super().setup_test()
         self._provider.setup_provider_simulator(SETUP_TIMEOUT_SEC)
-        self._provider.start_model_id_advertising(DEFAULT_MODEL_ID, DEFAULT_ANTI_SPOOFING_KEY)
+        self._provider.start_model_id_advertising(
+            PROVIDER_SIMULATOR_MODEL_ID, PROVIDER_SIMULATOR_ANTI_SPOOFING_KEY)
         self._provider.wait_for_discoverable_mode(BECOME_DISCOVERABLE_TIMEOUT_SEC)
         self._provider.wait_for_advertising_start(START_ADVERTISING_TIMEOUT_SEC)
         self._seeker.start_scan()
@@ -71,14 +74,14 @@
         self._seeker.stop_scan()
         self._provider.teardown_provider_simulator()
         # Create per-test excepts of logcat.
-        for dut in self.duts:
+        for dut in self._duts:
             dut.services.create_output_excerpts_all(self.current_test_info)
 
     def test_seeker_start_scanning_find_provider(self) -> None:
         provider_ble_mac_address = self._provider.get_ble_mac_address()
         self._seeker.wait_and_assert_provider_found(
             timeout_seconds=SCAN_TIMEOUT_SEC,
-            expected_model_id=DEFAULT_MODEL_ID,
+            expected_model_id=PROVIDER_SIMULATOR_MODEL_ID,
             expected_ble_mac_address=provider_ble_mac_address)
 
 
@@ -87,5 +90,5 @@
     index = sys.argv.index('--')
     sys.argv = sys.argv[:1] + sys.argv[index + 1:]
 
-    logging.basicConfig(filename="/tmp/seeker_scan_provider_test_log.txt", level=logging.INFO)
+    logging.basicConfig(filename="/tmp/seeker_discover_provider_test_log.txt", level=logging.INFO)
     test_runner.main()
diff --git a/nearby/tests/multidevices/host/test_helper/constants.py b/nearby/tests/multidevices/host/test_helper/constants.py
new file mode 100644
index 0000000..6b5185f
--- /dev/null
+++ b/nearby/tests/multidevices/host/test_helper/constants.py
@@ -0,0 +1,25 @@
+#  Copyright (C) 2022 The Android Open Source Project
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+# Default model ID to simulate on provider side.
+DEFAULT_MODEL_ID = '00000c'
+
+# Default public key to simulate as registered headsets.
+DEFAULT_ANTI_SPOOFING_KEY = 'Cbj9eCJrTdDgSYxLkqtfADQi86vIaMvxJsQ298sZYWE='
+
+# Time in seconds for events waiting.
+SETUP_TIMEOUT_SEC = 5
+BECOME_DISCOVERABLE_TIMEOUT_SEC = 10
+START_ADVERTISING_TIMEOUT_SEC = 5
+SCAN_TIMEOUT_SEC = 30
diff --git a/nearby/tests/multidevices/host/test_helper/fast_pair_provider_simulator.py b/nearby/tests/multidevices/host/test_helper/fast_pair_provider_simulator.py
index 8563e8e..8a98112 100644
--- a/nearby/tests/multidevices/host/test_helper/fast_pair_provider_simulator.py
+++ b/nearby/tests/multidevices/host/test_helper/fast_pair_provider_simulator.py
@@ -43,6 +43,7 @@
 
     def __init__(self, ad: AndroidDevice) -> None:
         self._ad = ad
+        self._ad.debug_tag = 'FastPairProviderSimulator'
         self._provider_status_callback = None
 
     def load_snippet(self) -> None:
@@ -92,6 +93,9 @@
             0x00000C).
           anti_spoofing_key: A public key for registered headsets.
         """
+        self._ad.log.info(
+            'Provider simulator starts advertising as model id "%s" with anti-spoofing key "%s".',
+            model_id, anti_spoofing_key)
         self._provider_status_callback = (
             self._ad.fp.startModelIdAdvertising(model_id, anti_spoofing_key))
 
diff --git a/nearby/tests/multidevices/host/test_helper/fast_pair_seeker.py b/nearby/tests/multidevices/host/test_helper/fast_pair_seeker.py
index 85c37df..9bb2689 100644
--- a/nearby/tests/multidevices/host/test_helper/fast_pair_seeker.py
+++ b/nearby/tests/multidevices/host/test_helper/fast_pair_seeker.py
@@ -37,6 +37,7 @@
 
     def __init__(self, ad: AndroidDevice) -> None:
         self._ad = ad
+        self._ad.debug_tag = 'MainlineFastPairSeeker'
         self._scan_result_callback = None
 
     def load_snippet(self) -> None: