fix native shell ticking resident game
This commit is contained in:
@@ -4,7 +4,7 @@ use crate::os::{
|
||||
DEFAULT_GAME_PAUSE_BUDGET_TICKS, GameLifecycleEvent, GameLifecycleEventKind, LifecycleError,
|
||||
LifecycleOperation,
|
||||
};
|
||||
use crate::process::{ProcessId, ProcessState};
|
||||
use crate::process::{ProcessId, ProcessKind, ProcessState};
|
||||
use crate::services::foreground::{
|
||||
ForegroundOwner, ForegroundStackError, ResidentGame, ResidentGameState,
|
||||
};
|
||||
@@ -28,6 +28,15 @@ impl<'a> LifecycleFacade<'a> {
|
||||
.ok_or(LifecycleError::ProcessNotFound(process_id))
|
||||
}
|
||||
|
||||
pub fn process_kind_for_task(&self, task_id: TaskId) -> Result<ProcessKind, LifecycleError> {
|
||||
let process_id = process_id_for_task(self.os, task_id)?;
|
||||
self.os
|
||||
.process_manager
|
||||
.get(process_id)
|
||||
.map(|process| process.kind)
|
||||
.ok_or(LifecycleError::ProcessNotFound(process_id))
|
||||
}
|
||||
|
||||
pub fn set_foreground_task(&mut self, task_id: TaskId) -> Result<(), LifecycleError> {
|
||||
match task_kind_for_task(self.os, task_id)? {
|
||||
TaskKind::Game => return self.set_game_foreground_task(task_id),
|
||||
|
||||
@@ -141,7 +141,7 @@ impl SystemOS {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::os::{GameLifecycleEventKind, LifecycleError, LifecycleOperation};
|
||||
use crate::process::ProcessState;
|
||||
use crate::process::{ProcessKind, ProcessState};
|
||||
use crate::services::foreground::{ForegroundOwner, ResidentGame, ResidentGameState};
|
||||
use crate::task::{TaskId, TaskState};
|
||||
|
||||
@@ -288,6 +288,21 @@ mod tests {
|
||||
assert_eq!(process_state_for_task(&os, game), ProcessState::Suspended);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lifecycle_exposes_process_kind_for_shell_tasks() {
|
||||
let mut os = SystemOS::new(None);
|
||||
let vm_shell = os.sessions().create_vm_shell_task(7, "Settings");
|
||||
os.lifecycle().close_task(vm_shell).expect("vm shell should close");
|
||||
|
||||
let native_shell = os.sessions().create_native_shell_task(8, "Files");
|
||||
|
||||
assert_eq!(os.lifecycle().process_kind_for_task(vm_shell), Ok(ProcessKind::VmShell));
|
||||
assert_eq!(
|
||||
os.lifecycle().process_kind_for_task(native_shell),
|
||||
Ok(ProcessKind::NativeShell)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn second_foreground_shell_is_rejected() {
|
||||
let mut os = SystemOS::new(None);
|
||||
|
||||
Reference in New Issue
Block a user