diff --git a/com.steampowered.SteamOSManager1.Manager.xml b/com.steampowered.SteamOSManager1.Manager.xml index 4f5fe46..437b22d 100644 --- a/com.steampowered.SteamOSManager1.Manager.xml +++ b/com.steampowered.SteamOSManager1.Manager.xml @@ -31,17 +31,6 @@ --> - - - - - - diff --git a/src/bin/steamosctl.rs b/src/bin/steamosctl.rs index 0506c8f..eb05bd0 100644 --- a/src/bin/steamosctl.rs +++ b/src/bin/steamosctl.rs @@ -14,7 +14,7 @@ use steamos_manager::hardware::FanControlState; use steamos_manager::power::{CPUScalingGovernor, GPUPerformanceLevel, GPUPowerProfile}; use steamos_manager::proxy::{ AmbientLightSensor1Proxy, CpuScaling1Proxy, FactoryReset1Proxy, FanControl1Proxy, - HdmiCec1Proxy, ManagerProxy, Storage1Proxy, UpdateBios1Proxy, UpdateDock1Proxy, + HdmiCec1Proxy, Manager2Proxy, ManagerProxy, Storage1Proxy, UpdateBios1Proxy, UpdateDock1Proxy, WifiPowerManagement1Proxy, }; use steamos_manager::wifi::{WifiBackend, WifiDebugMode, WifiPowerManagement}; @@ -203,6 +203,7 @@ async fn main() -> Result<()> { println!("ALS calibration gain: {gain}"); } Commands::GetHardwareCurrentlySupported => { + let proxy = Manager2Proxy::new(&conn).await?; let supported = proxy.hardware_currently_supported().await?; println!("Hardware currently supported: {supported}"); } diff --git a/src/hardware.rs b/src/hardware.rs index a864369..8f6cbf7 100644 --- a/src/hardware.rs +++ b/src/hardware.rs @@ -28,8 +28,9 @@ pub(crate) enum HardwareVariant { #[derive(PartialEq, Debug, Copy, Clone)] #[repr(u32)] pub(crate) enum HardwareCurrentlySupported { - Unsupported = 0, - Supported = 1, + Unknown = 0, + UnsupportedPrototype = 1, + Supported = 2, } #[derive(PartialEq, Debug, Copy, Clone)] @@ -54,8 +55,11 @@ impl TryFrom for HardwareCurrentlySupported { type Error = &'static str; fn try_from(v: u32) -> Result { match v { - x if x == HardwareCurrentlySupported::Unsupported as u32 => { - Ok(HardwareCurrentlySupported::Unsupported) + x if x == HardwareCurrentlySupported::Unknown as u32 => { + Ok(HardwareCurrentlySupported::Unknown) + } + x if x == HardwareCurrentlySupported::UnsupportedPrototype as u32 => { + Ok(HardwareCurrentlySupported::UnsupportedPrototype) } x if x == HardwareCurrentlySupported::Supported as u32 => { Ok(HardwareCurrentlySupported::Supported) @@ -68,7 +72,8 @@ impl TryFrom for HardwareCurrentlySupported { impl fmt::Display for HardwareCurrentlySupported { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - HardwareCurrentlySupported::Unsupported => write!(f, "Unsupported"), + HardwareCurrentlySupported::Unknown => write!(f, "Unknown"), + HardwareCurrentlySupported::UnsupportedPrototype => write!(f, "Unsupported Prototype"), HardwareCurrentlySupported::Supported => write!(f, "Supported"), } } @@ -129,7 +134,7 @@ pub(crate) async fn check_support() -> Result { Ok(match res { 0 => HardwareCurrentlySupported::Supported, - _ => HardwareCurrentlySupported::Unsupported, + _ => HardwareCurrentlySupported::UnsupportedPrototype, }) } @@ -226,13 +231,15 @@ pub mod test { #[test] fn hardware_currently_supported_roundtrip() { enum_roundtrip!(HardwareCurrentlySupported { - 0: u32 = Unsupported, - 1: u32 = Supported, + 0: u32 = Unknown, + 1: u32 = UnsupportedPrototype, + 2: u32 = Supported, }); - assert!(HardwareCurrentlySupported::try_from(2).is_err()); + assert!(HardwareCurrentlySupported::try_from(3).is_err()); + assert_eq!(HardwareCurrentlySupported::Unknown.to_string(), "Unknown"); assert_eq!( - HardwareCurrentlySupported::Unsupported.to_string(), - "Unsupported" + HardwareCurrentlySupported::UnsupportedPrototype.to_string(), + "Unsupported Prototype" ); assert_eq!( HardwareCurrentlySupported::Supported.to_string(), diff --git a/src/manager/user.rs b/src/manager/user.rs index 2a14929..7631357 100644 --- a/src/manager/user.rs +++ b/src/manager/user.rs @@ -19,7 +19,7 @@ use crate::cec::{HdmiCecControl, HdmiCecState}; use crate::daemon::user::Command; use crate::daemon::DaemonCommand; use crate::error::{to_zbus_error, to_zbus_fdo_error, zbus_to_zbus_fdo}; -use crate::hardware::check_support; +use crate::hardware::{check_support, HardwareCurrentlySupported}; use crate::job::JobManagerCommand; use crate::power::{ get_available_cpu_scaling_governors, get_cpu_scaling_governor, get_gpu_clocks, @@ -93,7 +93,6 @@ macro_rules! setter { struct SteamOSManager { proxy: Proxy<'static>, - channel: Sender, } struct AmbientLightSensor1 { @@ -116,6 +115,11 @@ struct HdmiCec1 { hdmi_cec: HdmiCecControl<'static>, } +struct Manager2 { + proxy: Proxy<'static>, + channel: Sender, +} + struct Storage1 { proxy: Proxy<'static>, job_manager: UnboundedSender, @@ -139,11 +143,10 @@ impl SteamOSManager { pub async fn new( system_conn: Connection, proxy: Proxy<'static>, - channel: Sender, job_manager: UnboundedSender, ) -> Result { job_manager.send(JobManagerCommand::MirrorConnection(system_conn))?; - Ok(SteamOSManager { proxy, channel }) + Ok(SteamOSManager { proxy }) } } @@ -154,14 +157,6 @@ impl SteamOSManager { API_VERSION } - #[zbus(property(emits_changed_signal = "const"))] - async fn hardware_currently_supported(&self) -> fdo::Result { - match check_support().await { - Ok(res) => Ok(res as u32), - Err(e) => Err(to_zbus_fdo_error(e)), - } - } - #[zbus(property(emits_changed_signal = "false"))] async fn gpu_power_profiles(&self) -> fdo::Result> { get_gpu_power_profiles().await.map_err(to_zbus_fdo_error) @@ -286,15 +281,6 @@ impl SteamOSManager { .await .map_err(to_zbus_error) } - - async fn reload_config(&self) -> fdo::Result<()> { - self.channel - .send(DaemonCommand::ReadConfig) - .await - .inspect_err(|message| error!("Error sending ReadConfig command: {message}")) - .map_err(to_zbus_fdo_error)?; - method!(self, "ReloadConfig") - } } #[interface(name = "com.steampowered.SteamOSManager1.AmbientLightSensor1")] @@ -399,6 +385,26 @@ impl HdmiCec1 { } } +#[interface(name = "com.steampowered.SteamOSManager1.Manager2")] +impl Manager2 { + #[zbus(property(emits_changed_signal = "const"))] + async fn hardware_currently_supported(&self) -> u32 { + match check_support().await { + Ok(res) => res as u32, + Err(_) => HardwareCurrentlySupported::Unknown as u32, + } + } + + async fn reload_config(&self) -> fdo::Result<()> { + self.channel + .send(DaemonCommand::ReadConfig) + .await + .inspect_err(|message| error!("Error sending ReadConfig command: {message}")) + .map_err(to_zbus_fdo_error)?; + method!(self, "ReloadConfig") + } +} + #[interface(name = "com.steampowered.SteamOSManager1.Storage1")] impl Storage1 { async fn format_device( @@ -462,8 +468,7 @@ pub(crate) async fn create_interfaces( .build() .await?; - let manager = - SteamOSManager::new(system.clone(), proxy.clone(), daemon, job_manager.clone()).await?; + let manager = SteamOSManager::new(system.clone(), proxy.clone(), job_manager.clone()).await?; let als = AmbientLightSensor1 { proxy: proxy.clone(), @@ -478,6 +483,10 @@ pub(crate) async fn create_interfaces( proxy: proxy.clone(), }; let hdmi_cec = HdmiCec1::new(&session).await?; + let manager2 = Manager2 { + proxy: proxy.clone(), + channel: daemon, + }; let storage = Storage1 { proxy: proxy.clone(), job_manager: job_manager.clone(), @@ -501,6 +510,7 @@ pub(crate) async fn create_interfaces( object_server.at(MANAGER_PATH, factory_reset).await?; object_server.at(MANAGER_PATH, fan_control).await?; object_server.at(MANAGER_PATH, hdmi_cec).await?; + object_server.at(MANAGER_PATH, manager2).await?; object_server.at(MANAGER_PATH, storage).await?; object_server.at(MANAGER_PATH, update_bios).await?; object_server.at(MANAGER_PATH, update_dock).await?; @@ -620,6 +630,15 @@ mod test { .unwrap()); } + #[tokio::test] + async fn interface_matches_manager2() { + let test = start().await.expect("start"); + + assert!(test_interface_matches::(&test.connection) + .await + .unwrap()); + } + #[tokio::test] async fn interface_matches_storage1() { let test = start().await.expect("start"); diff --git a/src/proxy/manager.rs b/src/proxy/manager.rs index 22235ef..68b02f0 100644 --- a/src/proxy/manager.rs +++ b/src/proxy/manager.rs @@ -19,9 +19,6 @@ use zbus::proxy; assume_defaults = true )] trait Manager { - /// ReloadConfig method - fn reload_config(&self) -> zbus::Result<()>; - /// SetWifiDebugMode method fn set_wifi_debug_mode(&self, mode: u32, buffer_size: u32) -> zbus::Result<()>; @@ -41,10 +38,6 @@ trait Manager { #[zbus(property)] fn gpu_power_profiles(&self) -> zbus::Result>; - /// HardwareCurrentlySupported property - #[zbus(property)] - fn hardware_currently_supported(&self) -> zbus::Result; - /// ManualGpuClock property #[zbus(property)] fn manual_gpu_clock(&self) -> zbus::Result;