Merge "Add local-vendor-boot-image argument to set vendor boot image" into main
diff --git a/Android.bp b/Android.bp
index 18c3436..7dee67f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -67,6 +67,12 @@
     dist: {
         targets: ["droidcore"],
     },
+    version: {
+        py3: {
+            // TODO(b/174041232): Make acloud work with embedded_launcher
+            embedded_launcher: false,
+        },
+    },
 }
 
 python_test_host {
diff --git a/acloud_test.py b/acloud_test.py
index 1950de1..04a5981 100644
--- a/acloud_test.py
+++ b/acloud_test.py
@@ -15,9 +15,8 @@
 # limitations under the License.
 """Main entry point for all of acloud's unittest."""
 
-from importlib import import_module
 import logging
-import os
+import pkgutil
 import sys
 import unittest
 
@@ -37,35 +36,7 @@
 logger.addHandler(logging.FileHandler("/dev/null"))
 
 
-def GetTestModules():
-    """Return list of testable modules.
-
-    We need to find all the test files (*_test.py) and get their relative
-    path (internal/lib/utils_test.py) and translate it to an import path and
-    strip the py ext (internal.lib.utils_test).
-
-    Returns:
-        List of strings (the testable module import path).
-    """
-    testable_modules = []
-    package = os.path.dirname(os.path.realpath(__file__))
-    base_path = os.path.dirname(package)
-
-    # Get list of all python files that end in _test.py (except for __file__).
-    for dirpath, _, files in os.walk(package):
-        for f in files:
-            if f.endswith("_test.py") and f != os.path.basename(__file__):
-                # Now transform it into a relative import path.
-                full_file_path = os.path.join(dirpath, f)
-                rel_file_path = os.path.relpath(full_file_path, base_path)
-                rel_file_path, _ = os.path.splitext(rel_file_path)
-                rel_file_path = rel_file_path.replace(os.sep, ".")
-                testable_modules.append(rel_file_path)
-
-    return testable_modules
-
-
-def main(_):
+def main():
     """Main unittest entry.
 
     Args:
@@ -74,9 +45,11 @@
     Returns:
         0 if success. None-zero if fails.
     """
-    test_modules = GetTestModules()
-    for mod in test_modules:
-        import_module(mod)
+    test_modules = [
+        mod.name
+        for mod in pkgutil.walk_packages()
+        if mod.name.startswith('acloud') and mod.name.endswith('_test')
+    ]
 
     loader = unittest.defaultTestLoader
     test_suite = loader.loadTestsFromNames(test_modules)
@@ -86,4 +59,4 @@
 
 
 if __name__ == '__main__':
-    main(sys.argv[1:])
+    main()
diff --git a/public/config.py b/public/config.py
index 29a5b91..aba1655 100755
--- a/public/config.py
+++ b/public/config.py
@@ -44,6 +44,7 @@
 """
 
 import logging
+import importlib.resources
 import os
 
 from google.protobuf import text_format
@@ -58,8 +59,6 @@
 
 logger = logging.getLogger(__name__)
 
-_CONFIG_DATA_PATH = os.path.join(
-    os.path.dirname(os.path.abspath(__file__)), "data")
 _DEFAULT_CONFIG_FILE = "acloud.config"
 _DEFAULT_HW_PROPERTY = "cpu:4,resolution:720x1280,dpi:320,memory:4g"
 
@@ -69,6 +68,10 @@
 _NUM_INSTANCES_ARG = "-num_instances"
 
 
+def _Resources():
+    return importlib.resources.files("acloud.public.data")
+
+
 def GetVersion():
     """Print the version of acloud.
 
@@ -78,11 +81,11 @@
     Returns:
         String of the acloud version.
     """
-    version_file_path = os.path.join(_CONFIG_DATA_PATH, _VERSION_FILE)
-    if os.path.exists(version_file_path):
-        with open(version_file_path) as version_file:
+    try:
+        with _Resources().joinpath(_VERSION_FILE).open("r") as version_file:
             return version_file.read()
-    return _UNKNOWN
+    except FileNotFoundError:
+        return _UNKNOWN
 
 
 def GetDefaultConfigFile():
@@ -347,20 +350,13 @@
 class AcloudConfigManager():
     """A class that loads configurations."""
 
-    _DEFAULT_INTERNAL_CONFIG_PATH = os.path.join(_CONFIG_DATA_PATH,
-                                                 "default.config")
-
-    def __init__(self,
-                 user_config_path,
-                 internal_config_path=_DEFAULT_INTERNAL_CONFIG_PATH):
+    def __init__(self, user_config_path):
         """Initialize with user specified paths to configs.
 
         Args:
             user_config_path: path to the user config.
-            internal_config_path: path to the internal conifg.
         """
         self.user_config_path = user_config_path
-        self._internal_config_path = internal_config_path
 
     def Load(self):
         """Load the configurations.
@@ -382,9 +378,9 @@
         internal_cfg = None
         usr_cfg = None
         try:
-            with open(self._internal_config_path) as config_file:
+            with _Resources().joinpath("default.config").open('r') as cfg_file:
                 internal_cfg = self.LoadConfigFromProtocolBuffer(
-                    config_file, internal_config_pb2.InternalConfig)
+                    cfg_file, internal_config_pb2.InternalConfig)
         except OSError as e:
             raise errors.ConfigError("Could not load config files: %s" % str(e))
         # Load user config file