manager/user: Only enable HdmiCec1 if plasma-remotecontrollers.service exists

This commit is contained in:
Vicki Pfau 2024-08-14 20:55:24 -07:00
parent 7dc0d0969d
commit 1de2109c6d
2 changed files with 27 additions and 6 deletions

View file

@ -611,7 +611,10 @@ pub(crate) async fn create_interfaces(
object_server.at(MANAGER_PATH, gpu_tdp_limit).await?; object_server.at(MANAGER_PATH, gpu_tdp_limit).await?;
} }
if hdmi_cec.hdmi_cec.get_enabled_state().await.is_ok() {
object_server.at(MANAGER_PATH, hdmi_cec).await?; object_server.at(MANAGER_PATH, hdmi_cec).await?;
}
object_server.at(MANAGER_PATH, manager2).await?; object_server.at(MANAGER_PATH, manager2).await?;
if config if config
@ -651,6 +654,7 @@ mod test {
use crate::hardware::test::fake_model; use crate::hardware::test::fake_model;
use crate::hardware::HardwareVariant; use crate::hardware::HardwareVariant;
use crate::platform::{PlatformConfig, ScriptConfig, ServiceConfig, StorageConfig}; use crate::platform::{PlatformConfig, ScriptConfig, ServiceConfig, StorageConfig};
use crate::systemd::test::{MockManager, MockUnit};
use crate::{power, testing}; use crate::{power, testing};
use std::time::Duration; use std::time::Duration;
@ -682,6 +686,23 @@ mod test {
handle.test.platform_config.replace(platform_config); handle.test.platform_config.replace(platform_config);
let connection = handle.new_dbus().await?; let connection = handle.new_dbus().await?;
connection.request_name("org.freedesktop.systemd1").await?;
{
let object_server = connection.object_server();
object_server
.at("/org/freedesktop/systemd1", MockManager::default())
.await?;
let mut prc = MockUnit::default();
prc.unit_file = String::from("disabled");
object_server
.at(
"/org/freedesktop/systemd1/unit/plasma_2dremotecontrollers_2eservice",
prc,
)
.await?;
}
fake_model(HardwareVariant::Jupiter).await?; fake_model(HardwareVariant::Jupiter).await?;
power::test::create_nodes().await?; power::test::create_nodes().await?;
create_interfaces(connection.clone(), connection.clone(), tx_ctx, tx_job).await?; create_interfaces(connection.clone(), connection.clone(), tx_ctx, tx_job).await?;

View file

@ -173,7 +173,7 @@ pub fn escape(name: &str) -> String {
} }
#[cfg(test)] #[cfg(test)]
mod test { pub mod test {
use super::*; use super::*;
use crate::error::to_zbus_fdo_error; use crate::error::to_zbus_fdo_error;
use crate::{enum_roundtrip, testing}; use crate::{enum_roundtrip, testing};
@ -201,14 +201,14 @@ mod test {
} }
#[derive(Default)] #[derive(Default)]
struct MockUnit { pub struct MockUnit {
active: String, pub active: String,
unit_file: String, pub unit_file: String,
job: u32, job: u32,
} }
#[derive(Default)] #[derive(Default)]
struct MockManager { pub struct MockManager {
states: HashMap<String, EnableState>, states: HashMap<String, EnableState>,
} }