diff --git a/.filenesting.json b/.filenesting.json
new file mode 100644
index 0000000..2c46e1b
--- /dev/null
+++ b/.filenesting.json
@@ -0,0 +1,16 @@
+{
+ "help": "https://go.microsoft.com/fwlink/?linkid=866610",
+ "dependentFileProviders": {
+ "add": {
+ "pathSegment": {
+ "add": {
+ ".*": [
+ ".bin",
+ ".cs",
+ ".txt"
+ ]
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 9eba94a..cd13217 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -14,7 +14,7 @@ on:
workflow_dispatch:
env:
- DOTNET_VERSION: '8.0.x' # The .NET SDK version to use
+ DOTNET_VERSION: '9.0.x' # The .NET SDK version to use
jobs:
build-and-test:
diff --git a/.gitignore b/.gitignore
index f11eb3a..95ad761 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
-## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
@@ -29,14 +29,11 @@ x86/
bld/
[Bb]in/
[Oo]bj/
-[Oo]ut/
[Ll]og/
#[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
-# JetBrains Rider options directory
-.idea/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
@@ -85,6 +82,8 @@ StyleCopReport.xml
*.pgc
*.pgd
*.rsp
+# but not Directory.Build.rsp, as it configures directory-level build defaults
+!Directory.Build.rsp
*.sbr
*.tlb
*.tli
@@ -93,6 +92,7 @@ StyleCopReport.xml
*.tmp_proj
*_wpftmp.csproj
*.log
+*.tlog
*.vspscc
*.vssscc
.builds
@@ -296,6 +296,17 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
@@ -352,6 +363,9 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/
+# Visual Studio History (VSHistory) files
+.vshistory/
+
# BeatPulse healthcheck temp database
healthchecksdb
@@ -363,3 +377,24 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
\ No newline at end of file
diff --git a/AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs b/AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs
index 01d5065..ba1c14c 100644
--- a/AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs
+++ b/AdvancedSharpAdbClient.Tests/AdbClientTests.Async.cs
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -367,7 +365,7 @@ await File.ReadAllBytesAsync("Assets/Framebuffer.bin")
Assert.Equal(1u, header.Version);
Assert.Equal(0u, header.ColorSpace);
-#if WINDOWS
+#if HAS_IMAGING
if (!OperatingSystem.IsWindows()) { return; }
using Bitmap image = framebuffer.ToImage();
@@ -937,7 +935,7 @@ await RunTestAsync(
() => TestClient.InstallCommitAsync(Device, "936013062"));
}
-#if WINDOWS10_0_17763_0_OR_GREATER
+#if WINDOWS10_0_18362_0_OR_GREATER
///
/// Tests the method.
///
@@ -963,7 +961,7 @@ public async Task InstallWinRTAsyncTest()
byte[] response = "Success\n"u8.ToArray();
- StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\base.apk"));
+ StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/base.apk"));
using (IRandomAccessStreamWithContentType stream = await storageFile.OpenReadAsync())
{
string[] requests =
@@ -1012,7 +1010,7 @@ public async Task InstallMultipleWinRTAsyncTest()
}
}
- StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\split_config.arm64_v8a.apk"));
+ StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/split_config.arm64_v8a.apk"));
using IRandomAccessStreamWithContentType abiStream = await storageFile.OpenReadAsync();
string[] requests =
@@ -1086,9 +1084,9 @@ public async Task InstallMultipleWinRTWithBaseAsyncTest()
}
}
- StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\base.apk"));
+ StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/base.apk"));
using IRandomAccessStreamWithContentType baseStream = await storageFile.OpenReadAsync();
- storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\split_config.arm64_v8a.apk"));
+ storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/split_config.arm64_v8a.apk"));
using IRandomAccessStreamWithContentType abiStream = await storageFile.OpenReadAsync();
string[] requests =
@@ -1153,7 +1151,7 @@ public async Task InstallWriteWinRTAsyncTest()
}
}
- StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\TestApp\base.apk"));
+ StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/TestApp/base.apk"));
using (IRandomAccessStreamWithContentType stream = await storageFile.OpenReadAsync())
{
string[] requests =
diff --git a/AdvancedSharpAdbClient.Tests/AdbClientTests.cs b/AdvancedSharpAdbClient.Tests/AdbClientTests.cs
index b8401f5..4beaef4 100644
--- a/AdvancedSharpAdbClient.Tests/AdbClientTests.cs
+++ b/AdvancedSharpAdbClient.Tests/AdbClientTests.cs
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -489,7 +487,7 @@ public void GetFrameBufferTest()
Assert.Equal(1u, header.Version);
Assert.Equal(0u, header.ColorSpace);
-#if WINDOWS
+#if HAS_IMAGING
if (!OperatingSystem.IsWindows()) { return; }
using Bitmap image = framebuffer.ToImage();
@@ -1141,7 +1139,7 @@ public void GetFeatureSetTest()
public void CloneTest()
{
Assert.True(TestClient is ICloneable);
-#if WINDOWS10_0_17763_0_OR_GREATER
+#if WINDOWS10_0_18362_0_OR_GREATER
Assert.True(TestClient is ICloneable);
#endif
AdbClient client = TestClient.Clone();
diff --git a/AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj b/AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj
index 03de9f0..6bb67e2 100644
--- a/AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj
+++ b/AdvancedSharpAdbClient.Tests/AdvancedSharpAdbClient.Tests.csproj
@@ -1,10 +1,11 @@
+ True
latest
$(NoWarn);CS1591
-
+
@@ -19,13 +20,13 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
+
+
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -39,5 +40,9 @@
PreserveNewest
+
+
+ $(DefineConstants);HAS_IMAGING
+
diff --git a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.Async.cs b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.Async.cs
index 598da93..2319523 100644
--- a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.Async.cs
+++ b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.Async.cs
@@ -105,7 +105,7 @@ public async Task DumpScreenAsyncTest()
Assert.Equal(doc, xml);
}
-#if WINDOWS10_0_17763_0_OR_GREATER
+#if WINDOWS10_0_18362_0_OR_GREATER
///
/// Tests the method.
///
diff --git a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.cs b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.cs
index 23cb8b5..382faf3 100644
--- a/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.cs
+++ b/AdvancedSharpAdbClient.Tests/DeviceCommands/DeviceClientTexts.cs
@@ -191,7 +191,7 @@ public void DumpScreenTest()
Assert.Equal(doc, xml);
}
-#if WINDOWS10_0_17763_0_OR_GREATER
+#if WINDOWS10_0_18362_0_OR_GREATER
///
/// Tests the method.
///
diff --git a/AdvancedSharpAdbClient.Tests/DeviceCommands/Models/VersionInfoTests.cs b/AdvancedSharpAdbClient.Tests/DeviceCommands/Models/VersionInfoTests.cs
index 8197d47..8d9da8f 100644
--- a/AdvancedSharpAdbClient.Tests/DeviceCommands/Models/VersionInfoTests.cs
+++ b/AdvancedSharpAdbClient.Tests/DeviceCommands/Models/VersionInfoTests.cs
@@ -32,7 +32,7 @@ public void TryAsVersionTest(int versionCode, string versionName, bool expected)
}
}
-#if WINDOWS10_0_17763_0_OR_GREATER
+#if WINDOWS10_0_18362_0_OR_GREATER
///
/// Tests the method.
///
diff --git a/AdvancedSharpAdbClient.Tests/DeviceCommands/Receivers/GetPropReceiverTests.cs b/AdvancedSharpAdbClient.Tests/DeviceCommands/Receivers/GetPropReceiverTests.cs
index 7463316..181be70 100644
--- a/AdvancedSharpAdbClient.Tests/DeviceCommands/Receivers/GetPropReceiverTests.cs
+++ b/AdvancedSharpAdbClient.Tests/DeviceCommands/Receivers/GetPropReceiverTests.cs
@@ -14,7 +14,7 @@ public void ListPropertiesTest()
};
DummyAdbClient client = new();
- client.Commands["shell:/system/bin/getprop"] =
+ client.Commands["shell:/system/bin/getprop"] =
"""
[init.svc.BGW]: [running]
[init.svc.MtkCodecService]: [running]
diff --git a/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbClient.cs b/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbClient.cs
index ad40f25..7d7be23 100644
--- a/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbClient.cs
+++ b/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbClient.cs
@@ -26,8 +26,8 @@ public void ExecuteRemoteCommand(string command, DeviceData device) =>
public void ExecuteRemoteCommand(string command, DeviceData device, IShellOutputReceiver receiver, Encoding encoding) =>
ExecuteServerCommand("shell", command, receiver, encoding);
- public IEnumerable ExecuteRemoteCommand(string command, DeviceData device, Encoding encoding) =>
- ExecuteServerCommand("shell", command, encoding);
+ public IEnumerable ExecuteRemoteEnumerable(string command, DeviceData device, Encoding encoding) =>
+ ExecuteServerEnumerable("shell", command, encoding);
public Task ExecuteRemoteCommandAsync(string command, DeviceData device, CancellationToken cancellationToken = default) =>
ExecuteServerCommandAsync("shell", command, cancellationToken);
@@ -35,8 +35,8 @@ public Task ExecuteRemoteCommandAsync(string command, DeviceData device, Cancell
public Task ExecuteRemoteCommandAsync(string command, DeviceData device, IShellOutputReceiver receiver, Encoding encoding, CancellationToken cancellationToken = default) =>
ExecuteServerCommandAsync("shell", command, receiver, encoding, cancellationToken);
- public IAsyncEnumerable ExecuteRemoteCommandAsync(string command, DeviceData device, Encoding encoding, CancellationToken cancellationToken) =>
- ExecuteServerCommandAsync("shell", command, encoding, cancellationToken);
+ public IAsyncEnumerable ExecuteRemoteEnumerableAsync(string command, DeviceData device, Encoding encoding, CancellationToken cancellationToken) =>
+ ExecuteServerEnumerableAsync("shell", command, encoding, cancellationToken);
public void ExecuteServerCommand(string target, string command)
{
@@ -89,7 +89,7 @@ public void ExecuteServerCommand(string target, string command, IShellOutputRece
public void ExecuteServerCommand(string target, string command, IAdbSocket socket, IShellOutputReceiver receiver, Encoding encoding) =>
ExecuteServerCommand(target, command, receiver, encoding);
- public IEnumerable ExecuteServerCommand(string target, string command, Encoding encoding)
+ public IEnumerable ExecuteServerEnumerable(string target, string command, Encoding encoding)
{
StringBuilder requestBuilder = new();
if (!StringExtensions.IsNullOrWhiteSpace(target))
@@ -115,8 +115,8 @@ public IEnumerable ExecuteServerCommand(string target, string command, E
}
}
- public IEnumerable ExecuteServerCommand(string target, string command, IAdbSocket socket, Encoding encoding) =>
- ExecuteServerCommand(target, command, encoding);
+ public IEnumerable ExecuteServerEnumerable(string target, string command, IAdbSocket socket, Encoding encoding) =>
+ ExecuteServerEnumerable(target, command, encoding);
public async Task ExecuteServerCommandAsync(string target, string command, CancellationToken cancellationToken = default)
{
@@ -171,7 +171,7 @@ public async Task ExecuteServerCommandAsync(string target, string command, IShel
public Task ExecuteServerCommandAsync(string target, string command, IAdbSocket socket, IShellOutputReceiver receiver, Encoding encoding, CancellationToken cancellationToken) =>
ExecuteServerCommandAsync(target, command, receiver, encoding, cancellationToken);
- public async IAsyncEnumerable ExecuteServerCommandAsync(string target, string command, Encoding encoding, [EnumeratorCancellation] CancellationToken cancellationToken)
+ public async IAsyncEnumerable ExecuteServerEnumerableAsync(string target, string command, Encoding encoding, [EnumeratorCancellation] CancellationToken cancellationToken)
{
StringBuilder requestBuilder = new();
if (!StringExtensions.IsNullOrWhiteSpace(target))
@@ -197,8 +197,8 @@ public async IAsyncEnumerable ExecuteServerCommandAsync(string target, s
}
}
- public IAsyncEnumerable ExecuteServerCommandAsync(string target, string command, IAdbSocket socket, Encoding encoding, CancellationToken cancellationToken = default) =>
- ExecuteServerCommandAsync(target, command, socket, encoding, cancellationToken);
+ public IAsyncEnumerable ExecuteServerEnumerableAsync(string target, string command, IAdbSocket socket, Encoding encoding, CancellationToken cancellationToken = default) =>
+ ExecuteServerEnumerableAsync(target, command, socket, encoding, cancellationToken);
#region Not Implemented
diff --git a/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs b/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs
index 2821b76..c54d040 100644
--- a/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs
+++ b/AdvancedSharpAdbClient.Tests/Dummys/DummyAdbSocket.cs
@@ -11,7 +11,7 @@ namespace AdvancedSharpAdbClient.Tests
///
/// A mock implementation of the class.
///
- internal class DummyAdbSocket : IDummyAdbSocket, ICloneable
+ internal partial class DummyAdbSocket : IDummyAdbSocket, ICloneable
{
///
/// Use this message to cause and to throw
@@ -314,7 +314,5 @@ public async Task ReconnectAsync(bool isForce, CancellationToken cancellationTok
SyncRequests = SyncRequests,
ShellStreams = ShellStreams
};
-
- object ICloneable.Clone() => Clone();
}
}
diff --git a/AdvancedSharpAdbClient.Tests/Dummys/DummySyncService.cs b/AdvancedSharpAdbClient.Tests/Dummys/DummySyncService.cs
index 17a27e1..f5008ad 100644
--- a/AdvancedSharpAdbClient.Tests/Dummys/DummySyncService.cs
+++ b/AdvancedSharpAdbClient.Tests/Dummys/DummySyncService.cs
@@ -9,7 +9,7 @@ namespace AdvancedSharpAdbClient.Tests
///
/// A mock implementation of the class.
///
- internal class DummySyncService : ISyncService
+ internal partial class DummySyncService : ISyncService
{
public Dictionary UploadedFiles { get; } = [];
diff --git a/AdvancedSharpAdbClient.Tests/Dummys/DummyTcpSocket.cs b/AdvancedSharpAdbClient.Tests/Dummys/DummyTcpSocket.cs
index 9223dfd..aa0c20e 100644
--- a/AdvancedSharpAdbClient.Tests/Dummys/DummyTcpSocket.cs
+++ b/AdvancedSharpAdbClient.Tests/Dummys/DummyTcpSocket.cs
@@ -10,7 +10,7 @@ namespace AdvancedSharpAdbClient.Tests
///
/// A mock implementation of the class.
///
- internal class DummyTcpSocket : ITcpSocket, ICloneable
+ internal partial class DummyTcpSocket : ITcpSocket, ICloneable
{
///
/// The stream from which the reads.
@@ -114,16 +114,10 @@ public async ValueTask SendAsync(ReadOnlyMemory buffer, SocketFlags s
public byte[] GetBytesSent() => OutputStream.ToArray();
- public DummyTcpSocket Clone()
+ public DummyTcpSocket Clone() => new()
{
- DummyTcpSocket socket = new()
- {
- Connected = true,
- ReceiveBufferSize = ReceiveBufferSize
- };
- return socket;
- }
-
- object ICloneable.Clone() => Clone();
+ Connected = true,
+ ReceiveBufferSize = ReceiveBufferSize
+ };
}
}
diff --git a/AdvancedSharpAdbClient.Tests/Dummys/TracingAdbSocket.cs b/AdvancedSharpAdbClient.Tests/Dummys/TracingAdbSocket.cs
index 02f08be..83e780b 100644
--- a/AdvancedSharpAdbClient.Tests/Dummys/TracingAdbSocket.cs
+++ b/AdvancedSharpAdbClient.Tests/Dummys/TracingAdbSocket.cs
@@ -8,7 +8,7 @@
namespace AdvancedSharpAdbClient.Tests
{
- internal class TracingAdbSocket(EndPoint endPoint) : AdbSocket(endPoint), IDummyAdbSocket
+ internal partial class TracingAdbSocket(EndPoint endPoint) : AdbSocket(endPoint), IDummyAdbSocket
{
private readonly EndPoint endPoint = endPoint;
diff --git a/AdvancedSharpAdbClient.Tests/Extensions/AdbClientExtensionsTests.Async.cs b/AdvancedSharpAdbClient.Tests/Extensions/AdbClientExtensionsTests.Async.cs
index be84f69..7603dcd 100644
--- a/AdvancedSharpAdbClient.Tests/Extensions/AdbClientExtensionsTests.Async.cs
+++ b/AdvancedSharpAdbClient.Tests/Extensions/AdbClientExtensionsTests.Async.cs
@@ -44,7 +44,7 @@ public async Task ExecuteServerCommandAsyncTest()
Assert.Equal(default, x.ArgAt(5));
return Task.CompletedTask;
});
- _ = client.ExecuteServerCommandAsync(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any())
+ _ = client.ExecuteServerEnumerableAsync(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any())
.Returns(x =>
{
Assert.Equal(target, x.ArgAt(0));
@@ -53,7 +53,7 @@ public async Task ExecuteServerCommandAsyncTest()
Assert.Equal(default, x.ArgAt(3));
return result.AsEnumerableAsync(x.ArgAt(3));
});
- _ = client.ExecuteServerCommandAsync(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any())
+ _ = client.ExecuteServerEnumerableAsync(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any())
.Returns(x =>
{
Assert.Equal(target, x.ArgAt(0));
@@ -70,8 +70,8 @@ public async Task ExecuteServerCommandAsyncTest()
await client.ExecuteServerCommandAsync(target, command, socket, predicate);
await client.ExecuteServerCommandAsync(target, command, predicate, encoding);
await client.ExecuteServerCommandAsync(target, command, socket, predicate, encoding);
- Assert.Equal(result, await AdbClientExtensions.ExecuteServerCommandAsync(client, target, command).ToListAsync());
- Assert.Equal(result, await AdbClientExtensions.ExecuteServerCommandAsync(client, target, command, socket).ToListAsync());
+ Assert.Equal(result, await client.ExecuteServerEnumerableAsync(target, command).ToListAsync());
+ Assert.Equal(result, await client.ExecuteServerEnumerableAsync(target, command, socket).ToListAsync());
}
[Fact]
@@ -95,7 +95,7 @@ public async Task ExecuteRemoteCommandAsyncTest()
Assert.Equal(default, x.ArgAt(4));
return Task.CompletedTask;
});
- _ = client.ExecuteRemoteCommandAsync(Arg.Any(), device, Arg.Any(), Arg.Any())
+ _ = client.ExecuteRemoteEnumerableAsync(Arg.Any(), device, Arg.Any(), Arg.Any())
.Returns(x =>
{
Assert.Equal(command, x.ArgAt(0));
@@ -108,7 +108,7 @@ public async Task ExecuteRemoteCommandAsyncTest()
await client.ExecuteRemoteCommandAsync(command, device, receiver);
await client.ExecuteRemoteCommandAsync(command, device, predicate);
await client.ExecuteRemoteCommandAsync(command, device, predicate, encoding);
- Assert.Equal(result, await AdbClientExtensions.ExecuteRemoteCommandAsync(client, command, device).ToListAsync());
+ Assert.Equal(result, await client.ExecuteRemoteEnumerableAsync(command, device).ToListAsync());
}
[Fact]
diff --git a/AdvancedSharpAdbClient.Tests/Extensions/AdbClientExtensionsTests.cs b/AdvancedSharpAdbClient.Tests/Extensions/AdbClientExtensionsTests.cs
index 5333a83..14b11fd 100644
--- a/AdvancedSharpAdbClient.Tests/Extensions/AdbClientExtensionsTests.cs
+++ b/AdvancedSharpAdbClient.Tests/Extensions/AdbClientExtensionsTests.cs
@@ -41,7 +41,7 @@ public void ExecuteServerCommandTest()
Assert.Equal(receiver, x.ArgAt(3));
Assert.Equal(encoding, x.ArgAt(4));
});
- _ = client.ExecuteServerCommand(Arg.Any(), Arg.Any(), Arg.Any())
+ _ = client.ExecuteServerEnumerable(Arg.Any(), Arg.Any(), Arg.Any())
.Returns(x =>
{
Assert.Equal(target, x.ArgAt(0));
@@ -49,7 +49,7 @@ public void ExecuteServerCommandTest()
Assert.Equal(encoding, x.ArgAt(2));
return result;
});
- _ = client.ExecuteServerCommand(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any())
+ _ = client.ExecuteServerEnumerable(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any())
.Returns(x =>
{
Assert.Equal(target, x.ArgAt(0));
@@ -65,8 +65,8 @@ public void ExecuteServerCommandTest()
client.ExecuteServerCommand(target, command, socket, predicate);
client.ExecuteServerCommand(target, command, predicate, encoding);
client.ExecuteServerCommand(target, command, socket, predicate, encoding);
- Assert.Equal(result, AdbClientExtensions.ExecuteServerCommand(client, target, command));
- Assert.Equal(result, AdbClientExtensions.ExecuteServerCommand(client, target, command, socket));
+ Assert.Equal(result, client.ExecuteServerEnumerable(target, command));
+ Assert.Equal(result, client.ExecuteServerEnumerable(target, command, socket));
}
[Fact]
@@ -88,7 +88,7 @@ public void ExecuteRemoteCommandTest()
Assert.Equal(receiver, x.ArgAt(2));
Assert.Equal(encoding, x.ArgAt(3));
});
- _ = client.ExecuteRemoteCommand(Arg.Any(), device, Arg.Any())
+ _ = client.ExecuteRemoteEnumerable(Arg.Any(), device, Arg.Any())
.Returns(x =>
{
Assert.Equal(command, x.ArgAt(0));
@@ -100,7 +100,7 @@ public void ExecuteRemoteCommandTest()
client.ExecuteRemoteCommand(command, device, receiver);
client.ExecuteRemoteCommand(command, device, predicate);
client.ExecuteRemoteCommand(command, device, predicate, encoding);
- Assert.Equal(result, AdbClientExtensions.ExecuteRemoteCommand(client, command, device));
+ Assert.Equal(result, client.ExecuteRemoteEnumerable(command, device));
}
[Fact]
diff --git a/AdvancedSharpAdbClient.Tests/Extensions/FactoriesLocker.cs b/AdvancedSharpAdbClient.Tests/Extensions/FactoriesLocker.cs
index c04988f..bccccc1 100644
--- a/AdvancedSharpAdbClient.Tests/Extensions/FactoriesLocker.cs
+++ b/AdvancedSharpAdbClient.Tests/Extensions/FactoriesLocker.cs
@@ -7,7 +7,7 @@ namespace AdvancedSharpAdbClient.Tests
///
/// Locker for the class.
///
- public class FactoriesLocker : IDisposable
+ public partial class FactoriesLocker : IDisposable
{
public static SemaphoreSlim SlimLocker { get; } = new(1, 1);
diff --git a/AdvancedSharpAdbClient.Tests/Models/FramebufferHeaderTests.cs b/AdvancedSharpAdbClient.Tests/Models/FramebufferHeaderTests.cs
index e6fb001..8886933 100644
--- a/AdvancedSharpAdbClient.Tests/Models/FramebufferHeaderTests.cs
+++ b/AdvancedSharpAdbClient.Tests/Models/FramebufferHeaderTests.cs
@@ -1,6 +1,4 @@
using System;
-using System.Drawing;
-using System.Drawing.Imaging;
using System.IO;
using Xunit;
@@ -71,7 +69,7 @@ public void ReadFramebufferV2Test()
Assert.Equal(data.AsSpan(), [.. header]);
}
-#if WINDOWS
+#if HAS_IMAGING
[Fact]
public void ToImageTest()
{
diff --git a/AdvancedSharpAdbClient.Tests/Models/FramebufferTests.cs b/AdvancedSharpAdbClient.Tests/Models/FramebufferTests.cs
index 93d453a..ba88bd5 100644
--- a/AdvancedSharpAdbClient.Tests/Models/FramebufferTests.cs
+++ b/AdvancedSharpAdbClient.Tests/Models/FramebufferTests.cs
@@ -1,6 +1,4 @@
using System;
-using System.Drawing;
-using System.Drawing.Imaging;
using System.IO;
using System.Net;
using System.Threading.Tasks;
@@ -69,7 +67,7 @@ public void RefreshTest()
Assert.Equal(1u, header.Version);
Assert.Equal(0u, header.ColorSpace);
-#if WINDOWS
+#if HAS_IMAGING
if (!OperatingSystem.IsWindows()) { return; }
using Bitmap image = (Bitmap)framebuffer;
@@ -132,7 +130,7 @@ public async Task RefreshAsyncTest()
Assert.Equal(1u, header.Version);
Assert.Equal(0u, header.ColorSpace);
-#if WINDOWS
+#if HAS_IMAGING
if (!OperatingSystem.IsWindows()) { return; }
using Bitmap image = (Bitmap)framebuffer;
diff --git a/AdvancedSharpAdbClient.Tests/Properties/GlobalUsings.cs b/AdvancedSharpAdbClient.Tests/Properties/GlobalUsings.cs
index 0765899..a22aa63 100644
--- a/AdvancedSharpAdbClient.Tests/Properties/GlobalUsings.cs
+++ b/AdvancedSharpAdbClient.Tests/Properties/GlobalUsings.cs
@@ -13,7 +13,7 @@
global using AdvancedSharpAdbClient.Logs.Tests;
#endregion
-#if WINDOWS10_0_17763_0_OR_GREATER
+#if WINDOWS10_0_18362_0_OR_GREATER
global using Windows.ApplicationModel;
global using System.Runtime.InteropServices.WindowsRuntime;
global using Windows.Storage;
diff --git a/AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs b/AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs
index b92b5a4..c17cb2c 100644
--- a/AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs
+++ b/AdvancedSharpAdbClient.Tests/SyncServiceTests.Async.cs
@@ -252,7 +252,7 @@ await RunTestAsync(
Assert.True(service.IsProcessing);
_ = await Assert.ThrowsAsync(() => service.PushAsync((Stream)null, null, default, default));
_ = await Assert.ThrowsAsync(() => service.PullAsync(null, (Stream)null));
-#if WINDOWS10_0_17763_0_OR_GREATER
+#if WINDOWS10_0_18362_0_OR_GREATER
_ = await Assert.ThrowsAsync(() => service.PushAsync((IInputStream)null, null, default, default));
_ = await Assert.ThrowsAsync(() => service.PullAsync(null, (IOutputStream)null));
#endif
@@ -264,7 +264,7 @@ await RunTestAsync(
});
}
-#if WINDOWS10_0_17763_0_OR_GREATER
+#if WINDOWS10_0_18362_0_OR_GREATER
///
/// Tests the method.
///
@@ -313,7 +313,7 @@ public async Task PushWinRTAsyncTest()
{
if (!OperatingSystem.IsWindowsVersionAtLeast(10)) { return; }
- StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Assets\Fstab.bin"));
+ StorageFile storageFile = await StorageFile.GetFileFromPathAsync(Path.GetFullPath("Assets/Fstab.bin"));
using IRandomAccessStreamWithContentType stream = await storageFile.OpenReadAsync();
byte[] content = await File.ReadAllBytesAsync("Assets/Fstab.bin");
byte[] contentMessage =
diff --git a/AdvancedSharpAdbClient.Tests/SyncServiceTests.cs b/AdvancedSharpAdbClient.Tests/SyncServiceTests.cs
index 60f998e..0cc2bff 100644
--- a/AdvancedSharpAdbClient.Tests/SyncServiceTests.cs
+++ b/AdvancedSharpAdbClient.Tests/SyncServiceTests.cs
@@ -233,7 +233,7 @@ public void CloneTest()
socket.Responses.Enqueue(AdbResponse.OK);
using SyncService syncService = new(socket, Device);
Assert.True(syncService is ICloneable);
-#if WINDOWS10_0_17763_0_OR_GREATER
+#if WINDOWS10_0_18362_0_OR_GREATER
Assert.True(syncService is ICloneable);
#endif
using SyncService service = syncService.Clone();
diff --git a/AdvancedSharpAdbClient/AdbClient.Async.cs b/AdvancedSharpAdbClient/AdbClient.Async.cs
index 9da6a00..c44267f 100644
--- a/AdvancedSharpAdbClient/AdbClient.Async.cs
+++ b/AdvancedSharpAdbClient/AdbClient.Async.cs
@@ -178,6 +178,29 @@ public virtual async Task ExecuteServerCommandAsync(string target, string comman
await socket.SendAdbRequestAsync(request.ToString(), cancellationToken);
await socket.ReadAdbResponseAsync(cancellationToken).ConfigureAwait(false);
+
+ try
+ {
+ using StreamReader reader = new(socket.GetShellStream());
+ // Previously, we would loop while reader.Peek() >= 0. Turns out that this would
+ // break too soon in certain cases (about every 10 loops, so it appears to be a timing
+ // issue). Checking for reader.ReadLine() to return null appears to be much more robust
+ // -- one of the integration test fetches output 1000 times and found no truncations.
+ while (!cancellationToken.IsCancellationRequested)
+ {
+ if (await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false) == null) { break; }
+ }
+ }
+ catch (Exception e)
+ {
+ // If a cancellation was requested, this main loop is interrupted with an exception
+ // because the socket is closed. In that case, we don't need to throw a ShellCommandUnresponsiveException.
+ // In all other cases, something went wrong, and we want to report it to the user.
+ if (!cancellationToken.IsCancellationRequested)
+ {
+ throw new ShellCommandUnresponsiveException(e);
+ }
+ }
}
///
@@ -258,18 +281,18 @@ public async Task ExecuteRemoteCommandAsync(string command, DeviceData device, I
#if COMP_NETSTANDARD2_1
///
- public async IAsyncEnumerable ExecuteServerCommandAsync(string target, string command, Encoding encoding, [EnumeratorCancellation] CancellationToken cancellationToken = default)
+ public async IAsyncEnumerable ExecuteServerEnumerableAsync(string target, string command, Encoding encoding, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
ExceptionExtensions.ThrowIfNull(encoding);
using IAdbSocket socket = CreateAdbSocket();
- await foreach (string? line in ExecuteServerCommandAsync(target, command, socket, encoding, cancellationToken).ConfigureAwait(false))
+ await foreach (string? line in ExecuteServerEnumerableAsync(target, command, socket, encoding, cancellationToken).ConfigureAwait(false))
{
yield return line;
}
}
///
- public virtual async IAsyncEnumerable ExecuteServerCommandAsync(string target, string command, IAdbSocket socket, Encoding encoding, [EnumeratorCancellation] CancellationToken cancellationToken = default)
+ public virtual async IAsyncEnumerable ExecuteServerEnumerableAsync(string target, string command, IAdbSocket socket, Encoding encoding, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
ExceptionExtensions.ThrowIfNull(encoding);
@@ -311,7 +334,7 @@ public virtual async IAsyncEnumerable ExecuteServerCommandAsync(string t
}
///
- public async IAsyncEnumerable ExecuteRemoteCommandAsync(string command, DeviceData device, Encoding encoding, [EnumeratorCancellation] CancellationToken cancellationToken = default)
+ public async IAsyncEnumerable ExecuteRemoteEnumerableAsync(string command, DeviceData device, Encoding encoding, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
EnsureDevice(device);
ExceptionExtensions.ThrowIfNull(encoding);
@@ -319,7 +342,7 @@ public async IAsyncEnumerable ExecuteRemoteCommandAsync(string command,
using IAdbSocket socket = CreateAdbSocket();
await socket.SetDeviceAsync(device, cancellationToken);
- await foreach (string? line in ExecuteServerCommandAsync("shell", command, socket, encoding, cancellationToken).ConfigureAwait(false))
+ await foreach (string? line in ExecuteServerEnumerableAsync("shell", command, socket, encoding, cancellationToken).ConfigureAwait(false))
{
yield return line;
}
@@ -653,8 +676,7 @@ void OnSplitSyncProgressChanged(string? sender, double args)
}
}
- int i = 0;
- await splitAPKs.Select(splitAPK => InstallWriteAsync(device, splitAPK, $"{nameof(splitAPK)}{i++}", session, OnSplitSyncProgressChanged, cancellationToken)).WhenAll().ConfigureAwait(false);
+ await splitAPKs.Select((splitAPK, index) => InstallWriteAsync(device, splitAPK, $"{nameof(splitAPK)}{index}", session, OnSplitSyncProgressChanged, cancellationToken)).WhenAll().ConfigureAwait(false);
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Installing));
await InstallCommitAsync(device, session, cancellationToken).ConfigureAwait(false);
@@ -697,8 +719,7 @@ void OnSyncProgressChanged(string? sender, double args)
}
}
- int i = 0;
- await splitAPKs.Select(splitAPK => InstallWriteAsync(device, splitAPK, $"{nameof(splitAPK)}{i++}", session, OnSyncProgressChanged, cancellationToken)).WhenAll().ConfigureAwait(false);
+ await splitAPKs.Select((splitAPK, index) => InstallWriteAsync(device, splitAPK, $"{nameof(splitAPK)}{index}", session, OnSyncProgressChanged, cancellationToken)).WhenAll().ConfigureAwait(false);
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Installing));
await InstallCommitAsync(device, session, cancellationToken).ConfigureAwait(false);
@@ -934,7 +955,9 @@ public async Task InstallCommitAsync(DeviceData device, string session, Cancella
#if HAS_WINRT
///
- [ContractVersion(typeof(UniversalApiContract), 65536u)]
+#if NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public virtual async Task InstallAsync(DeviceData device, IRandomAccessStream apk, Action? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
{
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -1003,6 +1026,9 @@ public virtual async Task InstallAsync(DeviceData device, IRandomAccessStream ap
}
///
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public async Task InstallMultipleAsync(DeviceData device, IRandomAccessStream baseAPK, IEnumerable splitAPKs, Action? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
{
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -1048,8 +1074,7 @@ void OnSplitSyncProgressChanged(string? sender, double args)
}
}
- int i = 0;
- await splitAPKs.Select(splitAPK => InstallWriteAsync(device, splitAPK, $"{nameof(splitAPK)}{i++}", session, OnSplitSyncProgressChanged, cancellationToken)).WhenAll().ConfigureAwait(false);
+ await splitAPKs.Select((splitAPK, index) => InstallWriteAsync(device, splitAPK, $"{nameof(splitAPK)}{index}", session, OnSplitSyncProgressChanged, cancellationToken)).WhenAll().ConfigureAwait(false);
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Installing));
await InstallCommitAsync(device, session, cancellationToken).ConfigureAwait(false);
@@ -1057,6 +1082,9 @@ void OnSplitSyncProgressChanged(string? sender, double args)
}
///
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public async Task InstallMultipleAsync(DeviceData device, IEnumerable splitAPKs, string packageName, Action? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
{
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -1092,8 +1120,7 @@ void OnSyncProgressChanged(string? sender, double args)
}
}
- int i = 0;
- await splitAPKs.Select(splitAPK => InstallWriteAsync(device, splitAPK, $"{nameof(splitAPK)}{i++}", session, OnSyncProgressChanged, cancellationToken)).WhenAll().ConfigureAwait(false);
+ await splitAPKs.Select((splitAPK, index) => InstallWriteAsync(device, splitAPK, $"{nameof(splitAPK)}{index}", session, OnSyncProgressChanged, cancellationToken)).WhenAll().ConfigureAwait(false);
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Installing));
await InstallCommitAsync(device, session, cancellationToken).ConfigureAwait(false);
@@ -1101,6 +1128,9 @@ void OnSyncProgressChanged(string? sender, double args)
}
///
+#if NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public virtual async Task InstallWriteAsync(DeviceData device, IRandomAccessStream apk, string apkName, string session, Action? callback = null, CancellationToken cancellationToken = default)
{
callback?.Invoke(0);
@@ -1173,6 +1203,9 @@ public virtual async Task InstallWriteAsync(DeviceData device, IRandomAccessStre
/// The progress is reported as a value between 0 and 100, representing the percentage of the apk which has been transferred.
/// A which can be used to cancel the asynchronous operation.
/// A which represents the asynchronous operation.
+#if NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
protected virtual async Task InstallWriteAsync(DeviceData device, IRandomAccessStream apk, string apkName, string session, Action? callback, CancellationToken cancellationToken = default)
{
callback?.Invoke(apkName, 0);
diff --git a/AdvancedSharpAdbClient/AdbClient.cs b/AdvancedSharpAdbClient/AdbClient.cs
index e2ae127..e4b32f6 100644
--- a/AdvancedSharpAdbClient/AdbClient.cs
+++ b/AdvancedSharpAdbClient/AdbClient.cs
@@ -339,6 +339,20 @@ public virtual void ExecuteServerCommand(string target, string command, IAdbSock
socket.SendAdbRequest(request.ToString());
_ = socket.ReadAdbResponse();
+
+ try
+ {
+ using StreamReader reader = new(socket.GetShellStream());
+ // Previously, we would loop while reader.Peek() >= 0. Turns out that this would
+ // break too soon in certain cases (about every 10 loops, so it appears to be a timing
+ // issue). Checking for reader.ReadLine() to return null appears to be much more robust
+ // -- one of the integration test fetches output 1000 times and found no truncations.
+ while (reader.ReadLine() != null) ;
+ }
+ catch (Exception e)
+ {
+ throw new ShellCommandUnresponsiveException(e);
+ }
}
///
@@ -411,18 +425,18 @@ public void ExecuteRemoteCommand(string command, DeviceData device, IShellOutput
}
///
- public IEnumerable ExecuteServerCommand(string target, string command, Encoding encoding)
+ public IEnumerable ExecuteServerEnumerable(string target, string command, Encoding encoding)
{
ExceptionExtensions.ThrowIfNull(encoding);
using IAdbSocket socket = CreateAdbSocket();
- foreach (string line in ExecuteServerCommand(target, command, socket, encoding))
+ foreach (string line in ExecuteServerEnumerable(target, command, socket, encoding))
{
yield return line;
}
}
///
- public virtual IEnumerable ExecuteServerCommand(string target, string command, IAdbSocket socket, Encoding encoding)
+ public virtual IEnumerable ExecuteServerEnumerable(string target, string command, IAdbSocket socket, Encoding encoding)
{
ExceptionExtensions.ThrowIfNull(encoding);
@@ -458,14 +472,14 @@ public virtual IEnumerable ExecuteServerCommand(string target, string co
}
///
- public IEnumerable ExecuteRemoteCommand(string command, DeviceData device, Encoding encoding)
+ public IEnumerable ExecuteRemoteEnumerable(string command, DeviceData device, Encoding encoding)
{
EnsureDevice(device);
using IAdbSocket socket = CreateAdbSocket();
socket.SetDevice(device);
- foreach (string line in ExecuteServerCommand("shell", command, socket, encoding))
+ foreach (string line in ExecuteServerEnumerable("shell", command, socket, encoding))
{
yield return line;
}
diff --git a/AdvancedSharpAdbClient/AdbCommandLineClient.Async.cs b/AdvancedSharpAdbClient/AdbCommandLineClient.Async.cs
index 3aa0e8c..dfda3c9 100644
--- a/AdvancedSharpAdbClient/AdbCommandLineClient.Async.cs
+++ b/AdvancedSharpAdbClient/AdbCommandLineClient.Async.cs
@@ -76,9 +76,12 @@ public async Task StartServerAsync(CancellationToken cancellationToken = default
}
///
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public virtual Task CheckAdbFileExistsAsync(string adbPath, CancellationToken cancellationToken = default) => adbPath == "adb" ? TaskExExtensions.FromResult(true) :
-#if WINDOWS_UWP
- StorageFile.GetFileFromPathAsync(adbPath).AsTask(cancellationToken).ContinueWith(x => x.Result != null && x.Result.IsOfType(StorageItemTypes.File));
+#if HAS_WINRT
+ StorageFile.GetFileFromPathAsync(Extensions.GetFullPath(adbPath)).AsTask(cancellationToken).ContinueWith(x => x.Result != null && x.Result.IsOfType(StorageItemTypes.File));
#else
TaskExExtensions.FromResult(File.Exists(adbPath));
#endif
diff --git a/AdvancedSharpAdbClient/AdbCommandLineClient.cs b/AdvancedSharpAdbClient/AdbCommandLineClient.cs
index 5e7ea60..29a5e25 100644
--- a/AdvancedSharpAdbClient/AdbCommandLineClient.cs
+++ b/AdvancedSharpAdbClient/AdbCommandLineClient.cs
@@ -36,6 +36,9 @@ public partial class AdbCommandLineClient : IAdbCommandLineClient
/// The path to the adb.exe executable.
/// Doesn't check adb file when .
/// The logger to use when logging.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public AdbCommandLineClient(string adbPath, bool isForce = false, ILogger? logger = null)
{
if (StringExtensions.IsNullOrWhiteSpace(adbPath))
@@ -123,9 +126,12 @@ public virtual List ExecuteAdbCommand(string command, int timeout = 5000
}
///
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public virtual bool CheckAdbFileExists(string adbPath) => adbPath == "adb" ||
-#if WINDOWS_UWP
- StorageFile.GetFileFromPathAsync(adbPath).AwaitByTaskCompleteSource() is StorageFile file && file.IsOfType(StorageItemTypes.File);
+#if HAS_WINRT
+ (StorageFile.GetFileFromPathAsync(Extensions.GetFullPath(adbPath)).AwaitByTaskCompleteSource() is StorageFile file && file.IsOfType(StorageItemTypes.File));
#else
File.Exists(adbPath);
#endif
diff --git a/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj b/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj
index 7af8766..49e39e9 100644
--- a/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj
+++ b/AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj
@@ -19,8 +19,8 @@
$(NoWarn);NU1603;NU1605;NU1902;NU1903
- net6.0;net8.0;netcoreapp2.1;netcoreapp3.1;netstandard1.3;netstandard2.0;netstandard2.1
- $(TargetFrameworks);net2.0;net3.5-client;net4.0-client;net4.5;net4.6.1;net4.8;net6.0-windows10.0.17763.0;net8.0-windows10.0.17763.0
+ net6.0;net8.0;net9.0;netcoreapp2.1;netcoreapp3.1;netstandard1.3;netstandard2.0;netstandard2.1
+ $(TargetFrameworks);net2.0;net3.5-client;net4.0-client;net4.5;net4.6.1;net4.8;net8.0-windows10.0.17763.0;net9.0-windows10.0.17763.0
$(TargetFrameworks);netcore5.0;uap10.0;uap10.0.15138.0
@@ -59,6 +59,10 @@
10.0.15138.0
+
+ True
+
+
@@ -71,7 +75,7 @@
-
+
-
+
-
-
-
-
$(DefineConstants);COMP_NETSTANDARD2_1
@@ -132,9 +132,12 @@
or $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net5.0-windows10.0.17763.0'))">
$(DefineConstants);HAS_WINRT
+
+
+ $(DefineConstants);HAS_WUXC
+
-
+
$(DefineConstants);HAS_IMAGING
diff --git a/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.Async.cs b/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.Async.cs
index 195512c..4aaf664 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.Async.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.Async.cs
@@ -68,7 +68,6 @@ public async Task DumpScreenStringAsync(CancellationToken cancellationTo
#if NET
[SupportedOSPlatform("Windows10.0.10240.0")]
#endif
- [ContractVersion(typeof(UniversalApiContract), 65536u)]
public async Task DumpScreenWinRTAsync(CancellationToken cancellationToken = default)
{
string xmlString = await DumpScreenStringAsync(cancellationToken).ConfigureAwait(false);
diff --git a/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.cs b/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.cs
index 5454d5e..7b6d387 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/DeviceClient.cs
@@ -19,7 +19,7 @@ namespace AdvancedSharpAdbClient.DeviceCommands
/// The to use to communicate with the Android Debug Bridge.
/// The device on which to process command.
[DebuggerDisplay($"{{{nameof(ToString)}(),nq}}")]
- public partial record class DeviceClient(IAdbClient AdbClient, DeviceData Device)
+ public partial record class DeviceClient(IAdbClient AdbClient, DeviceData Device) : ICloneable, ICloneable
{
///
/// The to use when communicating with the device.
@@ -98,7 +98,6 @@ public string DumpScreenString()
#if NET
[SupportedOSPlatform("Windows10.0.10240.0")]
#endif
- [ContractVersion(typeof(UniversalApiContract), 65536u)]
public Windows.Data.Xml.Dom.XmlDocument? DumpScreenWinRT()
{
Windows.Data.Xml.Dom.XmlDocument doc = new();
@@ -444,6 +443,12 @@ public void Deconstruct(out IAdbClient client, out DeviceData device)
device = Device;
}
+ ///
+ DeviceClient ICloneable.Clone() => this with { };
+
+ ///
+ object ICloneable.Clone() => ((ICloneable)this).Clone();
+
#if !NET40_OR_GREATER && !NETCOREAPP2_0_OR_GREATER && !NETSTANDARD2_0_OR_GREATER && !UAP10_0_15138_0
///
public override int GetHashCode() => HashCode.Combine(EqualityContract, AdbClient, Device);
diff --git a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs
index f530785..f9c3603 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.Async.cs
@@ -337,6 +337,9 @@ public static async Task> GetEnvironmentVariablesAsyn
/// A which can be used to cancel the asynchronous operation.
/// The arguments to pass to adb install.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static Task InstallPackageAsync(this IAdbClient client, DeviceData device, string packageFilePath, Action? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
@@ -355,6 +358,9 @@ public static Task InstallPackageAsync(this IAdbClient client, DeviceData device
/// A which can be used to cancel the asynchronous operation.
/// The arguments to pass to pm install-create.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static Task InstallMultiplePackageAsync(this IAdbClient client, DeviceData device, string basePackageFilePath, IEnumerable splitPackageFilePaths, Action? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
@@ -373,6 +379,9 @@ public static Task InstallMultiplePackageAsync(this IAdbClient client, DeviceDat
/// A which can be used to cancel the asynchronous operation.
/// The arguments to pass to pm install-create.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static Task InstallMultiplePackageAsync(this IAdbClient client, DeviceData device, IEnumerable splitPackageFilePaths, string packageName, Action? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
@@ -431,6 +440,9 @@ public static async Task PushAsync(this IAdbClient client, DeviceData device,
/// A which can be used to cancel the asynchronous operation.
/// The arguments to pass to adb install.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static Task InstallPackageAsync(this IAdbClient client, DeviceData device, string packageFilePath, IProgress? progress = null, CancellationToken cancellationToken = default, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
@@ -449,6 +461,9 @@ public static Task InstallPackageAsync(this IAdbClient client, DeviceData device
/// A which can be used to cancel the asynchronous operation.
/// The arguments to pass to pm install-create.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static Task InstallMultiplePackageAsync(this IAdbClient client, DeviceData device, string basePackageFilePath, IEnumerable splitPackageFilePaths, IProgress? progress = null, CancellationToken cancellationToken = default, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
@@ -467,6 +482,9 @@ public static Task InstallMultiplePackageAsync(this IAdbClient client, DeviceDat
/// A which can be used to cancel the asynchronous operation.
/// The arguments to pass to pm install-create.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static Task InstallMultiplePackageAsync(this IAdbClient client, DeviceData device, IEnumerable splitPackageFilePaths, string packageName, IProgress? progress = null, CancellationToken cancellationToken = default, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
diff --git a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs
index 842cdba..e9da616 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/DeviceExtensions.cs
@@ -288,6 +288,9 @@ public static Dictionary GetEnvironmentVariables(this IAdbClient
/// An optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to adb install.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static void InstallPackage(this IAdbClient client, DeviceData device, string packageFilePath, Action? callback = null, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
@@ -304,6 +307,9 @@ public static void InstallPackage(this IAdbClient client, DeviceData device, str
/// An optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to pm install-create.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static void InstallMultiplePackage(this IAdbClient client, DeviceData device, string basePackageFilePath, IEnumerable splitPackageFilePaths, Action? callback = null, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
@@ -320,6 +326,9 @@ public static void InstallMultiplePackage(this IAdbClient client, DeviceData dev
/// An optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to pm install-create.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static void InstallMultiplePackage(this IAdbClient client, DeviceData device, IEnumerable splitPackageFilePaths, string packageName, Action? callback = null, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
@@ -375,6 +384,9 @@ public static void Push(this IAdbClient client, DeviceData device,
/// An optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to adb install.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static void InstallPackage(this IAdbClient client, DeviceData device, string packageFilePath, IProgress? progress = null, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
@@ -391,6 +403,9 @@ public static void InstallPackage(this IAdbClient client, DeviceData device, str
/// An optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to pm install-create.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static void InstallMultiplePackage(this IAdbClient client, DeviceData device, string basePackageFilePath, IEnumerable splitPackageFilePaths, IProgress? progress = null, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
@@ -407,6 +422,9 @@ public static void InstallMultiplePackage(this IAdbClient client, DeviceData dev
/// An optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to pm install-create.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public static void InstallMultiplePackage(this IAdbClient client, DeviceData device, IEnumerable splitPackageFilePaths, string packageName, IProgress? progress = null, params string[] arguments)
{
PackageManager manager = new(client, device, skipInit: true);
diff --git a/AdvancedSharpAdbClient/DeviceCommands/Models/Element.cs b/AdvancedSharpAdbClient/DeviceCommands/Models/Element.cs
index 1522dcd..ce3d772 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/Models/Element.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/Models/Element.cs
@@ -92,7 +92,6 @@ static IEnumerable FindElements(IAdbClient client, DeviceData device, X
/// The of the element.
#if NET
[SupportedOSPlatform("Windows10.0.10240.0")]
- [ContractVersion(typeof(UniversalApiContract), 65536u)]
#endif
public Element(IAdbClient client, DeviceData device, Windows.Data.Xml.Dom.IXmlNode xmlNode)
{
@@ -223,7 +222,6 @@ static IEnumerable FindElements(IAdbClient client, DeviceData device, W
#if NET
[SupportedOSPlatform("Windows10.0.10240.0")]
#endif
- [ContractVersion(typeof(UniversalApiContract), 65536u)]
public static Element? FromIXmlNode(IAdbClient client, DeviceData device, Windows.Data.Xml.Dom.IXmlNode xmlNode) =>
xmlNode.Attributes?.GetNamedItem("bounds") != null ? new Element(client, device, xmlNode) : null;
#endif
diff --git a/AdvancedSharpAdbClient/DeviceCommands/Models/VersionInfo.cs b/AdvancedSharpAdbClient/DeviceCommands/Models/VersionInfo.cs
index c097d55..abdeeba 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/Models/VersionInfo.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/Models/VersionInfo.cs
@@ -73,7 +73,6 @@ public readonly bool TryAsVersion(out Version? version)
#if NET
[SupportedOSPlatform("Windows10.0.10240.0")]
#endif
- [ContractVersion(typeof(UniversalApiContract), 65536u)]
public readonly bool TryAsPackageVersion(out PackageVersion version)
{
ushort[] numbs = GetVersionNumbers(VersionName).Split('.', StringSplitOptions.RemoveEmptyEntries).Select(ushort.Parse).Take(4).ToArray();
diff --git a/AdvancedSharpAdbClient/DeviceCommands/PackageManager.Async.cs b/AdvancedSharpAdbClient/DeviceCommands/PackageManager.Async.cs
index 8f4e547..9e2b0b8 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/PackageManager.Async.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/PackageManager.Async.cs
@@ -47,6 +47,9 @@ public Task RefreshPackagesAsync(CancellationToken cancellationToken = default)
/// A which can be used to cancel the asynchronous operation.
/// The arguments to pass to adb install.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public async Task InstallPackageAsync(string packageFilePath, Action? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
{
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -114,6 +117,9 @@ public async Task InstallRemotePackageAsync(string remoteFilePath, ActionA which can be used to cancel the asynchronous operation.
/// The arguments to pass to pm install-create.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public async Task InstallMultiplePackageAsync(string basePackageFilePath, IEnumerable splitPackageFilePaths, Action? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
{
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -160,13 +166,12 @@ void OnSplitSyncProgressChanged(string? sender, SyncProgressChangedEventArgs arg
await InstallMultipleRemotePackageAsync(baseRemoteFilePath, splitRemoteFilePaths, callback, cancellationToken, arguments);
- callback?.Invoke(new InstallProgressEventArgs(0, splitRemoteFilePaths.Length + 1, PackageInstallProgressState.PostInstall));
int count = 0;
+ callback?.Invoke(new InstallProgressEventArgs(0, splitRemoteFilePaths.Length + 1, PackageInstallProgressState.PostInstall));
await splitRemoteFilePaths.Select(async x =>
{
- count++;
await RemoveRemotePackageAsync(x, cancellationToken).ConfigureAwait(false);
- callback?.Invoke(new InstallProgressEventArgs(count, splitRemoteFilePaths.Length + 1, PackageInstallProgressState.PostInstall));
+ callback?.Invoke(new InstallProgressEventArgs(++count, splitRemoteFilePaths.Length + 1, PackageInstallProgressState.PostInstall));
}).WhenAll().ConfigureAwait(false);
if (count < splitRemoteFilePaths.Length)
@@ -190,6 +195,9 @@ await splitRemoteFilePaths.Select(async x =>
/// A which can be used to cancel the asynchronous operation.
/// The arguments to pass to pm install-create.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public async Task InstallMultiplePackageAsync(IEnumerable splitPackageFilePaths, string packageName, Action? callback = null, CancellationToken cancellationToken = default, params string[] arguments)
{
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -231,13 +239,12 @@ void OnSyncProgressChanged(string? sender, SyncProgressChangedEventArgs args)
await InstallMultipleRemotePackageAsync(splitRemoteFilePaths, packageName, callback, cancellationToken, arguments);
- callback?.Invoke(new InstallProgressEventArgs(0, splitRemoteFilePaths.Length, PackageInstallProgressState.PostInstall));
int count = 0;
+ callback?.Invoke(new InstallProgressEventArgs(0, splitRemoteFilePaths.Length, PackageInstallProgressState.PostInstall));
await splitRemoteFilePaths.Select(async x =>
{
- count++;
await RemoveRemotePackageAsync(x, cancellationToken).ConfigureAwait(false);
- callback?.Invoke(new InstallProgressEventArgs(count, splitRemoteFilePaths.Length, PackageInstallProgressState.PostInstall));
+ callback?.Invoke(new InstallProgressEventArgs(++count, splitRemoteFilePaths.Length, PackageInstallProgressState.PostInstall));
}).WhenAll().ConfigureAwait(false);
if (count < splitRemoteFilePaths.Length)
@@ -275,10 +282,10 @@ public async Task InstallMultipleRemotePackageAsync(string baseRemoteFilePath, I
callback?.Invoke(new InstallProgressEventArgs(1, splitRemoteFileCount + 1, PackageInstallProgressState.WriteSession));
int count = 0;
- await splitRemoteFilePaths.Select(async splitRemoteFilePath =>
+ await splitRemoteFilePaths.Select(async (splitRemoteFilePath, index) =>
{
- await WriteInstallSessionAsync(session, $"split{count++}", splitRemoteFilePath, cancellationToken).ConfigureAwait(false);
- callback?.Invoke(new InstallProgressEventArgs(count, splitRemoteFileCount + 1, PackageInstallProgressState.WriteSession));
+ await WriteInstallSessionAsync(session, $"split{index}", splitRemoteFilePath, cancellationToken).ConfigureAwait(false);
+ callback?.Invoke(new InstallProgressEventArgs(++count, splitRemoteFileCount + 1, PackageInstallProgressState.WriteSession));
}).WhenAll().ConfigureAwait(false);
if (count < splitRemoteFileCount)
@@ -320,10 +327,10 @@ public async Task InstallMultipleRemotePackageAsync(IEnumerable splitRem
callback?.Invoke(new InstallProgressEventArgs(0, splitRemoteFileCount, PackageInstallProgressState.WriteSession));
int count = 0;
- await splitRemoteFilePaths.Select(async splitRemoteFilePath =>
+ await splitRemoteFilePaths.Select(async (splitRemoteFilePath, index) =>
{
- await WriteInstallSessionAsync(session, $"split{count++}", splitRemoteFilePath, cancellationToken).ConfigureAwait(false);
- callback?.Invoke(new InstallProgressEventArgs(count, splitRemoteFileCount, PackageInstallProgressState.WriteSession));
+ await WriteInstallSessionAsync(session, $"split{index}", splitRemoteFilePath, cancellationToken).ConfigureAwait(false);
+ callback?.Invoke(new InstallProgressEventArgs(++count, splitRemoteFileCount, PackageInstallProgressState.WriteSession));
}).WhenAll().ConfigureAwait(false);
if (count < splitRemoteFileCount)
@@ -352,6 +359,9 @@ await splitRemoteFilePaths.Select(async splitRemoteFilePath =>
/// A which can be used to cancel the asynchronous operation.
/// The arguments to pass to adb install.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public async Task InstallPackageAsync(string packageFilePath, IProgress? progress = null, CancellationToken cancellationToken = default, params string[] arguments) =>
await InstallPackageAsync(packageFilePath, progress.AsAction(), cancellationToken, arguments).ConfigureAwait(false);
@@ -377,6 +387,9 @@ public async Task InstallRemotePackageAsync(string remoteFilePath, IProgressA which can be used to cancel the asynchronous operation.
/// The arguments to pass to pm install-create.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public async Task InstallMultiplePackageAsync(string basePackageFilePath, IEnumerable splitPackageFilePaths, IProgress? progress = null, CancellationToken cancellationToken = default, params string[] arguments) =>
await InstallMultiplePackageAsync(basePackageFilePath, splitPackageFilePaths, progress.AsAction(), cancellationToken, arguments).ConfigureAwait(false);
@@ -390,6 +403,9 @@ public async Task InstallMultiplePackageAsync(string basePackageFilePath, IEnume
/// A which can be used to cancel the asynchronous operation.
/// The arguments to pass to pm install-create.
/// A which represents the asynchronous operation.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public async Task InstallMultiplePackageAsync(IEnumerable splitPackageFilePaths, string packageName, IProgress? progress = null, CancellationToken cancellationToken = default, params string[] arguments) =>
await InstallMultiplePackageAsync(splitPackageFilePaths, packageName, progress.AsAction(), cancellationToken, arguments).ConfigureAwait(false);
@@ -545,9 +561,12 @@ protected async Task WriteInstallSessionAsync(string session, string apkName, st
/// The file to be opened for reading.
/// A which can be used to cancel the asynchronous operation.
/// A which returns a read-only on the specified path.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
protected virtual Task GetFileStreamAsync(string path, CancellationToken cancellationToken = default) =>
-#if WINDOWS_UWP
- StorageFile.GetFileFromPathAsync(path).AsTask(cancellationToken).ContinueWith(x => x.Result.OpenStreamForReadAsync()).Unwrap();
+#if HAS_WINRT
+ StorageFile.GetFileFromPathAsync(Extensions.GetFullPath(path)).AsTask(cancellationToken).ContinueWith(x => x.Result.OpenStreamForReadAsync()).Unwrap();
#else
TaskExExtensions.FromResult(File.OpenRead(path));
#endif
@@ -560,6 +579,9 @@ protected virtual Task GetFileStreamAsync(string path, CancellationToken
/// A which can be used to cancel the asynchronous operation.
/// A which returns the destination path on device for file.
/// If fatal error occurred when pushing file.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
protected virtual async Task SyncPackageToDeviceAsync(string localFilePath, Action? callback, CancellationToken cancellationToken = default)
{
callback?.Invoke(localFilePath, new SyncProgressChangedEventArgs(0, 100));
diff --git a/AdvancedSharpAdbClient/DeviceCommands/PackageManager.cs b/AdvancedSharpAdbClient/DeviceCommands/PackageManager.cs
index 013ccbb..34a6cb8 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/PackageManager.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/PackageManager.cs
@@ -153,6 +153,9 @@ public void RefreshPackages()
/// An optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to adb install.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public void InstallPackage(string packageFilePath, Action? callback = null, params string[] arguments)
{
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -216,6 +219,9 @@ public void InstallRemotePackage(string remoteFilePath, ActionAn optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to pm install-create.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public void InstallMultiplePackage(string basePackageFilePath, IEnumerable splitPackageFilePaths, Action? callback = null, params string[] arguments)
{
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -278,6 +284,9 @@ void OnSplitSyncProgressChanged(string? sender, SyncProgressChangedEventArgs arg
/// An optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to pm install-create.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public void InstallMultiplePackage(IEnumerable splitPackageFilePaths, string packageName, Action? callback = null, params string[] arguments)
{
callback?.Invoke(new InstallProgressEventArgs(PackageInstallProgressState.Preparing));
@@ -313,8 +322,8 @@ void OnSyncProgressChanged(string? sender, SyncProgressChangedEventArgs args)
InstallMultipleRemotePackage(splitRemoteFilePaths, packageName, callback, arguments);
- callback?.Invoke(new InstallProgressEventArgs(0, splitRemoteFilePaths.Length, PackageInstallProgressState.PostInstall));
int count = 0;
+ callback?.Invoke(new InstallProgressEventArgs(0, splitRemoteFilePaths.Length, PackageInstallProgressState.PostInstall));
foreach (string splitRemoteFilePath in splitRemoteFilePaths)
{
RemoveRemotePackage(splitRemoteFilePath);
@@ -412,6 +421,9 @@ public void InstallMultipleRemotePackage(IEnumerable splitRemoteFilePath
/// An optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to adb install.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public void InstallPackage(string packageFilePath, IProgress? progress = null, params string[] arguments) =>
InstallPackage(packageFilePath, progress.AsAction(), arguments);
@@ -433,6 +445,9 @@ public void InstallRemotePackage(string remoteFilePath, IProgressAn optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to pm install-create.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public void InstallMultiplePackage(string basePackageFilePath, IEnumerable splitPackageFilePaths, IProgress? progress = null, params string[] arguments) =>
InstallMultiplePackage(basePackageFilePath, splitPackageFilePaths, progress.AsAction(), arguments);
@@ -444,6 +459,9 @@ public void InstallMultiplePackage(string basePackageFilePath, IEnumerableAn optional parameter which, when specified, returns progress notifications.
/// The progress is reported as , representing the state of installation.
/// The arguments to pass to pm install-create.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
public void InstallMultiplePackage(IEnumerable splitPackageFilePaths, string packageName, IProgress? progress = null, params string[] arguments) =>
InstallMultiplePackage(splitPackageFilePaths, packageName, progress.AsAction(), arguments);
@@ -593,9 +611,12 @@ protected void WriteInstallSession(string session, string apkName, string path)
///
/// The file to be opened for reading.
/// A read-only on the specified path.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
protected virtual Stream GetFileStream(string path) =>
-#if WINDOWS_UWP
- StorageFile.GetFileFromPathAsync(path).AwaitByTaskCompleteSource().OpenStreamForReadAsync().AwaitByTaskCompleteSource();
+#if HAS_WINRT
+ StorageFile.GetFileFromPathAsync(Extensions.GetFullPath(path)).AwaitByTaskCompleteSource().OpenStreamForReadAsync().AwaitByTaskCompleteSource();
#else
File.OpenRead(path);
#endif
@@ -607,6 +628,9 @@ protected virtual Stream GetFileStream(string path) =>
/// An optional parameter which, when specified, returns progress notifications.
/// Destination path on device for file.
/// If fatal error occurred when pushing file.
+#if HAS_WINRT && NET
+ [SupportedOSPlatform("Windows10.0.10240.0")]
+#endif
protected virtual string SyncPackageToDevice(string localFilePath, Action? callback)
{
callback?.Invoke(localFilePath, new SyncProgressChangedEventArgs(0, 100));
diff --git a/AdvancedSharpAdbClient/DeviceCommands/Receivers/PackageManagerReceiver.cs b/AdvancedSharpAdbClient/DeviceCommands/Receivers/PackageManagerReceiver.cs
index 9f2b50a..cdd6ac4 100644
--- a/AdvancedSharpAdbClient/DeviceCommands/Receivers/PackageManagerReceiver.cs
+++ b/AdvancedSharpAdbClient/DeviceCommands/Receivers/PackageManagerReceiver.cs
@@ -25,7 +25,7 @@ public class PackageManagerReceiver(PackageManager packageManager) : MultiLineRe
public PackageManager PackageManager => packageManager;
///
- protected override void ProcessNewLines(IEnumerable lines)
+ protected override void ProcessNewLines(params IEnumerable lines)
{
PackageManager.Packages.Clear();
diff --git a/AdvancedSharpAdbClient/DeviceMonitor.Async.cs b/AdvancedSharpAdbClient/DeviceMonitor.Async.cs
index 195bbd9..9520f9b 100644
--- a/AdvancedSharpAdbClient/DeviceMonitor.Async.cs
+++ b/AdvancedSharpAdbClient/DeviceMonitor.Async.cs
@@ -19,7 +19,11 @@ public partial class DeviceMonitor
/// is used to block the method until the
/// has processed the first list of devices.
///
+#if NET
+ protected TaskCompletionSource? FirstDeviceListParsed;
+#else
protected TaskCompletionSource