Skip to content

Commit

Permalink
更新 v0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
wherewhere committed Jan 9, 2024
1 parent c179e7a commit 8e28daa
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 65 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ body:
label: App version
description: Specify the version of APK Installer you're using.
options:
- "0.0.3"
- "0.0.2"
- "0.0.1"
- type: dropdown
Expand Down
16 changes: 9 additions & 7 deletions APKInstaller/AAPTForNet/AAPTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,7 @@ public async Task<ApkInfo> DecompileAsync(StorageFile file)

if (file.FileType.Equals(".apk", StringComparison.OrdinalIgnoreCase))
{
if (!HasDumpOverride ? !file.Path.StartsWith(LocalPath, StringComparison.OrdinalIgnoreCase)
: !(file.Path.StartsWith(LocalPath, StringComparison.OrdinalIgnoreCase)
|| await file.GetBasicPropertiesAsync().AsTask().ContinueWith(x => x.Result.Size) > 500 * 1024 * 1024))
{
file = await CreateTempApk(file).ConfigureAwait(false);
}
file = await PrefixStorageFile(file).ConfigureAwait(false);
apkList.Add(file.Path);
}
else
Expand Down Expand Up @@ -248,8 +243,15 @@ public async Task<ApkInfo> DecompileAsync(StorageFile file)
return baseApk;
}

private static async Task<StorageFile> CreateTempApk(StorageFile sourceFile)
protected virtual async Task<StorageFile> PrefixStorageFile(StorageFile sourceFile)
{
if (HasDumpOverride ? sourceFile.Path.StartsWith(LocalPath, StringComparison.OrdinalIgnoreCase)
|| await sourceFile.GetBasicPropertiesAsync().AsTask().ContinueWith(x => x.Result.Size) > 500 * 1024 * 1024
: sourceFile.Path.StartsWith(LocalPath, StringComparison.OrdinalIgnoreCase))
{
return sourceFile;
}

if (!Directory.Exists(TempPath))
{
_ = Directory.CreateDirectory(TempPath);
Expand Down
21 changes: 11 additions & 10 deletions APKInstaller/APKInstaller.Metadata/ServerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "sddl.h"
#include "winrt/Windows.ApplicationModel.h"

using namespace std::chrono;
using namespace Windows::ApplicationModel;

namespace winrt::APKInstaller::Metadata::implementation
Expand All @@ -24,7 +25,7 @@ namespace winrt::APKInstaller::Metadata::implementation
m_serverManagerDestructedEvent.remove(token);
}

unsigned int ServerManager::RunProcess(hstring filename, hstring command, IVector<hstring> errorOutput, IVector<hstring> standardOutput)
unsigned int ServerManager::RunProcess(hstring filename, hstring command, IVector<hstring> errorOutput, IVector<hstring> standardOutput) const
{
const hstring commandLine = BuildCommandLine(filename, command);

Expand Down Expand Up @@ -108,7 +109,7 @@ namespace winrt::APKInstaller::Metadata::implementation
return _exitCode;
}

IAsyncOperation<unsigned int> ServerManager::RunProcessAsync(hstring filename, hstring command, IVector<hstring> errorOutput, IVector<hstring> standardOutput)
IAsyncOperation<unsigned int> ServerManager::RunProcessAsync(hstring filename, hstring command, IVector<hstring> errorOutput, IVector<hstring> standardOutput) const
{
const hstring commandLine = BuildCommandLine(filename, command);

Expand Down Expand Up @@ -176,7 +177,7 @@ namespace winrt::APKInstaller::Metadata::implementation
ReadFromPipe(parentOutputPipeHandle, standardOutput, encode);
ReadFromPipe(parentErrorPipeHandle, errorOutput, encode);

if (co_await resume_on_signal(processInfo.hProcess, std::chrono::seconds(5)))
if (co_await resume_on_signal(processInfo.hProcess, seconds(5)))
{
TerminateProcess(processInfo.hProcess, (UINT)-1);
}
Expand All @@ -192,7 +193,7 @@ namespace winrt::APKInstaller::Metadata::implementation
co_return _exitCode;
}

IAsyncOperation<unsigned int> ServerManager::DumpAsync(hstring filename, hstring command, DumpDelegate callback, IVector<hstring> output, int encode)
IAsyncOperation<unsigned int> ServerManager::DumpAsync(hstring filename, hstring command, DumpDelegate callback, IVector<hstring> output, int encode) const
{
const hstring commandLine = BuildCommandLine(filename, command);

Expand Down Expand Up @@ -267,7 +268,7 @@ namespace winrt::APKInstaller::Metadata::implementation
ReadFromPipe(parentErrorPipeHandle, output, encode);

end:
if (co_await resume_on_signal(processInfo.hProcess, std::chrono::seconds(5)))
if (co_await resume_on_signal(processInfo.hProcess, seconds(5)))
{
TerminateProcess(processInfo.hProcess, (UINT)-1);
}
Expand All @@ -285,7 +286,7 @@ namespace winrt::APKInstaller::Metadata::implementation

bool ServerManager::EnableLoopback() const
{
std::vector<std::wstring> list = std::vector<std::wstring>();
vector<wstring> list = vector<wstring>();
HINSTANCE firewallAPI = LoadLibrary(L"FirewallAPI.dll");
if (!firewallAPI) { return false; }

Expand Down Expand Up @@ -342,7 +343,7 @@ namespace winrt::APKInstaller::Metadata::implementation
const INET_FIREWALL_APP_CONTAINER cur = arrayValue[i];
if (cur.packageFullName)
{
std::wstring packageFullName = cur.packageFullName;
wstring packageFullName = cur.packageFullName;
if (packageFullName.compare(fullName) == 0)
{
ConvertSidToStringSid(cur.appContainerSid, &currentSid);
Expand All @@ -366,7 +367,7 @@ namespace winrt::APKInstaller::Metadata::implementation

if (currentSid)
{
for (std::wstring left : list)
for (wstring left : list)
{
if (left.compare(currentSid) == 0)
{
Expand All @@ -381,11 +382,11 @@ namespace winrt::APKInstaller::Metadata::implementation

if (NetworkIsolationSetAppContainerConfig)
{
std::vector<SID_AND_ATTRIBUTES> arr;
vector<SID_AND_ATTRIBUTES> arr;
DWORD count = 0;

list.push_back(currentSid);
for (std::wstring app : list)
for (wstring app : list)
{
SID_AND_ATTRIBUTES sid{};
sid.Attributes = 0;
Expand Down
24 changes: 12 additions & 12 deletions APKInstaller/APKInstaller.Metadata/ServerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "ServerManager.g.h"

using namespace std;
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
Expand All @@ -18,13 +19,12 @@ namespace winrt::APKInstaller::Metadata::implementation
event_token ServerManagerDestructed(EventHandler<bool> const& handler);
void ServerManagerDestructed(event_token const& token);

unsigned int RunProcess(hstring filename, hstring command, IVector<hstring> errorOutput, IVector<hstring> standardOutput);
IAsyncOperation<unsigned int> RunProcessAsync(hstring filename, hstring command, IVector<hstring> errorOutput, IVector<hstring> standardOutput);
IAsyncOperation<unsigned int> DumpAsync(hstring filename, hstring command, DumpDelegate callback, IVector<hstring> output, int encode);
unsigned int RunProcess(hstring filename, hstring command, IVector<hstring> errorOutput, IVector<hstring> standardOutput) const;
IAsyncOperation<unsigned int> RunProcessAsync(hstring filename, hstring command, IVector<hstring> errorOutput, IVector<hstring> standardOutput) const;
IAsyncOperation<unsigned int> DumpAsync(hstring filename, hstring command, DumpDelegate callback, IVector<hstring> output, int encode) const;
bool EnableLoopback() const;

private:
const DWORD defaultBufferSize = 1024;
event<EventHandler<bool>> m_serverManagerDestructedEvent;

static void CreatePipeWithSecurityAttributes(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, int nSize)
Expand Down Expand Up @@ -89,7 +89,7 @@ namespace winrt::APKInstaller::Metadata::implementation
}
}

inline const hstring BuildCommandLine(const hstring fileName, const hstring command)
static const hstring BuildCommandLine(const hstring fileName, const hstring command)
{
// Construct a StringBuilder with the appropriate command line
// to pass to CreateProcess. If the filename isn't already
Expand All @@ -100,15 +100,15 @@ namespace winrt::APKInstaller::Metadata::implementation
return fileNameIsQuoted ? fileName + ' ' + command : '"' + fileName + L"\" " + command;
}

inline void ReadFromPipe(const HANDLE hPipeRead, const IVector<hstring> output, const UINT encode) const
static void ReadFromPipe(const HANDLE hPipeRead, const IVector<hstring> output, const UINT encode)
{
const DWORD bufferLen = defaultBufferSize;
const DWORD bufferLen = 1024;
char* buffer = new char[bufferLen];
memset(buffer, '\0', bufferLen);
DWORD recLen = 0;
if (output)
{
std::wstringstream line = {};
wstringstream line = {};
do
{
if (!ReadFile(hPipeRead, buffer, bufferLen, &recLen, NULL))
Expand Down Expand Up @@ -188,7 +188,7 @@ namespace winrt::APKInstaller::Metadata::implementation
delete[] buffer;
}

inline IAsyncAction ProcessCallback(DumpDelegate callback, hstring line, int index, bool& terminated) const
static IAsyncAction ProcessCallback(DumpDelegate callback, hstring line, int index, bool& terminated)
{
co_await resume_background();
try
Expand All @@ -201,15 +201,15 @@ namespace winrt::APKInstaller::Metadata::implementation
catch (...) {}
}

inline bool ReadFromPipe(const HANDLE hPipeRead, DumpDelegate callback, const IVector<hstring> output, const UINT encode) const
static const bool ReadFromPipe(const HANDLE hPipeRead, DumpDelegate callback, const IVector<hstring> output, const UINT encode)
{
const DWORD bufferLen = defaultBufferSize;
const DWORD bufferLen = 1024;
char* buffer = new char[bufferLen];
memset(buffer, '\0', bufferLen);
bool terminated = false;
DWORD recLen = 0;
int index = 0;
std::wstringstream line = {};
wstringstream line = {};
do
{
if (!ReadFile(hPipeRead, buffer, bufferLen, &recLen, NULL))
Expand Down
10 changes: 10 additions & 0 deletions APKInstaller/APKInstaller.Package/APKInstaller.Package.wapproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@
<NoWarn>$(NoWarn);NU1702</NoWarn>
<EntryPointProjectUniqueName>..\APKInstaller\APKInstaller.csproj</EntryPointProjectUniqueName>
<GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundlePlatforms>x86|x64|arm|arm64</AppxBundlePlatforms>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<AppxBundle>Never</AppxBundle>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
Expand All @@ -63,5 +70,8 @@
<ItemGroup>
<None Include="Package.StoreAssociation.xml" />
</ItemGroup>
<ItemGroup>
<AppxSystemBinary Include="APKInstaller.Metadata.dll"/>
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
</Project>
33 changes: 1 addition & 32 deletions APKInstaller/APKInstaller.Package/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Identity
Name="18184wherewhere.AndroidAppInstaller.UWP"
Publisher="CN=2C3A37C0-35FC-4839-B08C-751C1C1AFBF5"
Version="0.0.2.0" />
Version="0.0.3.0" />

<Properties>
<DisplayName>APK 安装程序 - UWP</DisplayName>
Expand Down Expand Up @@ -98,37 +98,6 @@
<uap:DataFormat>StorageItems</uap:DataFormat>
</uap:ShareTarget>
</uap:Extension>
</Extensions>
</Application>
<Application Id="APKInstallerComServer"
Executable="APKInstaller.Server\APKInstaller.Server.exe"
EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
DisplayName="APK Installer COM Server"
Description="The APK Installer COM server."
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
AppListEntry="none" >
<uap:DefaultTile
Wide310x150Logo="Assets\Wide310x150Logo.png"
Square71x71Logo="Assets\SmallTile.png"
Square310x310Logo="Assets\LargeTile.png">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo"/>
<uap:ShowOn Tile="wide310x150Logo"/>
<uap:ShowOn Tile="square310x310Logo"/>
</uap:ShowNameOnTiles>
</uap:DefaultTile >
<uap:SplashScreen Image="Assets\SplashScreen.png" uap5:Optional="true" />
<uap:InitialRotationPreference>
<uap:Rotation Preference="landscape"/>
<uap:Rotation Preference="portrait"/>
<uap:Rotation Preference="landscapeFlipped"/>
<uap:Rotation Preference="portraitFlipped"/>
</uap:InitialRotationPreference>
</uap:VisualElements>
<Extensions>
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:ExeServer
Expand Down
2 changes: 1 addition & 1 deletion APKInstaller/APKInstaller/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Identity
Name="18184wherewhere.AndroidAppInstaller.UWP"
Publisher="CN=2C3A37C0-35FC-4839-B08C-751C1C1AFBF5"
Version="0.0.2.0" />
Version="0.0.3.0" />

<mp:PhoneIdentity PhoneProductId="b74bb720-bf67-4453-bb15-9ac9ba2f0d6a" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
6 changes: 3 additions & 3 deletions APKInstaller/APKInstaller/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("APKInstaller")]
[assembly: AssemblyCopyright("Copyright © 2017 - 2023 PavingBase. All rights reserved.")]
[assembly: AssemblyCopyright("Copyright © 2017 - 2024 PavingBase. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -23,6 +23,6 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.2.0")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyVersion("0.0.3.0")]
[assembly: AssemblyFileVersion("0.0.3.0")]
[assembly: ComVisible(false)]

0 comments on commit 8e28daa

Please sign in to comment.