Add support for STANDALONE_SYSTEMSERVER_JARS
Stop differentiating between the different ways an APEX can contribute
to derive_classpath - it makes no difference to us, and it doesn't
scale if new environment variables are added.
Remove the workaround to stop the tests failing. Extended the existing
temporary workaround for setting the environment variables in the VM.
Bug: 210472252
Test: atest ApexTestCases
Test: atest ComposTestCase
Test: composd_cmd staged-apex-compile
Change-Id: I97b48cf71c6f22ade27c1ca2e0bad1bb9ab582fc
diff --git a/compos/aidl/com/android/compos/ICompOsService.aidl b/compos/aidl/com/android/compos/ICompOsService.aidl
index 395a09b..ad37806 100644
--- a/compos/aidl/com/android/compos/ICompOsService.aidl
+++ b/compos/aidl/com/android/compos/ICompOsService.aidl
@@ -38,8 +38,8 @@
* 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, String systemServerClassPath);
+ void initializeClasspaths(String bootClasspath, String dex2oatBootClasspath,
+ String systemServerClasspath, String standaloneSystemServerJars);
/**
* Run odrefresh in the VM context.
diff --git a/compos/apk/assets/vm_config.json b/compos/apk/assets/vm_config.json
index 3a6eff4..d008c12 100644
--- a/compos/apk/assets/vm_config.json
+++ b/compos/apk/assets/vm_config.json
@@ -18,13 +18,7 @@
"name": "com.android.compos"
},
{
- "name": "{DEX2OATBOOTCLASSPATH}"
- },
- {
- "name": "{BOOTCLASSPATH}"
- },
- {
- "name": "{SYSTEMSERVERCLASSPATH}"
+ "name": "{CLASSPATH}"
}
]
}
\ No newline at end of file
diff --git a/compos/apk/assets/vm_config_staged.json b/compos/apk/assets/vm_config_staged.json
index 9c81e4e..e42ebe0 100644
--- a/compos/apk/assets/vm_config_staged.json
+++ b/compos/apk/assets/vm_config_staged.json
@@ -19,13 +19,7 @@
"name": "com.android.compos"
},
{
- "name": "{DEX2OATBOOTCLASSPATH}"
- },
- {
- "name": "{BOOTCLASSPATH}"
- },
- {
- "name": "{SYSTEMSERVERCLASSPATH}"
+ "name": "{CLASSPATH}"
}
]
}
\ No newline at end of file
diff --git a/compos/apk/assets/vm_test_config.json b/compos/apk/assets/vm_test_config.json
index 22f8293..9fd55b7 100644
--- a/compos/apk/assets/vm_test_config.json
+++ b/compos/apk/assets/vm_test_config.json
@@ -15,13 +15,7 @@
"name": "com.android.compos"
},
{
- "name": "{DEX2OATBOOTCLASSPATH}"
- },
- {
- "name": "{BOOTCLASSPATH}"
- },
- {
- "name": "{SYSTEMSERVERCLASSPATH}"
+ "name": "{CLASSPATH}"
}
]
}
\ No newline at end of file
diff --git a/compos/composd/src/instance_starter.rs b/compos/composd/src/instance_starter.rs
index 91a0e61..729e5b6 100644
--- a/compos/composd/src/instance_starter.rs
+++ b/compos/composd/src/instance_starter.rs
@@ -161,6 +161,7 @@
&env::var("BOOTCLASSPATH")?,
&env::var("DEX2OATBOOTCLASSPATH")?,
&env::var("SYSTEMSERVERCLASSPATH")?,
+ &env::var("STANDALONE_SYSTEMSERVER_JARS")?,
)
.context("Initializing *CLASSPATH")?;
Ok(())
diff --git a/compos/service/java/com/android/server/compos/IsolatedCompilationService.java b/compos/service/java/com/android/server/compos/IsolatedCompilationService.java
index 6918572..6ecccd2 100644
--- a/compos/service/java/com/android/server/compos/IsolatedCompilationService.java
+++ b/compos/service/java/com/android/server/compos/IsolatedCompilationService.java
@@ -132,9 +132,7 @@
for (String moduleName : moduleNames) {
try {
StagedApexInfo apexInfo = mPackageNative.getStagedApexInfo(moduleName);
- if (apexInfo != null && (apexInfo.hasBootClassPathJars
- || apexInfo.hasDex2OatBootClassPathJars
- || apexInfo.hasSystemServerClassPathJars)) {
+ if (apexInfo != null && apexInfo.hasClassPathJars) {
Log.i(TAG, "Classpath affecting module updated: " + moduleName);
needCompilation = true;
break;
diff --git a/compos/src/compsvc.rs b/compos/src/compsvc.rs
index 8f1e205..3e9fc34 100644
--- a/compos/src/compsvc.rs
+++ b/compos/src/compsvc.rs
@@ -100,11 +100,13 @@
boot_classpath: &str,
dex2oat_boot_classpath: &str,
system_server_classpath: &str,
+ standalone_systemserver_jars: &str,
) -> BinderResult<()> {
// TODO(198211396): Implement correctly.
env::set_var("BOOTCLASSPATH", boot_classpath);
env::set_var("DEX2OATBOOTCLASSPATH", dex2oat_boot_classpath);
env::set_var("SYSTEMSERVERCLASSPATH", system_server_classpath);
+ env::set_var("STANDALONE_SYSTEMSERVER_JARS", standalone_systemserver_jars);
Ok(())
}
diff --git a/compos/tests/java/android/compos/test/ComposTestCase.java b/compos/tests/java/android/compos/test/ComposTestCase.java
index 8906361..7b027de 100644
--- a/compos/tests/java/android/compos/test/ComposTestCase.java
+++ b/compos/tests/java/android/compos/test/ComposTestCase.java
@@ -126,8 +126,6 @@
private CommandResult runOdrefresh(CommandRunner android, String command) throws Exception {
return android.runForResultWithTimeout(
ODREFRESH_TIMEOUT_MS,
- // TODO(b/210472252): Remove this when the VM handles STANDALONE_SYSTEMSERVER_JARS
- "STANDALONE_SYSTEMSERVER_JARS=",
ODREFRESH_BIN,
"--dalvik-cache=" + TEST_ARTIFACTS_DIR,
command);
diff --git a/virtualizationservice/src/payload.rs b/virtualizationservice/src/payload.rs
index 8f7a69a..bbd7fec 100644
--- a/virtualizationservice/src/payload.rs
+++ b/virtualizationservice/src/payload.rs
@@ -58,11 +58,7 @@
path: PathBuf,
#[serde(default)]
- boot_classpath: bool,
- #[serde(default)]
- systemserver_classpath: bool,
- #[serde(default)]
- dex2oatboot_classpath: bool,
+ has_classpath_jar: bool,
}
impl ApexInfoList {
@@ -76,17 +72,19 @@
.context(format!("Failed to parse {}", APEX_INFO_LIST_PATH))?;
// For active APEXes, we refer env variables to see if it contributes to classpath
+ // TODO(b/210472252): Don't hard code the env variable names
let boot_classpath_apexes = find_apex_names_in_classpath_env("BOOTCLASSPATH");
let systemserver_classpath_apexes =
find_apex_names_in_classpath_env("SYSTEMSERVERCLASSPATH");
let dex2oatboot_classpath_apexes =
find_apex_names_in_classpath_env("DEX2OATBOOTCLASSPATH");
+ let standalone_jar_apexes =
+ find_apex_names_in_classpath_env("STANDALONE_SYSTEMSERVER_JARS");
for apex_info in apex_info_list.list.iter_mut() {
- apex_info.boot_classpath = boot_classpath_apexes.contains(&apex_info.name);
- apex_info.systemserver_classpath =
- systemserver_classpath_apexes.contains(&apex_info.name);
- apex_info.dex2oatboot_classpath =
- dex2oatboot_classpath_apexes.contains(&apex_info.name);
+ apex_info.has_classpath_jar = boot_classpath_apexes.contains(&apex_info.name)
+ || systemserver_classpath_apexes.contains(&apex_info.name)
+ || dex2oatboot_classpath_apexes.contains(&apex_info.name)
+ || standalone_jar_apexes.contains(&apex_info.name);
}
Ok(apex_info_list)
})
@@ -133,11 +131,7 @@
let staged_apex_info = pm.getStagedApexInfo(&apex_info.name)?;
if let Some(staged_apex_info) = staged_apex_info {
apex_info.path = PathBuf::from(staged_apex_info.diskImagePath);
- apex_info.boot_classpath = staged_apex_info.hasBootClassPathJars;
- apex_info.systemserver_classpath =
- staged_apex_info.hasSystemServerClassPathJars;
- apex_info.dex2oatboot_classpath =
- staged_apex_info.hasDex2OatBootClassPathJars;
+ apex_info.has_classpath_jar = staged_apex_info.hasClassPathJars;
}
}
}
@@ -293,17 +287,13 @@
apexes: &[ApexConfig],
debug_level: DebugLevel,
) -> Vec<String> {
- // Process pseudo names like "{BOOTCLASSPATH}".
+ // Process pseudo names like "{CLASSPATH}".
// For now we have following pseudo APEX names:
- // - {BOOTCLASSPATH}: represents APEXes contributing "BOOTCLASSPATH" environment variable
- // - {DEX2OATBOOTCLASSPATH}: represents APEXes contributing "DEX2OATBOOTCLASSPATH" environment variable
- // - {SYSTEMSERVERCLASSPATH}: represents APEXes contributing "SYSTEMSERVERCLASSPATH" environment variable
+ // - {CLASSPATH}: represents APEXes contributing to any derive_classpath environment variable
let mut apex_names: Vec<String> = apexes
.iter()
.flat_map(|apex| match apex.name.as_str() {
- "{BOOTCLASSPATH}" => apex_list.get_matching(|apex| apex.boot_classpath),
- "{DEX2OATBOOTCLASSPATH}" => apex_list.get_matching(|apex| apex.dex2oatboot_classpath),
- "{SYSTEMSERVERCLASSPATH}" => apex_list.get_matching(|apex| apex.systemserver_classpath),
+ "{CLASSPATH}" => apex_list.get_matching(|apex| apex.has_classpath_jar),
_ => vec![apex.name.clone()],
})
.collect();