Example usage for android.os Build MODEL

List of usage examples for android.os Build MODEL

Introduction

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

Prototype

String MODEL

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

Click Source Link

Document

The end-user-visible name for the end product.

Usage

From source file:com.tencent.wetest.common.util.DeviceUtil.java

/**
 * ??//from  w w  w  .j  a v a2 s . c o  m
 * @param cx 
 * @return BRAND ( MODEL )
 */
public static String getManu(Context cx) {

    return android.os.Build.BRAND + "(" + android.os.Build.MODEL + ")";
}

From source file:io.teak.sdk.DeviceConfiguration.java

public DeviceConfiguration(@NonNull final Context context, @NonNull AppConfiguration appConfiguration) {
    if (android.os.Build.VERSION.RELEASE == null) {
        this.platformString = "android_unknown";
    } else {//from w w  w  .j a v a  2  s .co  m
        this.platformString = "android_" + android.os.Build.VERSION.RELEASE;
    }

    // Preferences file
    {
        SharedPreferences tempPreferences = null;
        try {
            tempPreferences = context.getSharedPreferences(Teak.PREFERENCES_FILE, Context.MODE_PRIVATE);
        } catch (Exception e) {
            Log.e(LOG_TAG, "Error calling getSharedPreferences(). " + Log.getStackTraceString(e));
        } finally {
            this.preferences = tempPreferences;
        }

        if (this.preferences == null) {
            Log.e(LOG_TAG, "getSharedPreferences() returned null. Some caching is disabled.");
        }
    }

    // Device model/manufacturer
    // https://raw.githubusercontent.com/jaredrummler/AndroidDeviceNames/master/library/src/main/java/com/jaredrummler/android/device/DeviceName.java
    {
        this.deviceManufacturer = Build.MANUFACTURER == null ? "" : Build.MANUFACTURER;
        this.deviceModel = Build.MODEL == null ? "" : Build.MODEL;
        if (this.deviceModel.startsWith(Build.MANUFACTURER)) {
            this.deviceFallback = capitalize(Build.MODEL);
        } else {
            this.deviceFallback = capitalize(Build.MANUFACTURER) + " " + Build.MODEL;
        }
    }

    // Device id
    {
        String tempDeviceId = null;
        try {
            tempDeviceId = UUID.nameUUIDFromBytes(android.os.Build.SERIAL.getBytes("utf8")).toString();
        } catch (Exception e) {
            Log.e(LOG_TAG, "android.os.Build.SERIAL not available, falling back to Settings.Secure.ANDROID_ID. "
                    + Log.getStackTraceString(e));
        }

        if (tempDeviceId == null) {
            try {
                String androidId = Settings.Secure.getString(context.getContentResolver(),
                        Settings.Secure.ANDROID_ID);
                if (androidId.equals("9774d56d682e549c")) {
                    Log.e(LOG_TAG,
                            "Settings.Secure.ANDROID_ID == '9774d56d682e549c', falling back to random UUID stored in preferences.");
                } else {
                    tempDeviceId = UUID.nameUUIDFromBytes(androidId.getBytes("utf8")).toString();
                }
            } catch (Exception e) {
                Log.e(LOG_TAG,
                        "Error generating device id from Settings.Secure.ANDROID_ID, falling back to random UUID stored in preferences. "
                                + Log.getStackTraceString(e));
            }
        }

        if (tempDeviceId == null) {
            if (this.preferences != null) {
                tempDeviceId = this.preferences.getString(PREFERENCE_DEVICE_ID, null);
                if (tempDeviceId == null) {
                    try {
                        String prefDeviceId = UUID.randomUUID().toString();
                        SharedPreferences.Editor editor = this.preferences.edit();
                        editor.putString(PREFERENCE_DEVICE_ID, prefDeviceId);
                        editor.apply();
                        tempDeviceId = prefDeviceId;
                    } catch (Exception e) {
                        Log.e(LOG_TAG,
                                "Error storing random UUID, no more fallbacks. " + Log.getStackTraceString(e));
                    }
                }
            } else {
                Log.e(LOG_TAG,
                        "getSharedPreferences() returned null, unable to store random UUID, no more fallbacks.");
            }
        }

        this.deviceId = tempDeviceId;

        if (this.deviceId == null) {
            return;
        }
    }

    // Kick off GCM request
    if (this.preferences != null) {
        int storedAppVersion = this.preferences.getInt(PREFERENCE_APP_VERSION, 0);
        String storedGcmId = this.preferences.getString(PREFERENCE_GCM_ID, null);
        if (storedAppVersion == appConfiguration.appVersion && storedGcmId != null) {
            // No need to get a new one, so put it on the blocking queue
            if (Teak.isDebug) {
                Log.d(LOG_TAG, "GCM Id found in cache: " + storedGcmId);
            }
            this.gcmId = storedGcmId;
            displayGCMDebugMessage();
        }
    }

    this.gcm = new FutureTask<>(new RetriableTask<>(100, 2000L, new Callable<GoogleCloudMessaging>() {
        @Override
        public GoogleCloudMessaging call() throws Exception {
            return GoogleCloudMessaging.getInstance(context);
        }
    }));
    new Thread(this.gcm).start();

    if (this.gcmId == null) {
        registerForGCM(appConfiguration);
    }

    // Kick off Advertising Info request
    fetchAdvertisingInfo(context);
}

From source file:info.martinmarinov.dvbdriver.ExceptionDialog.java

private String getConstants() {
    StringBuilder res = new StringBuilder();

    res.append("Last Device: ").append(lastDeviceDebugString).append('\n');
    res.append("Build.MANUFACTURER: ").append(Build.MANUFACTURER).append('\n');
    res.append("Build.MODEL: ").append(Build.MODEL).append('\n');
    res.append("Build.PRODUCT: ").append(Build.PRODUCT).append('\n');
    res.append("Build.VERSION.SDK_INT: ").append(Build.VERSION.SDK_INT).append('\n');
    res.append("Build.VERSION.RELEASE: ").append(Build.VERSION.RELEASE).append('\n');

    try {// ww w.  ja  va 2s .  com
        PackageInfo packageInfo = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(),
                0);
        res.append("Driver versionName: ").append(packageInfo.versionName).append('\n');
        res.append("Driver versionCode: ").append(packageInfo.versionCode).append('\n');
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    return res.toString();
}

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.linphone.setup.EchoCancellerCalibrationFragment.java

private void sendEcCalibrationResult(EcCalibratorStatus status, int delayMs) {
    try {/*from   w  ww .j av a2 s .  c  o m*/
        XMLRPCClient client = new XMLRPCClient(new URL(getString(R.string.wizard_url)));

        XMLRPCCallback listener = new XMLRPCCallback() {
            Runnable runFinished = new Runnable() {
                public void run() {
                    SetupActivity.instance().isEchoCalibrationFinished();
                }
            };

            public void onResponse(long id, Object result) {
                mHandler.post(runFinished);
            }

            public void onError(long id, XMLRPCException error) {
                mHandler.post(runFinished);
            }

            public void onServerError(long id, XMLRPCServerException error) {
                mHandler.post(runFinished);
            }
        };

        Boolean hasBuiltInEchoCanceler = LinphoneManager.getLc().hasBuiltInEchoCanceler();
        Log.i("Add echo canceller calibration result: manufacturer=" + Build.MANUFACTURER + " model="
                + Build.MODEL + " status=" + status + " delay=" + delayMs + "ms" + " hasBuiltInEchoCanceler "
                + hasBuiltInEchoCanceler);
        client.callAsync(listener, "add_ec_calibration_result", Build.MANUFACTURER, Build.MODEL,
                status.toString(), delayMs, hasBuiltInEchoCanceler);
    } catch (Exception ex) {
    }
}

From source file:cc.metapro.openct.utils.CrashHandler.java

private void dumpPhoneInfo(PrintWriter pw) throws PackageManager.NameNotFoundException {
    PackageManager pm = mContext.getPackageManager();
    PackageInfo pi = pm.getPackageInfo(mContext.getPackageName(), PackageManager.GET_ACTIVITIES);
    pw.print("OpenCT Version: ");
    pw.print(pi.versionName);/*  w w w.j a v  a  2s .c om*/
    pw.print("_");
    pw.println(pi.versionCode);

    pw.print("OS Version: ");
    pw.print(Build.VERSION.RELEASE);
    pw.print("_");
    pw.println(Build.VERSION.SDK_INT);

    pw.print("Vendor: ");
    pw.println(Build.MANUFACTURER);

    pw.print("Model: ");
    pw.println(Build.MODEL);
}

From source file:altermarkive.uploader.Report.java

private static JSONObject reportDevice(Context context) throws JSONException {
    JSONObject device = new JSONObject();
    device.put("id", hash(id(context)));
    device.put("manufacturer", Build.MANUFACTURER);
    device.put("brand", Build.BRAND);
    device.put("product", Build.PRODUCT);
    device.put("model", Build.MODEL);
    device.put("design", Build.DEVICE);
    device.put("board", Build.BOARD);
    device.put("hardware", Build.HARDWARE);
    device.put("build", Build.FINGERPRINT);
    return device;
}

From source file:com.apptentive.android.sdk.storage.DeviceManager.java

private static Device generateNewDevice(Context context) {
    Device device = new Device();

    // First, get all the information we can load from static resources.
    device.setOsName("Android");
    device.setOsVersion(Build.VERSION.RELEASE);
    device.setOsBuild(Build.VERSION.INCREMENTAL);
    device.setOsApiLevel(String.valueOf(Build.VERSION.SDK_INT));
    device.setManufacturer(Build.MANUFACTURER);
    device.setModel(Build.MODEL);
    device.setBoard(Build.BOARD);//from w  w w .  ja va 2  s.  com
    device.setProduct(Build.PRODUCT);
    device.setBrand(Build.BRAND);
    device.setCpu(Build.CPU_ABI);
    device.setDevice(Build.DEVICE);
    device.setUuid(GlobalInfo.androidId);
    device.setBuildType(Build.TYPE);
    device.setBuildId(Build.ID);

    // Second, set the stuff that requires querying system services.
    TelephonyManager tm = ((TelephonyManager) (context.getSystemService(Context.TELEPHONY_SERVICE)));
    device.setCarrier(tm.getSimOperatorName());
    device.setCurrentCarrier(tm.getNetworkOperatorName());
    device.setNetworkType(Constants.networkTypeAsString(tm.getNetworkType()));

    // Finally, use reflection to try loading from APIs that are not available on all Android versions.
    device.setBootloaderVersion(Reflection.getBootloaderVersion());
    device.setRadioVersion(Reflection.getRadioVersion());

    device.setLocaleCountryCode(Locale.getDefault().getCountry());
    device.setLocaleLanguageCode(Locale.getDefault().getLanguage());
    device.setLocaleRaw(Locale.getDefault().toString());
    device.setUtcOffset(String.valueOf((TimeZone.getDefault().getRawOffset() / 1000)));
    return device;
}

From source file:org.droidmate.uiautomator_daemon.UiAutomatorDaemonDriver.java

private String getDeviceModel() {
    if (_deviceModel == null) {
        String model = Build.MODEL;
        String manufacturer = Build.MANUFACTURER;
        _deviceModel = manufacturer + "-" + model;
        Log.d(uiaDaemon_logcatTag, "Device model: " + _deviceModel);
    }/*w w w . ja v  a 2 s .c  om*/
    return _deviceModel;
}

From source file:jp.kyuuki.rensou.android.activity.BaseActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    FragmentManager manager = getSupportFragmentManager();
    DialogFragment dialog;//  w w w. j av  a2  s.co m

    Intent intent;

    switch (item.getItemId()) {
    case R.id.action_ranking:
        // ?
        EasyTracker.getTracker().sendEvent(Analysis.GA_EC_UI_ACTION, Analysis.GA_EA_MENU_RANKING, null, null);
        intent = new Intent(this, RankingActivity.class);
        startActivity(intent);
        return true;
    case R.id.action_about:
        EasyTracker.getTracker().sendEvent(Analysis.GA_EC_UI_ACTION, Analysis.GA_EA_MENU_ABOUT, null, null);
        // ????
        //            AlertDialog.Builder ab = new AlertDialog.Builder(this);
        //            AlertDialog ad = ab.create();
        //            ad.setTitle(getString(R.string.action_about));
        //            ad.setMessage(getString(R.string.app_name) + " " + versionName);
        //            ad.show();
        dialog = new AboutDialogFragment();
        dialog.show(manager, "dialog");
        return true;
    case R.id.action_license:
        dialog = new LicenseInfomationDialogFragment();
        dialog.show(manager, "dialog");
        return true;
    case R.id.action_request:
        intent = new Intent();
        intent.setAction(Intent.ACTION_SENDTO);
        intent.setData(Uri.parse("mailto:" + getString(R.string.request_email)));
        //intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"kyuuki.japan+rensou@gmail.com"});
        intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.request_subject));
        intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.request_text, Utils.getVersionName(this),
                Build.VERSION.RELEASE, Build.MANUFACTURER + " " + Build.MODEL));
        startActivity(intent);
        return true;
    case R.id.action_debug:
        Intent i = new Intent(this, AboutActivity.class);
        startActivity(i);
        return true;
    }

    return false;
}