Java Code Examples for android.os.Build#CPU_ABI

The following examples show how to use android.os.Build#CPU_ABI . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CpuInfo.java    From MobileInfo with Apache License 2.0 8 votes vote down vote up
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;

}
 
Example 2
Source File: MainActivity.java    From VirtualAPK with Apache License 2.0 7 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TextView textView = (TextView)findViewById(R.id.textView);
    String cpuArch;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        cpuArch = Build.SUPPORTED_ABIS[0];
    } else {
        cpuArch = Build.CPU_ABI;
    }
    textView.setText(cpuArch);
    Log.d("ryg", "onCreate cpu arch is "+ cpuArch);
    Log.d("ryg", "onCreate classloader is "+ getClassLoader());

    if (hasPermission()) {
        Log.d(TAG,"loadPlugin");

        this.loadPlugin(this);
    } else {
        requestPermission();
    }
}
 
Example 3
Source File: VPNLaunchHelper.java    From bitmask_android with GNU General Public License v3.0 7 votes vote down vote up
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());
}
 
Example 4
Source File: CrashConstants.java    From java-n-IDE-for-Android with Apache License 2.0 7 votes vote down vote up
/**
 * Helper method to create a salt for the crash identifier.
 *
 * @param context the context to use. Usually your Activity object.
 */
@SuppressLint("InlinedApi")
@SuppressWarnings("deprecation")
private static String createSalt(Context context) {
    String abiString;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        abiString = Build.SUPPORTED_ABIS[0];
    } else {
        abiString = Build.CPU_ABI;
    }

    String fingerprint = "HA" + (Build.BOARD.length() % 10) + (Build.BRAND.length() % 10) +
            (abiString.length() % 10) + (Build.PRODUCT.length() % 10);
    String serial = "";
    try {
        serial = android.os.Build.class.getField("SERIAL").get(null).toString();
    } catch (Throwable t) {
    }

    return fingerprint + ":" + serial;
}
 
Example 5
Source File: CrashHelper.java    From AndroidCrashHelper with MIT License 6 votes vote down vote up
/**
 * 获取崩溃异常日志
 */
public static String getDeviceInfo() {
    StringBuilder builder = new StringBuilder();
    PackageInfo pi = getPackageInfo();
    String dateTime = DateFormat.getDateTimeInstance().format(Calendar.getInstance(Locale.CHINA).getTime());
    String appName = pi.applicationInfo.loadLabel(application.getPackageManager()).toString();
    int[] pixels = getPixels();
    String cpu;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        cpu = Arrays.deepToString(Build.SUPPORTED_ABIS);
    } else {
        //noinspection deprecation
        cpu = Build.CPU_ABI;
    }
    builder.append("Date Time: ").append(dateTime).append("\n");
    builder.append("App Version: ").append(appName).append(" v").append(pi.versionName).append("(").append(pi.versionCode).append(")\n");
    builder.append("Android OS: ").append(Build.VERSION.RELEASE).append("(").append(cpu).append(")\n");
    builder.append("Phone Model: ").append(getDeviceModelName()).append("\n");
    builder.append("Screen Pixel: ").append(pixels[0]).append("x").append(pixels[1]).append(",").append(pixels[2]).append("\n\n");
    return builder.toString();
}
 
Example 6
Source File: VPNLaunchHelper.java    From Cake-VPN with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 7
Source File: VPNLaunchHelper.java    From SimpleOpenVpn-Android with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 8
Source File: Method1.java    From Busybox-Installer-No-Root with GNU General Public License v2.0 6 votes vote down vote up
protected Void doInBackground(Void... params) {
    DeleteBusybox();
    if(Build.VERSION.SDK_INT >= 21){
        s = Build.SUPPORTED_ABIS[0];
    }else{
        s = Build.CPU_ABI;
    }
    if(s.equals("arm64-v8a")){
        CreateFile("busybox", R.raw.busybox_arm64);
    }else if (s.contains("arm")){
        CreateFile("busybox", R.raw.busybox_arm);
    }else if(s.equals("x86")){
        CreateFile("busybox", R.raw.busybox_x86);
    }else if(s.equals("x86_64")){
        CreateFile("busybox", R.raw.busybox_amd64);
    }else if(s.equals("mips")){
        CreateFile("busybox", R.raw.busybox_mips);
    }else if(s.equals("mips64")){
        CreateFile("busybox", R.raw.busybox_mips64);
    }else{
        Toast.makeText(context, "Sorry, your device is not supported !", Toast.LENGTH_LONG).show();
    }
    return null;
}
 
Example 9
Source File: VPNLaunchHelper.java    From EasyVPN-Free with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 10
Source File: VPNLaunchHelper.java    From Cybernet-VPN with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 11
Source File: Method1.java    From Busybox-Installer-No-Root with GNU General Public License v2.0 6 votes vote down vote up
protected Void doInBackground(Void... params) {
    DeleteBusybox();
    if(Build.VERSION.SDK_INT >= 21){
        s = Build.SUPPORTED_ABIS[0];
    }else{
        s = Build.CPU_ABI;
    }
    if(s.equals("arm64-v8a")){
        CreateFile("busybox", R.raw.busybox_arm64);
    }else if (s.contains("arm")){
        CreateFile("busybox", R.raw.busybox_arm);
    }else if(s.equals("x86")){
        CreateFile("busybox", R.raw.busybox_x86);
    }else if(s.equals("x86_64")){
        CreateFile("busybox", R.raw.busybox_amd64);
    }else if(s.equals("mips")){
        CreateFile("busybox", R.raw.busybox_mips);
    }else if(s.equals("mips64")){
        CreateFile("busybox", R.raw.busybox_mips64);
    }else{
        Toast.makeText(context, "Sorry, your device is not supported !", Toast.LENGTH_LONG).show();
    }
    return null;
}
 
Example 12
Source File: CpuArchHelper.java    From FFmpeg-Android with MIT License 5 votes vote down vote up
public static CpuArch getCpuArch() {
    Log.d("Build.CPU_ABI : " + Build.CPU_ABI);

    switch (Build.CPU_ABI) {
        case X86_CPU:
        case X86_64_CPU:
            return CpuArch.x86;
        case ARM_64_CPU:
        case ARM_V7_CPU:
            return CpuArch.ARMv7;
        default:
            return CpuArch.NONE;
    }
}
 
Example 13
Source File: Tools.java    From m2g_android_miner with GNU General Public License v3.0 5 votes vote down vote up
public static String getABI() {
    String abiString;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        abiString = Build.SUPPORTED_ABIS[0];
    } else {
        abiString = Build.CPU_ABI;
    }
    return abiString.toLowerCase().trim();
}
 
Example 14
Source File: CpuAbiUtils.java    From Neptune with Apache License 2.0 5 votes vote down vote up
/**
 * 获取设备支持的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;
}
 
Example 15
Source File: DeviceUuidFactory.java    From apigee-android-sdk with Apache License 2.0 5 votes vote down vote up
private UUID generateDeviceUuid(Context context) {

		// Get some of the hardware information
		String buildParams = Build.BOARD + Build.BRAND + Build.CPU_ABI
				+ Build.DEVICE + Build.DISPLAY + Build.FINGERPRINT + Build.HOST
				+ Build.ID + Build.MANUFACTURER + Build.MODEL + Build.PRODUCT
				+ Build.TAGS + Build.TYPE + Build.USER;

		// Requires READ_PHONE_STATE
		TelephonyManager tm = (TelephonyManager) context
				.getSystemService(Context.TELEPHONY_SERVICE);

		// gets the imei (GSM) or MEID/ESN (CDMA)
		String imei = tm.getDeviceId();

		// gets the android-assigned id
		String androidId = Secure.getString(context.getContentResolver(),
				Secure.ANDROID_ID);

		// requires ACCESS_WIFI_STATE
		WifiManager wm = (WifiManager) context
				.getSystemService(Context.WIFI_SERVICE);

		// gets the MAC address
		String mac = wm.getConnectionInfo().getMacAddress();

		// if we've got nothing, return a random UUID
		if (isEmpty(imei) && isEmpty(androidId) && isEmpty(mac)) {
			return UUID.randomUUID();
		}

		// concatenate the string
		String fullHash = buildParams.toString() + imei + androidId + mac;

		return UUID.nameUUIDFromBytes(fullHash.getBytes());
	}
 
Example 16
Source File: CrashlyticsReportDataCapture.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
@Architecture
private static int getDeviceArchitecture() {
  final String primaryAbi = Build.CPU_ABI;

  if (TextUtils.isEmpty(primaryAbi)) {
    return Architecture.UNKNOWN;
  }

  final Integer arch = ARCHITECTURES_BY_NAME.get(primaryAbi.toLowerCase(Locale.US));
  if (arch == null) {
    return Architecture.UNKNOWN;
  }

  return arch;
}
 
Example 17
Source File: SystemLibraryLoader.java    From ReLinker with Apache License 2.0 5 votes vote down vote up
@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};
    }
}
 
Example 18
Source File: DeviceUtils.java    From Android-utils with Apache License 2.0 5 votes vote down vote up
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};
    }
}
 
Example 19
Source File: Platform9.java    From ForgePE with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public String getABIS() {
    return Build.CPU_ABI;
}
 
Example 20
Source File: SoFileLoader.java    From ZjDroid with Apache License 2.0 2 votes vote down vote up
public static void loadLibrary(String libName) {


        try {
            ZipFile zipFile = new ZipFile(ReverseXposedModule.MODULE_PATH);


            String soEntryPath;


            if (Build.VERSION.SDK_INT >= 21) {
                soEntryPath = "lib" + "/" + getSuitAbi() + "/lib" + libName + ".so";
            } else {
                soEntryPath = "lib" + "/" + Build.CPU_ABI + "/lib" + libName + ".so";
            }

            ZipEntry soEntry = zipFile.getEntry(soEntryPath);


            if (soEntry.isDirectory()) {
                Logger.log(soEntryPath + " in " + ReverseXposedModule.MODULE_PATH + " is not a file");
                return;
            } else {

                File outFileDir = new File(ReverseXposedModule.APPINFO_DATA_DIR + "/" + CACHE_NAME + "/" + SO_CACHE_SECONDARY_FOLDER_NAME);

                if (!outFileDir.exists()) {
                    outFileDir.mkdirs();
                }

                File outFile = new File(outFileDir, "lib" + libName + ".so");

                FileOutputStream fileOutputStream = new FileOutputStream(outFile);

                InputStream inputStream = zipFile.getInputStream(soEntry);

                byte[] temp = new byte[2048];

                int len;

                while ((len = inputStream.read(temp)) != -1) {
                    fileOutputStream.write(temp, 0, len);
                }

                inputStream.close();
                fileOutputStream.close();

                System.load(outFile.getAbsolutePath());

                outFile.delete();
                outFileDir.delete();
                outFileDir.getParentFile().delete();

            }


        } catch (IOException e) {
            Logger.log("Load So File Error!");
            e.printStackTrace();
        }

    }