Rename compile method to compile_cmd

And add an empty implement of compile method.

Bug: 193668901
Test: m
Change-Id: I690be577a4ac79b00f2e151e5c9bf3d507feb83c
diff --git a/compos/aidl/com/android/compos/ICompOsService.aidl b/compos/aidl/com/android/compos/ICompOsService.aidl
index 7904130..29c453b 100644
--- a/compos/aidl/com/android/compos/ICompOsService.aidl
+++ b/compos/aidl/com/android/compos/ICompOsService.aidl
@@ -43,7 +43,22 @@
      * @param fd_annotation Additional file descriptor information of the execution
      * @return a CompilationResult
      */
-    CompilationResult compile(in String[] args, in FdAnnotation fd_annotation);
+    CompilationResult compile_cmd(in String[] args, in FdAnnotation fd_annotation);
+
+    /**
+     * Runs dexopt compilation encoded in the marshaled dexopt arguments.
+     *
+     * To keep ART indepdendantly updatable, the compilation arguments are not stabilized. As a
+     * result, the arguments are marshaled into byte array.  Upon received, the service asks ART to
+     * return relevant information (since ART is able to unmarshal its own encoding), in order to
+     * set up the execution context (mainly file descriptors for compiler input and output) then
+     * invokes the compiler.
+     *
+     * @param marshaledArguments The marshaled dexopt arguments.
+     * @param fd_annotation Additional file descriptor information of the execution.
+     * @return exit code
+     */
+    byte compile(in byte[] marshaledArguments, in FdAnnotation fd_annotation);
 
     /**
      * Generate a new public/private key pair suitable for signing CompOs output files.
diff --git a/compos/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl b/compos/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl
index 5ff72fe..a1bb92c 100644
--- a/compos/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl
+++ b/compos/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl
@@ -24,10 +24,19 @@
 
     /**
      * Run dex2oat in the currently running instance of the CompOS VM. This is a simple proxy
-     * to ICompOsService#compile.
+     * to ICompOsService#compile_cmd.
      *
      * This method can only be called from odrefresh. If there is no currently running instance
      * an error is returned.
      */
-    CompilationResult compile(in String[] args, in FdAnnotation fd_annotation);
+    CompilationResult compile_cmd(in String[] args, in FdAnnotation fd_annotation);
+
+    /**
+     * Run dex2oat in the currently running instance of the CompOS VM. This is a simple proxy
+     * to ICompOsService#compile.
+     *
+     * This method can only be called from libcompos_client. If there is no currently running
+     * instance an error is returned.
+     */
+    byte compile(in byte[] marshaledArguments, in FdAnnotation fd_annotation);
 }
diff --git a/compos/composd/src/service.rs b/compos/composd/src/service.rs
index 2a67a27..be9c30c 100644
--- a/compos/composd/src/service.rs
+++ b/compos/composd/src/service.rs
@@ -47,7 +47,7 @@
         to_binder_result(self.do_run_forced_compile())
     }
 
-    fn compile(
+    fn compile_cmd(
         &self,
         args: &[String],
         fd_annotation: &FdAnnotation,
@@ -55,6 +55,10 @@
         // TODO - check caller is odrefresh
         to_binder_result(self.do_compile(args, fd_annotation))
     }
+
+    fn compile(&self, _marshaled: &[u8], _fd_annotation: &FdAnnotation) -> binder::Result<i8> {
+        Err(new_binder_service_specific_error(-1, "Not yet implemented"))
+    }
 }
 
 fn to_binder_result<T>(result: Result<T>) -> binder::Result<T> {
@@ -89,6 +93,6 @@
         fd_annotation: &FdAnnotation,
     ) -> Result<CompilationResult> {
         let compos = self.instance_manager.get_running_service()?;
-        compos.compile(args, fd_annotation).context("Compiling")
+        compos.compile_cmd(args, fd_annotation).context("Compiling")
     }
 }
diff --git a/compos/src/compilation.rs b/compos/src/compilation.rs
index fec82a6..1499d4b 100644
--- a/compos/src/compilation.rs
+++ b/compos/src/compilation.rs
@@ -52,7 +52,7 @@
 
 /// Runs the compiler with given flags with file descriptors described in `fd_annotation` retrieved
 /// via `authfs_service`. Returns exit code of the compiler process.
-pub fn compile(
+pub fn compile_cmd(
     compiler_path: &Path,
     compiler_args: &[String],
     authfs_service: Strong<dyn IAuthFsService>,
diff --git a/compos/src/compsvc.rs b/compos/src/compsvc.rs
index 954adf5..08f3521 100644
--- a/compos/src/compsvc.rs
+++ b/compos/src/compsvc.rs
@@ -25,7 +25,7 @@
 use std::path::PathBuf;
 use std::sync::{Arc, RwLock};
 
-use crate::compilation::{compile, CompilerOutput};
+use crate::compilation::{compile_cmd, CompilerOutput};
 use crate::compos_key_service::CompOsKeyService;
 use crate::fsverity;
 use authfs_aidl_interface::aidl::com::android::virt::fs::IAuthFsService::IAuthFsService;
@@ -85,14 +85,14 @@
         }
     }
 
-    fn compile(
+    fn compile_cmd(
         &self,
         args: &[String],
         fd_annotation: &FdAnnotation,
     ) -> BinderResult<CompilationResult> {
         let authfs_service = get_authfs_service()?;
         let output =
-            compile(&self.dex2oat_path, args, authfs_service, fd_annotation).map_err(|e| {
+            compile_cmd(&self.dex2oat_path, args, authfs_service, fd_annotation).map_err(|e| {
                 new_binder_exception(
                     ExceptionCode::SERVICE_SPECIFIC,
                     format!("Compilation failed: {}", e),
@@ -124,6 +124,10 @@
         }
     }
 
+    fn compile(&self, _marshaled: &[u8], _fd_annotation: &FdAnnotation) -> BinderResult<i8> {
+        Err(new_binder_exception(ExceptionCode::UNSUPPORTED_OPERATION, "Not yet implemented"))
+    }
+
     fn generateSigningKey(&self) -> BinderResult<CompOsKeyData> {
         self.key_service
             .do_generate()
diff --git a/compos/src/pvm_exec.rs b/compos/src/pvm_exec.rs
index 8ce27db..fd5ffaf 100644
--- a/compos/src/pvm_exec.rs
+++ b/compos/src/pvm_exec.rs
@@ -202,12 +202,12 @@
         // Sentinel value that indicates we should use composd
         let composd = get_composd()?;
         wait_for_fd_server_ready(ready_read_fd)?;
-        composd.compile(&args, &fd_annotation)
+        composd.compile_cmd(&args, &fd_annotation)
     } else {
         // Call directly into the VM
         let compos_vm = get_rpc_binder(cid)?;
         wait_for_fd_server_ready(ready_read_fd)?;
-        compos_vm.compile(&args, &fd_annotation)
+        compos_vm.compile_cmd(&args, &fd_annotation)
     };
     let result = result.context("Binder call failed")?;