Support devices with more than two ABIs on >=21
Also, start using String[] like Android's SUPPORTED_ABIS instead of Set<String>. Said list of ABIs will always be very short, at most containing a handful of elements.
This commit is contained in:
parent
a03053e80a
commit
55c1bd0572
@ -18,7 +18,7 @@ public class CompatibilityChecker extends Compatibility {
|
||||
|
||||
private Context context;
|
||||
private Set<String> features;
|
||||
private Set<String> cpuAbis;
|
||||
private String[] cpuAbis;
|
||||
private String cpuAbisDesc;
|
||||
private boolean ignoreTouchscreen;
|
||||
|
||||
@ -59,8 +59,8 @@ public class CompatibilityChecker extends Compatibility {
|
||||
|
||||
private boolean compatibleApi(Utils.CommaSeparatedList nativecode) {
|
||||
if (nativecode == null) return true;
|
||||
for (String abi : nativecode) {
|
||||
if (cpuAbis.contains(abi)) {
|
||||
for (final String abi : nativecode) {
|
||||
if (Utils.arrayContains(cpuAbis, abi)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -79,7 +79,7 @@ public class CompatibilityChecker extends Compatibility {
|
||||
}
|
||||
|
||||
if (apk.features != null) {
|
||||
for (String feat : apk.features) {
|
||||
for (final String feat : apk.features) {
|
||||
if (ignoreTouchscreen
|
||||
&& feat.equals("android.hardware.touchscreen")) {
|
||||
// Don't check it!
|
||||
|
@ -507,4 +507,13 @@ public final class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> boolean arrayContains(final T[] array, final T v) {
|
||||
for (final T e : array) {
|
||||
if (e == v || v != null && v.equals(e)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,30 +1,35 @@
|
||||
package org.fdroid.fdroid.compat;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
|
||||
public class SupportedArchitectures extends Compatibility {
|
||||
|
||||
private static Set<String> getOneAbi() {
|
||||
Set<String> abis = new HashSet<String>(1);
|
||||
abis.add(Build.CPU_ABI);
|
||||
return abis;
|
||||
private static String[] getAbisDonut() {
|
||||
return new String[]{Build.CPU_ABI};
|
||||
}
|
||||
|
||||
@TargetApi(8)
|
||||
private static Set<String> getTwoAbis() {
|
||||
Set<String> abis = new HashSet<String>(2);
|
||||
abis.add(Build.CPU_ABI);
|
||||
abis.add(Build.CPU_ABI2);
|
||||
return abis;
|
||||
private static String[] getAbisFroyo() {
|
||||
return new String[]{Build.CPU_ABI, Build.CPU_ABI2};
|
||||
}
|
||||
|
||||
public static Set<String> getAbis() {
|
||||
if (hasApi(8)) return getTwoAbis();
|
||||
return getOneAbi();
|
||||
@TargetApi(21)
|
||||
private static String[] getAbisLollipop() {
|
||||
return Build.SUPPORTED_ABIS;
|
||||
}
|
||||
|
||||
/**
|
||||
* The most preferred ABI is the first element in the list.
|
||||
*/
|
||||
public static String[] getAbis() {
|
||||
if (hasApi(21)) {
|
||||
return getAbisLollipop();
|
||||
}
|
||||
if (hasApi(8)) {
|
||||
return getAbisFroyo();
|
||||
}
|
||||
return getAbisDonut();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user