mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix: gracefully handle unsupported ABIs
This commit is contained in:
+4
-3
@@ -44,8 +44,9 @@ open class IDEBuildConfigProviderImpl : IDEBuildConfigProvider {
|
||||
get() = CpuArch.forAbi(cpuAbiName)!!
|
||||
|
||||
override val deviceArch: CpuArch
|
||||
get() = CpuArch.forAbi(supportedAbis[0])!!
|
||||
get() = CpuArch.forAbi(Build.SUPPORTED_ABIS[0])!!
|
||||
|
||||
override val supportedAbis: Array<String>
|
||||
get() = Build.SUPPORTED_ABIS
|
||||
override val supportedAbis: Array<String> by lazy {
|
||||
arrayOf(BuildConfig.ABI_ARM64_V8A, BuildConfig.ABI_ARMEABI_V7A, BuildConfig.ABI_X86_64)
|
||||
}
|
||||
}
|
||||
@@ -40,9 +40,6 @@ class IDEBuildConfigProviderImplTest {
|
||||
assertThat(cpuArch).isEqualTo(CpuArch.AARCH64)
|
||||
assertThat(deviceArch).isEqualTo(CpuArch.AARCH64)
|
||||
|
||||
assertThat(supportedAbis.toList()).containsExactly(ABI_ARM64_V8A)
|
||||
|
||||
|
||||
assertThat(isArm64v8aBuild()).isTrue()
|
||||
assertThat(isX86_64Build()).isFalse()
|
||||
assertThat(isArmeabiv7aBuild()).isFalse()
|
||||
@@ -63,9 +60,6 @@ class IDEBuildConfigProviderImplTest {
|
||||
assertThat(cpuArch).isEqualTo(CpuArch.ARM)
|
||||
assertThat(deviceArch).isEqualTo(CpuArch.ARM)
|
||||
|
||||
assertThat(supportedAbis.toList()).containsExactly(ABI_ARMEABI_V7A)
|
||||
|
||||
|
||||
assertThat(isArm64v8aBuild()).isFalse()
|
||||
assertThat(isX86_64Build()).isFalse()
|
||||
assertThat(isArmeabiv7aBuild()).isTrue()
|
||||
@@ -86,9 +80,6 @@ class IDEBuildConfigProviderImplTest {
|
||||
assertThat(cpuArch).isEqualTo(CpuArch.X86_64)
|
||||
assertThat(deviceArch).isEqualTo(CpuArch.X86_64)
|
||||
|
||||
assertThat(supportedAbis.toList()).containsExactly(ABI_X86_64)
|
||||
|
||||
|
||||
assertThat(isArm64v8aBuild()).isFalse()
|
||||
assertThat(isX86_64Build()).isTrue()
|
||||
assertThat(isArmeabiv7aBuild()).isFalse()
|
||||
@@ -109,9 +100,6 @@ class IDEBuildConfigProviderImplTest {
|
||||
assertThat(cpuArch).isEqualTo(CpuArch.ARM)
|
||||
assertThat(deviceArch).isEqualTo(CpuArch.AARCH64)
|
||||
|
||||
assertThat(supportedAbis.toList()).containsExactly(ABI_ARM64_V8A, ABI_ARMEABI_V7A)
|
||||
|
||||
|
||||
assertThat(isArm64v8aBuild()).isFalse()
|
||||
assertThat(isX86_64Build()).isFalse()
|
||||
assertThat(isArmeabiv7aBuild()).isTrue()
|
||||
@@ -132,9 +120,6 @@ class IDEBuildConfigProviderImplTest {
|
||||
assertThat(cpuArch).isEqualTo(CpuArch.ARM)
|
||||
assertThat(deviceArch).isEqualTo(CpuArch.X86_64)
|
||||
|
||||
assertThat(supportedAbis.toList()).containsExactly(ABI_X86_64, ABI_ARMEABI_V7A)
|
||||
|
||||
|
||||
assertThat(isArm64v8aBuild()).isFalse()
|
||||
assertThat(isX86_64Build()).isFalse()
|
||||
assertThat(isArmeabiv7aBuild()).isTrue()
|
||||
@@ -155,9 +140,6 @@ class IDEBuildConfigProviderImplTest {
|
||||
assertThat(cpuArch).isEqualTo(CpuArch.AARCH64)
|
||||
assertThat(deviceArch).isEqualTo(CpuArch.ARM)
|
||||
|
||||
assertThat(supportedAbis.toList()).containsExactly(ABI_ARMEABI_V7A)
|
||||
|
||||
|
||||
assertThat(isArm64v8aBuild()).isTrue()
|
||||
assertThat(isX86_64Build()).isFalse()
|
||||
assertThat(isArmeabiv7aBuild()).isFalse()
|
||||
@@ -178,9 +160,6 @@ class IDEBuildConfigProviderImplTest {
|
||||
assertThat(cpuArch).isEqualTo(CpuArch.AARCH64)
|
||||
assertThat(deviceArch).isEqualTo(CpuArch.X86_64)
|
||||
|
||||
assertThat(supportedAbis.toList()).containsExactly(ABI_X86_64)
|
||||
|
||||
|
||||
assertThat(isArm64v8aBuild()).isTrue()
|
||||
assertThat(isX86_64Build()).isFalse()
|
||||
assertThat(isArmeabiv7aBuild()).isFalse()
|
||||
@@ -201,9 +180,6 @@ class IDEBuildConfigProviderImplTest {
|
||||
assertThat(cpuArch).isEqualTo(CpuArch.AARCH64)
|
||||
assertThat(deviceArch).isEqualTo(CpuArch.X86_64)
|
||||
|
||||
assertThat(supportedAbis.toList()).containsExactly(ABI_X86_64, ABI_ARM64_V8A)
|
||||
|
||||
|
||||
assertThat(isArm64v8aBuild()).isTrue()
|
||||
assertThat(isX86_64Build()).isFalse()
|
||||
assertThat(isArmeabiv7aBuild()).isFalse()
|
||||
|
||||
@@ -67,6 +67,7 @@ abstract class SetupAapt2Task : DefaultTask() {
|
||||
"F-Droid AAPT2 file does not exist or is not a file: $aapt2"
|
||||
}
|
||||
|
||||
logger.info("Copying $aapt2 to $file")
|
||||
aapt2.copyTo(file, overwrite = true)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -35,14 +35,20 @@ object DownloadUtils {
|
||||
* Download the file at given [URL][remoteUrl] to the given [local file][file] and verify the
|
||||
* SHA-256 checksum of the downloaded file with the [expected checksum][expectedChecksum].
|
||||
*/
|
||||
fun doDownload(file: File, remoteUrl: String, expectedChecksum: String,
|
||||
logger: Logger) {
|
||||
fun doDownload(
|
||||
file: File,
|
||||
remoteUrl: String,
|
||||
expectedChecksum: String,
|
||||
logger: Logger
|
||||
) {
|
||||
|
||||
logger.info("Download $remoteUrl to $file having checksum ${expectedChecksum}...")
|
||||
|
||||
val digest = MessageDigest.getInstance("SHA-256")
|
||||
|
||||
if (file.exists()) {
|
||||
logger.debug("{} already exists. Checking checksum...", file)
|
||||
|
||||
digest.update(file.readBytes())
|
||||
var checksum = BigInteger(1, digest.digest()).toString(16)
|
||||
while (checksum.length < 64) {
|
||||
@@ -59,7 +65,7 @@ object DownloadUtils {
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Downloading ${remoteUrl}...")
|
||||
logger.info("File does not exist. Downloading ${remoteUrl}...")
|
||||
|
||||
file.parentFile.mkdirs()
|
||||
|
||||
|
||||
@@ -29,15 +29,20 @@ enum class CpuArch(val abi: String) {
|
||||
*/
|
||||
AARCH64("arm64-v8a"),
|
||||
|
||||
/**
|
||||
* `x86_64` (64-bit).
|
||||
*/
|
||||
X86_64("x86_64"),
|
||||
|
||||
/**
|
||||
* `armeabi-v7a` flavor (32-bit).
|
||||
*/
|
||||
ARM("armeabi-v7a");
|
||||
ARM("armeabi-v7a"),
|
||||
|
||||
/**
|
||||
* `x86` (32-bit).
|
||||
*/
|
||||
X86("x86"),
|
||||
|
||||
/**
|
||||
* `x86_64` (64-bit).
|
||||
*/
|
||||
X86_64("x86_64");
|
||||
|
||||
companion object {
|
||||
|
||||
|
||||
@@ -176,13 +176,11 @@ public class ToolsManager {
|
||||
final var context = BaseApplication.getBaseInstance();
|
||||
final var nativeLibraryDir = context.getApplicationInfo().nativeLibraryDir;
|
||||
final var sourceAapt2 = new File(nativeLibraryDir, "libaapt2.so");
|
||||
if (!(sourceAapt2.exists() && sourceAapt2.isFile())) {
|
||||
// halt the application
|
||||
TaskExecutorKt.runOnUiThread(() -> {
|
||||
throw new IllegalStateException(sourceAapt2 + " does not exist!");
|
||||
});
|
||||
if (sourceAapt2.exists() && sourceAapt2.isFile()) {
|
||||
FilesKt.copyTo(sourceAapt2, Environment.AAPT2, true, ConstantsKt.DEFAULT_BUFFER_SIZE);
|
||||
} else {
|
||||
LOG.error(sourceAapt2 + " file does not exist! This can be problematic.");
|
||||
}
|
||||
FilesKt.copyTo(sourceAapt2, Environment.AAPT2, true, ConstantsKt.DEFAULT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
if (!Environment.AAPT2.canExecute() && !Environment.AAPT2.setExecutable(true)) {
|
||||
|
||||
Reference in New Issue
Block a user