Example usage for android.os Build ID

List of usage examples for android.os Build ID

Introduction

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

Prototype

String ID

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

Click Source Link

Document

Either a changelist number, or a label like "M4-rc20".

Usage

From source file:io.kristal.appinfos.AppInfosPlugin.java

private synchronized static String getUniqueId(Context context) {
    String uniqueID = null;/*  w ww.j a  va  2 s  . co m*/
    SharedPreferences sharedPrefs = context.getSharedPreferences(PREF_UNIQUE_ID, Context.MODE_PRIVATE);
    uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null);
    if (uniqueID == null) {
        uniqueID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
        if (uniqueID == null || uniqueID.length() == 0 || "9774d56d682e549c".equals(uniqueID)) {
            // old version of reto meier
            //uniqueID = UUID.randomUUID().toString();
            uniqueID = "35" + //we make this look like a valid IMEI
                    Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10
                    + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10
                    + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10
                    + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10
                    + Build.USER.length() % 10; //13 digits
        }
        SharedPreferences.Editor editor = sharedPrefs.edit();
        editor.putString(PREF_UNIQUE_ID, uniqueID);
        editor.commit();
    }
    return uniqueID;
}

From source file:de.schildbach.wallet.util.CrashReporter.java

public static void appendDeviceInfo(final Appendable report, final Context context) throws IOException {
    final Resources res = context.getResources();
    final android.content.res.Configuration config = res.getConfiguration();
    final ActivityManager activityManager = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    final DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context
            .getSystemService(Context.DEVICE_POLICY_SERVICE);

    report.append("Device Model: " + Build.MODEL + "\n");
    report.append("Android Version: " + Build.VERSION.RELEASE + "\n");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
        report.append("Android security patch level: ").append(Build.VERSION.SECURITY_PATCH).append("\n");
    report.append("ABIs: ").append(Joiner.on(", ").skipNulls().join(Strings.emptyToNull(Build.CPU_ABI),
            Strings.emptyToNull(Build.CPU_ABI2))).append("\n");
    report.append("Board: " + Build.BOARD + "\n");
    report.append("Brand: " + Build.BRAND + "\n");
    report.append("Device: " + Build.DEVICE + "\n");
    report.append("Display: " + Build.DISPLAY + "\n");
    report.append("Finger Print: " + Build.FINGERPRINT + "\n");
    report.append("Host: " + Build.HOST + "\n");
    report.append("ID: " + Build.ID + "\n");
    report.append("Product: " + Build.PRODUCT + "\n");
    report.append("Tags: " + Build.TAGS + "\n");
    report.append("Time: " + Build.TIME + "\n");
    report.append("Type: " + Build.TYPE + "\n");
    report.append("User: " + Build.USER + "\n");
    report.append("Configuration: " + config + "\n");
    report.append("Screen Layout: size "
            + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK) + " long "
            + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_LONG_MASK) + "\n");
    report.append("Display Metrics: " + res.getDisplayMetrics() + "\n");
    report.append("Memory Class: " + activityManager.getMemoryClass() + "/"
            + activityManager.getLargeMemoryClass()
            + (ActivityManagerCompat.isLowRamDevice(activityManager) ? " (low RAM device)" : "") + "\n");
    report.append("Storage Encryption Status: " + devicePolicyManager.getStorageEncryptionStatus() + "\n");
    report.append("Bluetooth MAC: " + bluetoothMac() + "\n");
    report.append("Runtime: ").append(System.getProperty("java.vm.name")).append(" ")
            .append(System.getProperty("java.vm.version")).append("\n");
}

From source file:org.cook_e.cook_e.BugReportActivity.java

/**
 * Gathers information about the device running the application and returns it as a JSONObject
 * @return information about the system/*from w  ww.  j  a  v a2 s .c  o m*/
 */
private JSONObject getSystemInformation() {
    final JSONObject json = new JSONObject();

    try {
        final JSONObject build = new JSONObject();
        build.put("version_name", BuildConfig.VERSION_NAME);
        build.put("version_code", BuildConfig.VERSION_CODE);
        build.put("build_type", BuildConfig.BUILD_TYPE);
        build.put("debug", BuildConfig.DEBUG);

        json.put("build", build);

        final JSONObject device = new JSONObject();
        device.put("board", Build.BOARD);
        device.put("bootloader", Build.BOOTLOADER);
        device.put("brand", Build.BRAND);
        device.put("device", Build.DEVICE);
        device.put("display", Build.DISPLAY);
        device.put("fingerprint", Build.FINGERPRINT);
        device.put("hardware", Build.HARDWARE);
        device.put("host", Build.HOST);
        device.put("id", Build.ID);
        device.put("manufacturer", Build.MANUFACTURER);
        device.put("model", Build.MODEL);
        device.put("product", Build.PRODUCT);
        device.put("radio", Build.getRadioVersion());
        device.put("serial", Build.SERIAL);
        device.put("tags", Build.TAGS);
        device.put("time", Build.TIME);
        device.put("type", Build.TYPE);
        device.put("user", Build.USER);

        json.put("device", device);
    } catch (JSONException e) {
        // Ignore
    }

    return json;
}

From source file:com.example.feedback.ActivityMain.java

/**
 * Get device information and save to application cache to send as attachment in feedback email.
 *//* w  ww . ja v  a 2  s. c  o m*/
public void getDeviceInfo() {
    try {
        dateTime = new Date();
        timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US);

        packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        appName = getApplicationContext().getString(packageInfo.applicationInfo.labelRes);
        appVersion = packageInfo.versionName;
        appCode = Integer.toString(packageInfo.versionCode);

        // Get application information.
        stringInfo = "date/time: " + timeFormat.format(dateTime) + "\n\n";
        stringInfo += "packageName: " + packageInfo.packageName + "\n";
        stringInfo += "packageCode: " + appCode + "\n";
        stringInfo += "packageVersion: " + appVersion + "\n";

        // Get network information.
        telephonyManager = ((TelephonyManager) getApplicationContext()
                .getSystemService(Context.TELEPHONY_SERVICE));

        if (!telephonyManager.getNetworkOperatorName().equals("")) {
            stringInfo += "operatorNetName: " + telephonyManager.getNetworkOperatorName() + "\n";
        } else if (!telephonyManager.getSimOperatorName().equals("")) {
            stringInfo += "operatorSimName: " + telephonyManager.getSimOperatorName() + "\n";
        }

        // Get device information.
        stringInfo += "Build.MODEL: " + Build.MODEL + "\n";
        stringInfo += "Build.BRAND: " + Build.BRAND + "\n";
        stringInfo += "Build.DEVICE: " + Build.DEVICE + "\n";
        stringInfo += "Build.PRODUCT: " + Build.PRODUCT + "\n";
        stringInfo += "Build.ID: " + Build.ID + "\n";
        stringInfo += "Build.TYPE: " + Build.TYPE + "\n";
        stringInfo += "Build.VERSION.SDK_INT: " + Build.VERSION.SDK_INT + "\n";
        stringInfo += "Build.VERSION.RELEASE: " + Build.VERSION.RELEASE + "\n";
        stringInfo += "Build.VERSION.INCREMENTAL: " + Build.VERSION.INCREMENTAL + "\n";
        stringInfo += "Build.VERSION.CODENAME: " + Build.VERSION.CODENAME + "\n";
        stringInfo += "Build.BOARD: " + Build.BOARD + "\n\n";

        // Get other application information.
        activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
        runningProcesses = activityManager.getRunningAppProcesses();
        runningApplications = "";

        for (ActivityManager.RunningAppProcessInfo runningProcess : runningProcesses) {
            runningApplications += "\n  " + runningProcess.processName;
        }

        stringInfo += "Applications running:" + runningApplications;

        // Save information to cached file.
        fileOutput = new FileOutputStream(getCacheDir().getAbsolutePath() + "/deviceInfo.log");
        fileOutput.write(stringInfo.getBytes());
        fileOutput.close();
    } catch (Exception e) {
    }
}

From source file:com.gm.goldencity.util.Utils.java

/**
 * Get Device ID
 *
 * @return
 */
public static String getMobileId() {
    // Device model
    return Build.ID;
}

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

/**
  * Generates a unique ID for the device.
  * /*  w w w  .jav  a 2  s.  c o  m*/
  * 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.wso2.emm.system.service.api.OTADownload.java

public void onStateChecked(int error, final BuildPropParser parser) {
    final String operation = Preference.getBoolean(context,
            context.getResources().getString(R.string.firmware_status_check_in_progress))
                    ? Constants.Operation.GET_FIRMWARE_UPGRADE_PACKAGE_STATUS
                    : Constants.Operation.UPGRADE_FIRMWARE;
    if (error == 0) {
        if (!otaServerManager.compareLocalVersionToServer(parser)) {
            Log.i(TAG, "Software is up to date:" + Build.VERSION.RELEASE + ", " + Build.ID);
            JSONObject result = new JSONObject();
            try {
                result.put(UPGRADE_AVAILABLE, false);
                if (parser != null) {
                    result.put(UPGRADE_DESCRIPTION, parser.getProp("Software is up to date"));
                }//  w  w  w  . j ava  2s  .com
                CommonUtils.sendBroadcast(context, operation, Constants.Code.SUCCESS,
                        Constants.Status.NO_UPGRADE_FOUND, result.toString());
            } catch (JSONException e) {
                String message = "Result payload build failed.";
                CommonUtils.sendBroadcast(context, operation, Constants.Code.FAILURE,
                        Constants.Status.UPDATE_INFO_NOT_READABLE, message);
                Log.e(TAG, message + e);
            }
        } else if (checkNetworkOnline()) {
            new AsyncTask<Void, Void, Long>() {
                protected Long doInBackground(Void... param) {
                    URL url = otaServerManager.getServerConfig().getPackageURL();
                    URLConnection con;
                    try {
                        con = url.openConnection();
                        con.setConnectTimeout(Constants.FIRMWARE_UPGRADE_CONNECTIVITY_TIMEOUT);
                        con.setReadTimeout(Constants.FIRMWARE_UPGRADE_READ_TIMEOUT);
                        return (long) con.getContentLength();
                    } catch (SocketTimeoutException e) {
                        String message = "Connection failure (Socket timeout) when retrieving update package size.";
                        Log.e(TAG, message + e);
                        CommonUtils.sendBroadcast(context, operation, Constants.Code.FAILURE,
                                Constants.Status.CONNECTION_FAILED, message);
                        CommonUtils.callAgentApp(context,
                                Constants.Operation.FAILED_FIRMWARE_UPGRADE_NOTIFICATION, 0, null);
                        return (long) -1;
                    } catch (IOException e) {
                        String message = "Connection failure when retrieving update package size.";
                        Log.e(TAG, message + e);
                        CommonUtils.sendBroadcast(context, operation, Constants.Code.FAILURE,
                                Constants.Status.CONNECTION_FAILED, message);
                        CommonUtils.callAgentApp(context,
                                Constants.Operation.FAILED_FIRMWARE_UPGRADE_NOTIFICATION, 0, null);
                        return (long) -1;
                    }
                }

                protected void onPostExecute(Long bytes) {
                    Log.i(TAG, "New release found " + Build.VERSION.RELEASE + ", " + Build.ID);
                    String length = "Unknown";
                    if (bytes > 0) {
                        length = byteCountToDisplaySize(bytes, false);
                    }

                    Log.i(TAG, "version :" + parser.getProp("ro.build.id") + "\n" + "full_version :"
                            + parser.getProp("ro.build.description") + "\n" + "size : " + length);
                    //Downloading the new update package if a new version is available.
                    if (Preference.getBoolean(context,
                            context.getResources().getString(R.string.firmware_status_check_in_progress))) {
                        JSONObject result = new JSONObject();
                        try {
                            result.put(UPGRADE_AVAILABLE, true);
                            result.put(UPGRADE_SIZE, length);
                            result.put(UPGRADE_RELEASE, parser.getNumRelease());
                            result.put(UPGRADE_VERSION, parser.getProp("ro.build.id"));
                            result.put(UPGRADE_DESCRIPTION, parser.getProp("ro.build.description"));
                            CommonUtils.sendBroadcast(context,
                                    Constants.Operation.GET_FIRMWARE_UPGRADE_PACKAGE_STATUS,
                                    Constants.Code.SUCCESS, Constants.Status.SUCCESSFUL, result.toString());
                        } catch (JSONException e) {
                            String message = "Result payload build failed.";
                            CommonUtils.sendBroadcast(context,
                                    Constants.Operation.GET_FIRMWARE_UPGRADE_PACKAGE_STATUS,
                                    Constants.Code.FAILURE, Constants.Status.OTA_IMAGE_VERIFICATION_FAILED,
                                    message);
                            Log.e(TAG, message + e);
                        }

                    } else {
                        if (checkNetworkOnline()) {
                            Boolean isAutomaticRetry = (Preference.hasPreferenceKey(context,
                                    context.getResources().getString(R.string.firmware_upgrade_automatic_retry))
                                    && Preference.getBoolean(context,
                                            context.getResources()
                                                    .getString(R.string.firmware_upgrade_automatic_retry)))
                                    || !Preference.hasPreferenceKey(context, context.getResources()
                                            .getString(R.string.firmware_upgrade_automatic_retry));

                            if (getBatteryLevel(
                                    context) >= Constants.REQUIRED_BATTERY_LEVEL_TO_FIRMWARE_UPGRADE) {
                                otaServerManager.startDownloadUpgradePackage(otaServerManager);
                            } else if (isAutomaticRetry) {
                                String message = "Upgrade download has been differed due to insufficient battery level.";
                                Log.w(TAG, message);
                                Preference.putString(context,
                                        context.getResources().getString(R.string.upgrade_download_status),
                                        Constants.Status.BATTERY_LEVEL_INSUFFICIENT_TO_DOWNLOAD);
                                CommonUtils.sendBroadcast(context, Constants.Operation.UPGRADE_FIRMWARE,
                                        Constants.Code.PENDING,
                                        Constants.Status.BATTERY_LEVEL_INSUFFICIENT_TO_DOWNLOAD, message);
                            } else {
                                String message = "Upgrade download has been failed due to insufficient battery level.";
                                Preference.putString(context,
                                        context.getResources().getString(R.string.upgrade_download_status),
                                        Constants.Status.BATTERY_LEVEL_INSUFFICIENT_TO_DOWNLOAD);
                                Log.e(TAG, message);
                                CommonUtils.sendBroadcast(context, Constants.Operation.UPGRADE_FIRMWARE,
                                        Constants.Code.FAILURE,
                                        Constants.Status.BATTERY_LEVEL_INSUFFICIENT_TO_DOWNLOAD, message);
                                CommonUtils.callAgentApp(context, Constants.Operation.FIRMWARE_UPGRADE_FAILURE,
                                        0, message);
                            }
                        } else {
                            String message = "Connection failure when starting upgrade download.";
                            Log.e(TAG, message);
                            CommonUtils.sendBroadcast(context, Constants.Operation.UPGRADE_FIRMWARE,
                                    Constants.Code.FAILURE, Constants.Status.NETWORK_UNREACHABLE, message);
                            CommonUtils.callAgentApp(context,
                                    Constants.Operation.FAILED_FIRMWARE_UPGRADE_NOTIFICATION, 0, message);
                        }
                    }
                }
            }.execute();

        } else {
            String message = "Connection failure when starting build prop download.";
            Log.e(TAG, message);
            CommonUtils.sendBroadcast(context, operation, Constants.Code.FAILURE,
                    Constants.Status.CONNECTION_FAILED, message);
            CommonUtils.callAgentApp(context, Constants.Operation.FAILED_FIRMWARE_UPGRADE_NOTIFICATION, 0,
                    null);
        }
    } else if (error == ERROR_WIFI_NOT_AVAILABLE) {
        Preference.putString(context, context.getResources().getString(R.string.upgrade_download_status),
                Constants.Status.WIFI_OFF);
        Log.e(TAG, "OTA failed due to WIFI connection failure.");
    } else if (error == ERROR_CANNOT_FIND_SERVER) {
        String message = "OTA failed due to OTA server not accessible.";
        Log.e(TAG, message);
    } else if (error == ERROR_WRITE_FILE_ERROR) {
        String message = "OTA failed due to file write error.";
        Log.e(TAG, message);
    }
}

From source file:com.appaholics.email.mail.store.ImapStoreUnitTests.java

/**
 * Setup code.  We generate a lightweight ImapStore and ImapStore.ImapFolder.
 *///www . j  a  v a 2 s  . com
@Override
protected void setUp() throws Exception {
    super.setUp();
    Context realContext = getInstrumentation().getTargetContext();
    ImapStore.sImapId = ImapStore.makeCommonImapId(realContext.getPackageName(), Build.VERSION.RELEASE,
            Build.VERSION.CODENAME, Build.MODEL, Build.ID, Build.MANUFACTURER, "FakeNetworkOperator");
    mTestContext = new SecondaryMockContext(
            DBTestHelper.ProviderContextSetupHelper.getProviderContext(realContext), realContext);
    MockVendorPolicy.inject(mTestContext);

    TempDirectory.setTempDirectory(mTestContext);

    // These are needed so we can get at the inner classes
    HostAuth testAuth = new HostAuth();
    Account testAccount = new Account();

    testAuth.setLogin("user", "password");
    testAuth.setConnection("imap", "server", 999);
    testAccount.mHostAuthRecv = testAuth;
    mStore = (ImapStore) ImapStore.newInstance(testAccount, mTestContext);
    mFolder = (ImapFolder) mStore.getFolder(FOLDER_NAME);
    resetTag();
}

From source file:org.wso2.iot.system.service.api.OTADownload.java

public void onStateChecked(int error, final BuildPropParser parser) {
    final String operation = Preference.getBoolean(context,
            context.getResources().getString(R.string.firmware_status_check_in_progress))
                    ? Constants.Operation.GET_FIRMWARE_UPGRADE_PACKAGE_STATUS
                    : Constants.Operation.UPGRADE_FIRMWARE;
    if (error == 0) {
        if (!otaServerManager.compareLocalVersionToServer(parser)) {
            JSONObject result = new JSONObject();
            try {
                result.put(UPGRADE_AVAILABLE, false);
                if (parser != null) {
                    result.put(UPGRADE_DESCRIPTION, parser.getProp("Software is up to date"));
                }//from w  w w .j ava 2  s  .  c o m
                CommonUtils.sendBroadcast(context, operation, Constants.Code.SUCCESS,
                        Constants.Status.NO_UPGRADE_FOUND, result.toString());
            } catch (JSONException e) {
                String message = "Result payload build failed.";
                CommonUtils.sendBroadcast(context, operation, Constants.Code.FAILURE,
                        Constants.Status.UPDATE_INFO_NOT_READABLE, message);
                Log.e(TAG, message + e);
            }
            String message = "Software is up to date:" + Build.VERSION.RELEASE + ", " + Build.ID;
            Log.i(TAG, message);
            CommonUtils.callAgentApp(context, Constants.Operation.FIRMWARE_UPGRADE_COMPLETE,
                    Preference.getInt(context, context.getResources().getString(R.string.operation_id)),
                    "No upgrades available. " + message);
        } else if (checkNetworkOnline()) {
            new AsyncTask<Void, Void, Long>() {
                protected Long doInBackground(Void... param) {
                    URL url = otaServerManager.getServerConfig().getPackageURL();
                    URLConnection con;
                    try {
                        con = url.openConnection();
                        con.setConnectTimeout(Constants.FIRMWARE_UPGRADE_CONNECTIVITY_TIMEOUT);
                        con.setReadTimeout(Constants.FIRMWARE_UPGRADE_READ_TIMEOUT);
                        return (long) con.getContentLength();
                    } catch (SocketTimeoutException e) {
                        String message = "Connection failure (Socket timeout) when retrieving update package size.";
                        Log.e(TAG, message + e);
                        CommonUtils.sendBroadcast(context, operation, Constants.Code.FAILURE,
                                Constants.Status.CONNECTION_FAILED, message);
                        CommonUtils
                                .callAgentApp(context, Constants.Operation.FAILED_FIRMWARE_UPGRADE_NOTIFICATION,
                                        Preference.getInt(context,
                                                context.getResources().getString(R.string.operation_id)),
                                        message);
                        return (long) -1;
                    } catch (IOException e) {
                        String message = "Connection failure when retrieving update package size.";
                        Log.e(TAG, message + e);
                        CommonUtils.sendBroadcast(context, operation, Constants.Code.FAILURE,
                                Constants.Status.CONNECTION_FAILED, message);
                        CommonUtils
                                .callAgentApp(context, Constants.Operation.FAILED_FIRMWARE_UPGRADE_NOTIFICATION,
                                        Preference.getInt(context,
                                                context.getResources().getString(R.string.operation_id)),
                                        message);
                        return (long) -1;
                    }
                }

                protected void onPostExecute(Long bytes) {
                    Log.i(TAG, "New release found " + Build.VERSION.RELEASE + ", " + Build.ID);
                    String length = "Unknown";
                    if (bytes > 0) {
                        length = byteCountToDisplaySize(bytes, false);
                    }

                    Log.i(TAG, "version :" + parser.getProp("ro.build.id") + "\n" + "full_version :"
                            + parser.getProp("ro.build.description") + "\n" + "size : " + length);
                    //Downloading the new update package if a new version is available.
                    if (Preference.getBoolean(context,
                            context.getResources().getString(R.string.firmware_status_check_in_progress))) {
                        JSONObject result = new JSONObject();
                        try {
                            result.put(UPGRADE_AVAILABLE, true);
                            result.put(UPGRADE_SIZE, length);
                            result.put(UPGRADE_RELEASE, parser.getNumRelease());
                            result.put(UPGRADE_VERSION, parser.getProp("ro.build.id"));
                            result.put(UPGRADE_DESCRIPTION, parser.getProp("ro.build.description"));
                            CommonUtils.sendBroadcast(context,
                                    Constants.Operation.GET_FIRMWARE_UPGRADE_PACKAGE_STATUS,
                                    Constants.Code.SUCCESS, Constants.Status.SUCCESSFUL, result.toString());
                        } catch (JSONException e) {
                            String message = "Result payload build failed.";
                            CommonUtils.sendBroadcast(context,
                                    Constants.Operation.GET_FIRMWARE_UPGRADE_PACKAGE_STATUS,
                                    Constants.Code.FAILURE, Constants.Status.OTA_IMAGE_VERIFICATION_FAILED,
                                    message);
                            Log.e(TAG, message + e);
                        }

                    } else {
                        Boolean isAutomaticRetry = !Preference.hasPreferenceKey(context,
                                context.getResources().getString(R.string.firmware_upgrade_automatic_retry))
                                || Preference.getBoolean(context, context.getResources()
                                        .getString(R.string.firmware_upgrade_automatic_retry));

                        if (checkNetworkOnline()) {
                            if (getBatteryLevel(
                                    context) >= Constants.REQUIRED_BATTERY_LEVEL_TO_FIRMWARE_UPGRADE) {
                                otaServerManager.startDownloadUpgradePackage(otaServerManager);
                            } else if (isAutomaticRetry) {
                                String message = "Upgrade download has been differed due to insufficient battery level.";
                                Log.w(TAG, message);
                                Preference.putString(context,
                                        context.getResources().getString(R.string.upgrade_download_status),
                                        Constants.Status.BATTERY_LEVEL_INSUFFICIENT_TO_DOWNLOAD);
                                CommonUtils.sendBroadcast(context, Constants.Operation.UPGRADE_FIRMWARE,
                                        Constants.Code.PENDING,
                                        Constants.Status.BATTERY_LEVEL_INSUFFICIENT_TO_DOWNLOAD, message);
                            } else {
                                String message = "Upgrade download has been failed due to insufficient battery level.";
                                Preference.putString(context,
                                        context.getResources().getString(R.string.upgrade_download_status),
                                        Constants.Status.BATTERY_LEVEL_INSUFFICIENT_TO_DOWNLOAD);
                                Log.e(TAG, message);
                                CommonUtils.sendBroadcast(context, Constants.Operation.UPGRADE_FIRMWARE,
                                        Constants.Code.FAILURE,
                                        Constants.Status.BATTERY_LEVEL_INSUFFICIENT_TO_DOWNLOAD, message);
                                CommonUtils.callAgentApp(context, Constants.Operation.FIRMWARE_UPGRADE_FAILURE,
                                        Preference.getInt(context,
                                                context.getResources().getString(R.string.operation_id)),
                                        message);
                            }
                        } else {
                            String message = "Connection failure when starting upgrade download.";
                            Log.e(TAG, message);
                            if (isAutomaticRetry) {
                                Preference.putString(context,
                                        context.getResources().getString(R.string.upgrade_download_status),
                                        Constants.Status.NETWORK_UNREACHABLE);
                                CommonUtils.sendBroadcast(context, Constants.Operation.UPGRADE_FIRMWARE,
                                        Constants.Code.PENDING, Constants.Status.NETWORK_UNREACHABLE, message);
                                CommonUtils.callAgentApp(context,
                                        Constants.Operation.FAILED_FIRMWARE_UPGRADE_NOTIFICATION,
                                        Preference.getInt(context,
                                                context.getResources().getString(R.string.operation_id)),
                                        message);
                            } else {
                                CommonUtils.sendBroadcast(context, Constants.Operation.UPGRADE_FIRMWARE,
                                        Constants.Code.FAILURE, Constants.Status.NETWORK_UNREACHABLE, message);
                                CommonUtils.callAgentApp(context, Constants.Operation.FIRMWARE_UPGRADE_FAILURE,
                                        Preference.getInt(context,
                                                context.getResources().getString(R.string.operation_id)),
                                        message);
                            }
                        }
                    }
                }
            }.execute();

        } else {
            String message = "Connection failure when starting build prop download.";
            Log.e(TAG, message);
            CommonUtils.sendBroadcast(context, operation, Constants.Code.FAILURE,
                    Constants.Status.CONNECTION_FAILED, message);
            CommonUtils.callAgentApp(context, Constants.Operation.FAILED_FIRMWARE_UPGRADE_NOTIFICATION,
                    Preference.getInt(context, context.getResources().getString(R.string.operation_id)), null);
        }
    } else if (error == ERROR_WIFI_NOT_AVAILABLE) {
        Preference.putString(context, context.getResources().getString(R.string.upgrade_download_status),
                Constants.Status.WIFI_OFF);
        Log.e(TAG, "OTA failed due to WIFI connection failure.");
    } else if (error == ERROR_CANNOT_FIND_SERVER) {
        String message = "OTA failed due to OTA server not accessible.";
        Log.e(TAG, message);
    } else if (error == ERROR_WRITE_FILE_ERROR) {
        String message = "OTA failed due to file write error.";
        Log.e(TAG, message);
    }
}

From source file:com.cc.signalinfo.fragments.SignalFragment.java

/**
 * Set the phone model, OS version, carrier name on the screen
 *///from ww  w.j ava2s .c  o m
private void setPhoneInfo() {
    setTextViewText(R.id.deviceName, String.format("%s %s", Build.MANUFACTURER, Build.MODEL));
    setTextViewText(R.id.deviceModel, String.format("%s/%s (%s) ", Build.PRODUCT, Build.DEVICE, Build.ID));
    setTextViewText(R.id.androidVersion, String.format(activity.getString(R.string.androidVersion),
            Build.VERSION.RELEASE, Build.VERSION.SDK_INT));

    setTextViewText(R.id.carrierName, tm.getNetworkOperatorName());
    setTextViewText(R.id.buildHost, Build.HOST);
    setNetworkTypeText();
}