Sync desktop daily logs and fix emulator ADB upstream connections
This commit is contained in:
1 parent
87e1fff59b
commit
0d269f3ded
15 files changed
+139
-12
No files matched your search
@@ -25,7 +25,7 @@
|
|||||||
| `crates/ads-core/` | 共用网络与协议代码,包括 WSS、WebRTC P2P、节点回退、ADB smart socket 和流式转发;源码在 `src/` | Rust、TOML |
|
| `crates/ads-core/` | 共用网络与协议代码,包括 WSS、WebRTC P2P、节点回退、ADB smart socket 和流式转发;源码在 `src/` | Rust、TOML |
|
||||||
| `flutter_manager/` | 独立 Flutter Windows 管理中心,使用 Cupertino UI,提供电脑分组设备、Agent 管理、按天滚动日志、多设备连接、虚拟 USB、托盘与内嵌投屏 | Dart、C++、CMake、YAML、ICO |
|
| `flutter_manager/` | 独立 Flutter Windows 管理中心,使用 Cupertino UI,提供电脑分组设备、Agent 管理、按天滚动日志、多设备连接、虚拟 USB、托盘与内嵌投屏 | Dart、C++、CMake、YAML、ICO |
|
||||||
| `desktop/` | 跨平台桌面客户端及其测试项目、.NET SDK 配置与使用说明 | C#、Avalonia XAML(AXAML)、JSON、Markdown |
|
| `desktop/` | 跨平台桌面客户端及其测试项目、.NET SDK 配置与使用说明 | C#、Avalonia XAML(AXAML)、JSON、Markdown |
|
||||||
| `desktop/Ads.Desktop/` | Avalonia 多设备工作台,管理独立连接、自动端口分配、USB 模拟、多个 scrcpy 窗口及托盘;`Assets/` 保存图标资源 | C#、AXAML、XML(csproj)、PNG |
|
| `desktop/Ads.Desktop/` | Avalonia 多设备工作台,管理独立连接、自动端口分配、USB 模拟、多个 scrcpy 窗口、电脑名、按天滚动日志及托盘;`Assets/` 保存图标资源 | C#、AXAML、XML(csproj)、PNG |
|
||||||
| `desktop/Ads.Desktop.Tests/` | 桌面客户端单元测试 | C#、XML(csproj) |
|
| `desktop/Ads.Desktop.Tests/` | 桌面客户端单元测试 | C#、XML(csproj) |
|
||||||
| `desktop/Ads.Desktop.Smoke/` | 桌面离屏布局、连接及可选真机冒烟验证入口 | C#、XML(csproj) |
|
| `desktop/Ads.Desktop.Smoke/` | 桌面离屏布局、连接及可选真机冒烟验证入口 | C#、XML(csproj) |
|
||||||
| `deploy/` | 服务器/设备端部署脚本与 Caddy、Nginx、systemd、launchd 配置示例 | Shell、服务/代理配置、XML(plist)、Markdown |
|
| `deploy/` | 服务器/设备端部署脚本与 Caddy、Nginx、systemd、launchd 配置示例 | Shell、服务/代理配置、XML(plist)、Markdown |
|
||||||
|
|||||||
@@ -231,3 +231,5 @@ Linux 安装包:`bash scripts/build-linux-packages.sh`,提供 `.deb` 和 `.t
|
|||||||
Linux 原生虚拟 USB 已在 Ubuntu 实机通过 CLI 验证,部署和权限说明见 [Linux USB](docs/linux-usb.md)。Avalonia Linux GUI 已接入 pkexec 挂载,Flutter Linux 尚未接入。
|
Linux 原生虚拟 USB 已在 Ubuntu 实机通过 CLI 验证,部署和权限说明见 [Linux USB](docs/linux-usb.md)。Avalonia Linux GUI 已接入 pkexec 挂载,Flutter Linux 尚未接入。
|
||||||
|
|
||||||
Flutter 管理中心已迁移 Cupertino UI,设备按电脑归属分组,支持按电脑名搜索;运行日志按天保存并按大小滚动,路径及策略见 [Flutter 使用说明](flutter_manager/README.md)。
|
Flutter 管理中心已迁移 Cupertino UI,设备按电脑归属分组,支持按电脑名搜索;运行日志按天保存并按大小滚动,路径及策略见 [Flutter 使用说明](flutter_manager/README.md)。
|
||||||
|
|
||||||
|
桌面日志界面提供“打开日志文件夹”。Avalonia 与 Flutter 均按天保存日志,单文件达到 5 MiB 后滚动,每日最多 5 份,保留最近 14 天。设备列表显示所属电脑及 Agent。Windows 安装包默认安装到 `%LOCALAPPDATA%/Programs/TongTongStudio/ADS-{Edition}`;用户配置和日志位置保持兼容。升级保持原 AppId,安装目录不再自动沿用旧的 TTSTD 路径。
|
||||||
@@ -94,7 +94,7 @@ async fn online(args: Arc<Gateway>, health: &Option<WorkerHealth>) -> Result<()>
|
|||||||
tasks.spawn(async move {
|
tasks.spawn(async move {
|
||||||
let device=args.device.clone();
|
let device=args.device.clone();
|
||||||
if let Err(error) = serve_session(args, session, signal_key).await {
|
if let Err(error) = serve_session(args, session, signal_key).await {
|
||||||
if let Some(health)=health {health.lock().unwrap_or_else(|e|e.into_inner()).last_error=Some(error.to_string());}
|
if let Some(health)=health {health.lock().unwrap_or_else(|e|e.into_inner()).last_error=Some(format!("{error:#}"));}
|
||||||
warn!(%device,%error, "device stream ended");
|
warn!(%device,%error, "device stream ended");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -113,7 +113,7 @@ pub async fn run(args: Arc<Gateway>, health: Option<WorkerHealth>) {
|
|||||||
if let Some(health) = &health {
|
if let Some(health) = &health {
|
||||||
let mut state = health.lock().unwrap_or_else(|e| e.into_inner());
|
let mut state = health.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
state.connected = false;
|
state.connected = false;
|
||||||
state.last_error = Some(error.to_string());
|
state.last_error = Some(format!("{error:#}"));
|
||||||
}
|
}
|
||||||
warn!(device=%args.device,%error, "gateway offline; reconnecting");
|
warn!(device=%args.device,%error, "gateway offline; reconnecting");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,8 +243,24 @@ async fn adb_request(stream: &mut TcpStream, service: &str) -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Requires TCP adbd on the phone, even when selecting a USB transport.
|
/// Uses host-side adbd for emulators; other transports require TCP adbd on the phone.
|
||||||
pub async fn adb_tcp_connect(server: &str, serial: &str, port: u16) -> Result<TcpStream> {
|
pub async fn adb_tcp_connect(server: &str, serial: &str, port: u16) -> Result<TcpStream> {
|
||||||
|
// Emulator console serials identify a host-side raw adbd socket, not a
|
||||||
|
// device-internal TCP adbd listener. No tcpip restart is needed.
|
||||||
|
if let Some(console) = serial
|
||||||
|
.strip_prefix("emulator-")
|
||||||
|
.and_then(|v| v.parse::<u16>().ok())
|
||||||
|
{
|
||||||
|
if console >= 1024 && console % 2 == 0 {
|
||||||
|
let host = server
|
||||||
|
.rsplit_once(':')
|
||||||
|
.context("ADB server requires host:port")?
|
||||||
|
.0;
|
||||||
|
return tcp_connect(&format!("{host}:{}", console + 1))
|
||||||
|
.await
|
||||||
|
.context("cannot reach emulator host adbd");
|
||||||
|
}
|
||||||
|
}
|
||||||
let mut stream = tcp_connect(server).await?;
|
let mut stream = tcp_connect(server).await?;
|
||||||
timeout(CONNECT_TIMEOUT, async {
|
timeout(CONNECT_TIMEOUT, async {
|
||||||
adb_request(&mut stream, &format!("host:transport:{serial}")).await?;
|
adb_request(&mut stream, &format!("host:transport:{serial}")).await?;
|
||||||
@@ -268,6 +284,26 @@ pub fn init_logging() {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn emulator_uses_host_adbd_socket() {
|
||||||
|
let listener = loop {
|
||||||
|
let socket = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||||
|
if socket.local_addr().unwrap().port() % 2 == 1 {
|
||||||
|
break socket;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let serial = format!("emulator-{}", listener.local_addr().unwrap().port() - 1);
|
||||||
|
let peer = tokio::spawn(async move {
|
||||||
|
let (mut stream, _) = listener.accept().await.unwrap();
|
||||||
|
stream.write_all(b"raw-adbd").await.unwrap();
|
||||||
|
});
|
||||||
|
let mut stream = adb_tcp_connect("127.0.0.1:1", &serial, 5555).await.unwrap();
|
||||||
|
let mut bytes = [0; 8];
|
||||||
|
stream.read_exact(&mut bytes).await.unwrap();
|
||||||
|
assert_eq!(&bytes, b"raw-adbd");
|
||||||
|
peer.await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rejects_unsafe_configuration() {
|
fn rejects_unsafe_configuration() {
|
||||||
let network = NetworkArgs {
|
let network = NetworkArgs {
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ AppId=TTSTD.ADS.{#Edition}
|
|||||||
AppName=ADS {#Edition}
|
AppName=ADS {#Edition}
|
||||||
AppVersion={#Version}
|
AppVersion={#Version}
|
||||||
AppPublisher=TongTong Studio
|
AppPublisher=TongTong Studio
|
||||||
DefaultDirName={localappdata}\Programs\TTSTD\ADS-{#Edition}
|
DefaultDirName={localappdata}\Programs\TongTongStudio\ADS-{#Edition}
|
||||||
|
UsePreviousAppDir=no
|
||||||
DefaultGroupName=ADS {#Edition}
|
DefaultGroupName=ADS {#Edition}
|
||||||
PrivilegesRequired=lowest
|
PrivilegesRequired=lowest
|
||||||
ArchitecturesAllowed=x64compatible
|
ArchitecturesAllowed=x64compatible
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using Ads.Desktop;
|
||||||
|
using Xunit;
|
||||||
|
namespace Ads.Desktop.Tests;
|
||||||
|
public class DailyLogTests {
|
||||||
|
[Fact] public void PersistsAndCleansOnlyOwnedExpiredLogs() {
|
||||||
|
var folder=Path.Combine(Path.GetTempPath(),Guid.NewGuid().ToString());
|
||||||
|
Directory.CreateDirectory(folder);
|
||||||
|
try {
|
||||||
|
File.WriteAllText(Path.Combine(folder,"ads-2000-01-01.1.log"),"old");
|
||||||
|
File.WriteAllText(Path.Combine(folder,"ads-2000-01-01-custom.log"),"keep");
|
||||||
|
new DailyLog(folder).Write("connection diagnostic");
|
||||||
|
Assert.False(File.Exists(Path.Combine(folder,"ads-2000-01-01.1.log")));
|
||||||
|
Assert.True(File.Exists(Path.Combine(folder,"ads-2000-01-01-custom.log")));
|
||||||
|
Assert.Contains("connection diagnostic",File.ReadAllText(Path.Combine(folder,$"ads-{DateTime.Now:yyyy-MM-dd}.log")));
|
||||||
|
} finally { Directory.Delete(folder,true); }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using System.Text;
|
||||||
|
namespace Ads.Desktop;
|
||||||
|
public sealed class DailyLog
|
||||||
|
{
|
||||||
|
readonly string folder; readonly object gate = new(); DateTime cleanedDate;
|
||||||
|
public string Folder => folder;
|
||||||
|
public DailyLog(string path) => folder = path;
|
||||||
|
public void Write(string message)
|
||||||
|
{
|
||||||
|
lock (gate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(folder); var now = DateTime.Now; var name = $"ads-{now:yyyy-MM-dd}";
|
||||||
|
if (cleanedDate != now.Date)
|
||||||
|
{
|
||||||
|
foreach (var file in Directory.EnumerateFiles(folder, "ads-*.log"))
|
||||||
|
{
|
||||||
|
var text = Path.GetFileName(file);
|
||||||
|
if (System.Text.RegularExpressions.Regex.IsMatch(text, @"^ads-\d{4}-\d{2}-\d{2}(\.[1-4])?\.log$") && DateTime.TryParseExact(text.Substring(4, 10), "yyyy-MM-dd", null, System.Globalization.DateTimeStyles.None, out var date) && date < now.Date.AddDays(-13)) File.Delete(file);
|
||||||
|
}
|
||||||
|
cleanedDate = now.Date;
|
||||||
|
}
|
||||||
|
var path = Path.Combine(folder, name + ".log");
|
||||||
|
if (File.Exists(path) && new FileInfo(path).Length >= 5 * 1024 * 1024)
|
||||||
|
{
|
||||||
|
var oldest = Path.Combine(folder, name + ".4.log"); if (File.Exists(oldest)) File.Delete(oldest);
|
||||||
|
for (var i = 3; i >= 1; i--) { var old = Path.Combine(folder, $"{name}.{i}.log"); if (File.Exists(old)) File.Move(old, Path.Combine(folder, $"{name}.{i + 1}.log")); }
|
||||||
|
File.Move(path, Path.Combine(folder, name + ".1.log"));
|
||||||
|
}
|
||||||
|
if (message.Length > 16384) message = message[..16384] + " [truncated]";
|
||||||
|
File.AppendAllText(path, $"{now:O} {message}\n", Encoding.UTF8);
|
||||||
|
}
|
||||||
|
catch (IOException) { }
|
||||||
|
catch (UnauthorizedAccessException) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,8 +8,9 @@ using CommunityToolkit.Mvvm.Input;
|
|||||||
|
|
||||||
namespace Ads.Desktop;
|
namespace Ads.Desktop;
|
||||||
|
|
||||||
public sealed record DeviceItem(string Id, bool Busy, bool IsLocal, bool Online = true, string LocalSummary = "")
|
public sealed record DeviceItem(string Id, bool Busy, bool IsLocal, bool Online = true, string LocalSummary = "", string ComputerName="", string AgentId="")
|
||||||
{
|
{
|
||||||
|
public string ComputerLabel => "电脑:"+(ComputerName.Length==0?"未上报电脑名":ComputerName)+(AgentId.Length==0?"":" · "+AgentId);
|
||||||
public string Description => IsLocal ? "本机 · " + LocalSummary : !Online ? "远程暂时离线" : Busy ? "在线 · 其他客户端使用中" : "在线 · 可连接";
|
public string Description => IsLocal ? "本机 · " + LocalSummary : !Online ? "远程暂时离线" : Busy ? "在线 · 其他客户端使用中" : "在线 · 可连接";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,9 +144,13 @@ public partial class MainViewModel : ObservableObject, IDisposable
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DailyLog? dailyLog;
|
||||||
|
public string LogFolder => Path.Combine(folder,"logs");
|
||||||
|
[RelayCommand] private void OpenLogFolder(){try{Directory.CreateDirectory(LogFolder);Process.Start(new ProcessStartInfo(LogFolder){UseShellExecute=true});}catch(Exception error){Report(error);}}
|
||||||
private void Log(string message)
|
private void Log(string message)
|
||||||
{
|
{
|
||||||
var line = $"{DateTime.Now:HH:mm:ss} {Redact(message)}";
|
var safe=Redact(message);(dailyLog ??= new DailyLog(LogFolder)).Write(safe);
|
||||||
|
var line = $"{DateTime.Now:HH:mm:ss} {safe}";
|
||||||
void Append() { if (disposed) return; Logs.Add(line); while (Logs.Count > 1000) Logs.RemoveAt(0); }
|
void Append() { if (disposed) return; Logs.Add(line); while (Logs.Count > 1000) Logs.RemoveAt(0); }
|
||||||
if (Dispatcher.UIThread.CheckAccess()) Append(); else Dispatcher.UIThread.Post(Append);
|
if (Dispatcher.UIThread.CheckAccess()) Append(); else Dispatcher.UIThread.Post(Append);
|
||||||
}
|
}
|
||||||
@@ -202,7 +207,7 @@ public partial class MainViewModel : ObservableObject, IDisposable
|
|||||||
Devices.Clear();
|
Devices.Clear();
|
||||||
foreach (var row in rows) {
|
foreach (var row in rows) {
|
||||||
var connection = sessions.GetValueOrDefault(row.Id);
|
var connection = sessions.GetValueOrDefault(row.Id);
|
||||||
Devices.Add(new DeviceItem(row.Id, row.Busy || connection?.HasConnection == true, connection?.HasConnection == true, true, connection?.Status ?? ""));
|
Devices.Add(new DeviceItem(row.Id, row.Busy || connection?.HasConnection == true, connection?.HasConnection == true, true, connection?.Status ?? "",row.ComputerName,row.AgentId));
|
||||||
}
|
}
|
||||||
foreach (var local in Connections.Where(c => rows.All(r => r.Id != c.DeviceId)))
|
foreach (var local in Connections.Where(c => rows.All(r => r.Id != c.DeviceId)))
|
||||||
Devices.Add(new DeviceItem(local.DeviceId, true, true, false, local.Status));
|
Devices.Add(new DeviceItem(local.DeviceId, true, true, false, local.Status));
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<TextBlock Text="连接远程手机,在本机调试与控制" Classes="label"/>
|
<TextBlock Text="连接远程手机,在本机调试与控制" Classes="label"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Spacing="8">
|
<StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Spacing="8">
|
||||||
|
<Border Height="3" HorizontalAlignment="Stretch"><ProgressBar IsIndeterminate="True" IsVisible="{Binding IsRefreshing}" Height="3"/></Border>
|
||||||
<TextBlock x:Name="RelayStatusText" Text="{Binding RelayStatus}" HorizontalAlignment="Right" Foreground="#66D9C0"/>
|
<TextBlock x:Name="RelayStatusText" Text="{Binding RelayStatus}" HorizontalAlignment="Right" Foreground="#66D9C0"/>
|
||||||
<StackPanel Orientation="Horizontal"><Button x:Name="RefreshButton" Content="刷新设备" Command="{Binding RefreshCommand}"/><Button Content="保存配置" Command="{Binding SaveCommand}"/></StackPanel>
|
<StackPanel Orientation="Horizontal"><Button x:Name="RefreshButton" Content="刷新设备" Command="{Binding RefreshCommand}"/><Button Content="保存配置" Command="{Binding SaveCommand}"/></StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
<Grid RowDefinitions="Auto,*,Auto,Auto,Auto">
|
<Grid RowDefinitions="Auto,*,Auto,Auto,Auto">
|
||||||
<TextBlock Text="在线设备" Classes="section"/>
|
<TextBlock Text="在线设备" Classes="section"/>
|
||||||
<ListBox x:Name="DeviceList" Grid.Row="1" ItemsSource="{Binding Devices}" SelectedItem="{Binding SelectedDevice}" Margin="0,14,0,12" Background="Transparent">
|
<ListBox x:Name="DeviceList" Grid.Row="1" ItemsSource="{Binding Devices}" SelectedItem="{Binding SelectedDevice}" Margin="0,14,0,12" Background="Transparent">
|
||||||
<ListBox.ItemTemplate><DataTemplate><StackPanel Margin="5,10" Spacing="6"><TextBlock Text="{Binding Id}" FontSize="17" TextWrapping="Wrap"/><TextBlock Text="{Binding Description}" Classes="label" TextWrapping="Wrap"/></StackPanel></DataTemplate></ListBox.ItemTemplate>
|
<ListBox.ItemTemplate><DataTemplate><StackPanel Margin="5,10" Spacing="6"><TextBlock Text="{Binding Id}" FontSize="17" TextWrapping="Wrap"/><TextBlock Text="{Binding ComputerLabel}" Classes="label" TextWrapping="Wrap"/><TextBlock Text="{Binding Description}" Classes="label" TextWrapping="Wrap"/></StackPanel></DataTemplate></ListBox.ItemTemplate>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
<TextBlock Grid.Row="2" Text="{Binding ConnectionSummary}" Foreground="#66D9C0" Margin="0,0,0,8" TextWrapping="Wrap"/>
|
<TextBlock Grid.Row="2" Text="{Binding ConnectionSummary}" Foreground="#66D9C0" Margin="0,0,0,8" TextWrapping="Wrap"/>
|
||||||
<TextBlock Grid.Row="3" Text="{Binding DeviceSummary}" Classes="label" TextWrapping="Wrap"/>
|
<TextBlock Grid.Row="3" Text="{Binding DeviceSummary}" Classes="label" TextWrapping="Wrap"/>
|
||||||
@@ -146,7 +147,7 @@
|
|||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="运行日志">
|
<TabItem Header="运行日志">
|
||||||
<Grid RowDefinitions="Auto,*" Margin="0,16,0,0">
|
<Grid RowDefinitions="Auto,*" Margin="0,16,0,0">
|
||||||
<StackPanel Orientation="Horizontal"><Button Content="清空日志" Command="{Binding ClearLogsCommand}"/><Button Content="导出日志" Command="{Binding ExportLogsCommand}"/></StackPanel>
|
<StackPanel Orientation="Horizontal"><Button Content="打开日志文件夹" Command="{Binding OpenLogFolderCommand}"/><Button Content="清空日志" Command="{Binding ClearLogsCommand}"/><Button Content="导出日志" Command="{Binding ExportLogsCommand}"/></StackPanel>
|
||||||
<ListBox Grid.Row="1" ItemsSource="{Binding Logs}" Margin="0,8,0,0" FontFamily="Cascadia Mono,Consolas" FontSize="12"><ListBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding}" TextWrapping="Wrap"/></DataTemplate></ListBox.ItemTemplate></ListBox>
|
<ListBox Grid.Row="1" ItemsSource="{Binding Logs}" Margin="0,8,0,0" FontFamily="Cascadia Mono,Consolas" FontSize="12"><ListBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding}" TextWrapping="Wrap"/></DataTemplate></ListBox.ItemTemplate></ListBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public sealed record RelayOptions(Uri BaseUri, string Origin, string Token)
|
|||||||
}.Uri;
|
}.Uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed record RelayDevice(string Id, bool Busy);
|
public sealed record RelayDevice(string Id, bool Busy, [property:System.Text.Json.Serialization.JsonPropertyName("agent_id")] string AgentId="", [property:System.Text.Json.Serialization.JsonPropertyName("computer_name")] string ComputerName="");
|
||||||
|
|
||||||
public sealed record RelayNode(string Id, bool Healthy, int Sessions, int Capacity)
|
public sealed record RelayNode(string Id, bool Healthy, int Sessions, int Capacity)
|
||||||
{
|
{
|
||||||
@@ -111,6 +111,6 @@ public static class RelayApi
|
|||||||
if (devices.Any(d => string.IsNullOrWhiteSpace(d.Id) || d.Id.Length > 128 ||
|
if (devices.Any(d => string.IsNullOrWhiteSpace(d.Id) || d.Id.Length > 128 ||
|
||||||
d.Id.Any(c => !char.IsAsciiLetterOrDigit(c) && c != '-' && c != '_' && c != '.')))
|
d.Id.Any(c => !char.IsAsciiLetterOrDigit(c) && c != '-' && c != '_' && c != '.')))
|
||||||
throw new InvalidOperationException("中继返回了无效的设备 ID。");
|
throw new InvalidOperationException("中继返回了无效的设备 ID。");
|
||||||
return devices.OrderBy(d => d.Id, StringComparer.Ordinal).ToArray();
|
return devices.OrderBy(d => d.ComputerName, StringComparer.OrdinalIgnoreCase).ThenBy(d => d.AgentId, StringComparer.Ordinal).ThenBy(d => d.Id, StringComparer.Ordinal).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,3 +92,5 @@ USB 连续缺失 3 轮、USB 后端退出或投屏报告设备断开后,自动
|
|||||||
USB 会话后端已按操作系统选择:Windows 使用已签名 USBip 控制器,Linux 使用系统 usbip/vhci_hcd,挂载时通过 pkexec 请求桌面授权。转发和 ads-usb 仍以当前用户运行,断开时关闭本次导出,避免按可能复用的控制器端口误断其他设备。Linux 需安装 usbip、polkit、ADB 和兼容版本 scrcpy;首次授权需在手机确认。
|
USB 会话后端已按操作系统选择:Windows 使用已签名 USBip 控制器,Linux 使用系统 usbip/vhci_hcd,挂载时通过 pkexec 请求桌面授权。转发和 ads-usb 仍以当前用户运行,断开时关闭本次导出,避免按可能复用的控制器端口误断其他设备。Linux 需安装 usbip、polkit、ADB 和兼容版本 scrcpy;首次授权需在手机确认。
|
||||||
|
|
||||||
192.168.5.224 工程位于 `/home/tt/TongTongStudio/AndroidDeviceStreaming`,自包含发行目录为 `bin/desktop-linux-x64/`。已在 TT 的 X11 会话启动成功;已有 .NET 8.0.16 runtime 和 SDK 8.0.409 位于 `/home/tt/.dotnet`,SSH PATH 未包含此目录。工程要求 SDK 8.0.428,远程源码构建尚需安装该版本;自包含发行版无需安装 runtime。
|
192.168.5.224 工程位于 `/home/tt/TongTongStudio/AndroidDeviceStreaming`,自包含发行目录为 `bin/desktop-linux-x64/`。已在 TT 的 X11 会话启动成功;已有 .NET 8.0.16 runtime 和 SDK 8.0.409 位于 `/home/tt/.dotnet`,SSH PATH 未包含此目录。工程要求 SDK 8.0.428,远程源码构建尚需安装该版本;自包含发行版无需安装 runtime。
|
||||||
|
|
||||||
|
桌面日志界面提供“打开日志文件夹”。Avalonia 与 Flutter 均按天保存日志,单文件达到 5 MiB 后滚动,每日最多 5 份,保留最近 14 天。设备列表显示所属电脑及 Agent。Windows 安装包默认安装到 `%LOCALAPPDATA%/Programs/TongTongStudio/ADS-{Edition}`;用户配置和日志位置保持兼容。升级保持原 AppId,安装目录不再自动沿用旧的 TTSTD 路径。
|
||||||
@@ -55,3 +55,11 @@ Port cleanup follow-up:
|
|||||||
- Cleanup rechecks port ownership and process creation time, terminates only the matching process (not its entire process tree), verifies the port can be bound, and removes the corresponding local ADB endpoint.
|
- Cleanup rechecks port ownership and process creation time, terminates only the matching process (not its entire process tree), verifies the port can be bound, and removes the corresponding local ADB endpoint.
|
||||||
- Fifteen .NET tests passed, including actual disposable listener-process termination, unrelated-process survival, stale identity rejection, and protection for the current process / ADB main-service port.
|
- Fifteen .NET tests passed, including actual disposable listener-process termination, unrelated-process survival, stale identity rejection, and protection for the current process / ADB main-service port.
|
||||||
- Avalonia headless test invoked the new command against a real child listener and verified both process exit and port release. Temporary listener children were cleaned up after testing.
|
- Avalonia headless test invoked the new command against a real child listener and verified both process exit and port release. Temporary listener children were cleaned up after testing.
|
||||||
|
|
||||||
|
### 2026-11-13:模拟器离线修复与桌面日志同步
|
||||||
|
|
||||||
|
- Flutter 本地滚动日志中 `phone-006f8b2ae57e` 持续掉线;远端 Agent 对 emulator-5556/5558 报 `cannot reach phone adbd`。三个模拟器的主机 5555/5557/5559 端口均可返回 ADB CNXN。
|
||||||
|
- `ads-core` 对 `emulator-N` 改用同一 ADB 主机的 N+1 原始 adbd 端口;实体手机继续原有 smart socket 选定 transport 后连接内部 TCP adbd。错误状态保存完整错误链。
|
||||||
|
- 修复后的 Agent 已部署 Ubuntu-224,备份保留在原二进制旁。`phone-a9bbc18df94c` 通过公网 relay-1 被本地 ADB 识别并执行 shell;原离线虚拟 USB `ADS-phone-006f8b2ae57e` 已恢复 device,shell getprop ro.product.model 成功。临时网络 ADB 测试连接已断开。
|
||||||
|
- Rust ads-core 6 项测试、Avalonia 22 项测试、Flutter 27 项测试通过,Flutter analyze 无问题。
|
||||||
|
- 两桌面端新增打开日志目录;Avalonia 同步电脑名、电脑排序、固定高度刷新指示与按天滚动日志。安装位置采用 TongTongStudio,保留既有私有配置和日志路径。
|
||||||
@@ -133,3 +133,5 @@ USB ADB 连续 3 轮监控缺失(约 9 秒)、USB 后端退出或 scrcpy 以
|
|||||||
运行日志保存到 `%LOCALAPPDATA%/TTSTD/ADS-Flutter/logs/ads-YYYY-MM-DD.log`。单文件达到约 5 MiB 后滚动,每天最多 5 份(含当天主文件),保留 14 天;应用关闭前等待写入完成。已加载令牌在内存和磁盘日志中均脱敏,单条磁盘日志最多 16384 字符。包括客户端/USB/scrcpy 子进程日志、Agent 管理操作错误,以及主动读取/跟随的 Agent 日志。日志页显示实际路径和写入错误。文件中可能包含设备地址、路径等诊断信息,分享前按需检查。
|
运行日志保存到 `%LOCALAPPDATA%/TTSTD/ADS-Flutter/logs/ads-YYYY-MM-DD.log`。单文件达到约 5 MiB 后滚动,每天最多 5 份(含当天主文件),保留 14 天;应用关闭前等待写入完成。已加载令牌在内存和磁盘日志中均脱敏,单条磁盘日志最多 16384 字符。包括客户端/USB/scrcpy 子进程日志、Agent 管理操作错误,以及主动读取/跟随的 Agent 日志。日志页显示实际路径和写入错误。文件中可能包含设备地址、路径等诊断信息,分享前按需检查。
|
||||||
|
|
||||||
工作台和 Agent 页的刷新指示器使用固定高度占位。Agent 发现列表保留到切换主机;旧后端不支持 devices_discover 时提示同步更新 CLI 和 Agent。`test/daily_log_test.dart` 验证跨天、大小滚动、保留及脱敏,`test/cupertino_layout_test.dart` 验证电脑名和刷新布局不移位。
|
工作台和 Agent 页的刷新指示器使用固定高度占位。Agent 发现列表保留到切换主机;旧后端不支持 devices_discover 时提示同步更新 CLI 和 Agent。`test/daily_log_test.dart` 验证跨天、大小滚动、保留及脱敏,`test/cupertino_layout_test.dart` 验证电脑名和刷新布局不移位。
|
||||||
|
|
||||||
|
桌面日志界面提供“打开日志文件夹”。Avalonia 与 Flutter 均按天保存日志,单文件达到 5 MiB 后滚动,每日最多 5 份,保留最近 14 天。设备列表显示所属电脑及 Agent。Windows 安装包默认安装到 `%LOCALAPPDATA%/Programs/TongTongStudio/ADS-{Edition}`;用户配置和日志位置保持兼容。升级保持原 AppId,安装目录不再自动沿用旧的 TTSTD 路径。
|
||||||
@@ -35,6 +35,17 @@ class ManagerModel extends ChangeNotifier {
|
|||||||
List<Map<String, dynamic>> nodes = [];
|
List<Map<String, dynamic>> nodes = [];
|
||||||
final List<String> logs = [];
|
final List<String> logs = [];
|
||||||
late final DailyLog diskLog;
|
late final DailyLog diskLog;
|
||||||
|
Future<void> openLogDirectory() => action(() async {
|
||||||
|
await diskLog.directory.create(recursive: true);
|
||||||
|
final command = Platform.isWindows
|
||||||
|
? 'explorer.exe'
|
||||||
|
: Platform.isMacOS
|
||||||
|
? 'open'
|
||||||
|
: 'xdg-open';
|
||||||
|
await Process.start(command, [
|
||||||
|
logDirectory,
|
||||||
|
], mode: ProcessStartMode.detached);
|
||||||
|
});
|
||||||
String get logDirectory => diskLog.directory.path;
|
String get logDirectory => diskLog.directory.path;
|
||||||
final Set<String> pending = {};
|
final Set<String> pending = {};
|
||||||
String notice = '正在初始化', adbListing = '';
|
String notice = '正在初始化', adbListing = '';
|
||||||
|
|||||||
@@ -562,6 +562,10 @@ class _ManagerViewState extends State<ManagerView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
TextButton(
|
||||||
|
onPressed: m.openLogDirectory,
|
||||||
|
child: const Text('打开日志文件夹'),
|
||||||
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
Clipboard.setData(ClipboardData(text: m.logs.join('\n'))),
|
Clipboard.setData(ClipboardData(text: m.logs.join('\n'))),
|
||||||
|
|||||||
Reference in new issue
Block a user