mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 03:05:18 +08:00
Check arches in order of preference
The documentation for Build.SUPPORTED_ABIS says: "An ordered list of ABIs supported by this device. The most preferred ABI is the first element in the list." Respect that preference when checking for which arch to install packages for. Fixes #131.
This commit is contained in:
@@ -26,7 +26,9 @@ import java.net.MalformedURLException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
@@ -184,25 +186,28 @@ final class TermuxInstaller {
|
|||||||
|
|
||||||
/** Get bootstrap zip url for this systems cpu architecture. */
|
/** Get bootstrap zip url for this systems cpu architecture. */
|
||||||
static URL determineZipUrl() throws MalformedURLException {
|
static URL determineZipUrl() throws MalformedURLException {
|
||||||
String termuxArch = null;
|
String archName = determineTermuxArchName();
|
||||||
|
return new URL("https://termux.net/bootstrap/bootstrap-" + archName + ".zip");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String determineTermuxArchName() {
|
||||||
// Note that we cannot use System.getProperty("os.arch") since that may give e.g. "aarch64"
|
// Note that we cannot use System.getProperty("os.arch") since that may give e.g. "aarch64"
|
||||||
// while a 64-bit runtime may not be installed (like on the Samsung Galaxy S5 Neo).
|
// while a 64-bit runtime may not be installed (like on the Samsung Galaxy S5 Neo).
|
||||||
// Instead we search through the supported abi:s on the device, see:
|
// Instead we search through the supported abi:s on the device, see:
|
||||||
// http://developer.android.com/ndk/guides/abis.html
|
// http://developer.android.com/ndk/guides/abis.html
|
||||||
// Note that we search for abi:s in preferred order, and want to avoid installing arm on
|
// Note that we search for abi:s in preferred order (the ordering of the
|
||||||
// an x86 system where arm emulation is available.
|
// Build.SUPPORTED_ABIS list) to avoid e.g. installing arm on an x86 system where arm
|
||||||
final String[] androidArchNames = {"arm64-v8a", "x86_64", "x86", "armeabi-v7a"};
|
// emulation is available.
|
||||||
final String[] termuxArchNames = {"aarch64", "x86_64", "i686", "arm"};
|
for (String androidArch : Build.SUPPORTED_ABIS) {
|
||||||
|
switch (androidArch) {
|
||||||
final List<String> supportedArches = Arrays.asList(Build.SUPPORTED_ABIS);
|
case "arm64-v8a": return "aarch64";
|
||||||
for (int i = 0; i < termuxArchNames.length; i++) {
|
case "armeabi-v7a": return "arm";
|
||||||
if (supportedArches.contains(androidArchNames[i])) {
|
case "x86_64": return "x86_64";
|
||||||
termuxArch = termuxArchNames[i];
|
case "x86": return "i686";
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
throw new RuntimeException("Unable to determine arch from Build.SUPPORTED_ABIS = " +
|
||||||
return new URL("https://termux.net/bootstrap/bootstrap-" + termuxArch + ".zip");
|
Arrays.toString(Build.SUPPORTED_ABIS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Delete a folder and all its content or throw. */
|
/** Delete a folder and all its content or throw. */
|
||||||
|
Reference in New Issue
Block a user