summaryrefslogtreecommitdiff
path: root/libs/androidfw/AssetManager2.cpp
diff options
context:
space:
mode:
author Ryan Mitchell <rtmitchell@google.com> 2020-11-13 18:06:15 -0800
committer Ryan Mitchell <rtmitchell@google.com> 2020-11-17 23:02:00 +0000
commit43d2f21d628504de69a5cb75e0f837169c029899 (patch)
treebeac6fe514645dbfe8a20f019071c24bb46329bc /libs/androidfw/AssetManager2.cpp
parentdb21f09a8e02bcfd3fefea68084667688268f1fa (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
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;
}
}