Example usage for android.os Build CPU_ABI

List of usage examples for android.os Build CPU_ABI

Introduction

In this page you can find the example usage for android.os Build CPU_ABI.

Prototype

String CPU_ABI

To view the source code for android.os Build CPU_ABI.

Click Source Link

Document

The name of the instruction set (CPU type + ABI convention) of native code.

Usage

From source file:com.appbackr.android.tracker.Tracker.java

/**
  * Generates a unique ID for the device.
  * //from w  ww  .  j  av a2s.  com
  * This function obtain the Unique ID from the phone. The Unique ID consist of
  *    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;
  *    + IMEI (GSM) or MEID/ESN (CDMA)
  *    + Android-assigned id
  * 
  * The Android ID may be changed everytime the user perform Factory Reset
  * I heard that IMEI values might not be unique because phone factory
  * might reuse IMEI values to cut cost.
  * 
  * While the ID might be different from the same device, but resetting of the
  * Android phone should not occur that often. The values should be close 
  * enough.
  *
  * @param c android application contact 
  * @return unique ID as md5 hash generated of available parameters from device and cell phone service provider
  */
 private static String getUDID(Context c) {

     // 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) c.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(c.getContentResolver(), Secure.ANDROID_ID);

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

     return md5(fullHash);
 }

From source file:org.namelessrom.devicecontrol.device.DeviceInformationGeneralFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    addPreferencesFromResource(R.xml.device_information_general);

    final Device device = Device.get();

    // Platform/*from www .j  a v  a  2s  .c  om*/
    PreferenceCategory category = (PreferenceCategory) findPreference("platform");

    addPreference(category, KEY_PLATFORM_VERSION, R.string.version, device.platformVersion).setSelectable(true); // selectable because of the easter egg
    addPreference(category, "platform_id", R.string.build_id, device.platformId);
    addPreference(category, "platform_type", R.string.type, device.platformType);
    addPreference(category, "platform_tags", R.string.tags, device.platformTags);
    addPreference(category, "platform_build_date", R.string.build_date, device.platformBuildType);

    // Runtime
    category = (PreferenceCategory) findPreference("runtime");

    addPreference(category, "vm_library", R.string.type, device.vmLibrary);
    addPreference(category, "vm_version", R.string.version, device.vmVersion);

    // Device
    category = (PreferenceCategory) findPreference("device_information");

    // TODO: save / restore / check --> ANDROID ID
    addPreference(category, KEY_ANDROID_ID, R.string.android_id, device.androidId);
    addPreference(category, "device_manufacturer", R.string.manufacturer, device.manufacturer);
    addPreference(category, "device_model", R.string.model, device.model);
    addPreference(category, "device_product", R.string.product, device.product);
    addPreference(category, "device_board", R.string.board, device.board);
    addPreference(category, "device_bootloader", R.string.bootloader, device.bootloader);
    addPreference(category, "device_radio_version", R.string.radio_version, device.radio);

    // eMMC
    category = (PreferenceCategory) findPreference("emmc");
    addPreference(category, "emmc_name", R.string.name, Emmc.get().getName());
    addPreference(category, "emmc_cid", R.string.emmc_cid, Emmc.get().getCid());
    addPreference(category, "emmc_mid", R.string.emmc_mid, Emmc.get().getMid());
    addPreference(category, "emmc_rev", R.string.emmc_rev, Emmc.get().getRev());
    addPreference(category, "emmc_date", R.string.emmc_date, Emmc.get().getDate());
    String tmp = Emmc.get().canBrick() ? getString(R.string.emmc_can_brick_true)
            : getString(R.string.emmc_can_brick_false);
    tmp = String.format("%s\n%s", tmp, getString(R.string.press_learn_more));
    addPreference(category, "emmc_can_brick", R.string.emmc_can_brick, tmp).setSelectable(true);

    // Processor
    category = (PreferenceCategory) findPreference("processor");

    final String cpuAbi = getString(R.string.cpu_abi);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final int bitResId = Build.SUPPORTED_64_BIT_ABIS.length == 0 ? R.string.bit_32 : R.string.bit_64;
        addPreference(category, "cpu_bit", R.string.arch, getString(bitResId));
        for (int i = 0; i < Build.SUPPORTED_ABIS.length; i++) {
            addPreference(category, String.format("cpu_abi%s", i + 1), cpuAbi + String.valueOf(i + 1),
                    Build.SUPPORTED_ABIS[i]);
        }
    } else {
        //noinspection deprecation
        addPreference(category, "cpu_abi", cpuAbi, Build.CPU_ABI);
        //noinspection deprecation
        addPreference(category, "cpu_abi2", cpuAbi + "2", Build.CPU_ABI2);
    }
    new CpuInfoTask(category).execute();

    // Kernel
    category = (PreferenceCategory) findPreference("kernel");
    new KernelInfoTask(category).execute();

    // Memory
    category = (PreferenceCategory) findPreference("memory");
    new MemoryInfoTask(category).execute();

    if (category.getPreferenceCount() == 0) {
        getPreferenceScreen().removePreference(category);
    }
}

From source file:com.mozilla.SUTAgentAndroid.SUTAgentAndroid.java

/** Called when the activity is first created. */
@Override/*ww w.  j  a  v  a  2 s .  c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    fixScreenOrientation();

    DoCommand dc = new DoCommand(getApplication());

    Log.i("SUTAgentAndroid", dc.prgVersion);
    dc.FixDataLocalPermissions();

    // Get configuration settings from "ini" file
    File dir = getFilesDir();
    File iniFile = new File(dir, "SUTAgent.ini");
    String sIniFile = iniFile.getAbsolutePath();

    String lc = dc.GetIniData("General", "LogCommands", sIniFile);
    if (lc != "" && Integer.parseInt(lc) == 1) {
        SUTAgentAndroid.LogCommands = true;
    }
    SUTAgentAndroid.RegSvrIPAddr = dc.GetIniData("Registration Server", "IPAddr", sIniFile);
    SUTAgentAndroid.RegSvrIPPort = dc.GetIniData("Registration Server", "PORT", sIniFile);
    SUTAgentAndroid.HardwareID = dc.GetIniData("Registration Server", "HARDWARE", sIniFile);
    SUTAgentAndroid.Pool = dc.GetIniData("Registration Server", "POOL", sIniFile);
    SUTAgentAndroid.sTestRoot = dc.GetIniData("Device", "TestRoot", sIniFile);
    SUTAgentAndroid.Abi = android.os.Build.CPU_ABI;
    log(dc, "onCreate");

    dc.SetTestRoot(SUTAgentAndroid.sTestRoot);

    Log.i("SUTAgentAndroid", "Test Root: " + SUTAgentAndroid.sTestRoot);

    tv = (TextView) this.findViewById(R.id.Textview01);

    if (getLocalIpAddress() == null)
        setUpNetwork(sIniFile);

    String macAddress = "Unknown";
    if (android.os.Build.VERSION.SDK_INT > 8) {
        try {
            NetworkInterface iface = NetworkInterface
                    .getByInetAddress(InetAddress.getAllByName(getLocalIpAddress())[0]);
            if (iface != null) {
                byte[] mac = iface.getHardwareAddress();
                if (mac != null) {
                    StringBuilder sb = new StringBuilder();
                    Formatter f = new Formatter(sb);
                    for (int i = 0; i < mac.length; i++) {
                        f.format("%02x%s", mac[i], (i < mac.length - 1) ? ":" : "");
                    }
                    macAddress = sUniqueID = sb.toString();
                }
            }
        } catch (UnknownHostException ex) {
        } catch (SocketException ex) {
        }
    } else {
        // Fall back to getting info from wifiman on older versions of Android,
        // which don't support the NetworkInterface interface
        WifiManager wifiMan = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        if (wifiMan != null) {
            WifiInfo wifi = wifiMan.getConnectionInfo();
            if (wifi != null)
                macAddress = wifi.getMacAddress();
            if (macAddress != null)
                sUniqueID = macAddress;
        }
    }

    if (sUniqueID == null) {
        BluetoothAdapter ba = BluetoothAdapter.getDefaultAdapter();
        if ((ba != null) && (ba.isEnabled() != true)) {
            ba.enable();
            while (ba.getState() != BluetoothAdapter.STATE_ON) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            sUniqueID = ba.getAddress();

            ba.disable();
            while (ba.getState() != BluetoothAdapter.STATE_OFF) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        } else {
            if (ba != null) {
                sUniqueID = ba.getAddress();
                sUniqueID.toLowerCase();
            }
        }
    }

    if (sUniqueID == null) {
        TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
        if (mTelephonyMgr != null) {
            sUniqueID = mTelephonyMgr.getDeviceId();
            if (sUniqueID == null) {
                sUniqueID = "0011223344556677";
            }
        }
    }

    String hwid = getHWID(this);

    sLocalIPAddr = getLocalIpAddress();
    Toast.makeText(getApplication().getApplicationContext(), "SUTAgent [" + sLocalIPAddr + "] ...",
            Toast.LENGTH_LONG).show();

    String sConfig = dc.prgVersion + lineSep;
    sConfig += "Test Root: " + sTestRoot + lineSep;
    sConfig += "Unique ID: " + sUniqueID + lineSep;
    sConfig += "HWID: " + hwid + lineSep;
    sConfig += "ABI: " + Abi + lineSep;
    sConfig += "OS Info" + lineSep;
    sConfig += "\t" + dc.GetOSInfo() + lineSep;
    sConfig += "Screen Info" + lineSep;
    int[] xy = dc.GetScreenXY();
    sConfig += "\t Width: " + xy[0] + lineSep;
    sConfig += "\t Height: " + xy[1] + lineSep;
    sConfig += "Memory Info" + lineSep;
    sConfig += "\t" + dc.GetMemoryInfo() + lineSep;
    sConfig += "Network Info" + lineSep;
    sConfig += "\tMac Address: " + macAddress + lineSep;
    sConfig += "\tIP Address: " + sLocalIPAddr + lineSep;

    displayStatus(sConfig);

    sRegString = "NAME=" + sUniqueID;
    sRegString += "&IPADDR=" + sLocalIPAddr;
    sRegString += "&CMDPORT=" + 20701;
    sRegString += "&DATAPORT=" + 20700;
    sRegString += "&OS=Android-" + dc.GetOSInfo();
    sRegString += "&SCRNWIDTH=" + xy[0];
    sRegString += "&SCRNHEIGHT=" + xy[1];
    sRegString += "&BPP=8";
    sRegString += "&MEMORY=" + dc.GetMemoryConfig();
    sRegString += "&HARDWARE=" + HardwareID;
    sRegString += "&POOL=" + Pool;
    sRegString += "&ABI=" + Abi;

    String sTemp = Uri.encode(sRegString, "=&");
    sRegString = "register " + sTemp;

    pruneCommandLog(dc.GetSystemTime(), dc.GetTestRoot());

    if (!bNetworkingStarted) {
        Thread thread = new Thread(null, doStartService, "StartServiceBkgnd");
        thread.start();
        bNetworkingStarted = true;

        Thread thread2 = new Thread(null, doRegisterDevice, "RegisterDeviceBkgnd");
        thread2.start();
    }

    monitorBatteryState();

    // If we are returning from an update let'em know we're back
    Thread thread3 = new Thread(null, doUpdateCallback, "UpdateCallbackBkgnd");
    thread3.start();

    final Button goButton = (Button) findViewById(R.id.Button01);
    goButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });
}

From source file:com.aps490.drdc.prototype.MainActivity.java

public static void initNativeLib(Context context) {
    try {/*  w  w w  . j  a v  a  2  s .  co m*/
        // Try loading our native lib, see if it works...
        System.loadLibrary("libarchitect");
    } catch (UnsatisfiedLinkError er) {
        ApplicationInfo appInfo = context.getApplicationInfo();
        String libName = "libarchitect.so";
        String destPath = context.getFilesDir().toString();
        try {
            String soName = destPath + File.separator + libName;
            new File(soName).delete();
            UnzipUtil.extractFile(appInfo.sourceDir, "lib/" + Build.CPU_ABI + "/" + libName, destPath);
            System.load(soName);
        } catch (IOException e) {
            // extractFile to app files dir did not work. Not enough space? Try elsewhere...
            destPath = context.getExternalCacheDir().toString();
            // Note: location on external memory is not secure, everyone can read/write it...
            // However we extract from a "secure" place (our apk) and instantly load it,
            // on each start of the app, this should make it safer.
            String soName = destPath + File.separator + libName;
            new File(soName).delete(); // this copy could be old, or altered by an attack
            try {
                UnzipUtil.extractFile(appInfo.sourceDir, "lib/" + Build.CPU_ABI + "/" + libName, destPath);
                System.load(soName);
            } catch (IOException e2) {
                Log.e("AMMAR:", "Exception in InstallInfo.init(): " + e);
                e.printStackTrace();
            }
        }
    }
}

From source file:net.frakbot.FWeather.util.FeedbackService.java

/**
 * Builds a feedback email body with some basic system info.
 *
 * @return Returns the generated system info.
 *///from w  w w . j av a 2 s. co  m
@SuppressWarnings("StringBufferReplaceableByString")
private String generateFeedbackBody() {
    StringBuilder sb = new StringBuilder("\n\n" + "-----------\n" + "System info\n" + "-----------\n\n");

    // HW information
    sb.append("Device model: ").append(Build.MODEL).append("\n");
    sb.append("Manifacturer: ").append(Build.MANUFACTURER).append("\n");
    sb.append("Brand: ").append(Build.BRAND).append("\n");
    sb.append("CPU ABI: ").append(Build.CPU_ABI).append("\n");
    sb.append("Product: ").append(Build.PRODUCT).append("\n").append("\n");

    // SW information
    sb.append("Android version: ").append(Build.VERSION.CODENAME).append("\n");
    sb.append("Release: ").append(Build.VERSION.RELEASE).append("\n");
    sb.append("Incremental: ").append(Build.VERSION.INCREMENTAL).append("\n");
    sb.append("Build: ").append(Build.FINGERPRINT).append("\n");
    sb.append("Kernel: ").append(getKernelVersion()).append("\n");

    // App info
    sb.append("App version: ").append(getAppVersionNumber(this));

    return sb.toString();
}

From source file:com.linroid.pushapp.ui.bind.BindActivity.java

private Device queryAndBuildDeviceInfo() {
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    return Device.DeviceBuilder.aDevice().withModel(Build.MODEL).withSdkLevel(Build.VERSION.SDK_INT)
            .withOsName(Build.VERSION.RELEASE).withNetworkType(DeviceUtil.networkType(this))
            .withCpuType(Build.CPU_ABI).withAlias(aliasET.getText().toString()).withDpi(metrics.densityDpi)
            .withHeight(AndroidUtil.getRealHeight(getWindowManager().getDefaultDisplay()))
            .withWidth(metrics.widthPixels).withMemorySize(AndroidUtil.totalMemorySize()).withToken(bindToken)
            .withUniqueId(DeviceUtil.id(this)).withInstallId(JPushInterface.getRegistrationID(this)).build();
}

From source file:com.github.chenxiaolong.dualbootpatcher.socket.MbtoolConnection.java

@SuppressWarnings("deprecation")
private static String getAbi() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return Build.SUPPORTED_ABIS[0];
    } else {/*from   w  w w .ja v  a 2 s  .  c o m*/
        return Build.CPU_ABI;
    }
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.service.BootUIActionTask.java

/**
 * Install or update boot UI//  w ww.j  a v a2 s.c om
 *
 * @param iface Mbtool interface
 * @return Whether the installation was successful
 * @throws IOException
 * @throws MbtoolException
 */
private boolean install(MbtoolInterface iface) throws IOException, MbtoolException {
    // Need to grab latest boot UI from the data archive
    PatcherUtils.initializePatcher(getContext());

    Device device = PatcherUtils.getCurrentDevice(getContext());
    if (device == null) {
        Log.e(TAG, "Failed to determine current device");
        return false;
    }

    // Uninstall first, so we don't get any leftover files
    Log.d(TAG, "Uninstalling before installing/updating");
    if (!uninstall(iface)) {
        return false;
    }

    String abi;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        abi = Build.SUPPORTED_ABIS[0];
    } else {
        //noinspection deprecation
        abi = Build.CPU_ABI;
    }

    File sourceDir = PatcherUtils.getTargetDirectory(getContext());
    String mountPoint = getCacheMountPoint(iface);

    for (FileMapping mapping : MAPPINGS) {
        String source = String.format(sourceDir + mapping.source, abi);
        String target = mountPoint + mapping.target;
        File parent = new File(target).getParentFile();

        try {
            iface.pathMkdir(parent.getAbsolutePath(), 0755, true);
            iface.pathCopy(source, target);
            iface.pathChmod(target, mapping.mode);
        } catch (MbtoolCommandException e) {
            Log.e(TAG, "Failed to install " + source + " -> " + target, e);
            return false;
        }
    }

    return true;
}

From source file:dentex.youtube.downloader.utils.Utils.java

public static String cpuVersion() {
    String cpuAbi = Build.CPU_ABI;
    Utils.logger("d", "CPU_ABI: " + cpuAbi, DEBUG_TAG);
    if (cpuAbi.equals("armeabi-v7a")) {
        if (neonCpu()) {
            Utils.logger("d", " -> v7a NEON", DEBUG_TAG);
            return YTD.ARMv7a_NEON;
        } else {/* w  w  w. ja v a 2  s .c  om*/
            Utils.logger("d", " -> v7a", DEBUG_TAG);
            return YTD.ARMv7a;
        }
        //      } else if (cpuAbi.equals("armeabi")) {
        //         Utils.logger("d", " -> v5te", DEBUG_TAG);
        //         return YTD.ARMv5te;
    } else if (cpuAbi.equals("x86")) {
        Utils.logger("d", " -> x86", DEBUG_TAG);
        return YTD.x86;
    } else {
        return YTD.UNSUPPORTED_CPU;
    }
}

From source file:com.becapps.easydownloader.utils.Utils.java

public static String getCpuInfo() {
    StringBuffer sb = new StringBuffer();
    sb.append("abi: ").append(Build.CPU_ABI).append("\n");
    if (new File("/proc/cpuinfo").exists()) {
        try {/*  w  w w .  ja va2  s  .  c  o m*/
            BufferedReader br = new BufferedReader(new FileReader(new File("/proc/cpuinfo")));
            String aLine;
            while ((aLine = br.readLine()) != null) {
                sb.append(aLine + "\n");
            }
            if (br != null) {
                br.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return sb.toString();
}