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:org.uguess.android.sysinfo.SiragonManager.java

static void createTextHeader(Context context, StringBuffer sb, String title) {
    sb.append(title).append("\n"); //$NON-NLS-1$

    sb.append(context.getString(R.string.collector_head, context.getString(R.string.app_name),
            SiragonManager.getVersionName(context.getPackageManager(), context.getPackageName())));

    sb.append(context.getString(R.string.device)).append(": ") //$NON-NLS-1$
            .append(Build.DEVICE).append('\n').append(context.getString(R.string.model)).append(": ") //$NON-NLS-1$
            .append(Build.MODEL).append('\n').append(context.getString(R.string.product)).append(": ") //$NON-NLS-1$
            .append(Build.PRODUCT).append('\n').append(context.getString(R.string.brand)).append(": ") //$NON-NLS-1$
            .append(Build.BRAND).append('\n').append(context.getString(R.string.release)).append(": ") //$NON-NLS-1$
            .append(Build.VERSION.RELEASE).append('\n').append(context.getString(R.string.build)).append(": ") //$NON-NLS-1$
            .append(Build.DISPLAY).append('\n').append(context.getString(R.string.locale)).append(": ") //$NON-NLS-1$
            .append(Locale.getDefault().toString()).append("\n"); //$NON-NLS-1$

    try {/*  w w  w.j  a  v a 2s  .  c om*/
        SiragonManager.readRawText(sb, new FileInputStream(SiragonManager.F_VERSION));

        sb.append('\n');
    } catch (Exception e) {
        Log.e(LogViewer.class.getName(), e.getLocalizedMessage(), e);
    }
}

From source file:org.uguess.android.sysinfo.SiragonManager.java

static void createHtmlHeader(Context context, StringBuffer sb, String title) {
    sb.append("<html><head><title>") //$NON-NLS-1$
            .append(title)/*from ww w. j a  v a 2  s  .c o m*/
            .append("</title><meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\"/></head>\n") //$NON-NLS-1$
            .append("<body bgcolor=FFFFFF><font face=\"Verdana\" color=\"#000000\">\n") //$NON-NLS-1$
            .append("<table border=0 width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">\n") //$NON-NLS-1$
            .append("<tr align=\"left\">") //$NON-NLS-1$
            .append("<td colspan=5>") //$NON-NLS-1$
            .append("<table border=0 width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">") //$NON-NLS-1$
            .append("<tr><td width=60>") //$NON-NLS-1$
            .append("<a href=\"http://code.google.com/p/qsysinfo/\">") //$NON-NLS-1$
            .append("<img src=\"http://code.google.com/p/qsysinfo/logo?logo_id=1261652286\" border=0></a>") //$NON-NLS-1$
            .append("</td><td valign=\"bottom\">") //$NON-NLS-1$
            .append("<h3>") //$NON-NLS-1$
            .append(title).append("</h3></td></tr></table></td></tr>\n"); //$NON-NLS-1$

    sb.append("<tr align=\"left\"><td colspan=5><font color=\"#a0a0a0\"><small>"); //$NON-NLS-1$
    sb.append(SiragonManager
            .escapeHtml(context.getString(R.string.collector_head, context.getString(R.string.app_name),
                    SiragonManager.getVersionName(context.getPackageManager(), context.getPackageName()))));
    sb.append("</small></font></td></tr>\n"); //$NON-NLS-1$

    sb.append(SiragonManager.openHeaderRow).append(context.getString(R.string.device_info))
            .append(SiragonManager.closeHeaderRow);
    sb.append(SiragonManager.openRow).append(context.getString(R.string.device))
            .append(SiragonManager.nextColumn4).append(SiragonManager.escapeHtml(Build.DEVICE))
            .append(SiragonManager.closeRow);
    sb.append(SiragonManager.openRow).append(context.getString(R.string.model))
            .append(SiragonManager.nextColumn4).append(SiragonManager.escapeHtml(Build.MODEL))
            .append(SiragonManager.closeRow);
    sb.append(SiragonManager.openRow).append(context.getString(R.string.product))
            .append(SiragonManager.nextColumn4).append(SiragonManager.escapeHtml(Build.PRODUCT))
            .append(SiragonManager.closeRow);
    sb.append(SiragonManager.openRow).append(context.getString(R.string.brand))
            .append(SiragonManager.nextColumn4).append(SiragonManager.escapeHtml(Build.BRAND))
            .append(SiragonManager.closeRow);
    sb.append(SiragonManager.openRow).append(context.getString(R.string.release))
            .append(SiragonManager.nextColumn4).append(SiragonManager.escapeHtml(Build.VERSION.RELEASE))
            .append(SiragonManager.closeRow);
    sb.append(SiragonManager.openRow).append(context.getString(R.string.build))
            .append(SiragonManager.nextColumn4).append(SiragonManager.escapeHtml(Build.DISPLAY))
            .append(SiragonManager.closeRow);
    sb.append(SiragonManager.openRow).append(context.getString(R.string.locale))
            .append(SiragonManager.nextColumn4)
            .append(SiragonManager.escapeHtml(Locale.getDefault().toString())).append(SiragonManager.closeRow);

    sb.append(SiragonManager.emptyRow);

    sb.append(SiragonManager.openHeaderRow).append(context.getString(R.string.sys_version))
            .append(SiragonManager.closeHeaderRow);

    try {
        SiragonManager.readRawHTML(sb, new FileInputStream(SiragonManager.F_VERSION));

        sb.append(SiragonManager.emptyRow);
    } catch (Exception e) {
        Log.e(LogViewer.class.getName(), e.getLocalizedMessage(), e);
    }
}

From source file:es.javocsoft.android.lib.toolbox.ToolBox.java

/**
 * Generates a unique device id using the device 
 * "serial" property if is available. If not, a bunch
 * of device properties will be used to get a reliable
 * unique string key for the device.//from   w  ww  . j  a v a 2  s.c o m
 * 
 * If there is an error in UUID generation null is
 * returned.
 *    
 * @return   The unique UUID or nul in case of error.
 */
private static UUID generateUniqueDeviceUUIDId() {
    UUID uuid = null;

    try {
        //We generate a unique id
        String serial = null;
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
            serial = Build.SERIAL;
            uuid = UUID.nameUUIDFromBytes(serial.getBytes("utf8"));
        } else {
            //This bunch of data should be enough to "ensure" the 
            //uniqueness.
            String m_szDevIDAlterbative = "35" + //To 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

            uuid = UUID.nameUUIDFromBytes(m_szDevIDAlterbative.getBytes("utf8"));
        }

    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "UnsupportedEncodingException (" + e.getMessage() + ").", e);
    }

    return uuid;
}

From source file:org.apache.usergrid.android.sdk.UGClient.java

/**
 * Creates or updates a device entity using the provided deviceId, and saves the device model, 
 * device platform, and OS version in the entity. 
 * If an entity does not exist for the device, it is created with a UUID equal to deviceId.
 * /*from   ww w  .ja v a 2 s. c  o m*/
 * @param  deviceId  the device entity's UUID
 * @param  properties  additional properties to save in the device entity.      
 * @return  a Device object if success. Models the Usergrid device entity.
 */
public ApiResponse registerDevice(UUID deviceId, Map<String, Object> properties) {
    assertValidApplicationId();
    if (properties == null) {
        properties = new HashMap<String, Object>();
    }
    properties.put("refreshed", System.currentTimeMillis());

    // add device meta-data
    properties.put("deviceModel", Build.MODEL);
    properties.put("devicePlatform", "android");
    properties.put("deviceOSVersion", Build.VERSION.RELEASE);

    ApiResponse response = apiRequest(HTTP_METHOD_PUT, null, properties, organizationId, applicationId,
            "devices", deviceId.toString());
    return response;
}

From source file:com.codename1.impl.android.AndroidImplementation.java

/**
 * @inheritDoc/* ww  w . ja v a2  s  .  co  m*/
 */
public String getProperty(String key, String defaultValue) {
    if (key.equalsIgnoreCase("cn1_push_prefix")) {
        /*if(!checkForPermission(Manifest.permission.READ_PHONE_STATE, "This is required to get notifications")){
        return "";
        }*/
        boolean has = hasAndroidMarket();
        if (has) {
            return "gcm";
        }
        return defaultValue;
    }
    if ("OS".equals(key)) {
        return "Android";
    }
    if ("androidId".equals(key)) {
        return Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    }

    if ("cellId".equals(key)) {
        try {
            if (!checkForPermission(Manifest.permission.READ_PHONE_STATE,
                    "This is required to get the cellId")) {
                return defaultValue;
            }
            String serviceName = Context.TELEPHONY_SERVICE;
            TelephonyManager telephonyManager = (TelephonyManager) getContext().getSystemService(serviceName);
            int cellId = ((GsmCellLocation) telephonyManager.getCellLocation()).getCid();
            return "" + cellId;
        } catch (Throwable t) {
            return defaultValue;
        }
    }
    if ("AppName".equals(key)) {

        final PackageManager pm = getContext().getPackageManager();
        ApplicationInfo ai;
        try {
            ai = pm.getApplicationInfo(getContext().getPackageName(), 0);
        } catch (NameNotFoundException e) {
            ai = null;
        }
        String applicationName = (String) (ai != null ? pm.getApplicationLabel(ai) : null);
        if (applicationName == null) {
            return defaultValue;
        }
        return applicationName;
    }
    if ("AppVersion".equals(key)) {
        try {
            PackageInfo i = getContext().getPackageManager()
                    .getPackageInfo(getContext().getApplicationInfo().packageName, 0);
            return i.versionName;
        } catch (NameNotFoundException ex) {
            ex.printStackTrace();
        }
        return defaultValue;
    }
    if ("Platform".equals(key)) {
        String p = System.getProperty("platform");
        if (p == null) {
            return defaultValue;
        }
        return p;
    }
    if ("User-Agent".equals(key)) {
        String ua = getUserAgent();
        if (ua == null) {
            return defaultValue;
        }
        return ua;
    }
    if ("OSVer".equals(key)) {
        return "" + android.os.Build.VERSION.RELEASE;
    }
    if ("DeviceName".equals(key)) {
        return "" + android.os.Build.MODEL;
    }
    try {
        if ("IMEI".equals(key) || "UDID".equals(key)) {
            if (!checkForPermission(Manifest.permission.READ_PHONE_STATE,
                    "This is required to get the device ID")) {
                return "";
            }
            TelephonyManager tm = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
            String imei = null;
            if (tm != null && tm.getDeviceId() != null) {
                // for phones or 3g tablets
                imei = tm.getDeviceId();
            } else {
                try {
                    imei = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID);
                } catch (Throwable t) {
                    com.codename1.io.Log.e(t);
                }
            }
            return imei;
        }
        if ("MSISDN".equals(key)) {
            if (!checkForPermission(Manifest.permission.READ_PHONE_STATE,
                    "This is required to get the device ID")) {
                return "";
            }
            TelephonyManager tm = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
            return tm.getLine1Number();
        }
    } catch (Throwable t) {
        // will be caused by no permissions.
        return defaultValue;
    }

    if (getActivity() != null) {
        android.content.Intent intent = getActivity().getIntent();
        if (intent != null) {
            Bundle extras = intent.getExtras();
            if (extras != null) {
                String value = extras.getString(key);
                if (value != null) {
                    return value;
                }
            }
        }
    }

    //these keys/values are from the Application Resources (strings values)
    try {
        int id = getContext().getResources().getIdentifier(key, "string",
                getContext().getApplicationInfo().packageName);
        if (id != 0) {
            String val = getContext().getResources().getString(id);
            return val;
        }
    } catch (Exception e) {
    }
    return System.getProperty(key, super.getProperty(key, defaultValue));
}

From source file:org.telegram.android.MessagesController.java

public void registerForPush(final String regid) {
    if (regid == null || regid.length() == 0 || registeringForPush || UserConfig.getClientUserId() == 0) {
        return;//from   ww  w  .j av a 2 s  .c  om
    }
    if (UserConfig.registeredForPush && regid.equals(UserConfig.pushString)) {
        return;
    }
    registeringForPush = true;
    TLRPC.TL_account_registerDevice req = new TLRPC.TL_account_registerDevice();
    req.token_type = 2;
    req.token = regid;
    req.app_sandbox = false;
    try {
        req.lang_code = LocaleController
                .getLocaleString(LocaleController.getInstance().getSystemDefaultLocale());
        if (req.lang_code == null || req.lang_code.length() == 0) {
            req.lang_code = "en";
        }
        req.device_model = Build.MANUFACTURER + Build.MODEL;
        if (req.device_model == null) {
            req.device_model = "Android unknown";
        }
        req.system_version = "SDK " + Build.VERSION.SDK_INT;
        PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager()
                .getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
        req.app_version = pInfo.versionName + " (" + pInfo.versionCode + ")";
        if (req.app_version == null) {
            req.app_version = "App version unknown";
        }

    } catch (Exception e) {
        FileLog.e("tmessages", e);
        req.lang_code = "en";
        req.device_model = "Android unknown";
        req.system_version = "SDK " + Build.VERSION.SDK_INT;
        req.app_version = "App version unknown";
    }

    if (req.lang_code == null || req.lang_code.length() == 0) {
        req.lang_code = "en";
    }
    if (req.device_model == null || req.device_model.length() == 0) {
        req.device_model = "Android unknown";
    }
    if (req.app_version == null || req.app_version.length() == 0) {
        req.app_version = "App version unknown";
    }
    if (req.system_version == null || req.system_version.length() == 0) {
        req.system_version = "SDK Unknown";
    }

    if (req.app_version != null) {
        ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
            @Override
            public void run(TLObject response, TLRPC.TL_error error) {
                if (error == null) {
                    FileLog.e("tmessages", "registered for push");
                    UserConfig.registeredForPush = true;
                    UserConfig.pushString = regid;
                    UserConfig.saveConfig(false);
                }
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        registeringForPush = false;
                    }
                });
            }
        });
    }
}

From source file:org.telegram.messenger.MessagesController.java

public void registerForPush(final String regid) {
    if (regid == null || regid.length() == 0 || registeringForPush || UserConfig.clientUserId == 0) {
        return;/*from   ww w  .j ava 2  s . c  o  m*/
    }
    if (UserConfig.registeredForPush && regid.equals(UserConfig.pushString)) {
        return;
    }
    registeringForPush = true;
    TLRPC.TL_account_registerDevice req = new TLRPC.TL_account_registerDevice();
    req.token_type = 2;
    req.token = regid;
    req.app_sandbox = false;
    try {
        req.lang_code = Locale.getDefault().getCountry();
        req.device_model = Build.MANUFACTURER + Build.MODEL;
        if (req.device_model == null) {
            req.device_model = "Android unknown";
        }
        req.system_version = "SDK " + Build.VERSION.SDK_INT;
        PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager()
                .getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
        req.app_version = pInfo.versionName;
        if (req.app_version == null) {
            req.app_version = "App version unknown";
        }

    } catch (Exception e) {
        FileLog.e("tmessages", e);
        req.lang_code = "en";
        req.device_model = "Android unknown";
        req.system_version = "SDK " + Build.VERSION.SDK_INT;
        req.app_version = "App version unknown";
    }

    if (req.lang_code == null || req.lang_code.length() == 0) {
        req.lang_code = "en";
    }
    if (req.device_model == null || req.device_model.length() == 0) {
        req.device_model = "Android unknown";
    }
    if (req.app_version == null || req.app_version.length() == 0) {
        req.app_version = "App version unknown";
    }
    if (req.system_version == null || req.system_version.length() == 0) {
        req.system_version = "SDK Unknown";
    }

    if (req.app_version != null) {
        ConnectionsManager.Instance.performRpc(req, new RPCRequest.RPCRequestDelegate() {
            @Override
            public void run(TLObject response, TLRPC.TL_error error) {
                if (error == null) {
                    FileLog.e("tmessages", "registered for push");
                    UserConfig.registeredForPush = true;
                    UserConfig.pushString = regid;
                    UserConfig.saveConfig(false);
                }
                Utilities.RunOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        registeringForPush = false;
                    }
                });
            }
        }, null, true, RPCRequest.RPCRequestClassGeneric);
    }
}

From source file:org.getlantern.firetweet.util.Utils.java

/**
 * User-Agent format of official client:
 * TwitterAndroid/[versionName] ([versionCode]-[buildName]-[r|d)]-[buildNumber]) [deviceInfo]
 *
 * @param context/* w  w  w. j a v a  2  s.c om*/
 * @param cb
 */
public static void setMockOfficialUserAgent(final Context context, final ConfigurationBuilder cb) {
    cb.setClientVersion("5.32.0");
    cb.setClientName("TwitterAndroid");
    cb.setClientURL(null);
    final String deviceInfo = String.format(Locale.ROOT, "%s/%s (%s;%s;%s;%s;)", Build.MODEL,
            Build.VERSION.RELEASE, Build.MANUFACTURER, Build.MODEL, Build.BRAND, Build.PRODUCT);
    cb.setHttpUserAgent(String.format(Locale.ROOT, "TwitterAndroid/%s (%d-%c-%d) %s", "5.32.0", 3030745, 'r',
            692, deviceInfo));
}