Better logging on failure
Log Anyhow errors with Debug not Display; that way we see the full
context rather than just the most recent failure.
Add context to calls to IPackageManagerNative. That's slightly ad hoc,
but useful, and calls to AIDL interfaces don't otherwise include much
detail.
Bug: 238312664
Test: Induce failure, see better logs
Change-Id: I3f119f937f2d07296d92d882c9fbabfbf17b0186
diff --git a/virtualizationservice/src/payload.rs b/virtualizationservice/src/payload.rs
index 8378df3..c0153b9 100644
--- a/virtualizationservice/src/payload.rs
+++ b/virtualizationservice/src/payload.rs
@@ -134,10 +134,13 @@
let pm =
wait_for_interface::<dyn IPackageManagerNative>(PACKAGE_MANAGER_NATIVE_SERVICE)
.context("Failed to get service when prefer_staged is set.")?;
- let staged = pm.getStagedApexModuleNames()?;
+ let staged =
+ pm.getStagedApexModuleNames().context("getStagedApexModuleNames failed")?;
for apex_info in list.list.iter_mut() {
if staged.contains(&apex_info.name) {
- if let Some(staged_apex_info) = pm.getStagedApexInfo(&apex_info.name)? {
+ if let Some(staged_apex_info) =
+ pm.getStagedApexInfo(&apex_info.name).context("getStagedApexInfo failed")?
+ {
apex_info.path = PathBuf::from(staged_apex_info.diskImagePath);
apex_info.has_classpath_jar = staged_apex_info.hasClassPathJars;
let metadata = metadata(&apex_info.path)?;