Skip to content

Commit 1d1af95

Browse files
committed
适配 SharpAdb 更新
1 parent f304771 commit 1d1af95

File tree

13 files changed

+273
-168
lines changed

13 files changed

+273
-168
lines changed

APKInstaller/APKInstaller/APKInstaller.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.2" />
5151
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Layout" Version="7.1.2" />
5252
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Markdown" Version="7.1.2" />
53-
<PackageReference Include="Downloader" Version="3.0.4" />
53+
<PackageReference Include="Downloader" Version="3.0.6" />
5454
<PackageReference Include="MetroLog.Net6" Version="2.1.0" />
55-
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.188-beta" PrivateAssets="all" />
55+
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.2-beta" PrivateAssets="all" />
5656
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
5757
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.3.230502000" />
5858
<PackageReference Include="QRCoder" Version="1.4.3" />

APKInstaller/APKInstaller/Controls/WebXAML.xaml.cs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,38 @@ namespace APKInstaller.Controls
1616
{
1717
public sealed partial class WebXAML : UserControl
1818
{
19-
public static readonly DependencyProperty ContentInfoProperty = DependencyProperty.Register(
20-
"ContentInfo",
21-
typeof(GitInfo),
22-
typeof(WebXAML),
23-
new PropertyMetadata(default(GitInfo), OnContentChanged));
19+
public static readonly DependencyProperty ContentInfoProperty =
20+
DependencyProperty.Register(
21+
nameof(ContentInfo),
22+
typeof(GitInfo),
23+
typeof(WebXAML),
24+
new PropertyMetadata(default(GitInfo), OnContentChanged));
2425

2526
public GitInfo ContentInfo
2627
{
2728
get => (GitInfo)GetValue(ContentInfoProperty);
2829
set => SetValue(ContentInfoProperty, value);
2930
}
3031

31-
public static readonly DependencyProperty ContentUrlProperty = DependencyProperty.Register(
32-
"ContentUrl",
33-
typeof(Uri),
34-
typeof(WebXAML),
35-
new PropertyMetadata(default(Uri), OnContentChanged));
32+
public static readonly DependencyProperty ContentUrlProperty =
33+
DependencyProperty.Register(
34+
nameof(ContentUrl),
35+
typeof(Uri),
36+
typeof(WebXAML),
37+
new PropertyMetadata(default(Uri), OnContentChanged));
3638

3739
public Uri ContentUrl
3840
{
3941
get => (Uri)GetValue(ContentUrlProperty);
4042
set => SetValue(ContentUrlProperty, value);
4143
}
4244

43-
public static readonly DependencyProperty ContentXAMLProperty = DependencyProperty.Register(
44-
"ContentXAML",
45-
typeof(string),
46-
typeof(WebXAML),
47-
new PropertyMetadata(default(string), OnContentChanged));
45+
public static readonly DependencyProperty ContentXAMLProperty =
46+
DependencyProperty.Register(
47+
nameof(ContentXAML),
48+
typeof(string),
49+
typeof(WebXAML),
50+
new PropertyMetadata(default(string), OnContentChanged));
4851

4952
public string ContentXAML
5053
{

APKInstaller/APKInstaller/Helpers/MonitorHelper.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Net;
66
using System.Collections.Generic;
77
using System.Threading.Tasks;
8+
using System.Threading;
89

910
namespace APKInstaller.Helpers
1011
{
@@ -18,7 +19,7 @@ public static DeviceMonitor Monitor
1819
if (_monitor == null && AdbServer.Instance.GetStatus().IsRunning)
1920
{
2021
_monitor = new(new AdbSocket(new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort)));
21-
_monitor.Start();
22+
_ = _monitor.StartAsync();
2223
}
2324
return _monitor;
2425
}
@@ -46,15 +47,16 @@ public static void DisposeConnectListener()
4647

4748
private static async void ConnectListener_ServiceFound(object sender, IZeroconfHost e)
4849
{
49-
if (AdbServer.Instance.GetStatus().IsRunning)
50+
if ((await AdbServer.Instance.GetStatusAsync(CancellationToken.None)).IsRunning)
5051
{
5152
await new AdbClient().ConnectAsync(e.IPAddress, e.Services.FirstOrDefault().Value.Port);
5253
}
5354
}
5455

5556
public static async Task ConnectPairedDevice()
5657
{
57-
IReadOnlyList<IZeroconfHost> hosts = ConnectListener != null ? ConnectListener.Hosts
58+
IReadOnlyList<IZeroconfHost> hosts = ConnectListener != null
59+
? ConnectListener.Hosts
5860
: await ZeroconfResolver.ResolveAsync("_adb-tls-connect._tcp.local.");
5961
if (hosts.Any())
6062
{
@@ -69,7 +71,8 @@ public static async Task ConnectPairedDevice()
6971
public static async Task<List<string>> ConnectPairedDeviceAsync()
7072
{
7173
List<string> results = new();
72-
IReadOnlyList<IZeroconfHost> hosts = ConnectListener != null ? ConnectListener.Hosts
74+
IReadOnlyList<IZeroconfHost> hosts = ConnectListener != null
75+
? ConnectListener.Hosts
7376
: await ZeroconfResolver.ResolveAsync("_adb-tls-connect._tcp.local.");
7477
if (hosts.Any())
7578
{

APKInstaller/APKInstaller/Helpers/ProgressHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ private static void SetProgressState(ProgressState state)
8282
private static void SetProgressValue(int current, int max)
8383
{
8484
_taskbarList?.SetProgressValue(
85-
GetHandle(),
86-
Convert.ToUInt64(current),
87-
Convert.ToUInt64(max));
85+
GetHandle(),
86+
Convert.ToUInt64(current),
87+
Convert.ToUInt64(max));
8888
}
8989

9090
private static HWND GetHandle() =>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Microsoft.UI.Dispatching;
2+
using System;
3+
using System.Runtime.CompilerServices;
4+
using System.Threading;
5+
using Windows.System.Threading;
6+
using ThreadPool = Windows.System.Threading.ThreadPool;
7+
8+
namespace APKInstaller.Helpers
9+
{
10+
public readonly struct DispatcherQueueThreadSwitcher : INotifyCompletion
11+
{
12+
private readonly DispatcherQueue dispatcher;
13+
14+
public bool IsCompleted => dispatcher.HasThreadAccess;
15+
16+
internal DispatcherQueueThreadSwitcher(DispatcherQueue dispatcher) => this.dispatcher = dispatcher;
17+
18+
public void GetResult() { }
19+
20+
public DispatcherQueueThreadSwitcher GetAwaiter() => this;
21+
22+
public void OnCompleted(Action continuation) => _ = dispatcher.TryEnqueue(DispatcherQueuePriority.Normal, () => continuation());
23+
}
24+
25+
public readonly struct ThreadPoolThreadSwitcher : INotifyCompletion
26+
{
27+
public bool IsCompleted => SynchronizationContext.Current == null;
28+
29+
public void GetResult() { }
30+
31+
public ThreadPoolThreadSwitcher GetAwaiter() => this;
32+
33+
public void OnCompleted(Action continuation) => _ = ThreadPool.RunAsync(_ => continuation(), WorkItemPriority.Normal);
34+
}
35+
36+
public static class ThreadSwitcher
37+
{
38+
public static DispatcherQueueThreadSwitcher ResumeForegroundAsync(this DispatcherQueue dispatcher) => new(dispatcher);
39+
40+
public static ThreadPoolThreadSwitcher ResumeBackgroundAsync() => new();
41+
}
42+
}

APKInstaller/APKInstaller/NativeMethods.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
ITaskbarList4
22
TaskbarList
33

4+
IInitializeWithWindow
5+
46
HTCAPTION
57

68
WA_ACTIVE

APKInstaller/APKInstaller/Strings/en-US/InstallPage.resw

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,46 +59,46 @@
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
62-
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
63-
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
6464
<xsd:element name="root" msdata:IsDataSet="true">
6565
<xsd:complexType>
6666
<xsd:choice maxOccurs="unbounded">
6767
<xsd:element name="metadata">
6868
<xsd:complexType>
6969
<xsd:sequence>
70-
<xsd:element name="value" type="xsd:string" minOccurs="0"/>
70+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
7171
</xsd:sequence>
72-
<xsd:attribute name="name" use="required" type="xsd:string"/>
73-
<xsd:attribute name="type" type="xsd:string"/>
74-
<xsd:attribute name="mimetype" type="xsd:string"/>
75-
<xsd:attribute ref="xml:space"/>
72+
<xsd:attribute name="name" use="required" type="xsd:string" />
73+
<xsd:attribute name="type" type="xsd:string" />
74+
<xsd:attribute name="mimetype" type="xsd:string" />
75+
<xsd:attribute ref="xml:space" />
7676
</xsd:complexType>
7777
</xsd:element>
7878
<xsd:element name="assembly">
7979
<xsd:complexType>
80-
<xsd:attribute name="alias" type="xsd:string"/>
81-
<xsd:attribute name="name" type="xsd:string"/>
80+
<xsd:attribute name="alias" type="xsd:string" />
81+
<xsd:attribute name="name" type="xsd:string" />
8282
</xsd:complexType>
8383
</xsd:element>
8484
<xsd:element name="data">
8585
<xsd:complexType>
8686
<xsd:sequence>
87-
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
88-
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"/>
87+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
8989
</xsd:sequence>
90-
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1"/>
91-
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3"/>
92-
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"/>
93-
<xsd:attribute ref="xml:space"/>
90+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+
<xsd:attribute ref="xml:space" />
9494
</xsd:complexType>
9595
</xsd:element>
9696
<xsd:element name="resheader">
9797
<xsd:complexType>
9898
<xsd:sequence>
99-
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
99+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100100
</xsd:sequence>
101-
<xsd:attribute name="name" type="xsd:string" use="required"/>
101+
<xsd:attribute name="name" type="xsd:string" use="required" />
102102
</xsd:complexType>
103103
</xsd:element>
104104
</xsd:choice>
@@ -180,6 +180,9 @@
180180
<data name="CopyFlyoutItem.Text" xml:space="preserve">
181181
<value>Copy</value>
182182
</data>
183+
<data name="CreateSession" xml:space="preserve">
184+
<value>Creating install session...</value>
185+
</data>
183186
<data name="Devices" xml:space="preserve">
184187
<value>Devices</value>
185188
</data>
@@ -252,10 +255,6 @@
252255
<data name="Installing" xml:space="preserve">
253256
<value>Installing...</value>
254257
</data>
255-
<data name="InstallingPercent" xml:space="preserve">
256-
<value>Installing {0}...</value>
257-
<comment>{0} - Progress.</comment>
258-
</data>
259258
<data name="InstallOutputTextBlock.Text" xml:space="preserve">
260259
<value>Reason: </value>
261260
</data>
@@ -329,6 +328,10 @@
329328
<value>Package Name: {0}</value>
330329
<comment>{0} - Package Name.</comment>
331330
</data>
331+
<data name="PostInstallFormat" xml:space="preserve">
332+
<value>Cleaning cache ({0}/{1})...</value>
333+
<comment>{0} - Finnished count. {1} - Total count.</comment>
334+
</data>
332335
<data name="Reinstall" xml:space="preserve">
333336
<value>Reinstall</value>
334337
</data>
@@ -366,7 +369,7 @@
366369
</data>
367370
<data name="UnzippingFormat" xml:space="preserve">
368371
<value>Unzipping {0}/{1} ...</value>
369-
<comment>{0} - Have done num. {1} - All num.</comment>
372+
<comment>{0} - Finnished count. {1} - Total count.</comment>
370373
</data>
371374
<data name="Update" xml:space="preserve">
372375
<value>Update</value>
@@ -375,6 +378,10 @@
375378
<value>Update {0}?</value>
376379
<comment>{0} - AppName.</comment>
377380
</data>
381+
<data name="UploadingFormat" xml:space="preserve">
382+
<value>Uploading {0} ({1}/{2})...</value>
383+
<comment>{0} - Progress. {1} - Finnished count. {2} - Total count.</comment>
384+
</data>
378385
<data name="VersionCodeFlyoutItem.Text" xml:space="preserve">
379386
<value>Version Code</value>
380387
</data>
@@ -399,6 +406,10 @@ This may take long time. Sit back and relax.</value>
399406
<data name="Welcome" xml:space="preserve">
400407
<value>Welcome!</value>
401408
</data>
409+
<data name="WriteSessionFormat" xml:space="preserve">
410+
<value>Writing install session ({0}/{1})...</value>
411+
<comment>{0} - Finnished count. {1} - Total count.</comment>
412+
</data>
402413
<data name="WSARunning" xml:space="preserve">
403414
<value>WSA is Running</value>
404415
</data>

0 commit comments

Comments
 (0)