Skip to content

Commit 4f4e093

Browse files
committed
Add LogReader
1 parent 2670cf1 commit 4f4e093

5 files changed

Lines changed: 49 additions & 16 deletions

File tree

AdvancedSharpAdbClient.WinRT.Tests/AdvancedSharpAdbClient.WinRT.Tests.exe.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3-
<assemblyIdentity version="1.0.0.0" name="CppConsoleApp"/>
3+
<assemblyIdentity version="1.0.0.0" name="AdvancedSharpAdbClient.WinRT.Tests"/>
44
<file name="WinRT.Host.dll">
55
<activatableClass
66
name="AdvancedSharpAdbClient.WinRT.AdbClient"

AdvancedSharpAdbClient.WinRT/AdvancedSharpAdbClient.WinRT.csproj

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,34 @@
22

33
<PropertyGroup>
44
<FullTargets>True</FullTargets>
5-
<OutputPathRoot Condition="'$(Platform)' == 'AnyCPU'">bin\$(Configuration)\</OutputPathRoot>
6-
<OutputPathRoot Condition="'$(Platform)' != 'AnyCPU'">bin\$(Platform)\$(Configuration)\</OutputPathRoot>
75
</PropertyGroup>
86

97
<PropertyGroup Condition="'$(FullTargets)' == 'true'">
108
<NoWarn>NU1603;NU5100</NoWarn>
9+
<OutputPathRoot Condition="'$(Platform)' == 'AnyCPU'">bin\$(Configuration)\</OutputPathRoot>
10+
<OutputPathRoot Condition="'$(Platform)' != 'AnyCPU'">bin\$(Platform)\$(Configuration)\</OutputPathRoot>
1111
<TargetFrameworks>uap10.0;net6.0-windows10.0.17763.0</TargetFrameworks>
1212
</PropertyGroup>
1313

1414
<PropertyGroup Condition="'$(FullTargets)' != 'true'">
1515
<TargetFramework>net6.0-windows10.0.17763.0</TargetFramework>
1616
</PropertyGroup>
1717

18-
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0-windows10.0.17763.0'">
19-
<CsWinRTComponent>true</CsWinRTComponent>
20-
<CsWinRTWindowsMetadata>10.0.22621.0</CsWinRTWindowsMetadata>
21-
<Platforms>x64;x86;ARM64;ARM</Platforms>
22-
</PropertyGroup>
23-
24-
<PropertyGroup Condition="'$(TargetFramework)' != 'net6.0-windows10.0.17763.0'">
18+
<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0'">
2519
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
2620
<DebugType>Full</DebugType>
21+
<NoWarn>CS0419</NoWarn>
2722
<OutputType>winmdobj</OutputType>
2823
<Platforms>AnyCPU;x64;x86;ARM64;ARM</Platforms>
2924
</PropertyGroup>
3025

26+
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0-windows10.0.17763.0'">
27+
<CsWinRTComponent>true</CsWinRTComponent>
28+
<CsWinRTWindowsMetadata>10.0.22621.0</CsWinRTWindowsMetadata>
29+
<NoWarn>CS1591</NoWarn>
30+
<Platforms>x64;x86;ARM64;ARM</Platforms>
31+
</PropertyGroup>
32+
3133
<ItemGroup>
3234
<PackageReference Include="AdvancedSharpAdbClient" Version="2.5.7" />
3335
</ItemGroup>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// <copyright file="LogReader.cs" company="The Android Open Source Project, Ryan Conrad, Quamotion, yungd1plomat, wherewhere">
2+
// Copyright (c) The Android Open Source Project, Ryan Conrad, Quamotion, yungd1plomat, wherewhere. All rights reserved.
3+
// </copyright>
4+
5+
using System.IO;
6+
using System.Runtime.InteropServices.WindowsRuntime;
7+
using Windows.Foundation;
8+
using Windows.Storage.Streams;
9+
10+
namespace AdvancedSharpAdbClient.WinRT.Logs
11+
{
12+
/// <summary>
13+
/// Processes Android log files in binary format. You usually get the binary format by running <c>logcat -B</c>.
14+
/// </summary>
15+
public sealed class LogReader
16+
{
17+
internal readonly AdvancedSharpAdbClient.Logs.LogReader logReader;
18+
19+
/// <summary>
20+
/// Initializes a new instance of the <see cref="LogReader"/> class.
21+
/// </summary>
22+
/// <param name="stream">A <see cref="IRandomAccessStream"/> that contains the logcat data.</param>
23+
public LogReader(IRandomAccessStream stream) => logReader = new(stream.AsStream());
24+
25+
/// <summary>
26+
/// Reads the next <see cref="ILogEntry"/> from the stream.
27+
/// </summary>
28+
/// <returns>A new <see cref="ILogEntry"/> object.</returns>
29+
public ILogEntry ReadEntry() => LogEntry.GetLogEntry(logReader.ReadEntry());
30+
31+
/// <summary>
32+
/// Reads the next <see cref="ILogEntry"/> from the stream.
33+
/// </summary>
34+
/// <returns>A <see cref="IAsyncOperation{ILogEntry}"/> which return a new <see cref="ILogEntry"/> object.</returns>
35+
public IAsyncOperation<ILogEntry> ReadEntryAsync() => AsyncInfo.Run(async (cancellationToken) => LogEntry.GetLogEntry(await logReader.ReadEntryAsync(cancellationToken)));
36+
}
37+
}

AdvancedSharpAdbClient.WinRT/Models/Area.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public sealed class Area
2929
/// <param name="height">The height of the area.</param>
3030
public Area(int x, int y, int width, int height) => area = new(x, y, width, height);
3131

32-
#pragma warning disable CS0419 // cref 特性中有不明确的引用
3332
/// <summary>
3433
/// Initializes a new instance of the <see cref='Area'/> class with the specified rectangle.
3534
/// </summary>
@@ -42,7 +41,6 @@ public sealed class Area
4241
/// <param name="location">A <see cref="Cords"/> that represents the upper-left corner of the rectangular region.</param>
4342
/// <param name="size">A <see cref="Size"/> that represents the width and height of the rectangular region.</param>
4443
public Area(Cords location, Size size) => area = new(location.cords, size);
45-
#pragma warning restore CS0419 // cref 特性中有不明确的引用
4644

4745
internal Area(AdvancedSharpAdbClient.Area area) => this.area = area;
4846

@@ -169,7 +167,6 @@ public int Height
169167
[DefaultOverload]
170168
public bool Equals(Area other) => area.Equals(other);
171169

172-
#pragma warning disable CS0419 // cref 特性中有不明确的引用
173170
/// <summary>
174171
/// Converts a <see cref="Rect"/> to a <see cref="Area"/> by performing a ceiling operation on all the coordinates.
175172
/// </summary>
@@ -187,7 +184,6 @@ public int Height
187184
/// </summary>
188185
/// <param name="_value">The <see cref="Rect"/> structure to be converted.</param>
189186
public static Area Round(Rect _value) => GetArea(AdvancedSharpAdbClient.Area.Round(_value));
190-
#pragma warning restore CS0419 // cref 特性中有不明确的引用
191187

192188
/// <summary>
193189
/// Determines if the specified point is contained within the rectangular region defined by this

AdvancedSharpAdbClient.WinRT/Models/Cords.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public int Y
5858
set => cords.Y = value;
5959
}
6060

61-
#pragma warning disable CS0419 // cref 特性中有不明确的引用
6261
/// <summary>
6362
/// Translates a <see cref='Cords'/> by a given <see cref='Size'/>.
6463
/// </summary>
@@ -95,7 +94,6 @@ public int Y
9594
/// <param name="_value">The <see cref='Point'/> to convert.</param>
9695
/// <returns>The <see cref='Cords'/> this method converts to.</returns>
9796
public static Cords Round(Point _value) => GetCords(AdvancedSharpAdbClient.Cords.Round(_value));
98-
#pragma warning restore CS0419 // cref 特性中有不明确的引用
9997

10098
/// <summary>
10199
/// Specifies whether this <see cref='Cords'/> contains the same coordinates as the specified

0 commit comments

Comments
 (0)