Add --prefer-staged to composd_cmd test-compile
This change makes it eaiser to expend the composd_cmd CLI to various
debugging options, starting with using staged APEX.
Bug: 220341414
Test: Stage an APEX. Run test-compile with and without --prefer-staged
# See VS' debug log with corresponding APEX path
Change-Id: I155681bc74f716e75ababb439e6bf48f43e0ce67
diff --git a/compos/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl b/compos/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl
index 8156265..dde75e1 100644
--- a/compos/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl
+++ b/compos/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl
@@ -19,6 +19,13 @@
import android.system.composd.ICompilationTaskCallback;
interface IIsolatedCompilationService {
+ enum ApexSource {
+ /** Only use the activated APEXes */
+ NoStaged,
+ /** Prefer any staged APEXes, otherwise use the activated ones */
+ PreferStaged,
+ }
+
/**
* Compile BCP extensions and system server, using any staged APEXes that are present in
* preference to active APEXes, writing the results to the pending artifacts directory to be
@@ -41,5 +48,5 @@
* callback, unless the returned ICompilationTask is cancelled. The caller should maintain
* a reference to the ICompilationTask until compilation completes or is cancelled.
*/
- ICompilationTask startTestCompile(ICompilationTaskCallback callback);
+ ICompilationTask startTestCompile(ApexSource apexSource, ICompilationTaskCallback callback);
}
diff --git a/compos/composd/src/instance_manager.rs b/compos/composd/src/instance_manager.rs
index 848fc8c..f1289e8 100644
--- a/compos/composd/src/instance_manager.rs
+++ b/compos/composd/src/instance_manager.rs
@@ -48,9 +48,12 @@
self.start_instance(CURRENT_INSTANCE_DIR, vm_parameters)
}
- pub fn start_test_instance(&self) -> Result<Arc<CompOsInstance>> {
+ pub fn start_test_instance(&self, prefer_staged: bool) -> Result<Arc<CompOsInstance>> {
let mut vm_parameters = new_vm_parameters()?;
vm_parameters.debug_mode = true;
+ if prefer_staged {
+ vm_parameters.config_path = Some(PREFER_STAGED_VM_CONFIG_PATH.to_owned());
+ }
self.start_instance(TEST_INSTANCE_DIR, vm_parameters)
}
diff --git a/compos/composd/src/service.rs b/compos/composd/src/service.rs
index f4798d7..a9b8202 100644
--- a/compos/composd/src/service.rs
+++ b/compos/composd/src/service.rs
@@ -22,7 +22,9 @@
use android_system_composd::aidl::android::system::composd::{
ICompilationTask::{BnCompilationTask, ICompilationTask},
ICompilationTaskCallback::ICompilationTaskCallback,
- IIsolatedCompilationService::{BnIsolatedCompilationService, IIsolatedCompilationService},
+ IIsolatedCompilationService::{
+ ApexSource::ApexSource, BnIsolatedCompilationService, IIsolatedCompilationService,
+ },
};
use android_system_composd::binder::{
self, BinderFeatures, ExceptionCode, Interface, Status, Strong, ThreadState,
@@ -58,10 +60,16 @@
fn startTestCompile(
&self,
+ apex_source: ApexSource,
callback: &Strong<dyn ICompilationTaskCallback>,
) -> binder::Result<Strong<dyn ICompilationTask>> {
check_permissions()?;
- to_binder_result(self.do_start_test_compile(callback))
+ let prefer_staged = match apex_source {
+ ApexSource::NoStaged => false,
+ ApexSource::PreferStaged => true,
+ _ => unreachable!("Invalid ApexSource {:?}", apex_source),
+ };
+ to_binder_result(self.do_start_test_compile(prefer_staged, callback))
}
}
@@ -85,9 +93,11 @@
fn do_start_test_compile(
&self,
+ prefer_staged: bool,
callback: &Strong<dyn ICompilationTaskCallback>,
) -> Result<Strong<dyn ICompilationTask>> {
- let comp_os = self.instance_manager.start_test_instance().context("Starting CompOS")?;
+ let comp_os =
+ self.instance_manager.start_test_instance(prefer_staged).context("Starting CompOS")?;
let target_dir_name = TEST_ARTIFACTS_SUBDIR.to_owned();
let task = OdrefreshTask::start(