From 9ef80be6228743a90e8fefb6c5dff4c195139be5 Mon Sep 17 00:00:00 2001 From: wherewhere Date: Sat, 27 May 2023 00:37:55 +0800 Subject: [PATCH] Add judgment for DumpScreenAsync #55 --- AdvancedSharpAdbClient/AdbClient.Async.cs | 4 +++- AdvancedSharpAdbClient/AdbClient.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/AdvancedSharpAdbClient/AdbClient.Async.cs b/AdvancedSharpAdbClient/AdbClient.Async.cs index 2bf1a99f..a330b02b 100644 --- a/AdvancedSharpAdbClient/AdbClient.Async.cs +++ b/AdvancedSharpAdbClient/AdbClient.Async.cs @@ -696,7 +696,9 @@ public async Task DumpScreenAsync(DeviceData device, CancellationTo string xmlString = await Utilities.Run(reader.ReadToEnd, cancellationToken).ConfigureAwait(false); #endif xmlString = xmlString.Replace("Events injected: 1\r\n", "").Replace("UI hierchary dumped to: /dev/tty", "").Trim(); - if (xmlString != "" && !xmlString.StartsWith("ERROR")) + if (!string.IsNullOrEmpty(xmlString) + && !xmlString.StartsWith("ERROR") + && !xmlString.StartsWith("java.lang.Exception")) { doc.LoadXml(xmlString); return doc; diff --git a/AdvancedSharpAdbClient/AdbClient.cs b/AdvancedSharpAdbClient/AdbClient.cs index 3e20e731..9a4b2f0b 100644 --- a/AdvancedSharpAdbClient/AdbClient.cs +++ b/AdvancedSharpAdbClient/AdbClient.cs @@ -657,7 +657,9 @@ public XmlDocument DumpScreen(DeviceData device) AdbResponse response = socket.ReadAdbResponse(); using StreamReader reader = new(socket.GetShellStream(), Encoding); string xmlString = reader.ReadToEnd().Replace("Events injected: 1\r\n", "").Replace("UI hierchary dumped to: /dev/tty", "").Trim(); - if (xmlString != "" && !xmlString.StartsWith("ERROR")) + if (!string.IsNullOrEmpty(xmlString) + && !xmlString.StartsWith("ERROR") + && !xmlString.StartsWith("java.lang.Exception")) { doc.LoadXml(xmlString); return doc;