diff --git a/experimental/libbox/command_server.go b/experimental/libbox/command_server.go index c75c4ccd..5f62d03d 100644 --- a/experimental/libbox/command_server.go +++ b/experimental/libbox/command_server.go @@ -193,6 +193,9 @@ func (s *CommandServer) Start() error { } func (s *CommandServer) Close() { + if s.endPauseTimer != nil { + s.endPauseTimer.Stop() + } if s.grpcServer != nil { s.grpcServer.Stop() } @@ -264,13 +267,21 @@ func (s *CommandServer) Pause() { instance.PauseManager().DevicePause() if C.IsIos { if s.endPauseTimer == nil { - s.endPauseTimer = time.AfterFunc(time.Minute, instance.PauseManager().DeviceWake) + s.endPauseTimer = time.AfterFunc(time.Minute, s.endDevicePause) } else { s.endPauseTimer.Reset(time.Minute) } } } +func (s *CommandServer) endDevicePause() { + instance := s.StartedService.Instance() + if instance == nil || instance.PauseManager() == nil { + return + } + instance.PauseManager().DeviceWake() +} + func (s *CommandServer) Wake() { recorder := s.powerManager.Recorder() if recorder != nil {