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.openmidaas.library.authentication.AuthCallbackForRegistration.java

@Override
public void onSuccess(String deviceToken) {
    try {//from w w  w. j  a  va 2s  . co  m
        AVSServer.registerDevice(deviceToken, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(String response) {
                if (response == null || response.isEmpty()) {
                    mInitCallback.onError(new MIDaaSException(MIDaaSError.SERVER_ERROR));
                } else {
                    try {
                        MIDaaS.logDebug(TAG, "device successfully registered. persisting registration.");
                        JSONObject responseObject = new JSONObject(response);
                        if (responseObject.has("subjectToken") && !(responseObject.isNull("subjectToken"))) {
                            SubjectToken subjectToken = SubjectTokenFactory.createAttribute();
                            subjectToken.setValue(Build.MODEL);
                            subjectToken.setSignedToken(responseObject.getString("subjectToken"));
                            subjectToken.save();
                            // if we didn't get the access token, we can get it on-demand at a later time. 
                            if ((responseObject.has(Constants.AccessTokenKeys.ACCESS_TOKEN)
                                    && !(responseObject.isNull(Constants.AccessTokenKeys.ACCESS_TOKEN)))
                                    && (responseObject.has(Constants.AccessTokenKeys.EXPIRES_IN)
                                            && !(responseObject
                                                    .isNull(Constants.AccessTokenKeys.EXPIRES_IN)))) {
                                MIDaaS.logDebug(TAG, "Registration response has an access token.");
                                AccessToken token = AccessToken.createAccessToken(
                                        responseObject.getString(Constants.AccessTokenKeys.ACCESS_TOKEN),
                                        responseObject.getInt(Constants.AccessTokenKeys.EXPIRES_IN));
                                if (token != null) {
                                    MIDaaS.logDebug(TAG, "Access token is ok.");
                                    AuthenticationManager.getInstance().setAccessToken(token);
                                } else {
                                    MIDaaS.logError(TAG, "Access token is null.");
                                    mInitCallback.onError(new MIDaaSException(MIDaaSError.SERVER_ERROR));
                                }
                            } else {
                                MIDaaS.logDebug(TAG,
                                        "No access token object in server response. Access token will be created on-demand.");
                            }
                        } else {
                            MIDaaS.logError(TAG, "Server response doesn't match expected response");
                            mInitCallback.onError(new MIDaaSException(MIDaaSError.SERVER_ERROR));
                        }
                        mInitCallback.onSuccess();
                    } catch (InvalidAttributeValueException e) {
                        // should never get here b/c we're returning true. 
                        MIDaaS.logError(TAG, "logic error. should never have thrown exception");
                    } catch (MIDaaSException e) {
                        MIDaaS.logError(TAG, e.getError().getErrorMessage());
                        mInitCallback.onError(e);

                    } catch (JSONException e) {
                        MIDaaS.logError(TAG, e.getMessage());
                        mInitCallback.onError(new MIDaaSException(MIDaaSError.SERVER_ERROR));
                    }
                }
            }

            @Override
            public void onFailure(Throwable e, String response) {
                MIDaaS.logError(TAG, response);
                mInitCallback.onError(new MIDaaSException(MIDaaSError.SERVER_ERROR));
            }
        });
    } catch (JSONException e) {
        MIDaaS.logError(TAG, "Internal error");
        MIDaaS.logError(TAG, e.getMessage());
        mInitCallback.onError(null);
    }

}

From source file:com.neuron.trafikanten.HelperFunctions.java

private static String getUserAgent(Context context) {
    if (userAgentString == null) {
        CharSequence appVersion = GetApplicationVersion(context);

        userAgentString = "TrafikantenAndroid/" + appVersion + " (aagaande) Device/" + Build.VERSION.RELEASE
                + " (" + Locale.getDefault() + "; " + Build.MODEL + ")";

        // + Locale.getDefault() + ")";
    }/*from  w  ww  . ja v  a 2s.c  om*/
    return userAgentString;
}

From source file:com.adjust.sdk.Util.java

private static String getDeviceName() {
    final String deviceName = Build.MODEL;
    return sanitizeString(deviceName);
}

From source file:com.vk.sdk.api.httpClient.VKHttpClient.java

/**
 * Creates the http client (if need). Returns reusing client
 *
 * @return Prepared client used for API requests loading
 *//*w  w w.j ava  2s  .  c  o m*/
public static VKHttpClient getClient() {
    if (sInstance == null) {
        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
        HttpParams params = new BasicHttpParams();
        Context ctx = VKUIHelper.getApplicationContext();

        try {
            if (ctx != null) {
                PackageManager packageManager = ctx.getPackageManager();
                if (packageManager != null) {
                    PackageInfo info = packageManager.getPackageInfo(ctx.getPackageName(), 0);
                    params.setParameter(CoreProtocolPNames.USER_AGENT,
                            String.format(Locale.US, "%s/%s (%s; Android %d; Scale/%.2f; VK SDK %s; %s)",
                                    VKUtil.getApplicationName(ctx), info.versionName, Build.MODEL,
                                    Build.VERSION.SDK_INT, ctx.getResources().getDisplayMetrics().density,
                                    VKSdkVersion.SDK_VERSION, info.packageName));
                }
            }
        } catch (Exception ignored) {
        }
        sInstance = new VKHttpClient(new ThreadSafeClientConnManager(params, schemeRegistry), params);
    }
    return sInstance;
}

From source file:org.LK8000.LK8000.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (serviceClass == null)
        serviceClass = MyService.class;

    super.onCreate(savedInstanceState);
    //    Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());

    Fabric fabric = new Fabric.Builder(this).debuggable(true).kits(new Crashlytics(), new CrashlyticsNdk())
            .build();/*from w w w  . j a  v  a 2s.c  o m*/

    Fabric.with(fabric);

    Log.d(TAG, "ABI=" + Build.CPU_ABI);
    Log.d(TAG, "PRODUCT=" + Build.PRODUCT);
    Log.d(TAG, "MANUFACTURER=" + Build.MANUFACTURER);
    Log.d(TAG, "MODEL=" + Build.MODEL);
    Log.d(TAG, "DEVICE=" + Build.DEVICE);
    Log.d(TAG, "BOARD=" + Build.BOARD);
    Log.d(TAG, "FINGERPRINT=" + Build.FINGERPRINT);

    if (!Loader.loaded) {
        TextView tv = new TextView(this);
        tv.setText("Failed to load the native LK8000 libary.\n"
                + "Report this problem to us, and include the following information:\n" + "ABI=" + Build.CPU_ABI
                + "\n" + "PRODUCT=" + Build.PRODUCT + "\n" + "FINGERPRINT=" + Build.FINGERPRINT + "\n"
                + "error=" + Loader.error);
        setContentView(tv);
        return;
    }

    initialiseNative();

    NetUtil.initialise(this);
    InternalGPS.Initialize();
    NonGPSSensors.Initialize();

    IOIOHelper.onCreateContext(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR)
        // Bluetooth suppoert was added in Android 2.0 "Eclair"
        BluetoothHelper.Initialize(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD)
        // the DownloadManager was added in Android 2.3 "Gingerbread"
        DownloadUtil.Initialise(getApplicationContext());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
        UsbSerialHelper.Initialise(this);
    }

    SoundUtil.Initialise();

    // fullscreen mode
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    /* Workaround for layout problems in Android KitKat with immersive full
       screen mode: Sometimes the content view was not initialized with the
       correct size, which caused graphics artifacts. */
    if (android.os.Build.VERSION.SDK_INT >= 19) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }

    enableImmersiveModeIfSupported();

    TextView tv = new TextView(this);
    tv.setText("Loading LK8000...");
    setContentView(tv);

    batteryReceiver = new BatteryReceiver();
    registerReceiver(batteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    SharedPreferences settings = getSharedPreferences("LK8000", 0);
    int screenOrientation = settings.getInt("screenOrientation", 0);
    switch (screenOrientation) {
    case 0:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        break;
    case 1:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    case 2:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    case 3:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
        break;
    case 4:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
        break;
    default:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    }

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

}

From source file:de.hackerspacebremen.communication.HackerspaceComm.java

protected final JSONObject doInBackground(final JSONObject... data) {
    final String userAgent = "HackerSpaceBremen/" + this.appVersionName + "; Android/" + Build.VERSION.RELEASE
            + "; " + Build.MANUFACTURER + "; " + Build.DEVICE + "; " + Build.MODEL;

    HttpClient httpclient = new DefaultHttpClient();
    HttpParams httpBodyParams = httpclient.getParams();
    httpBodyParams.setParameter(CoreProtocolPNames.USER_AGENT, userAgent);

    String response = null;/*from  www .  j a  va2s.  c  o  m*/
    int responseCode = 0;
    String httpOrS = HTTPS;
    if (httpReq) {
        httpOrS = HTTP;
    }

    if (getReq) {
        try {
            final HttpURLConnection connection = client
                    .open(new URL(httpOrS + SERVERURL + this.servletUrl + "?" + getParams));
            InputStream in = null;
            try {
                // Read the response.
                in = connection.getInputStream();
                final byte[] resp = readFully(in);
                response = new String(resp, Constants.UTF8);
                responseCode = connection.getResponseCode();
            } finally {
                if (in != null)
                    in.close();
            }
            // HttpGet httpget = new HttpGet(httpOrS + SERVERURL
            // + this.servletUrl + "?" + getParams);
            // response = httpclient.execute(httpget);
        } catch (IOException e) {
            errorcode = -1;
            cancel(false);
            return null;
        }
    } else {
        try {
            HttpURLConnection connection = client.open(new URL(httpOrS + SERVERURL + this.servletUrl));
            OutputStream out = null;
            InputStream in = null;
            try {
                // Write the request.
                connection.setRequestMethod("POST");
                out = connection.getOutputStream();
                out.write(createBody().getBytes(Constants.UTF8));
                out.close();

                responseCode = connection.getResponseCode();
                in = connection.getInputStream();
                response = readFirstLine(in);
            } finally {
                // Clean up.
                if (out != null)
                    out.close();
                if (in != null)
                    in.close();
            }
            // HttpPost httpPost = new HttpPost(httpOrS + SERVERURL
            // + this.servletUrl);
            // httpPost.setEntity(new UrlEncodedFormEntity(postParams,
            // "UTF-8"));
            // response = httpclient.execute(httpPost);

        } catch (IOException e) {
            errorcode = -1;
            cancel(false);
            return null;
        }
    }

    httpState = responseCode;

    JSONObject resData = new JSONObject();
    String resString = "";
    try {
        resString = response;
        resData = new JSONObject(resString);
        if (httpState != 200) {
            errorcode = resData.getInt("CODE");
            cancel(false);
            return null;
        }

    } catch (JSONException e) {
        if (httpState != 200) {
            errorcode = httpState;
        } else {
            errorcode = -2;
        }
        cancel(false);
        return null;
    }

    return resData;
}

From source file:com.vk.sdkweb.api.httpClient.VKHttpClient.java

/**
 * Creates the http client (if need). Returns reusing client
 *
 * @return Prepared client used for API requests loading
 *///from www.j  av a2 s.  co m
public static VKHttpClient getClient() {
    if (sInstance == null) {
        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
        HttpParams params = new BasicHttpParams();
        Context ctx = VKUIHelper.getTopActivity();

        try {
            if (ctx != null) {
                PackageManager packageManager = ctx.getPackageManager();
                if (packageManager != null) {
                    PackageInfo info = packageManager.getPackageInfo(ctx.getPackageName(), 0);
                    params.setParameter(CoreProtocolPNames.USER_AGENT,
                            String.format(Locale.US, "%s/%s (%s; Android %d; Scale/%.2f; VK SDK %s; %s)",
                                    VKUtil.getApplicationName(ctx), info.versionName, Build.MODEL,
                                    Build.VERSION.SDK_INT, ctx.getResources().getDisplayMetrics().density,
                                    VKSdkVersion.SDK_VERSION, info.packageName));
                }
            }
        } catch (Exception ignored) {
        }
        sInstance = new VKHttpClient(new ThreadSafeClientConnManager(params, schemeRegistry), params);
    }
    return sInstance;
}

From source file:com.stoutner.privacybrowser.AboutTabFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View tabLayout;/*from  w  w w.  jav a  2  s. c o  m*/

    // Load the about tab layout.  Tab numbers start at 0.
    if (tabNumber == 0) {
        // Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container.
        // The fragment will take care of attaching the root automatically.
        tabLayout = inflater.inflate(R.layout.about_tab_version, container, false);

        // Version.
        TextView versionNumberText = (TextView) tabLayout.findViewById(R.id.about_version_number_text);
        String version = getString(R.string.version) + " " + BuildConfig.VERSION_NAME + " ("
                + getString(R.string.version_code) + " " + Integer.toString(BuildConfig.VERSION_CODE) + ")";
        versionNumberText.setText(version);

        // Brand.
        TextView versionBrandText = (TextView) tabLayout.findViewById(R.id.about_version_brand_text);
        versionBrandText.setText(Build.BRAND);

        // Manufacturer.
        TextView versionManufacturerText = (TextView) tabLayout
                .findViewById(R.id.about_version_manufacturer_text);
        versionManufacturerText.setText(Build.MANUFACTURER);

        // Model.
        TextView versionModelText = (TextView) tabLayout.findViewById(R.id.about_version_model_text);
        versionModelText.setText(Build.MODEL);

        // Device.
        TextView versionDeviceText = (TextView) tabLayout.findViewById(R.id.about_version_device_text);
        versionDeviceText.setText(Build.DEVICE);

        // Bootloader.
        TextView versionBootloaderText = (TextView) tabLayout.findViewById(R.id.about_version_bootloader_text);
        versionBootloaderText.setText(Build.BOOTLOADER);

        // Radio.
        TextView versionRadioText = (TextView) tabLayout.findViewById(R.id.about_version_radio_text);
        // Hide versionRadioTextView if there is no radio.
        if (Build.getRadioVersion().equals("")) {
            TextView versionRadioTitle = (TextView) tabLayout.findViewById(R.id.about_version_radio_title);
            versionRadioTitle.setVisibility(View.GONE);
            versionRadioText.setVisibility(View.GONE);
        } else { // Else, set the text.
            versionRadioText.setText(Build.getRadioVersion());
        }

        // Android.
        TextView versionAndroidText = (TextView) tabLayout.findViewById(R.id.about_version_android_text);
        String android = Build.VERSION.RELEASE + " (" + getString(R.string.api) + " "
                + Integer.toString(Build.VERSION.SDK_INT) + ")";
        versionAndroidText.setText(android);

        // Build.
        TextView versionBuildText = (TextView) tabLayout.findViewById(R.id.about_version_build_text);
        versionBuildText.setText(Build.DISPLAY);

        // Security Patch.
        TextView versionSecurityPatchText = (TextView) tabLayout
                .findViewById(R.id.about_version_securitypatch_text);
        // Build.VERSION.SECURITY_PATCH is only available for SDK_INT >= 23.
        if (Build.VERSION.SDK_INT >= 23) {
            versionSecurityPatchText.setText(Build.VERSION.SECURITY_PATCH);
        } else { // Hide versionSecurityPatchTextView.
            TextView versionSecurityPatchTitle = (TextView) tabLayout
                    .findViewById(R.id.about_version_securitypatch_title);
            versionSecurityPatchTitle.setVisibility(View.GONE);
            versionSecurityPatchText.setVisibility(View.GONE);
        }

        // webViewLayout is only used to get the default user agent from about_tab_webview.  It is not used to render content on the screen.
        View webViewLayout = inflater.inflate(R.layout.about_tab_webview, container, false);
        WebView tabLayoutWebView = (WebView) webViewLayout.findViewById(R.id.about_tab_webview);
        String userAgentString = tabLayoutWebView.getSettings().getUserAgentString();

        // WebKit.
        TextView versionWebKitText = (TextView) tabLayout.findViewById(R.id.about_version_webkit_text);
        // Select the substring that begins after "Safari/" and goes to the end of the string.
        String webkitVersion = userAgentString.substring(userAgentString.indexOf("Safari/") + 7);
        versionWebKitText.setText(webkitVersion);

        // Chrome.
        TextView versionChromeText = (TextView) tabLayout.findViewById(R.id.about_version_chrome_text);
        // Select the substring that begins after "Chrome/" and goes until the next " ".
        String chromeVersion = userAgentString.substring(userAgentString.indexOf("Chrome/") + 7,
                userAgentString.indexOf(" ", userAgentString.indexOf("Chrome/")));
        versionChromeText.setText(chromeVersion);
    } else { // load a WebView for all the other tabs.  Tab numbers start at 0.
        // Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container.
        // The fragment will take care of attaching the root automatically.
        tabLayout = inflater.inflate(R.layout.about_tab_webview, container, false);
        WebView tabWebView = (WebView) tabLayout;

        switch (tabNumber) {
        case 1:
            tabWebView.loadUrl("file:///android_asset/about_permissions.html");
            break;

        case 2:
            tabWebView.loadUrl("file:///android_asset/about_privacy_policy.html");
            break;

        case 3:
            tabWebView.loadUrl("file:///android_asset/about_changelog.html");
            break;

        case 4:
            tabWebView.loadUrl("file:///android_asset/about_license.html");
            break;

        case 5:
            tabWebView.loadUrl("file:///android_asset/about_contributors.html");
            break;

        case 6:
            tabWebView.loadUrl("file:///android_asset/about_links.html");

        default:
            break;
        }
    }

    return tabLayout;
}

From source file:org.pixmob.droidlink.net.NetworkClient.java

private static final String generateUserAgent(Context context) {
    if (applicationVersion == null) {
        try {//from  w w  w.ja v  a  2s .co  m
            applicationVersion = context.getPackageManager().getPackageInfo(context.getPackageName(),
                    0).versionName;
        } catch (NameNotFoundException e) {
            applicationVersion = "0.0.0";
        }
    }
    return APPLICATION_NAME + "/" + applicationVersion + " (" + Build.MANUFACTURER + " " + Build.MODEL
            + " with Android " + Build.VERSION.RELEASE + "/" + Build.VERSION.SDK_INT + ")";
}

From source file:com.android.test.gallery3d.common.HttpClientFactory.java

private static String getUserAgent(Context context) {
    if (sUserAgent == null) {
        PackageInfo pi;// w  ww .  ja v a  2  s.  co 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, Build.VERSION.RELEASE,
                Build.VERSION.INCREMENTAL);
    }
    return sUserAgent;
}