Merge "Initiailize assumed BOOTCLASSPATH and DEX2OATBOOTCLASSPATH"
diff --git a/compos/aidl/com/android/compos/ICompOsService.aidl b/compos/aidl/com/android/compos/ICompOsService.aidl
index 29c453b..34dee54 100644
--- a/compos/aidl/com/android/compos/ICompOsService.aidl
+++ b/compos/aidl/com/android/compos/ICompOsService.aidl
@@ -33,6 +33,14 @@
void initializeSigningKey(in byte[] keyBlob);
/**
+ * Initializes the classpaths necessary for preparing and running compilation.
+ *
+ * TODO(198211396): Implement properly. We can't simply accepting the classpaths from Android
+ * since they are not derived from staged APEX (besides security reasons).
+ */
+ void initializeClasspaths(String bootClasspath, String dex2oatBootClasspath);
+
+ /**
* Run dex2oat command with provided args, in a context that may be specified in FdAnnotation,
* e.g. with file descriptors pre-opened. The service is responsible to decide what executables
* it may run.
diff --git a/compos/composd/src/instance_starter.rs b/compos/composd/src/instance_starter.rs
index 1751d35..63aefb8 100644
--- a/compos/composd/src/instance_starter.rs
+++ b/compos/composd/src/instance_starter.rs
@@ -28,6 +28,7 @@
COMPOS_DATA_ROOT, INSTANCE_IMAGE_FILE, PRIVATE_KEY_BLOB_FILE, PUBLIC_KEY_FILE,
};
use log::{info, warn};
+use std::env;
use std::fs;
use std::path::{Path, PathBuf};
@@ -100,7 +101,7 @@
// current set of APEXes) and the key blob can be successfully decrypted by the VM. So the
// files have not been tampered with and we're good to go.
- service.initializeSigningKey(&key_blob).context("Loading signing key")?;
+ Self::initialize_service(service, &key_blob)?;
Ok(compos_instance)
}
@@ -129,13 +130,25 @@
}
fs::write(&self.public_key, &rsa_public_key).context("Writing public key")?;
- // We don't need to verify the key, since we just generated it and have it in memory.
+ // Unlike when starting an existing instance, we don't need to verify the key, since we
+ // just generated it and have it in memory.
- service.initializeSigningKey(&key_data.keyBlob).context("Loading signing key")?;
+ Self::initialize_service(service, &key_data.keyBlob)?;
Ok(compos_instance)
}
+ fn initialize_service(service: &Strong<dyn ICompOsService>, key_blob: &[u8]) -> Result<()> {
+ // Key blob is assumed to be verified/trusted.
+ service.initializeSigningKey(key_blob).context("Loading signing key")?;
+
+ // TODO(198211396): Implement correctly.
+ service
+ .initializeClasspaths(&env::var("BOOTCLASSPATH")?, &env::var("DEX2OATBOOTCLASSPATH")?)
+ .context("Initializing *CLASSPATH")?;
+ Ok(())
+ }
+
fn start_vm(&self) -> Result<CompOsInstance> {
let instance_image = fs::OpenOptions::new()
.read(true)
diff --git a/compos/src/compsvc.rs b/compos/src/compsvc.rs
index 08f3521..2a5534c 100644
--- a/compos/src/compsvc.rs
+++ b/compos/src/compsvc.rs
@@ -22,6 +22,7 @@
use binder_common::new_binder_exception;
use log::warn;
use std::default::Default;
+use std::env;
use std::path::PathBuf;
use std::sync::{Arc, RwLock};
@@ -85,6 +86,17 @@
}
}
+ fn initializeClasspaths(
+ &self,
+ boot_classpath: &str,
+ dex2oat_boot_classpath: &str,
+ ) -> BinderResult<()> {
+ // TODO(198211396): Implement correctly.
+ env::set_var("BOOTCLASSPATH", boot_classpath);
+ env::set_var("DEX2OATBOOTCLASSPATH", dex2oat_boot_classpath);
+ Ok(())
+ }
+
fn compile_cmd(
&self,
args: &[String],