Update ClassLoaderContext to support artd use cases.

- Change `FlattenDexPaths` to returning `std::vector<std::string>`
  so that artd can use it in a more flexible way.

Bug: 229268202
Test: Presubmit
Change-Id: Iab0d018d4f52eea6b60f7f2d88cc56f23db6bd5c
Merged-In: Iab0d018d4f52eea6b60f7f2d88cc56f23db6bd5c
(cherry picked from commit 55e733f0f582f3edafa2b3bfd1168ade01813a54)
diff --git a/dexoptanalyzer/dexoptanalyzer.cc b/dexoptanalyzer/dexoptanalyzer.cc
index 7d0aff0..6137766 100644
--- a/dexoptanalyzer/dexoptanalyzer.cc
+++ b/dexoptanalyzer/dexoptanalyzer.cc
@@ -451,7 +451,7 @@
       Usage("Invalid --class-loader-context '%s'", context_str_.c_str());
     }
 
-    std::cout << context->FlattenDexPaths() << std::flush;
+    std::cout << android::base::Join(context->FlattenDexPaths(), ':') << std::flush;
     return ReturnCode::kFlattenClassLoaderContextSuccess;
   }
 
diff --git a/runtime/class_loader_context.cc b/runtime/class_loader_context.cc
index 2419b7b..31c310e 100644
--- a/runtime/class_loader_context.cc
+++ b/runtime/class_loader_context.cc
@@ -950,12 +950,13 @@
   return result;
 }
 
-std::string ClassLoaderContext::FlattenDexPaths() const {
+std::vector<std::string> ClassLoaderContext::FlattenDexPaths() const {
+  std::vector<std::string> result;
+
   if (class_loader_chain_ == nullptr) {
-    return "";
+    return result;
   }
 
-  std::vector<std::string> result;
   std::vector<ClassLoaderInfo*> work_list;
   work_list.push_back(class_loader_chain_.get());
   while (!work_list.empty()) {
@@ -966,7 +967,7 @@
     }
     AddToWorkList(info, work_list);
   }
-  return FlattenClasspath(result);
+  return result;
 }
 
 const char* ClassLoaderContext::GetClassLoaderTypeName(ClassLoaderType type) {
diff --git a/runtime/class_loader_context.h b/runtime/class_loader_context.h
index eceea00..ccc5c73 100644
--- a/runtime/class_loader_context.h
+++ b/runtime/class_loader_context.h
@@ -155,9 +155,8 @@
   // Should only be called if OpenDexFiles() returned true.
   std::vector<const DexFile*> FlattenOpenedDexFiles() const;
 
-  // Return a colon-separated list of dex file locations from this class loader
-  // context after flattening.
-  std::string FlattenDexPaths() const;
+  // Return a list of dex file locations from this class loader context after flattening.
+  std::vector<std::string> FlattenDexPaths() const;
 
   // Verifies that the current context is identical to the context encoded as `context_spec`.
   // Identical means: