diff --git a/MetaforceInstaller.Core/Services/AdbService.cs b/MetaforceInstaller.Core/Services/AdbService.cs index ddf790f..8ff60f7 100644 --- a/MetaforceInstaller.Core/Services/AdbService.cs +++ b/MetaforceInstaller.Core/Services/AdbService.cs @@ -53,8 +53,6 @@ public class AdbService : IAdbService if (File.Exists(adbPath)) return adbPath; ExtractResource("MetaforceInstaller.Core.adb.adb.exe", adbPath); - ExtractResource("MetaforceInstaller.Core.adb.AdbWinApi.dll", Path.Combine(tempDir, "AdbWinApi.dll")); - ExtractResource("MetaforceInstaller.Core.adb.AdbWinUsbApi.dll", Path.Combine(tempDir, "AdbWinUsbApi.dll")); return adbPath; } diff --git a/MetaforceInstaller.UI/MainWindow.axaml.cs b/MetaforceInstaller.UI/MainWindow.axaml.cs index 6c24f34..66866b9 100644 --- a/MetaforceInstaller.UI/MainWindow.axaml.cs +++ b/MetaforceInstaller.UI/MainWindow.axaml.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Reflection; +using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Platform.Storage; @@ -30,11 +31,8 @@ public partial class MainWindow : Window LogMessage("MetaforceInstaller by slavagm"); VersionTextBlock.Text = Assembly.GetExecutingAssembly() .GetCustomAttribute()?.Version; - - - _adbService = new AdbService(); - _adbService.ProgressChanged += OnAdbProgressChanged; - _adbService.StatusChanged += OnAdbStatusChanged; + + _ = InitializeAdbAsync(); CheckAndEnableInstallButton(); @@ -43,6 +41,19 @@ public partial class MainWindow : Window InstallButton.Click += OnInstallClicked; } + private async Task InitializeAdbAsync() + { + LogMessage("Инициализация ADB сервера..."); + await Task.Run(() => + { + _adbService = new AdbService(); + _adbService.ProgressChanged += OnAdbProgressChanged; + _adbService.StatusChanged += OnAdbStatusChanged; + }); + + LogMessage("ADB сервер готов"); + } + private void OnAdbProgressChanged(object? sender, ProgressInfo e) { Dispatcher.UIThread.InvokeAsync(() => @@ -182,6 +193,12 @@ public partial class MainWindow : Window return; } + if (_adbService == null) + { + LogMessage("ADB сервис еще инициализируется, попробуйте позже"); + return; + } + _adbService.RefreshDeviceData(); InstallButton.IsEnabled = false;