oh my gotto no mor outputto
This commit is contained in:
parent
4d5371be5e
commit
1e8f8d6dc9
4 changed files with 30 additions and 3 deletions
|
|
@ -13,8 +13,7 @@ static class Program
|
||||||
|
|
||||||
if (installationRequest is null ||
|
if (installationRequest is null ||
|
||||||
string.IsNullOrEmpty(installationRequest.ApkPath) ||
|
string.IsNullOrEmpty(installationRequest.ApkPath) ||
|
||||||
string.IsNullOrEmpty(installationRequest.ZipPath) ||
|
string.IsNullOrEmpty(installationRequest.ZipPath))
|
||||||
string.IsNullOrEmpty(installationRequest.OutputPath))
|
|
||||||
{
|
{
|
||||||
ShowUsage();
|
ShowUsage();
|
||||||
return;
|
return;
|
||||||
|
|
@ -22,6 +21,11 @@ static class Program
|
||||||
|
|
||||||
var adbService = new AdbService();
|
var adbService = new AdbService();
|
||||||
|
|
||||||
|
var apkInfo = ApkScrapper.GetApkInfo(installationRequest.ApkPath);
|
||||||
|
var zipName = Path.GetFileName(installationRequest.ZipPath);
|
||||||
|
var outputPath =
|
||||||
|
@$"/storage/emulated/0/Android/data/{apkInfo.PackageName}/files/{zipName}";
|
||||||
|
|
||||||
// Подписка на события прогресса
|
// Подписка на события прогресса
|
||||||
adbService.ProgressChanged += OnProgressChanged;
|
adbService.ProgressChanged += OnProgressChanged;
|
||||||
adbService.StatusChanged += OnStatusChanged;
|
adbService.StatusChanged += OnStatusChanged;
|
||||||
|
|
@ -41,7 +45,7 @@ static class Program
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
|
||||||
// Копирование файла
|
// Копирование файла
|
||||||
await adbService.CopyFileAsync(installationRequest.ZipPath, installationRequest.OutputPath, progress);
|
await adbService.CopyFileAsync(installationRequest.ZipPath, outputPath, progress);
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
|
||||||
Console.WriteLine("Операция завершена успешно!");
|
Console.WriteLine("Операция завершена успешно!");
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AlphaOmega.ApkReader" Version="2.0.5" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||||
<PackageReference Include="AdvancedSharpAdbClient" Version="3.4.14" />
|
<PackageReference Include="AdvancedSharpAdbClient" Version="3.4.14" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
3
MetaforceInstaller.Core/Models/ApkInfo.cs
Normal file
3
MetaforceInstaller.Core/Models/ApkInfo.cs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
namespace MetaforceInstaller.Core.Models;
|
||||||
|
|
||||||
|
public record ApkInfo(string PackageName, string VersionName, string VersionCode);
|
||||||
19
MetaforceInstaller.Core/Services/ApkScrapper.cs
Normal file
19
MetaforceInstaller.Core/Services/ApkScrapper.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
using AlphaOmega.Debug;
|
||||||
|
using MetaforceInstaller.Core.Models;
|
||||||
|
|
||||||
|
namespace MetaforceInstaller.Core.Services;
|
||||||
|
|
||||||
|
public static class ApkScrapper
|
||||||
|
{
|
||||||
|
public static ApkInfo GetApkInfo(string apkPath)
|
||||||
|
{
|
||||||
|
using var apk = new ApkFile(apkPath);
|
||||||
|
if (apk is { IsValid: true, AndroidManifest: not null })
|
||||||
|
{
|
||||||
|
return new ApkInfo(apk.AndroidManifest.Package, apk.AndroidManifest.VersionName,
|
||||||
|
apk.AndroidManifest.VersionCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception("Invalid APK file");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue