Set ApkAssets path for fabricated rros

Fabricated RROs do not provide assets but are stored on disk. Ensure
that the path to the frro is returned when querying for the ApkAssets
path (which is mostly for debug purposes).

Bug: 181338216
Test: enable frro, use cmd overlay lookup to see path in resolution
Change-Id: Ibf9b1bf0a995325affbf084c71b1e87c5682e734
diff --git a/libs/androidfw/ApkAssets.cpp b/libs/androidfw/ApkAssets.cpp
index 76366fc..26d8363 100755
--- a/libs/androidfw/ApkAssets.cpp
+++ b/libs/androidfw/ApkAssets.cpp
@@ -88,7 +88,7 @@
   if (IsFabricatedOverlay(overlay_path)) {
     // Fabricated overlays do not contain resource definitions. All of the overlay resource values
     // are defined inline in the idmap.
-    overlay_assets = EmptyAssetsProvider::Create();
+    overlay_assets = EmptyAssetsProvider::Create(overlay_path);
   } else {
     // The overlay should be an APK.
     overlay_assets = ZipAssetsProvider::Create(overlay_path);
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp
index 7e45f95..237effe 100644
--- a/libs/androidfw/AssetManager2.cpp
+++ b/libs/androidfw/AssetManager2.cpp
@@ -602,6 +602,11 @@
         result->entry = overlay_entry.GetInlineValue();
         result->dynamic_ref_table = id_map.overlay_res_maps_.GetOverlayDynamicRefTable();
         result->cookie = id_map.cookie;
+
+        if (UNLIKELY(logging_enabled)) {
+          last_resolution_.steps.push_back(
+              Resolution::Step{Resolution::Step::Type::OVERLAID_INLINE, String8(), result->cookie});
+        }
         continue;
       }
 
@@ -630,7 +635,6 @@
       if (UNLIKELY(logging_enabled)) {
         last_resolution_.steps.push_back(
             Resolution::Step{Resolution::Step::Type::OVERLAID, overlay_result->config.toString(),
-                             overlay_result->package_name,
                              overlay_result->cookie});
       }
     }
@@ -713,7 +717,6 @@
         if (UNLIKELY(logging_enabled)) {
           resolution_steps.push_back(Resolution::Step{Resolution::Step::Type::SKIPPED,
                                                       this_config.toString(),
-                                                      &loaded_package->GetPackageName(),
                                                       cookie});
         }
         continue;
@@ -731,7 +734,6 @@
         if (UNLIKELY(logging_enabled)) {
           resolution_steps.push_back(Resolution::Step{Resolution::Step::Type::NO_ENTRY,
                                                       this_config.toString(),
-                                                      &loaded_package->GetPackageName(),
                                                       cookie});
         }
         continue;
@@ -746,7 +748,6 @@
       if (UNLIKELY(logging_enabled)) {
         last_resolution_.steps.push_back(Resolution::Step{resolution_type,
                                                           this_config.toString(),
-                                                          &loaded_package->GetPackageName(),
                                                           cookie});
       }
 
@@ -829,18 +830,18 @@
   }
 
   std::stringstream log_stream;
-  log_stream << base::StringPrintf("Resolution for 0x%08x ", resid)
-            << resource_name_string
-            << "\n\tFor config -"
-            << configuration_.toString();
+  log_stream << base::StringPrintf("Resolution for 0x%08x %s\n"
+                                   "\tFor config - %s", resid, resource_name_string.c_str(),
+                                   configuration_.toString().c_str());
 
   for (const Resolution::Step& step : last_resolution_.steps) {
     const static std::unordered_map<Resolution::Step::Type, const char*> kStepStrings = {
-        {Resolution::Step::Type::INITIAL, "Found initial"},
-        {Resolution::Step::Type::BETTER_MATCH, "Found better"},
-        {Resolution::Step::Type::OVERLAID, "Overlaid"},
-        {Resolution::Step::Type::SKIPPED, "Skipped"},
-        {Resolution::Step::Type::NO_ENTRY, "No entry"}
+        {Resolution::Step::Type::INITIAL,         "Found initial"},
+        {Resolution::Step::Type::BETTER_MATCH,    "Found better"},
+        {Resolution::Step::Type::OVERLAID,        "Overlaid"},
+        {Resolution::Step::Type::OVERLAID_INLINE, "Overlaid inline"},
+        {Resolution::Step::Type::SKIPPED,         "Skipped"},
+        {Resolution::Step::Type::NO_ENTRY,        "No entry"}
     };
 
     const auto prefix = kStepStrings.find(step.type);
@@ -848,10 +849,9 @@
       continue;
     }
 
-    log_stream << "\n\t" << prefix->second << ": " << *step.package_name << " ("
-               << apk_assets_[step.cookie]->GetDebugName() << ")";
+    log_stream << "\n\t" << prefix->second << ": " << apk_assets_[step.cookie]->GetDebugName();
     if (!step.config_name.isEmpty()) {
-      log_stream << " -" << step.config_name;
+      log_stream << " - " << step.config_name;
     }
   }
 
diff --git a/libs/androidfw/AssetsProvider.cpp b/libs/androidfw/AssetsProvider.cpp
index 0aaf0b3..6c7a253 100644
--- a/libs/androidfw/AssetsProvider.cpp
+++ b/libs/androidfw/AssetsProvider.cpp
@@ -386,8 +386,15 @@
   return primary_->IsUpToDate() && secondary_->IsUpToDate();
 }
 
+EmptyAssetsProvider::EmptyAssetsProvider(std::optional<std::string>&& path) :
+    path_(std::move(path)) {}
+
 std::unique_ptr<AssetsProvider> EmptyAssetsProvider::Create() {
-  return std::make_unique<EmptyAssetsProvider>();
+  return std::unique_ptr<EmptyAssetsProvider>(new EmptyAssetsProvider({}));
+}
+
+std::unique_ptr<AssetsProvider> EmptyAssetsProvider::Create(const std::string& path) {
+  return std::unique_ptr<EmptyAssetsProvider>(new EmptyAssetsProvider(path));
 }
 
 std::unique_ptr<Asset> EmptyAssetsProvider::OpenInternal(const std::string& /* path */,
@@ -406,10 +413,16 @@
 }
 
 std::optional<std::string_view> EmptyAssetsProvider::GetPath() const {
+  if (path_.has_value()) {
+    return *path_;
+  }
   return {};
 }
 
 const std::string& EmptyAssetsProvider::GetDebugName() const {
+  if (path_.has_value()) {
+    return *path_;
+  }
   const static std::string kEmpty = kEmptyDebugString;
   return kEmpty;
 }
diff --git a/libs/androidfw/include/androidfw/AssetManager2.h b/libs/androidfw/include/androidfw/AssetManager2.h
index 10666ad..df3abf6 100644
--- a/libs/androidfw/include/androidfw/AssetManager2.h
+++ b/libs/androidfw/include/androidfw/AssetManager2.h
@@ -458,6 +458,7 @@
         INITIAL,
         BETTER_MATCH,
         OVERLAID,
+        OVERLAID_INLINE,
         SKIPPED,
         NO_ENTRY,
       };
@@ -468,10 +469,6 @@
       // Built name of configuration for this step.
       String8 config_name;
 
-      // Marks the package name of the better resource found in this step.
-      const std::string* package_name;
-
-      //
       ApkAssetsCookie cookie = kInvalidCookie;
     };
 
diff --git a/libs/androidfw/include/androidfw/AssetsProvider.h b/libs/androidfw/include/androidfw/AssetsProvider.h
index 63bbdcc..ec51c65 100644
--- a/libs/androidfw/include/androidfw/AssetsProvider.h
+++ b/libs/androidfw/include/androidfw/AssetsProvider.h
@@ -176,6 +176,7 @@
 // Does not provide any assets.
 struct EmptyAssetsProvider : public AssetsProvider {
   static std::unique_ptr<AssetsProvider> Create();
+  static std::unique_ptr<AssetsProvider> Create(const std::string& path);
 
   bool ForEachFile(const std::string& path,
                   const std::function<void(const StringPiece&, FileType)>& f) const override;
@@ -188,6 +189,10 @@
  protected:
   std::unique_ptr<Asset> OpenInternal(const std::string& path, Asset::AccessMode mode,
                                       bool* file_exists) const override;
+
+ private:
+  explicit EmptyAssetsProvider(std::optional<std::string>&& path);
+  std::optional<std::string> path_;
 };
 
 }  // namespace android
diff --git a/libs/androidfw/tests/AssetManager2_test.cpp b/libs/androidfw/tests/AssetManager2_test.cpp
index e1c0fab7..3c4ee4e 100644
--- a/libs/androidfw/tests/AssetManager2_test.cpp
+++ b/libs/androidfw/tests/AssetManager2_test.cpp
@@ -765,7 +765,8 @@
 
   auto result = assetmanager.GetLastResourceResolution();
   EXPECT_EQ("Resolution for 0x7f030000 com.android.basic:string/test1\n"
-            "\tFor config -de\n\tFound initial: com.android.basic (basic/basic.apk)", result);
+            "\tFor config - de\n"
+            "\tFound initial: basic/basic.apk", result);
 }
 
 TEST_F(AssetManager2Test, GetLastPathWithMultipleApkAssets) {
@@ -784,9 +785,9 @@
 
   auto result = assetmanager.GetLastResourceResolution();
   EXPECT_EQ("Resolution for 0x7f030000 com.android.basic:string/test1\n"
-            "\tFor config -de\n"
-            "\tFound initial: com.android.basic (basic/basic.apk)\n"
-            "\tFound better: com.android.basic (basic/basic_de_fr.apk) -de", result);
+            "\tFor config - de\n"
+            "\tFound initial: basic/basic.apk\n"
+            "\tFound better: basic/basic_de_fr.apk - de", result);
 }
 
 TEST_F(AssetManager2Test, GetLastPathAfterDisablingReturnsEmpty) {