mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-07 23:20:31 -04:00
manager/user: Move adding interfaces that need a config to a separate function
This commit is contained in:
parent
c19a488b62
commit
9ab3f939a0
1 changed files with 54 additions and 55 deletions
|
@ -13,7 +13,7 @@ use tokio::sync::oneshot;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use zbus::object_server::SignalEmitter;
|
use zbus::object_server::SignalEmitter;
|
||||||
use zbus::proxy::{Builder, CacheProperties};
|
use zbus::proxy::{Builder, CacheProperties};
|
||||||
use zbus::{fdo, interface, zvariant, Connection, Proxy};
|
use zbus::{fdo, interface, zvariant, Connection, ObjectServer, Proxy};
|
||||||
|
|
||||||
use crate::cec::{HdmiCecControl, HdmiCecState};
|
use crate::cec::{HdmiCecControl, HdmiCecState};
|
||||||
use crate::daemon::user::Command;
|
use crate::daemon::user::Command;
|
||||||
|
@ -562,6 +562,57 @@ impl WifiPowerManagement1 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn create_config_interfaces(
|
||||||
|
proxy: &Proxy<'static>,
|
||||||
|
object_server: &ObjectServer,
|
||||||
|
job_manager: &UnboundedSender<JobManagerCommand>,
|
||||||
|
) -> Result<()> {
|
||||||
|
let Some(config) = platform_config().await? else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
|
||||||
|
let factory_reset = FactoryReset1 {
|
||||||
|
proxy: proxy.clone(),
|
||||||
|
};
|
||||||
|
let fan_control = FanControl1 {
|
||||||
|
proxy: proxy.clone(),
|
||||||
|
};
|
||||||
|
let storage = Storage1 {
|
||||||
|
proxy: proxy.clone(),
|
||||||
|
job_manager: job_manager.clone(),
|
||||||
|
};
|
||||||
|
let update_bios = UpdateBios1 {
|
||||||
|
proxy: proxy.clone(),
|
||||||
|
job_manager: job_manager.clone(),
|
||||||
|
};
|
||||||
|
let update_dock = UpdateDock1 {
|
||||||
|
proxy: proxy.clone(),
|
||||||
|
job_manager: job_manager.clone(),
|
||||||
|
};
|
||||||
|
|
||||||
|
if config.factory_reset.is_some() {
|
||||||
|
object_server.at(MANAGER_PATH, factory_reset).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.fan_control.is_some() {
|
||||||
|
object_server.at(MANAGER_PATH, fan_control).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.storage.is_some() {
|
||||||
|
object_server.at(MANAGER_PATH, storage).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.update_bios.is_some() {
|
||||||
|
object_server.at(MANAGER_PATH, update_bios).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.update_dock.is_some() {
|
||||||
|
object_server.at(MANAGER_PATH, update_dock).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
pub(crate) async fn create_interfaces(
|
pub(crate) async fn create_interfaces(
|
||||||
session: Connection,
|
session: Connection,
|
||||||
|
@ -588,12 +639,6 @@ pub(crate) async fn create_interfaces(
|
||||||
let cpu_scaling = CpuScaling1 {
|
let cpu_scaling = CpuScaling1 {
|
||||||
proxy: proxy.clone(),
|
proxy: proxy.clone(),
|
||||||
};
|
};
|
||||||
let factory_reset = FactoryReset1 {
|
|
||||||
proxy: proxy.clone(),
|
|
||||||
};
|
|
||||||
let fan_control = FanControl1 {
|
|
||||||
proxy: proxy.clone(),
|
|
||||||
};
|
|
||||||
let gpu_performance_level = GpuPerformanceLevel1 {
|
let gpu_performance_level = GpuPerformanceLevel1 {
|
||||||
proxy: proxy.clone(),
|
proxy: proxy.clone(),
|
||||||
};
|
};
|
||||||
|
@ -605,21 +650,9 @@ pub(crate) async fn create_interfaces(
|
||||||
proxy: proxy.clone(),
|
proxy: proxy.clone(),
|
||||||
channel: daemon,
|
channel: daemon,
|
||||||
};
|
};
|
||||||
let storage = Storage1 {
|
|
||||||
proxy: proxy.clone(),
|
|
||||||
job_manager: job_manager.clone(),
|
|
||||||
};
|
|
||||||
let tdp_limit = TdpLimit1 {
|
let tdp_limit = TdpLimit1 {
|
||||||
proxy: proxy.clone(),
|
proxy: proxy.clone(),
|
||||||
};
|
};
|
||||||
let update_bios = UpdateBios1 {
|
|
||||||
proxy: proxy.clone(),
|
|
||||||
job_manager: job_manager.clone(),
|
|
||||||
};
|
|
||||||
let update_dock = UpdateDock1 {
|
|
||||||
proxy: proxy.clone(),
|
|
||||||
job_manager: job_manager.clone(),
|
|
||||||
};
|
|
||||||
let wifi_debug = WifiDebug1 {
|
let wifi_debug = WifiDebug1 {
|
||||||
proxy: proxy.clone(),
|
proxy: proxy.clone(),
|
||||||
};
|
};
|
||||||
|
@ -630,10 +663,11 @@ pub(crate) async fn create_interfaces(
|
||||||
proxy: proxy.clone(),
|
proxy: proxy.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let config = platform_config().await?;
|
|
||||||
let object_server = session.object_server();
|
let object_server = session.object_server();
|
||||||
object_server.at(MANAGER_PATH, manager).await?;
|
object_server.at(MANAGER_PATH, manager).await?;
|
||||||
|
|
||||||
|
create_config_interfaces(&proxy, object_server, &job_manager).await?;
|
||||||
|
|
||||||
if is_deck().await? {
|
if is_deck().await? {
|
||||||
object_server.at(MANAGER_PATH, als).await?;
|
object_server.at(MANAGER_PATH, als).await?;
|
||||||
}
|
}
|
||||||
|
@ -647,20 +681,6 @@ pub(crate) async fn create_interfaces(
|
||||||
|
|
||||||
object_server.at(MANAGER_PATH, cpu_scaling).await?;
|
object_server.at(MANAGER_PATH, cpu_scaling).await?;
|
||||||
|
|
||||||
if config
|
|
||||||
.as_ref()
|
|
||||||
.is_some_and(|config| config.factory_reset.is_some())
|
|
||||||
{
|
|
||||||
object_server.at(MANAGER_PATH, factory_reset).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config
|
|
||||||
.as_ref()
|
|
||||||
.is_some_and(|config| config.fan_control.is_some())
|
|
||||||
{
|
|
||||||
object_server.at(MANAGER_PATH, fan_control).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if !get_available_gpu_performance_levels()
|
if !get_available_gpu_performance_levels()
|
||||||
.await
|
.await
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
|
@ -685,31 +705,10 @@ pub(crate) async fn create_interfaces(
|
||||||
|
|
||||||
object_server.at(MANAGER_PATH, manager2).await?;
|
object_server.at(MANAGER_PATH, manager2).await?;
|
||||||
|
|
||||||
if config
|
|
||||||
.as_ref()
|
|
||||||
.is_some_and(|config| config.storage.is_some())
|
|
||||||
{
|
|
||||||
object_server.at(MANAGER_PATH, storage).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if get_tdp_limit().await.is_ok() {
|
if get_tdp_limit().await.is_ok() {
|
||||||
object_server.at(MANAGER_PATH, tdp_limit).await?;
|
object_server.at(MANAGER_PATH, tdp_limit).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if config
|
|
||||||
.as_ref()
|
|
||||||
.is_some_and(|config| config.update_bios.is_some())
|
|
||||||
{
|
|
||||||
object_server.at(MANAGER_PATH, update_bios).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config
|
|
||||||
.as_ref()
|
|
||||||
.is_some_and(|config| config.update_dock.is_some())
|
|
||||||
{
|
|
||||||
object_server.at(MANAGER_PATH, update_dock).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if variant().await.unwrap_or_default() == HardwareVariant::Galileo {
|
if variant().await.unwrap_or_default() == HardwareVariant::Galileo {
|
||||||
object_server.at(MANAGER_PATH, wifi_debug).await?;
|
object_server.at(MANAGER_PATH, wifi_debug).await?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue