mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-08 07:30:36 -04:00
manager/user: Move relevant methods to Manager2, update as specified
This commit is contained in:
parent
a661df64a1
commit
41382c7158
5 changed files with 62 additions and 62 deletions
|
@ -31,17 +31,6 @@
|
||||||
-->
|
-->
|
||||||
<property name="Version" type="u" access="read"/>
|
<property name="Version" type="u" access="read"/>
|
||||||
|
|
||||||
<!--
|
|
||||||
HardwareCurrentlySupported:
|
|
||||||
|
|
||||||
Reports whether the current hardware is supported or not.
|
|
||||||
|
|
||||||
Valid states: 0 = Unsupported, 1 = Supported
|
|
||||||
|
|
||||||
Since: 7
|
|
||||||
-->
|
|
||||||
<property name="HardwareCurrentlySupported" type="u" access="read"/>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
GpuPerformanceLevel:
|
GpuPerformanceLevel:
|
||||||
|
|
||||||
|
@ -170,15 +159,6 @@
|
||||||
-->
|
-->
|
||||||
<property name="GpuPowerProfile" type="u" access="readwrite"/>
|
<property name="GpuPowerProfile" type="u" access="readwrite"/>
|
||||||
|
|
||||||
<!--
|
|
||||||
ReloadConfig:
|
|
||||||
|
|
||||||
Reloads the configuration from disk.
|
|
||||||
|
|
||||||
Since: 9
|
|
||||||
-->
|
|
||||||
<method name="ReloadConfig"/>
|
|
||||||
|
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
</node>
|
</node>
|
||||||
|
|
|
@ -14,7 +14,7 @@ use steamos_manager::hardware::FanControlState;
|
||||||
use steamos_manager::power::{CPUScalingGovernor, GPUPerformanceLevel, GPUPowerProfile};
|
use steamos_manager::power::{CPUScalingGovernor, GPUPerformanceLevel, GPUPowerProfile};
|
||||||
use steamos_manager::proxy::{
|
use steamos_manager::proxy::{
|
||||||
AmbientLightSensor1Proxy, CpuScaling1Proxy, FactoryReset1Proxy, FanControl1Proxy,
|
AmbientLightSensor1Proxy, CpuScaling1Proxy, FactoryReset1Proxy, FanControl1Proxy,
|
||||||
HdmiCec1Proxy, ManagerProxy, Storage1Proxy, UpdateBios1Proxy, UpdateDock1Proxy,
|
HdmiCec1Proxy, Manager2Proxy, ManagerProxy, Storage1Proxy, UpdateBios1Proxy, UpdateDock1Proxy,
|
||||||
WifiPowerManagement1Proxy,
|
WifiPowerManagement1Proxy,
|
||||||
};
|
};
|
||||||
use steamos_manager::wifi::{WifiBackend, WifiDebugMode, WifiPowerManagement};
|
use steamos_manager::wifi::{WifiBackend, WifiDebugMode, WifiPowerManagement};
|
||||||
|
@ -203,6 +203,7 @@ async fn main() -> Result<()> {
|
||||||
println!("ALS calibration gain: {gain}");
|
println!("ALS calibration gain: {gain}");
|
||||||
}
|
}
|
||||||
Commands::GetHardwareCurrentlySupported => {
|
Commands::GetHardwareCurrentlySupported => {
|
||||||
|
let proxy = Manager2Proxy::new(&conn).await?;
|
||||||
let supported = proxy.hardware_currently_supported().await?;
|
let supported = proxy.hardware_currently_supported().await?;
|
||||||
println!("Hardware currently supported: {supported}");
|
println!("Hardware currently supported: {supported}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,9 @@ pub(crate) enum HardwareVariant {
|
||||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub(crate) enum HardwareCurrentlySupported {
|
pub(crate) enum HardwareCurrentlySupported {
|
||||||
Unsupported = 0,
|
Unknown = 0,
|
||||||
Supported = 1,
|
UnsupportedPrototype = 1,
|
||||||
|
Supported = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
|
@ -54,8 +55,11 @@ impl TryFrom<u32> for HardwareCurrentlySupported {
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
||||||
match v {
|
match v {
|
||||||
x if x == HardwareCurrentlySupported::Unsupported as u32 => {
|
x if x == HardwareCurrentlySupported::Unknown as u32 => {
|
||||||
Ok(HardwareCurrentlySupported::Unsupported)
|
Ok(HardwareCurrentlySupported::Unknown)
|
||||||
|
}
|
||||||
|
x if x == HardwareCurrentlySupported::UnsupportedPrototype as u32 => {
|
||||||
|
Ok(HardwareCurrentlySupported::UnsupportedPrototype)
|
||||||
}
|
}
|
||||||
x if x == HardwareCurrentlySupported::Supported as u32 => {
|
x if x == HardwareCurrentlySupported::Supported as u32 => {
|
||||||
Ok(HardwareCurrentlySupported::Supported)
|
Ok(HardwareCurrentlySupported::Supported)
|
||||||
|
@ -68,7 +72,8 @@ impl TryFrom<u32> for HardwareCurrentlySupported {
|
||||||
impl fmt::Display for HardwareCurrentlySupported {
|
impl fmt::Display for HardwareCurrentlySupported {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
HardwareCurrentlySupported::Unsupported => write!(f, "Unsupported"),
|
HardwareCurrentlySupported::Unknown => write!(f, "Unknown"),
|
||||||
|
HardwareCurrentlySupported::UnsupportedPrototype => write!(f, "Unsupported Prototype"),
|
||||||
HardwareCurrentlySupported::Supported => write!(f, "Supported"),
|
HardwareCurrentlySupported::Supported => write!(f, "Supported"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +134,7 @@ pub(crate) async fn check_support() -> Result<HardwareCurrentlySupported> {
|
||||||
|
|
||||||
Ok(match res {
|
Ok(match res {
|
||||||
0 => HardwareCurrentlySupported::Supported,
|
0 => HardwareCurrentlySupported::Supported,
|
||||||
_ => HardwareCurrentlySupported::Unsupported,
|
_ => HardwareCurrentlySupported::UnsupportedPrototype,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,13 +231,15 @@ pub mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn hardware_currently_supported_roundtrip() {
|
fn hardware_currently_supported_roundtrip() {
|
||||||
enum_roundtrip!(HardwareCurrentlySupported {
|
enum_roundtrip!(HardwareCurrentlySupported {
|
||||||
0: u32 = Unsupported,
|
0: u32 = Unknown,
|
||||||
1: u32 = Supported,
|
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!(
|
assert_eq!(
|
||||||
HardwareCurrentlySupported::Unsupported.to_string(),
|
HardwareCurrentlySupported::UnsupportedPrototype.to_string(),
|
||||||
"Unsupported"
|
"Unsupported Prototype"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
HardwareCurrentlySupported::Supported.to_string(),
|
HardwareCurrentlySupported::Supported.to_string(),
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::cec::{HdmiCecControl, HdmiCecState};
|
||||||
use crate::daemon::user::Command;
|
use crate::daemon::user::Command;
|
||||||
use crate::daemon::DaemonCommand;
|
use crate::daemon::DaemonCommand;
|
||||||
use crate::error::{to_zbus_error, to_zbus_fdo_error, zbus_to_zbus_fdo};
|
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::job::JobManagerCommand;
|
||||||
use crate::power::{
|
use crate::power::{
|
||||||
get_available_cpu_scaling_governors, get_cpu_scaling_governor, get_gpu_clocks,
|
get_available_cpu_scaling_governors, get_cpu_scaling_governor, get_gpu_clocks,
|
||||||
|
@ -93,7 +93,6 @@ macro_rules! setter {
|
||||||
|
|
||||||
struct SteamOSManager {
|
struct SteamOSManager {
|
||||||
proxy: Proxy<'static>,
|
proxy: Proxy<'static>,
|
||||||
channel: Sender<Command>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AmbientLightSensor1 {
|
struct AmbientLightSensor1 {
|
||||||
|
@ -116,6 +115,11 @@ struct HdmiCec1 {
|
||||||
hdmi_cec: HdmiCecControl<'static>,
|
hdmi_cec: HdmiCecControl<'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Manager2 {
|
||||||
|
proxy: Proxy<'static>,
|
||||||
|
channel: Sender<Command>,
|
||||||
|
}
|
||||||
|
|
||||||
struct Storage1 {
|
struct Storage1 {
|
||||||
proxy: Proxy<'static>,
|
proxy: Proxy<'static>,
|
||||||
job_manager: UnboundedSender<JobManagerCommand>,
|
job_manager: UnboundedSender<JobManagerCommand>,
|
||||||
|
@ -139,11 +143,10 @@ impl SteamOSManager {
|
||||||
pub async fn new(
|
pub async fn new(
|
||||||
system_conn: Connection,
|
system_conn: Connection,
|
||||||
proxy: Proxy<'static>,
|
proxy: Proxy<'static>,
|
||||||
channel: Sender<Command>,
|
|
||||||
job_manager: UnboundedSender<JobManagerCommand>,
|
job_manager: UnboundedSender<JobManagerCommand>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
job_manager.send(JobManagerCommand::MirrorConnection(system_conn))?;
|
job_manager.send(JobManagerCommand::MirrorConnection(system_conn))?;
|
||||||
Ok(SteamOSManager { proxy, channel })
|
Ok(SteamOSManager { proxy })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,14 +157,6 @@ impl SteamOSManager {
|
||||||
API_VERSION
|
API_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(property(emits_changed_signal = "const"))]
|
|
||||||
async fn hardware_currently_supported(&self) -> fdo::Result<u32> {
|
|
||||||
match check_support().await {
|
|
||||||
Ok(res) => Ok(res as u32),
|
|
||||||
Err(e) => Err(to_zbus_fdo_error(e)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[zbus(property(emits_changed_signal = "false"))]
|
#[zbus(property(emits_changed_signal = "false"))]
|
||||||
async fn gpu_power_profiles(&self) -> fdo::Result<HashMap<u32, String>> {
|
async fn gpu_power_profiles(&self) -> fdo::Result<HashMap<u32, String>> {
|
||||||
get_gpu_power_profiles().await.map_err(to_zbus_fdo_error)
|
get_gpu_power_profiles().await.map_err(to_zbus_fdo_error)
|
||||||
|
@ -286,15 +281,6 @@ impl SteamOSManager {
|
||||||
.await
|
.await
|
||||||
.map_err(to_zbus_error)
|
.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")]
|
#[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")]
|
#[interface(name = "com.steampowered.SteamOSManager1.Storage1")]
|
||||||
impl Storage1 {
|
impl Storage1 {
|
||||||
async fn format_device(
|
async fn format_device(
|
||||||
|
@ -462,8 +468,7 @@ pub(crate) async fn create_interfaces(
|
||||||
.build()
|
.build()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let manager =
|
let manager = SteamOSManager::new(system.clone(), proxy.clone(), job_manager.clone()).await?;
|
||||||
SteamOSManager::new(system.clone(), proxy.clone(), daemon, job_manager.clone()).await?;
|
|
||||||
|
|
||||||
let als = AmbientLightSensor1 {
|
let als = AmbientLightSensor1 {
|
||||||
proxy: proxy.clone(),
|
proxy: proxy.clone(),
|
||||||
|
@ -478,6 +483,10 @@ pub(crate) async fn create_interfaces(
|
||||||
proxy: proxy.clone(),
|
proxy: proxy.clone(),
|
||||||
};
|
};
|
||||||
let hdmi_cec = HdmiCec1::new(&session).await?;
|
let hdmi_cec = HdmiCec1::new(&session).await?;
|
||||||
|
let manager2 = Manager2 {
|
||||||
|
proxy: proxy.clone(),
|
||||||
|
channel: daemon,
|
||||||
|
};
|
||||||
let storage = Storage1 {
|
let storage = Storage1 {
|
||||||
proxy: proxy.clone(),
|
proxy: proxy.clone(),
|
||||||
job_manager: job_manager.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, factory_reset).await?;
|
||||||
object_server.at(MANAGER_PATH, fan_control).await?;
|
object_server.at(MANAGER_PATH, fan_control).await?;
|
||||||
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, storage).await?;
|
object_server.at(MANAGER_PATH, storage).await?;
|
||||||
object_server.at(MANAGER_PATH, update_bios).await?;
|
object_server.at(MANAGER_PATH, update_bios).await?;
|
||||||
object_server.at(MANAGER_PATH, update_dock).await?;
|
object_server.at(MANAGER_PATH, update_dock).await?;
|
||||||
|
@ -620,6 +630,15 @@ mod test {
|
||||||
.unwrap());
|
.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn interface_matches_manager2() {
|
||||||
|
let test = start().await.expect("start");
|
||||||
|
|
||||||
|
assert!(test_interface_matches::<Manager2>(&test.connection)
|
||||||
|
.await
|
||||||
|
.unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn interface_matches_storage1() {
|
async fn interface_matches_storage1() {
|
||||||
let test = start().await.expect("start");
|
let test = start().await.expect("start");
|
||||||
|
|
|
@ -19,9 +19,6 @@ use zbus::proxy;
|
||||||
assume_defaults = true
|
assume_defaults = true
|
||||||
)]
|
)]
|
||||||
trait Manager {
|
trait Manager {
|
||||||
/// ReloadConfig method
|
|
||||||
fn reload_config(&self) -> zbus::Result<()>;
|
|
||||||
|
|
||||||
/// SetWifiDebugMode method
|
/// SetWifiDebugMode method
|
||||||
fn set_wifi_debug_mode(&self, mode: u32, buffer_size: u32) -> zbus::Result<()>;
|
fn set_wifi_debug_mode(&self, mode: u32, buffer_size: u32) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
@ -41,10 +38,6 @@ trait Manager {
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
fn gpu_power_profiles(&self) -> zbus::Result<std::collections::HashMap<u32, String>>;
|
fn gpu_power_profiles(&self) -> zbus::Result<std::collections::HashMap<u32, String>>;
|
||||||
|
|
||||||
/// HardwareCurrentlySupported property
|
|
||||||
#[zbus(property)]
|
|
||||||
fn hardware_currently_supported(&self) -> zbus::Result<u32>;
|
|
||||||
|
|
||||||
/// ManualGpuClock property
|
/// ManualGpuClock property
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
fn manual_gpu_clock(&self) -> zbus::Result<u32>;
|
fn manual_gpu_clock(&self) -> zbus::Result<u32>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue