feat: improve desktop path selection and USB connection recovery
This commit is contained in:
1 parent
5aa575f182
commit
6490665af8
28 files changed
+846
-51
No files matched your search
@@ -240,8 +240,23 @@ internal static class Program
|
||||
throw new InvalidOperationException(error.Message + "; state=" + vm.ScreenRunning + "; notice=" + vm.Notice + "; logs=" + string.Join(" | ", vm.Logs.TakeLast(25)));
|
||||
}
|
||||
Require(vm.ScreenRunning, "scrcpy process exited unexpectedly");
|
||||
if(usb && Environment.GetCommandLineArgs().Contains("--recover")) {
|
||||
var connection=vm.Connections.Single(c=>c.DeviceId=="home-phone");
|
||||
var oldPort=connection.Options.UsbPort;
|
||||
var textures=vm.Logs.Count(l=>l.Contains("INFO: Texture"));
|
||||
var field=typeof(DeviceConnection).GetField("client",System.Reflection.BindingFlags.NonPublic|System.Reflection.BindingFlags.Instance)!;
|
||||
var owned=(System.Diagnostics.Process)field.GetValue(connection)!;
|
||||
owned.Kill(entireProcessTree:true);
|
||||
await owned.WaitForExitAsync();
|
||||
await UntilAsync(()=>connection.Options.UsbPort!=oldPort && connection.Ready && connection.ScreenRunning && vm.Logs.Count(l=>l.Contains("INFO: Texture"))>textures,"USB remount and video recovery failed: "+connection.Notice);
|
||||
Console.WriteLine("PASS: client failure automatically remounts USB and restores real scrcpy video");
|
||||
}
|
||||
await vm.StopScrcpyCommand.ExecuteAsync(null);
|
||||
Require(!vm.ScreenRunning, "scrcpy did not stop");
|
||||
if(usb && Environment.GetCommandLineArgs().Contains("--recover")) {
|
||||
await Task.Delay(7000);
|
||||
Require(!vm.ScreenRunning,"Manual stop must cancel automatic video restore");
|
||||
}
|
||||
Console.WriteLine("PASS: GUI starts real scrcpy video stream and stops its process");
|
||||
}
|
||||
await vm.ReconnectCommand.ExecuteAsync(null);
|
||||
|
||||
Reference in new issue
Block a user