compos: mount BuildManifestSystemExt.apk if exists
To specify the extra APK, we have to add two new VM config JSONs because
the APK may not exist, and there is no way to specify the config
dynamically.
Change VmParameters in order to derive the config path from two
variables at a more consistent place. As a result, there's no more
"default" config.
Bug: 246000387
Test: 1. manually add a jar from system_ext to SYSTEMSERVERCLASSPATH
2. boot the VM, saw 2 directories in /mnt/extra-apk/
(and with more local WIP changes, ComposHostTestCases passed)
Change-Id: I8aac49e0b347560fb65d8a8330e4333a29d90433
diff --git a/compos/composd/src/odrefresh_task.rs b/compos/composd/src/odrefresh_task.rs
index 5c926b1..a07a7f9 100644
--- a/compos/composd/src/odrefresh_task.rs
+++ b/compos/composd/src/odrefresh_task.rs
@@ -161,9 +161,18 @@
let output_dir_raw_fd = output_dir_fd.as_raw_fd();
let staging_dir_raw_fd = staging_dir_fd.as_raw_fd();
+ // Get the /system_ext FD differently because it may not exist.
+ // TODO(245761690): pass system_ext_dir_raw_fd to service.odrefresh(...)
+ let (_system_ext_dir_raw_fd, ro_dir_fds) =
+ if let Ok(system_ext_dir_fd) = open_dir(Path::new("/system_ext")) {
+ (system_ext_dir_fd.as_raw_fd(), vec![system_dir_fd, system_ext_dir_fd])
+ } else {
+ (-1, vec![system_dir_fd])
+ };
+
// Spawn a fd_server to serve the FDs.
let fd_server_config = FdServerConfig {
- ro_dir_fds: vec![system_dir_fd],
+ ro_dir_fds,
rw_dir_fds: vec![staging_dir_fd, output_dir_fd],
..Default::default()
};