Async interface for running odrefresh
This creates a variant of startTestOdrefresh that uses the
ICompilationTask async mechanism of startTestCompile.
OdrefreshTask implements ICompilationTask; instead of owning a spawned
odrefresh process it owns the VM and runs the blocking call to compsvc
inside a thread.
Add a new command to composd_cmd to exercise this.
Test: composd_cmd async-odrefresh
Bug: 209572296
Change-Id: I3780d40876dbca17d4e2a3d8f7c2b809f5561aee
diff --git a/compos/composd_cmd/composd_cmd.rs b/compos/composd_cmd/composd_cmd.rs
index f22dc13..37d5378 100644
--- a/compos/composd_cmd/composd_cmd.rs
+++ b/compos/composd_cmd/composd_cmd.rs
@@ -34,11 +34,9 @@
fn main() -> Result<()> {
let app = clap::App::new("composd_cmd").arg(
- clap::Arg::with_name("command")
- .index(1)
- .takes_value(true)
- .required(true)
- .possible_values(&["staged-apex-compile", "forced-compile-test", "forced-odrefresh"]),
+ clap::Arg::with_name("command").index(1).takes_value(true).required(true).possible_values(
+ &["staged-apex-compile", "forced-compile-test", "forced-odrefresh", "async-odrefresh"],
+ ),
);
let args = app.get_matches();
let command = args.value_of("command").unwrap();
@@ -49,6 +47,7 @@
"staged-apex-compile" => run_staged_apex_compile()?,
"forced-compile-test" => run_forced_compile_for_test()?,
"forced-odrefresh" => run_forced_odrefresh_for_test()?,
+ "async-odrefresh" => run_async_odrefresh_for_test()?,
_ => panic!("Unexpected command {}", command),
}
@@ -113,6 +112,10 @@
run_async_compilation(|service, callback| service.startTestCompile(callback))
}
+fn run_async_odrefresh_for_test() -> Result<()> {
+ run_async_compilation(|service, callback| service.startAsyncOdrefresh(callback))
+}
+
fn run_async_compilation<F>(start_compile_fn: F) -> Result<()>
where
F: FnOnce(