Remove the old interface that runs compiler with flags
Bug: 210998077
Test: atest ComposHostTestCases
Change-Id: I50bb4cb96e0eb4033c531d47f6620ba8ede78553
diff --git a/compos/composd/src/composd_main.rs b/compos/composd/src/composd_main.rs
index df088bc..6acf470 100644
--- a/compos/composd/src/composd_main.rs
+++ b/compos/composd/src/composd_main.rs
@@ -43,11 +43,11 @@
let virtualization_service = VmInstance::connect_to_virtualization_service()?;
let instance_manager = Arc::new(InstanceManager::new(virtualization_service));
- let composd_service = service::new_binder(instance_manager.clone());
+ let composd_service = service::new_binder(instance_manager);
register_lazy_service("android.system.composd", composd_service.as_binder())
.context("Registering composd service")?;
- let internal_service = internal_service::new_binder(instance_manager);
+ let internal_service = internal_service::new_binder();
register_lazy_service("android.system.composd.internal", internal_service.as_binder())
.context("Registering internal service")?;
diff --git a/compos/composd/src/instance_manager.rs b/compos/composd/src/instance_manager.rs
index 4fc4ad1..8950f20 100644
--- a/compos/composd/src/instance_manager.rs
+++ b/compos/composd/src/instance_manager.rs
@@ -19,8 +19,7 @@
use crate::instance_starter::{CompOsInstance, InstanceStarter};
use android_system_virtualizationservice::aidl::android::system::virtualizationservice;
-use anyhow::{bail, Context, Result};
-use compos_aidl_interface::aidl::com::android::compos::ICompOsService::ICompOsService;
+use anyhow::{bail, Result};
use compos_aidl_interface::binder::Strong;
use compos_common::compos_client::VmParameters;
use compos_common::{
@@ -43,12 +42,6 @@
Self { service, state: Default::default() }
}
- pub fn get_running_service(&self) -> Result<Strong<dyn ICompOsService>> {
- let mut state = self.state.lock().unwrap();
- let instance = state.get_running_instance().context("No running instance")?;
- Ok(instance.get_service())
- }
-
pub fn start_pending_instance(&self) -> Result<Arc<CompOsInstance>> {
let config_path = Some(PREFER_STAGED_VM_CONFIG_PATH.to_owned());
let mut vm_parameters = VmParameters { config_path, ..Default::default() };
@@ -142,17 +135,4 @@
self.running_instance = Some(Arc::downgrade(instance));
Ok(())
}
-
- // Return the running instance if we are in the Started state.
- fn get_running_instance(&mut self) -> Option<Arc<CompOsInstance>> {
- if self.is_starting {
- return None;
- }
- let instance = self.running_instance.as_ref()?.upgrade();
- if instance.is_none() {
- // No point keeping an orphaned weak reference
- self.running_instance = None;
- }
- instance
- }
}
diff --git a/compos/composd/src/internal_service.rs b/compos/composd/src/internal_service.rs
index 3fad6d4..33935ef 100644
--- a/compos/composd/src/internal_service.rs
+++ b/compos/composd/src/internal_service.rs
@@ -16,59 +16,24 @@
//! Implementation of ICompilationInternal, called from odrefresh during compilation.
-use crate::instance_manager::InstanceManager;
-use compos_common::binder::to_binder_result;
use android_system_composd_internal::aidl::android::system::composd::internal::ICompilationInternal::{
BnCompilationInternal, ICompilationInternal,
};
-use android_system_composd::binder::{
- self, BinderFeatures, ExceptionCode, Interface, Status, Strong, ThreadState,
-};
-use anyhow::{Context, Result};
+use android_system_composd::binder::{self, BinderFeatures, Interface, Strong};
use binder_common::new_binder_service_specific_error;
-use compos_aidl_interface::aidl::com::android::compos::{
- CompilationResult::CompilationResult, FdAnnotation::FdAnnotation,
-};
-use rustutils::users::AID_ROOT;
-use std::sync::Arc;
+use compos_aidl_interface::aidl::com::android::compos::FdAnnotation::FdAnnotation;
-pub struct CompilationInternalService {
- instance_manager: Arc<InstanceManager>,
-}
+pub struct CompilationInternalService {}
-pub fn new_binder(instance_manager: Arc<InstanceManager>) -> Strong<dyn ICompilationInternal> {
- let service = CompilationInternalService { instance_manager };
+pub fn new_binder() -> Strong<dyn ICompilationInternal> {
+ let service = CompilationInternalService {};
BnCompilationInternal::new_binder(service, BinderFeatures::default())
}
impl Interface for CompilationInternalService {}
impl ICompilationInternal for CompilationInternalService {
- fn compile_cmd(
- &self,
- args: &[String],
- fd_annotation: &FdAnnotation,
- ) -> binder::Result<CompilationResult> {
- let calling_uid = ThreadState::get_calling_uid();
- // This should only be called by odrefresh, which runs as root
- if calling_uid != AID_ROOT {
- return Err(Status::new_exception(ExceptionCode::SECURITY, None));
- }
- to_binder_result(self.do_compile_cmd(args, fd_annotation))
- }
-
fn compile(&self, _marshaled: &[u8], _fd_annotation: &FdAnnotation) -> binder::Result<i8> {
Err(new_binder_service_specific_error(-1, "Not yet implemented"))
}
}
-
-impl CompilationInternalService {
- fn do_compile_cmd(
- &self,
- args: &[String],
- fd_annotation: &FdAnnotation,
- ) -> Result<CompilationResult> {
- let compos = self.instance_manager.get_running_service()?;
- compos.compile_cmd(args, fd_annotation).context("Compiling")
- }
-}