summaryrefslogtreecommitdiff
path: root/libs/androidfw/AssetManager2.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2020-11-13 18:06:15 -0800
committerRyan Mitchell <rtmitchell@google.com>2020-12-08 16:58:42 +0000
commite7ab62723ac8bc1c95405353e7f625956b1dfbe3 (patch)
tree40082bf854ba078e9a94ec486a5ba82bb9a77d94 /libs/androidfw/AssetManager2.cpp
parent80094e39f90801c44cd80ab0f98df505828ea1f3 (diff)
Set resource id correctly when resolve fails
If for some reason the resource id cannot be resolved to a value (there is no configuration that matches the AssetManager configuration or some error occurs), set the resource id of the SelectedValue to the resource id that could not be resolved. This was the behavior before the AssetManager IncFs hardening refactor. Bug: 173203252 Test: atest com.google.android.config.pts.PreinstalledAppsTestCase Test: Chrome icon appears on launcher Change-Id: Iad1760c0e246da1a4bf64d1c2ec60bb08da32d06 Merged-In: Iad1760c0e246da1a4bf64d1c2ec60bb08da32d06
Diffstat (limited to 'libs/androidfw/AssetManager2.cpp')
-rw-r--r--libs/androidfw/AssetManager2.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp
index 3e54dc67db76..8bab73cd15f0 100644
--- a/libs/androidfw/AssetManager2.cpp
+++ b/libs/androidfw/AssetManager2.cpp
@@ -975,19 +975,23 @@ base::expected<std::monostate, NullOrIOError> AssetManager2::ResolveReference(
for (uint32_t i = 0U;; i++) {
auto result = GetResource(resolve_resid, true /*may_be_bag*/);
if (!result.has_value()) {
+ value.resid = resolve_resid;
return base::unexpected(result.error());
}
+ // If resource resolution fails, the value should be set to the last reference that was able to
+ // be resolved successfully.
+ value = *result;
+ value.flags |= combined_flags;
+
if (result->type != Res_value::TYPE_REFERENCE ||
result->data == Res_value::DATA_NULL_UNDEFINED ||
result->data == resolve_resid || i == kMaxIterations) {
// This reference can't be resolved, so exit now and let the caller deal with it.
- value = *result;
- value.flags |= combined_flags;
return {};
}
- combined_flags |= result->flags;
+ combined_flags = result->flags;
resolve_resid = result->data;
}
}