Skip to content

Commit

Permalink
Add judgment for DumpScreenAsync #55
Browse files Browse the repository at this point in the history
  • Loading branch information
wherewhere committed May 26, 2023
1 parent 2ca692b commit ee93161
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion AdvancedSharpAdbClient/AdbClient.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,9 @@ public async Task<XmlDocument> 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;
Expand Down
4 changes: 3 additions & 1 deletion AdvancedSharpAdbClient/AdbClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ee93161

Please sign in to comment.