Display supported ABIs in APK info panel

This commit is contained in:
ema
2025-06-25 01:58:32 +08:00
parent 1c1f6d55e7
commit f3c08d5b76
6 changed files with 94 additions and 35 deletions

View File

@@ -74,6 +74,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="* " />
</Grid.RowDefinitions>
<Grid Grid.Row="1"
@@ -160,15 +161,31 @@
Text="Searching..."
TextTrimming="CharacterEllipsis"
TextWrapping="Wrap" />
<!-- ABIs -->
<TextBlock x:Name="abisTitle"
Grid.Row="7"
Grid.Column="1"
Padding="3"
Foreground="{DynamicResource WindowTextForegroundAlternative}"
Text="ABIs" />
<TextBlock x:Name="abis"
Grid.Row="7"
Grid.Column="2"
Margin="8,0,0,0"
Padding="3"
Foreground="{DynamicResource WindowTextForegroundAlternative}"
Text="Searching..."
TextTrimming="CharacterEllipsis"
TextWrapping="Wrap" />
<!-- MinSdkVersion -->
<TextBlock x:Name="minSdkVersionTitle"
Grid.Row="7"
Grid.Row="8"
Grid.Column="1"
Padding="3"
Foreground="{DynamicResource WindowTextForegroundAlternative}"
Text="MinSdkVersion" />
<TextBlock x:Name="minSdkVersion"
Grid.Row="7"
Grid.Row="8"
Grid.Column="2"
Margin="8,0,0,0"
Padding="3"
@@ -178,13 +195,13 @@
TextWrapping="Wrap" />
<!-- TargetSdkVersion -->
<TextBlock x:Name="targetSdkVersionTitle"
Grid.Row="8"
Grid.Row="9"
Grid.Column="1"
Padding="3"
Foreground="{DynamicResource WindowTextForegroundAlternative}"
Text="TargetSdkVersion" />
<TextBlock x:Name="targetSdkVersion"
Grid.Row="8"
Grid.Row="9"
Grid.Column="2"
Margin="8,0,0,0"
Padding="3"
@@ -194,13 +211,13 @@
TextWrapping="Wrap" />
<!-- Total Size -->
<TextBlock x:Name="totalSizeTitle"
Grid.Row="9"
Grid.Row="10"
Grid.Column="1"
Padding="3"
Foreground="{DynamicResource WindowTextForegroundAlternative}"
Text="Total Size" />
<TextBlock x:Name="totalSize"
Grid.Row="9"
Grid.Row="10"
Grid.Column="2"
Margin="8,0,0,0"
Padding="3"
@@ -208,13 +225,13 @@
Text="Calculating size..." />
<!-- Last Modified -->
<TextBlock x:Name="modDateTitle"
Grid.Row="10"
Grid.Row="11"
Grid.Column="1"
Padding="3"
Foreground="{DynamicResource WindowTextForegroundAlternative}"
Text="Last Modified" />
<TextBlock x:Name="modDate"
Grid.Row="10"
Grid.Row="11"
Grid.Column="2"
Margin="8,0,0,0"
Padding="3"
@@ -223,7 +240,7 @@
TextTrimming="CharacterEllipsis" />
<!-- Permissions -->
<GroupBox x:Name="permissionsGroupBox"
Grid.Row="11"
Grid.Row="12"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="3,3,16,16"

View File

@@ -45,6 +45,7 @@ public partial class ApkInfoPanel : UserControl, IAppInfoPanel
versionNameTitle.Text = TranslationHelper.Get("APP_VERSION_NAME", translationFile);
versionCodeTitle.Text = TranslationHelper.Get("APP_VERSION_CODE", translationFile);
packageNameTitle.Text = TranslationHelper.Get("PACKAGE_NAME", translationFile);
abisTitle.Text = TranslationHelper.Get("ABI", translationFile);
minSdkVersionTitle.Text = TranslationHelper.Get("APP_MIN_SDK_VERSION", translationFile);
targetSdkVersionTitle.Text = TranslationHelper.Get("APP_TARGET_SDK_VERSION", translationFile);
totalSizeTitle.Text = TranslationHelper.Get("TOTAL_SIZE", translationFile);
@@ -70,6 +71,7 @@ public partial class ApkInfoPanel : UserControl, IAppInfoPanel
applicationName.Text = apkInfo.Label;
versionName.Text = apkInfo.VersionName;
versionCode.Text = apkInfo.VersionCode;
abis.Text = string.Join(", ", apkInfo.ABIs ?? []);
packageName.Text = apkInfo.PackageName;
minSdkVersion.Text = apkInfo.MinSdkVersion;
targetSdkVersion.Text = apkInfo.TargetSdkVersion;

View File

@@ -61,4 +61,6 @@ public class ApkInfo
public List<string> Densities { get; set; } = [];
public string LaunchableActivity { get; set; }
public string[] ABIs { get; set; } = [];
}

View File

@@ -16,6 +16,9 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using ICSharpCode.SharpZipLib.Zip;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -25,33 +28,62 @@ public static class ApkParser
{
public static ApkInfo Parse(string path)
{
using var zip = new ZipFile(path);
var apkReader = new ApkReader.ApkReader();
ApkReader.ApkInfo baseInfo = apkReader.Read(path);
ApkInfo info = new()
try
{
VersionName = baseInfo.VersionName,
VersionCode = baseInfo.VersionCode,
TargetSdkVersion = baseInfo.TargetSdkVersion,
Permissions = baseInfo.Permissions,
PackageName = baseInfo.PackageName,
MinSdkVersion = baseInfo.MinSdkVersion,
Icon = baseInfo.Icon,
Icons = baseInfo.Icons,
Label = baseInfo.Label,
Labels = baseInfo.Labels,
Locales = baseInfo.Locales,
Densities = baseInfo.Densities,
LaunchableActivity = baseInfo.LaunchableActivity,
};
using var zip = new ZipFile(path);
if (baseInfo.HasIcon)
{
ZipEntry entry = zip.GetEntry(baseInfo.Icons.Values.LastOrDefault());
using var s = new BinaryReader(zip.GetInputStream(entry));
info.Logo = s.ReadBytes((int)entry.Size);
var apkReader = new ApkReader.ApkReader();
ApkReader.ApkInfo baseInfo = apkReader.Read(path);
ApkInfo info = new()
{
VersionName = baseInfo.VersionName,
VersionCode = baseInfo.VersionCode,
TargetSdkVersion = baseInfo.TargetSdkVersion,
Permissions = baseInfo.Permissions,
PackageName = baseInfo.PackageName,
MinSdkVersion = baseInfo.MinSdkVersion,
Icon = baseInfo.Icon,
Icons = baseInfo.Icons,
Label = baseInfo.Label,
Labels = baseInfo.Labels,
Locales = baseInfo.Locales,
Densities = baseInfo.Densities,
LaunchableActivity = baseInfo.LaunchableActivity,
};
if (baseInfo.HasIcon)
{
ZipEntry entry = zip.GetEntry(baseInfo.Icons.Values.LastOrDefault());
using var s = new BinaryReader(zip.GetInputStream(entry));
info.Logo = s.ReadBytes((int)entry.Size);
}
var abiSet = new HashSet<string>();
foreach (ZipEntry entry in zip)
{
if (entry.IsFile && entry.Name.StartsWith("lib/"))
{
var relativePath = entry.Name.Substring("lib/".Length);
int slashIndex = relativePath.IndexOf('/');
if (slashIndex > 0)
{
string abi = relativePath.Substring(0, slashIndex);
abiSet.Add(abi);
}
}
}
info.ABIs = [.. abiSet];
return info;
}
return info;
catch (Exception e)
{
Debug.WriteLine(e);
}
return new ApkInfo();
}
}

View File

@@ -75,7 +75,7 @@ public class Plugin : IViewer
{
context.PreferredSize = Path.GetExtension(ConfirmPath(path)).ToLower() switch
{
".apk" => new Size { Width = 560, Height = 505 },
".apk" => new Size { Width = 560, Height = 510 },
".ipa" => new Size { Width = 560, Height = 510 },
".hap" => new Size { Width = 560, Height = 500 },
".msi" => new Size { Width = 560, Height = 230 },

View File

@@ -9,6 +9,7 @@
<LAST_MODIFIED>Last Modified</LAST_MODIFIED>
<PUBLISHER>Publisher</PUBLISHER>
<CAPABILITIES>Capabilities</CAPABILITIES>
<ABI>ABIs</ABI>
<APP_NAME>Application</APP_NAME>
<APP_VERSION>Version</APP_VERSION>
<APP_VERSION_NAME>Version Name</APP_VERSION_NAME>
@@ -41,6 +42,7 @@
<LAST_MODIFIED>Modificado em</LAST_MODIFIED>
<PUBLISHER>Editora</PUBLISHER>
<CAPABILITIES>Recursos</CAPABILITIES>
<ABI>ABIs</ABI>
<APP_NAME>Nome do aplicativo</APP_NAME>
<APP_VERSION>Versão</APP_VERSION>
<APP_VERSION_NAME>Nome da versão</APP_VERSION_NAME>
@@ -73,6 +75,7 @@
<LAST_MODIFIED>修改时间</LAST_MODIFIED>
<PUBLISHER>发布者</PUBLISHER>
<CAPABILITIES>功能</CAPABILITIES>
<ABI>支持的 ABI</ABI>
<APP_NAME>应用名称</APP_NAME>
<APP_VERSION>版本</APP_VERSION>
<APP_VERSION_NAME>版本名称</APP_VERSION_NAME>
@@ -105,6 +108,7 @@
<LAST_MODIFIED>修改時間</LAST_MODIFIED>
<PUBLISHER>發行者</PUBLISHER>
<CAPABILITIES>功能</CAPABILITIES>
<ABI>支援的 ABI</ABI>
<APP_NAME>程式名稱</APP_NAME>
<APP_VERSION>版本</APP_VERSION>
<APP_VERSION_NAME>版本名稱</APP_VERSION_NAME>
@@ -137,6 +141,7 @@
<LAST_MODIFIED>更新日時</LAST_MODIFIED>
<PUBLISHER>発行元</PUBLISHER>
<CAPABILITIES>機能</CAPABILITIES>
<ABI>対応ABI</ABI>
<APP_NAME>アプリケーションネーム</APP_NAME>
<APP_VERSION>バージョン</APP_VERSION>
<APP_VERSION_NAME>バージョン名</APP_VERSION_NAME>
@@ -169,6 +174,7 @@
<LAST_MODIFIED>Zuletzt geändert</LAST_MODIFIED>
<PUBLISHER>Herausgeber</PUBLISHER>
<CAPABILITIES>Funktionen</CAPABILITIES>
<ABI>Unterstützte ABIs</ABI>
<APP_NAME>Anwendung</APP_NAME>
<APP_VERSION>Version</APP_VERSION>
<APP_VERSION_NAME>Bezeichnung der Version</APP_VERSION_NAME>