Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions crates/core/src/firetv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub fn perform_action(ip: &str, action: FireTvAction) -> Result<String> {
if awake {
Ok(format!("Fire TV at {target} is awake"))
} else {
bail!("Fire TV at {target} did not wake after retries. Confirm the TV is powered on and still accepts ADB commands.")
bail!(fire_tv_not_awake_message(&target))
}
}
FireTvAction::LaunchSpotify => {
Expand Down Expand Up @@ -190,7 +190,7 @@ pub fn prepare_spotify_session(ip: &str) -> Result<FireTvPrepResult> {

let awake = ensure_awake(&target, 4)?;
if !awake {
bail!("Fire TV at {target} did not wake after retries");
bail!(fire_tv_not_awake_message(&target));
}

open_spotify(&target)?;
Expand Down Expand Up @@ -288,7 +288,7 @@ pub fn launch_app(ip: &str, package_name: &str) -> Result<String> {

let awake = ensure_awake(&target, 4)?;
if !awake {
bail!("Fire TV at {target} did not wake after retries");
bail!(fire_tv_not_awake_message(&target));
}

run_adb(&["-s", &target, "shell", "monkey", "-p", package_name, "1"])?;
Expand All @@ -311,6 +311,12 @@ fn fire_tv_unreachable_message(target: &str) -> String {
)
}

fn fire_tv_not_awake_message(target: &str) -> String {
format!(
"Fire TV at {target} did not wake after retries. Confirm the TV is powered on and still accepts ADB commands."
)
}

fn ensure_adb_available() -> Result<()> {
run_adb_with_timeout(&["version"], ADB_STATUS_TIMEOUT)
.map(|_| ())
Expand Down Expand Up @@ -592,6 +598,16 @@ mod tests {
assert!(message.contains("ADB debugging"));
assert!(message.contains("debugging prompt"));
}

#[test]
fn fire_tv_not_awake_message_lists_power_and_adb_steps() {
let message = fire_tv_not_awake_message("192.168.1.50:5555");

assert!(message.contains("192.168.1.50:5555"));
assert!(message.contains("powered on"));
assert!(message.contains("ADB commands"));
assert!(message.contains("retries"));
}
}

fn current_epoch_ms() -> Result<u64> {
Expand Down