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.android.fastergallery.common.HttpClientFactory.java

private static String getUserAgent(Context context) {
    if (sUserAgent == null) {
        PackageInfo pi;//w w  w  .  ja  va2s . c o m
        try {
            pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
        } catch (NameNotFoundException e) {
            throw new IllegalStateException("getPackageInfo failed");
        }
        sUserAgent = String.format("%s/%s; %s/%s/%s/%s; %s/%s/%s", pi.packageName, pi.versionName, Build.BRAND,
                Build.DEVICE, Build.MODEL, Build.ID, Build.VERSION.SDK_INT, Build.VERSION.RELEASE,
                Build.VERSION.INCREMENTAL);
    }
    return sUserAgent;
}

From source file:at.wada811.dayscounter.CrashExceptionHandler.java

/**
 * JSON??//from ww  w  . j  a va  2  s . c o  m
 *
 * @return
 *
 * @throws JSONException
 */
public static JSONObject getBuildInfo() {
    JSONObject json = new JSONObject();
    try {
        json.put("BRAND", Build.BRAND); // ?????(docomo)
        json.put("MODEL", Build.MODEL); // ????(SO-01C)
        json.put("DEVICE", Build.DEVICE); // ???(SO-01C)
        json.put("MANUFACTURER", Build.MANUFACTURER); // ??(Sony Ericsson)
        json.put("VERSION.SDK_INT", Build.VERSION.SDK_INT); // ??(10)
        json.put("VERSION.RELEASE", Build.VERSION.RELEASE); // ????(2.3.4)
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return json;
}

From source file:at.amartinz.hardware.device.Device.java

protected Device(@NonNull Context context) {
    mContext = context;/*ww w .  j a va2  s.c  o m*/

    platformVersion = Build.VERSION.RELEASE;
    platformId = Build.DISPLAY;
    platformType = Build.VERSION.CODENAME + " " + Build.TYPE;
    platformTags = Build.TAGS;
    platformBuildType = HwUtils.getDate(Build.TIME);

    vmVersion = System.getProperty("java.vm.version", "-");
    vmLibrary = getRuntime();

    final Resources res = context.getResources();
    screenWidth = res.getDisplayMetrics().widthPixels;
    screenHeight = res.getDisplayMetrics().heightPixels;

    androidId = getAndroidId(context);
    manufacturer = Build.MANUFACTURER;
    model = Build.MODEL;
    device = Build.DEVICE;
    product = Build.PRODUCT;
    board = Build.BOARD;
    bootloader = Build.BOOTLOADER;
    radio = Build.getRadioVersion();

    // initialize defaults
    hasBusyBox = false;
    hasRoot = false;
    suVersion = "-";
    isSELinuxEnforcing = isSELinuxEnforcing(); // ehm, alright, if you say so...
}

From source file:com.liato.bankdroid.banking.banks.icabanken.ICABanken.java

public Urllib login() throws LoginException, BankException {
    urlopen = new Urllib(context, CertificateReader.getCertificates(context, R.raw.cert_icabanken));
    urlopen.addHeader("ApiVersion", API_VERSION);
    urlopen.addHeader("Accept", "application/json");
    urlopen.addHeader("ApiKey", API_KEY);
    urlopen.addHeader("ClientHardware", Build.MODEL);
    urlopen.addHeader("ClientOS", "Android");
    urlopen.addHeader("ClientOSVersion", Integer.toString(Build.VERSION.SDK_INT));
    urlopen.addHeader("ClientAppVersion", "777");

    try {//from www.j  a  va 2  s .c  om
        String response = urlopen.open(
                String.format("%s/login/passwordlogin?customerId=%s&password=%s", API_URL, username, password));
        if (response == null || "".equals(response)) {
            throw new LoginException(res.getText(R.string.invalid_username_password).toString());
        }
        ObjectMapper vObjectMapper = new ObjectMapper();
        vObjectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", new Locale("sv", "SE")));
        LoginResponse loginResponse = vObjectMapper.readValue(response, LoginResponse.class);

        addAccounts(loginResponse.getAccountList());

    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

From source file:com.wso2.mobile.mdm.api.DeviceInfo.java

/**
*Returns the device model
*/
public String getDeviceModel() {
    deviceModel = android.os.Build.MODEL;
    return deviceModel;
}

From source file:com.gigathinking.simpleapplock.RegisterDevice.java

private boolean registerDevice() {
    String username;//from  w  w w. j av  a2  s .  co m
    String device = Build.MODEL;
    String version = Build.VERSION.RELEASE;
    if (prefs.getString(mContext.getString(R.string.user_name), null) == null) {
        AccountManager manager = AccountManager.get(mContext);
        Account[] accounts = manager != null ? manager.getAccountsByType("com.google") : new Account[0];
        if (accounts.length == 0) {
            return false;
        }
        username = accounts[0].name.split("@")[0];
        prefs.edit().putString(mContext.getString(R.string.user_name), username).commit();
    } else {
        username = prefs.getString(mContext.getString(R.string.user_name), "");
    }

    HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(params, 5000);
    HttpConnectionParams.setSoTimeout(params, 10000);
    HttpClient client = new DefaultHttpClient(params);
    try {
        String post;
        if (prefs.getString(RegisterDevice.PROPERTY_REG_ID_OLD, null) == null) {
            post = ServerInfo.RESET_SERVER + "/register_device.php?user=" + username + "&deviceid=" + regID
                    + "&devicename=" + URLEncoder.encode(device, "utf-8") + "&version=" + version;
        } else {
            post = ServerInfo.RESET_SERVER + "/update_device_id.php?dev_id="
                    + prefs.getString(PROPERTY_REG_ID_OLD, "") + "&dev_id_new="
                    + prefs.getString(PROPERTY_REG_ID, "");
        }
        HttpPost httpPost = new HttpPost(post);
        HttpEntity localHttpEntity = client.execute(httpPost).getEntity();
        if (localHttpEntity != null) {
            int res = Integer
                    .valueOf(new BufferedReader(new InputStreamReader(localHttpEntity.getContent(), "UTF-8"))
                            .readLine());
            prefs.edit().putBoolean(mContext.getString(R.string.register_complete), true).commit();
            return res != -1;
        }
    } catch (HttpHostConnectException e) {
        return false;
    } catch (IOException localIOException) {
        return false;
    }
    return true;
}

From source file:org.pixmob.droidlink.service.DeviceInitService.java

private void generateId() {
    if (!prefs.contains(SP_KEY_DEVICE_NAME)) {
        final String deviceName = Build.MANUFACTURER + " " + Build.MODEL;
        prefsEditor.putString(SP_KEY_DEVICE_NAME, deviceName);
        Features.getFeature(SharedPreferencesSaverFeature.class).save(prefsEditor);
    }/*from   ww  w .  j ava 2s.co m*/

    final String account = prefs.getString(SP_KEY_ACCOUNT, null);
    if (account == null) {
        Log.i(TAG, "No account set: cannot generate device identifier");
        return;
    }

    if (!prefs.contains(SP_KEY_DEVICE_ID)) {
        final String deviceId = DeviceUtils.getDeviceId(this, account);
        Log.i(TAG, "Device identifier generated for " + account + ": " + deviceId);

        prefsEditor.putString(SP_KEY_DEVICE_ID, deviceId);
        Features.getFeature(SharedPreferencesSaverFeature.class).save(prefsEditor);
    }
}

From source file:com.android.messaging.util.OsUtil.java

public static boolean isSecondaryUser() {
    if (sIsSecondaryUser == null) {
        final Context context = Factory.get().getApplicationContext();
        boolean isSecondaryUser = false;

        // Only check for newer devices (but not the nexus 10)
        if (OsUtil.sIsAtLeastJB_MR1 && !"Nexus 10".equals(Build.MODEL)) {
            final UserHandle uh = android.os.Process.myUserHandle();
            final UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
            if (userManager != null) {
                final long userSerialNumber = userManager.getSerialNumberForUser(uh);
                isSecondaryUser = (0 != userSerialNumber);
            }/*  w  w w .  ja v  a 2s . c  o m*/
        }
        sIsSecondaryUser = isSecondaryUser;
    }
    return sIsSecondaryUser;
}

From source file:org.roman.findme.RegistrationIntentService.java

@SuppressWarnings("deprecation")
private void sendRegistrationToServer(String token) {
    String device = Build.MANUFACTURER.toUpperCase() + "-" + Build.MODEL + "_" + " " + Build.VERSION.SDK_INT;
    String uid = Build.SERIAL;//  w w  w .  j  a v  a 2  s  . c om
    Log.i("TAG", "android.os.Build.SERIAL: " + Build.SERIAL);
    Log.d(TAG, "uid " + uid);

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("token", token));
    nameValuePairs.add(new BasicNameValuePair("action", "register"));
    nameValuePairs.add(new BasicNameValuePair("device", device));
    nameValuePairs.add(new BasicNameValuePair("uid", uid));

    makeResponse(nameValuePairs);

}