Start to add a function to compile staged APEXes
Add a new method to IIsolatedCompilationService which will eventually
run compilation over staged APEXes. Currently it doesn't, but it is
slightly more realistic than the test compile (which I'm leaving in
place since it's useful for testing) - we use the pending instance of
compos (so odsign will attempt to verify the keys) and we run
odrefresh --compile instead of --force-compile. For now the artifacts
are still written to the test-artifacts directory so odsign doesn't
see them.
Bug: 205296305
Test: composd_cmd staged-apex-compile
Change-Id: If4d449878e38a97aa0f1f1dbb71c9df9b86ca4d5
diff --git a/compos/composd/src/service.rs b/compos/composd/src/service.rs
index 3738e18..aa96ddf 100644
--- a/compos/composd/src/service.rs
+++ b/compos/composd/src/service.rs
@@ -53,21 +53,41 @@
impl Interface for IsolatedCompilationService {}
impl IIsolatedCompilationService for IsolatedCompilationService {
+ fn startStagedApexCompile(
+ &self,
+ callback: &Strong<dyn ICompilationTaskCallback>,
+ ) -> binder::Result<Strong<dyn ICompilationTask>> {
+ check_permissions()?;
+ to_binder_result(self.do_start_staged_apex_compile(callback))
+ }
+
fn startTestCompile(
&self,
callback: &Strong<dyn ICompilationTaskCallback>,
) -> binder::Result<Strong<dyn ICompilationTask>> {
- check_test_permissions()?;
+ check_permissions()?;
to_binder_result(self.do_start_test_compile(callback))
}
fn startTestOdrefresh(&self) -> binder::Result<i8> {
- check_test_permissions()?;
+ check_permissions()?;
to_binder_result(self.do_odrefresh_for_test())
}
}
impl IsolatedCompilationService {
+ fn do_start_staged_apex_compile(
+ &self,
+ callback: &Strong<dyn ICompilationTaskCallback>,
+ ) -> Result<Strong<dyn ICompilationTask>> {
+ // TODO: Try to start the current instance with staged APEXes to see if it works?
+ let comp_os = self.instance_manager.start_pending_instance().context("Starting CompOS")?;
+
+ let task = CompilationTask::start_staged_apex_compile(comp_os, callback)?;
+
+ Ok(BnCompilationTask::new_binder(task, BinderFeatures::default()))
+ }
+
fn do_start_test_compile(
&self,
callback: &Strong<dyn ICompilationTaskCallback>,
@@ -114,7 +134,7 @@
}
}
-fn check_test_permissions() -> binder::Result<()> {
+fn check_permissions() -> binder::Result<()> {
let calling_uid = ThreadState::get_calling_uid();
// This should only be called by system server, or root while testing
if calling_uid != AID_SYSTEM && calling_uid != AID_ROOT {
@@ -135,5 +155,5 @@
// make the library happy. The value does not appear to matter elsewhere in the library.
.read(true)
.open(path)
- .with_context(|| format!("Failed to open {} directory as path fd", path.display()))
+ .with_context(|| format!("Failed to open {:?} directory as path fd", path))
}