下面列出了android.os.Build#CPU_ABI2 ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static String writeMiniVPN(Context context) {
String[] abis;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) abis = getSupportedABIsLollipop();
else
//noinspection deprecation
abis = new String[]{Build.CPU_ABI, Build.CPU_ABI2};
String nativeAPI = NativeUtils.getNativeAPI();
if (!nativeAPI.equals(abis[0])) {
VpnStatus.logWarning(R.string.abi_mismatch, Arrays.toString(abis), nativeAPI);
abis = new String[]{nativeAPI};
}
for (String abi : abis) {
File vpnExecutable = new File(context.getCacheDir(), getMiniVPNExecutableName() + "." + abi);
if ((vpnExecutable.exists() && vpnExecutable.canExecute()) || writeMiniVPNBinary(context, abi, vpnExecutable)) {
return vpnExecutable.getPath();
}
}
return null;
}
private static String writeMiniVPN(Context context) {
String[] abis;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
abis = getSupportedABIsLollipop();
else
//noinspection deprecation
abis = new String[]{Build.CPU_ABI, Build.CPU_ABI2};
String nativeAPI = NativeUtils.getNativeAPI();
if (!nativeAPI.equals(abis[0])) {
VpnStatus.logWarning(R.string.abi_mismatch, Arrays.toString(abis), nativeAPI);
abis = new String[] {nativeAPI};
}
for (String abi: abis) {
File vpnExecutable = new File(context.getCacheDir(), getMiniVPNExecutableName() + "." + abi);
if ((vpnExecutable.exists() && vpnExecutable.canExecute()) || writeMiniVPNBinary(context, abi, vpnExecutable)) {
return vpnExecutable.getPath();
}
}
return null;
}
private static String putCpuAbi() {
String[] abis;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
abis = Build.SUPPORTED_ABIS;
} else {
abis = new String[]{Build.CPU_ABI, Build.CPU_ABI2};
}
StringBuilder stringBuilder = new StringBuilder();
for (String abi : abis) {
stringBuilder.append(abi);
stringBuilder.append(",");
}
try {
return stringBuilder.toString().substring(0, stringBuilder.toString().length() - 1);
} catch (Exception e) {
Log.i(TAG, e.toString());
}
return null;
}
public static String getDeviceDetails(Context context) {
return "Device Information\n"
+ "\nAPP.VERSION : " + getAppVersion(context)
+ "\nLAUNCHER.APP : " + getCurrentLauncherApp(context)
+ "\nTIMEZONE : " + timeZone()
+ "\nVERSION.RELEASE : " + Build.VERSION.RELEASE
+ "\nVERSION.INCREMENTAL : " + Build.VERSION.INCREMENTAL
+ "\nVERSION.SDK.NUMBER : " + Build.VERSION.SDK_INT
+ "\nBRAND : " + Build.BRAND
+ "\nCPU_ABI : " + Build.CPU_ABI
+ "\nCPU_ABI2 : " + Build.CPU_ABI2
+ "\nMANUFACTURER : " + Build.MANUFACTURER
+ "\nMODEL : " + Build.MODEL
+ "\nPRODUCT : " + Build.PRODUCT;
}
private static String writeMiniVPN(Context context) {
String[] abis;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) abis = getSupportedABIsLollipop();
else
//noinspection deprecation
abis = new String[]{Build.CPU_ABI, Build.CPU_ABI2};
String nativeAPI = NativeUtils.getNativeAPI();
if (!nativeAPI.equals(abis[0])) {
VpnStatus.logWarning(R.string.abi_mismatch, Arrays.toString(abis), nativeAPI);
abis = new String[]{nativeAPI};
}
for (String abi : abis) {
File vpnExecutable = new File(context.getCacheDir(), getMiniVPNExecutableName() + "." + abi);
if ((vpnExecutable.exists() && vpnExecutable.canExecute()) || writeMiniVPNBinary(context, abi, vpnExecutable)) {
return vpnExecutable.getPath();
}
}
return null;
}
private static String writeMiniVPN(Context context) {
String[] abis;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
abis = getSupportedABIsLollipop();
else
//noinspection deprecation
abis = new String[]{Build.CPU_ABI, Build.CPU_ABI2};
String nativeAPI = NativeUtils.getNativeAPI();
if (!nativeAPI.equals(abis[0])) {
VpnStatus.logWarning(R.string.abi_mismatch, Arrays.toString(abis), nativeAPI);
abis = new String[]{nativeAPI};
}
for (String abi : abis) {
File vpnExecutable = new File(context.getCacheDir(), "c_" + getMiniVPNExecutableName() + "." + abi);
if ((vpnExecutable.exists() && vpnExecutable.canExecute()) || writeMiniVPNBinary(context, abi, vpnExecutable)) {
return vpnExecutable.getPath();
}
}
throw new RuntimeException("Cannot find any execulte for this device's ABIs " + abis.toString());
}
private static String writeMiniVPN(Context context) {
String[] abis;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
abis = getSupportedABIsLollipop();
else
//noinspection deprecation
abis = new String[]{Build.CPU_ABI, Build.CPU_ABI2};
String nativeAPI = NativeUtils.getNativeAPI();
if (!nativeAPI.equals(abis[0])) {
VpnStatus.logWarning(R.string.abi_mismatch, Arrays.toString(abis), nativeAPI);
abis = new String[] {nativeAPI};
}
for (String abi: abis) {
File vpnExecutable = new File(context.getCacheDir(), getMiniVPNExecutableName() + "." + abi);
if ((vpnExecutable.exists() && vpnExecutable.canExecute()) || writeMiniVPNBinary(context, abi, vpnExecutable)) {
return vpnExecutable.getPath();
}
}
return null;
}
private static @NonNull Iterable<String> getSupportedAbis() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return Arrays.asList(Build.SUPPORTED_ABIS);
} else {
LinkedList<String> abis = new LinkedList<>();
abis.add(Build.CPU_ABI);
if (Build.CPU_ABI2 != null && !"unknown".equals(Build.CPU_ABI2)) {
abis.add(Build.CPU_ABI2);
}
return abis;
}
}
/**
* Return an list of ABIs we supported on this device ordered according to preference. Use a
* separate inner class to isolate the version-dependent call where it won't cause the whole class
* to fail preverification.
*
* @return Ordered array of supported ABIs
*/
public static String[] getSupportedAbis() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return MarshmallowSysdeps.getSupportedAbis();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return LollipopSysdeps.getSupportedAbis();
} else {
return new String[] {Build.CPU_ABI, Build.CPU_ABI2};
}
}
public static String[] getABIs() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return Build.SUPPORTED_ABIS;
} else {
if (!TextUtils.isEmpty(Build.CPU_ABI2)) {
return new String[]{Build.CPU_ABI, Build.CPU_ABI2};
}
return new String[]{Build.CPU_ABI};
}
}
private static String getCPUType() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return join(",", Build.SUPPORTED_ABIS);
} else {
if (!TextUtils.isEmpty(Build.CPU_ABI2)) {
return Build.CPU_ABI + "," + Build.CPU_ABI2;
}
return Build.CPU_ABI;
}
}
@Override
public String[] supportedAbis() {
if (Build.VERSION.SDK_INT >= 21 && Build.SUPPORTED_ABIS.length > 0) {
return Build.SUPPORTED_ABIS;
} else if (!TextUtils.isEmpty(Build.CPU_ABI2)) {
return new String[] {Build.CPU_ABI, Build.CPU_ABI2};
} else {
return new String[] {Build.CPU_ABI};
}
}
/**
* 获取支持的指令集 如: [arm64-v8a, armeabi-v7a, armeabi]
* @return 支持的指令集
*/
public static String[] getABIs() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return Build.SUPPORTED_ABIS;
} else {
if (!TextUtils.isEmpty(Build.CPU_ABI2)) {
return new String[]{Build.CPU_ABI, Build.CPU_ABI2};
}
return new String[]{Build.CPU_ABI};
}
}
/**
* Return an ordered list of ABIs supported by this device. The most preferred ABI is the first
* element in the list.
*
* @return an ordered list of ABIs supported by this device
*/
public static String[] getABIs() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return Build.SUPPORTED_ABIS;
} else {
if (!TextUtils.isEmpty(Build.CPU_ABI2)) {
return new String[]{Build.CPU_ABI, Build.CPU_ABI2};
}
return new String[]{Build.CPU_ABI};
}
}
/**
* 获取设备支持的abi列表
*/
public static String[] getSupportAbis() {
String[] cpuAbis;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cpuAbis = Build.SUPPORTED_ABIS;
} else {
cpuAbis = new String[]{Build.CPU_ABI, Build.CPU_ABI2};
}
// avoid NPE
if (cpuAbis == null) {
cpuAbis = new String[0];
}
return cpuAbis;
}
/**
* The most preferred ABI is the first element in the list.
*/
@TargetApi(21)
@SuppressWarnings("deprecation")
public static String[] getAbis() {
if (Build.VERSION.SDK_INT >= 21) {
return Build.SUPPORTED_ABIS;
}
return new String[]{Build.CPU_ABI, Build.CPU_ABI2};
}
public static String getDeviceDetails(Context context) {
return "Device Information\n"
+ "\nDEVICE.ID : " + getDeviceId(context)
+ "\nUSER.ID : " + getUserIdentity(context)
+ "\nAPP.VERSION : " + getAppVersion(context)
+ "\nLAUNCHER.APP : " + getCurrentLauncherApp(context)
+ "\nTIMEZONE : " + timeZone()
+ "\nVERSION.RELEASE : " + Build.VERSION.RELEASE
+ "\nVERSION.INCREMENTAL : " + Build.VERSION.INCREMENTAL
+ "\nVERSION.SDK.NUMBER : " + Build.VERSION.SDK_INT
+ "\nBOARD : " + Build.BOARD
+ "\nBOOTLOADER : " + Build.BOOTLOADER
+ "\nBRAND : " + Build.BRAND
+ "\nCPU_ABI : " + Build.CPU_ABI
+ "\nCPU_ABI2 : " + Build.CPU_ABI2
+ "\nDISPLAY : " + Build.DISPLAY
+ "\nFINGERPRINT : " + Build.FINGERPRINT
+ "\nHARDWARE : " + Build.HARDWARE
+ "\nHOST : " + Build.HOST
+ "\nID : " + Build.ID
+ "\nMANUFACTURER : " + Build.MANUFACTURER
+ "\nMODEL : " + Build.MODEL
+ "\nPRODUCT : " + Build.PRODUCT
+ "\nSERIAL : " + Build.SERIAL
+ "\nTAGS : " + Build.TAGS
+ "\nTIME : " + Build.TIME
+ "\nTYPE : " + Build.TYPE
+ "\nUNKNOWN : " + Build.UNKNOWN
+ "\nUSER : " + Build.USER;
}
/**
* Return an ordered list of ABIs supported by this device. The most preferred ABI is the first
* element in the list.
*
* @return an ordered list of ABIs supported by this device
*/
public static String[] getABIs() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return Build.SUPPORTED_ABIS;
} else {
if (!TextUtils.isEmpty(Build.CPU_ABI2)) {
return new String[]{Build.CPU_ABI, Build.CPU_ABI2};
}
return new String[]{Build.CPU_ABI};
}
}
private String donexteabi() {
switch (currentEabi++) {
case 0:
return Build.CPU_ABI;
case 1:
return Build.CPU_ABI2;
}
return null;
}
public static String getABI() {
String CPU_ABI = Build.CPU_ABI;
String CPU_ABI2 = Build.CPU_ABI2;
return CPU_ABI + " " + CPU_ABI2;
}