Use --force-compile for tests

The test uses --force-compile outside the VM, so we also need to
inside the VM. But we want --compile for the normal case of
compilation, so we only produce exactly the required artifacts.

That means we have to pass whether we are testing or not from the host
to guest, so lots of plumbing is needed.

(Also figured out how to solve a problem with type deduction that the
me of a few months ago was baffled by.)

Bug: 211458160
Test: atest ComposTestCase
Change-Id: Ie7e36bc3fab40744e9f9ea5e5928126899d9060d
diff --git a/compos/composd/src/odrefresh_task.rs b/compos/composd/src/odrefresh_task.rs
index 330f0ab..47ff590 100644
--- a/compos/composd/src/odrefresh_task.rs
+++ b/compos/composd/src/odrefresh_task.rs
@@ -23,7 +23,9 @@
 };
 use android_system_composd::binder::{Interface, Result as BinderResult, Strong};
 use anyhow::{Context, Result};
-use compos_aidl_interface::aidl::com::android::compos::ICompOsService::ICompOsService;
+use compos_aidl_interface::aidl::com::android::compos::ICompOsService::{
+    CompilationMode::CompilationMode, ICompOsService,
+};
 use compos_common::odrefresh::ExitCode;
 use log::{error, warn};
 use rustutils::system_properties;
@@ -68,6 +70,7 @@
 
     pub fn start(
         comp_os: Arc<CompOsInstance>,
+        compilation_mode: CompilationMode,
         target_dir_name: String,
         callback: &Strong<dyn ICompilationTaskCallback>,
     ) -> Result<OdrefreshTask> {
@@ -75,14 +78,19 @@
         let task = RunningTask { comp_os, callback: callback.clone() };
         let task = OdrefreshTask { running_task: Arc::new(Mutex::new(Some(task))) };
 
-        task.clone().start_thread(service, target_dir_name);
+        task.clone().start_thread(service, compilation_mode, target_dir_name);
 
         Ok(task)
     }
 
-    fn start_thread(self, service: Strong<dyn ICompOsService>, target_dir_name: String) {
+    fn start_thread(
+        self,
+        service: Strong<dyn ICompOsService>,
+        compilation_mode: CompilationMode,
+        target_dir_name: String,
+    ) {
         thread::spawn(move || {
-            let exit_code = run_in_vm(service, &target_dir_name);
+            let exit_code = run_in_vm(service, compilation_mode, &target_dir_name);
 
             let task = self.take();
             // We don't do the callback if cancel has already happened.
@@ -106,7 +114,11 @@
     }
 }
 
-fn run_in_vm(service: Strong<dyn ICompOsService>, target_dir_name: &str) -> Result<ExitCode> {
+fn run_in_vm(
+    service: Strong<dyn ICompOsService>,
+    compilation_mode: CompilationMode,
+    target_dir_name: &str,
+) -> Result<ExitCode> {
     let output_root = Path::new(ART_APEX_DATA);
 
     // We need to remove the target directory because odrefresh running in compos will create it
@@ -134,6 +146,7 @@
     let system_server_compiler_filter =
         system_properties::read("dalvik.vm.systemservercompilerfilter").unwrap_or_default();
     let exit_code = service.odrefresh(
+        compilation_mode,
         system_dir.as_raw_fd(),
         output_dir.as_raw_fd(),
         staging_dir.as_raw_fd(),