feat: support Linux virtual USB in Avalonia desktop
This commit is contained in:
1 parent
ac8eb72319
commit
de6ecae54f
8 files changed
+42
-12
No files matched your search
@@ -34,7 +34,7 @@ public partial class DeviceConnection : ObservableObject, IDisposable
|
||||
private int missingUsbPolls, recoveryAttempts, stablePolls;
|
||||
private DateTime nextRecovery=DateTime.MinValue;
|
||||
private CancellationTokenSource? recoveryCancellation;
|
||||
private WindowsUsbSession? usb;
|
||||
private UsbSession? usb;
|
||||
private string? transportFile, leaseFile;
|
||||
private readonly Action<string> log;
|
||||
private readonly SemaphoreSlim gate = new(1, 1);
|
||||
@@ -73,7 +73,7 @@ public partial class DeviceConnection : ObservableObject, IDisposable
|
||||
Model = AndroidVersion = ApiLevel = "—";
|
||||
log($"连接已启动,隧道 {RawEndpoint}。");
|
||||
if (Options.UsbMode) {
|
||||
usb = new WindowsUsbSession(DeviceId);
|
||||
usb = new UsbSession(DeviceId);
|
||||
await usb.StartAsync(Options.Usbip, Options.UsbPort!.Value, RawEndpoint, leaseFile!, log, lifetime.Token);
|
||||
Endpoint = usb.Serial;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public partial class DeviceConnection : ObservableObject, IDisposable
|
||||
}
|
||||
var newPort=ConnectionPorts.Allocate(Options.UsbPort is >=65535 ?3240:Options.UsbPort!.Value+1,new[]{Options.Port,ScreenPort??0});
|
||||
Options=Options with {UsbPort=newPort};OnPropertyChanged(nameof(PortSummary));
|
||||
usb=new WindowsUsbSession(DeviceId);
|
||||
usb=new UsbSession(DeviceId);
|
||||
await usb.StartAsync(Options.Usbip,newPort,RawEndpoint,leaseFile!,log,cancellation);
|
||||
Endpoint=usb.Serial;usbBroken=false;Status="USB 已重新挂载 · 等待 ADB 就绪";
|
||||
} catch(OperationCanceledException) when(cancellation.IsCancellationRequested) { }
|
||||
|
||||
Reference in new issue
Block a user