-
-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(adb): add client flavors and autolaunch #2515
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ mod parse; | |
|
||
use alvr_common::anyhow::Result; | ||
use alvr_common::{dbg_connection, error}; | ||
use alvr_session::{ClientFlavor, Settings}; | ||
use std::collections::HashSet; | ||
|
||
pub enum WiredConnectionStatus { | ||
|
@@ -24,7 +25,7 @@ impl WiredConnection { | |
Ok(Self { adb_path }) | ||
} | ||
|
||
pub fn setup(&self, control_port: u16, stream_port: u16) -> Result<WiredConnectionStatus> { | ||
pub fn setup(&self, control_port: u16, settings: &Settings) -> Result<WiredConnectionStatus> { | ||
let Some(device_serial) = commands::list_devices(&self.adb_path)? | ||
.into_iter() | ||
.filter_map(|d| d.serial) | ||
|
@@ -35,7 +36,7 @@ impl WiredConnection { | |
)); | ||
}; | ||
|
||
let ports = HashSet::from([control_port, stream_port]); | ||
let ports = HashSet::from([control_port, settings.connection.stream_port]); | ||
let forwarded_ports: HashSet<u16> = | ||
commands::list_forwarded_ports(&self.adb_path, &device_serial)? | ||
.into_iter() | ||
|
@@ -49,16 +50,39 @@ impl WiredConnection { | |
); | ||
} | ||
|
||
#[cfg(debug_assertions)] | ||
let process_name = "alvr.client.dev"; | ||
#[cfg(not(debug_assertions))] | ||
let process_name = "alvr.client.stable"; | ||
let process_name = match &settings.connection.client_flavor { | ||
ClientFlavor::Store => if alvr_common::is_stable() { | ||
"alvr.client" | ||
} else { | ||
"alvr.client.dev" | ||
} | ||
.to_owned(), | ||
ClientFlavor::Github => if alvr_common::is_stable() { | ||
"alvr.client.stable" | ||
} else { | ||
"alvr.client.dev" | ||
} | ||
.to_owned(), | ||
ClientFlavor::Custom(name) => name.clone(), | ||
}; | ||
Comment on lines
+53
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing the fallbacks. Skip store if not stable. You can implement this by storing a slice to |
||
|
||
if commands::get_process_id(&self.adb_path, &device_serial, process_name)?.is_none() { | ||
if !commands::is_package_installed(&self.adb_path, &device_serial, &process_name)? { | ||
Ok(WiredConnectionStatus::NotReady( | ||
"ALVR client is not running".to_owned(), | ||
"ALVR client is not installed".to_owned(), | ||
)) | ||
} else if !commands::is_activity_resumed(&self.adb_path, &device_serial, process_name)? { | ||
} else if commands::get_process_id(&self.adb_path, &device_serial, &process_name)?.is_none() | ||
{ | ||
if settings.connection.client_autolaunch { | ||
commands::start_application(&self.adb_path, &device_serial, &process_name)?; | ||
Ok(WiredConnectionStatus::NotReady( | ||
"Starting ALVR client".to_owned(), | ||
)) | ||
} else { | ||
Ok(WiredConnectionStatus::NotReady( | ||
"ALVR client is not running".to_owned(), | ||
)) | ||
} | ||
} else if !commands::is_activity_resumed(&self.adb_path, &device_serial, &process_name)? { | ||
Ok(WiredConnectionStatus::NotReady( | ||
"ALVR client is paused".to_owned(), | ||
)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1104,6 +1104,13 @@ pub enum SocketBufferSize { | |
Custom(#[schema(suffix = "B")] u32), | ||
} | ||
|
||
#[derive(SettingsSchema, Serialize, Deserialize, Clone)] | ||
pub enum ClientFlavor { | ||
Store, | ||
Github, | ||
Custom(String), | ||
} | ||
|
||
#[derive(SettingsSchema, Serialize, Deserialize, Clone)] | ||
pub struct ConnectionConfig { | ||
#[schema(strings( | ||
|
@@ -1114,6 +1121,16 @@ TCP: Slower than UDP, but more stable. Pick this if you experience video or audi | |
|
||
pub client_discovery: Switch<DiscoveryConfig>, | ||
|
||
#[schema(strings( | ||
help = r#"Wether ALVR should try to automatically launch the client when establishing a wired connection."# | ||
))] | ||
pub client_autolaunch: bool, | ||
|
||
#[schema(strings( | ||
help = r#"Which type of client should ALVR look for when establishing a wired connection."# | ||
))] | ||
pub client_flavor: ClientFlavor, | ||
Comment on lines
+1124
to
+1132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rename these to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. version_check makes no sense tho, this isn't about a the v version, which is probably going to confuse people There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. it's that "flavor" may sound a bit funny. I don't have better ideas so let's use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wired_client_type and maybe adjust the help string to "Which type of release of the client ..." |
||
|
||
#[schema(strings( | ||
help = "This script will be ran when the headset connects. Env var ACTION will be set to `connect`." | ||
))] | ||
|
@@ -1752,6 +1769,15 @@ pub fn session_settings_default() -> SettingsDefault { | |
auto_trust_clients: cfg!(debug_assertions), | ||
}, | ||
}, | ||
client_autolaunch: true, | ||
client_flavor: ClientFlavorDefault { | ||
Custom: "alvr.client".to_owned(), | ||
variant: if alvr_common::is_stable() { | ||
ClientFlavorDefaultVariant::Store | ||
} else { | ||
ClientFlavorDefaultVariant::Github | ||
}, | ||
}, | ||
web_server_port: 8082, | ||
stream_port: 9944, | ||
osc_local_port: 9942, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would pass the minimum subset of settings as parameter. This would be
ConnectionConfig