diff --git a/ApkManager/AdbWindow.xaml.cs b/ApkManager/AdbWindow.xaml.cs index f3a19e1..3af87da 100644 --- a/ApkManager/AdbWindow.xaml.cs +++ b/ApkManager/AdbWindow.xaml.cs @@ -110,20 +110,19 @@ private async void ComboDevices_SelectionChanged(object sender, SelectionChanged if (!string.IsNullOrWhiteSpace(address)) { var device = await adb.GetDevice(address); - var isArchSupported = apk.AbiList.Equals("any-cpu") || apk.Platforms.Contains(device.Arch) || - (apk.AbiList.Equals("armeabi") && device.Arch.StartsWith("arm")); - var isSdkSupported = apk.SdkVersion <= device.Sdk; + var isArchCompatible = apk.isAbiCompatible(device); + var isSdkCompatible = apk.isSdkCompatible(device); txtDevice.Text = device.Name; txtAndroid.Text = device.Android; txtArch.Text = device.Arch; - txtArch.Foreground = isArchSupported ? txtArch.Foreground : Brushes.Red; - txtArch.ToolTip = isArchSupported ? null : "not compatible"; + txtArch.Foreground = isArchCompatible ? txtArch.Foreground : Brushes.Red; + txtArch.ToolTip = isArchCompatible ? null : "not compatible"; txtSdk.Text = device.Sdk.ToString(); - txtSdk.Foreground = isSdkSupported ? txtArch.Foreground : Brushes.Red; - txtSdk.ToolTip = isSdkSupported ? null : "not compatible"; + txtSdk.Foreground = isSdkCompatible ? txtArch.Foreground : Brushes.Red; + txtSdk.ToolTip = isSdkCompatible ? null : "not compatible"; gbAction.IsEnabled = true; - btnMenuInstall.IsEnabled = isArchSupported && isSdkSupported; + btnMenuInstall.IsEnabled = apk.canInstallTo(device); } } diff --git a/ApkManager/Lib/Adb.cs b/ApkManager/Lib/Adb.cs index 8c77ce7..2ad6e12 100644 --- a/ApkManager/Lib/Adb.cs +++ b/ApkManager/Lib/Adb.cs @@ -8,7 +8,7 @@ namespace ApkManager { - internal class Adb + public class Adb { public class Device { diff --git a/ApkManager/Lib/Apk.cs b/ApkManager/Lib/Apk.cs index 2e0a1d1..77d31c7 100644 --- a/ApkManager/Lib/Apk.cs +++ b/ApkManager/Lib/Apk.cs @@ -23,5 +23,37 @@ public Apk() Permissions = new List(); Platforms = new List(); } + + public bool isAbiCompatible(Adb.Device device) + { + if (AbiList == "any-cpu") return true; + + if (device.Arch == "armeabi-v7a") + { + return AbiList.Contains("armeabi"); + } + + if (device.Arch == "arm64-v8a") + { + return AbiList.Contains("arm"); + } + + if (device.Arch == "x86_64") + { + return AbiList.Contains("x86"); + } + + return AbiList.Contains(device.Arch); + } + + public bool isSdkCompatible(Adb.Device device) + { + return SdkVersion <= device.Sdk; + } + + public bool canInstallTo(Adb.Device device) + { + return isAbiCompatible(device) && isSdkCompatible(device); + } } }