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.jungle.base.utils.MiscUtils.java

public static String getDeviceInfo() {
    // Nexus 5, API-19, google/hammerhead/...../release-keys, TIME-1403892907000, CPU_ABI-armeabi-v7a
    ///*from  w ww.j a v a2 s . co  m*/
    return new StringBuilder().append(Build.MODEL).append(", API-").append(Build.VERSION.SDK_INT).append(", ")
            .append(Build.FINGERPRINT).append(", TIME-").append(Build.TIME).append(", CPU_ABI-")
            .append(Build.CPU_ABI).toString();
}

From source file:net.heroicefforts.viable.android.rep.jira.JIRARepository.java

public int postIssue(Issue issue) throws ServiceException {
    try {// www.  j  a v  a 2  s  .  c o  m
        HttpPost post = new HttpPost(rootURL + "/issue.json");
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(12);
        nameValuePairs.add(new BasicNameValuePair("issue_type", issue.getType()));
        nameValuePairs.add(new BasicNameValuePair("priority", issue.getPriority()));
        nameValuePairs.add(new BasicNameValuePair("app_name", issue.getAppName()));
        nameValuePairs.add(new BasicNameValuePair("summary", issue.getSummary()));
        nameValuePairs.add(new BasicNameValuePair("description", issue.getDescription()));
        for (String version : issue.getAffectedVersions())
            nameValuePairs.add(new BasicNameValuePair("app_version_name", version));
        if (issue.getStacktrace() != null)
            nameValuePairs.add(new BasicNameValuePair("stacktrace", issue.getStacktrace()));

        if (issue instanceof BugContext) {
            nameValuePairs.add(new BasicNameValuePair("phone_model", Build.MODEL));
            nameValuePairs.add(new BasicNameValuePair("phone_device", Build.DEVICE));
            nameValuePairs.add(new BasicNameValuePair("phone_version", String.valueOf(Build.VERSION.SDK_INT)));
        }

        if (Config.LOGD)
            Log.d(TAG, "post params:  " + nameValuePairs.toString());
        post.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request  
        HttpResponse response = execute(post);
        int responseCode = response.getStatusLine().getStatusCode();
        if (HttpStatus.SC_OK == responseCode || HttpStatus.SC_CREATED == responseCode) {
            JSONObject obj = readJSON(response);
            if (Config.LOGV)
                Log.v(TAG, "postIssue response:  \n" + obj.toString(4));
            //TODO pull dates from response
            Issue newIssue = new Issue(obj.getJSONObject("issue").toString(4));
            issue.copy(newIssue);
        } else
            throw new ServiceException(MSG_REMOTE_ERROR + responseCode);

        if (Config.LOGD)
            Log.d(TAG, "postIssue code " + responseCode);

        return responseCode;
    } catch (UnsupportedEncodingException e) {
        throw new ServiceException("Encoding error occurred parsing JIRA response", e);
    } catch (IOException e) {
        throw new ServiceException(MSG_CONNECT_ERROR, e);
    } catch (JSONException e) {
        throw new ServiceException(MSG_PARSE_ERROR, e);
    }
}

From source file:eu.thecoder4.gpl.pleftdroid.PleftBroker.java

/**
 * @return the client/*from www . j  a v  a2 s  .c o  m*/
 */
protected static DefaultHttpClient getDefaultClient() {
    // Init HTTP params
    HttpParams httpParameters = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParameters, CONN_TIMEOUT);
    HttpConnectionParams.setSoTimeout(httpParameters, SO_TIMEOUT);
    httpParameters.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
    httpParameters.setParameter("http.protocol.content-charset", "UTF-8");
    DefaultHttpClient client = new DefaultHttpClient(httpParameters);
    client.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
            "PleftDroid/1.0 (Linux; U; Android " + Build.VERSION.RELEASE + "/" + Build.VERSION.CODENAME + "; "
                    + Locale.getDefault().getLanguage() + "; " + Build.MODEL + ")");

    return client;
}

From source file:com.num.mobiperf.Checkin.java

public void sendMeasurement(String string, Measurement measurement) {

    JSONObject status = new JSONObject();
    long timestamp = System.currentTimeMillis() * 1000;
    DeviceProperty dp = new DeviceProperty(measurement.getDeviceId().toString(), "MySpeedTest", timestamp,
            getVersionStr(), "IPv4 only", "IPv4 only", (double) -84.38707806563192, (double) 33.81981981981981,
            "network", measurement.getNetwork().getConnectionType().toString(),
            measurement.getDevice().getNetworkName().toString(), measurement.getBattery().getLevel(),
            (measurement.getBattery().getPlugged() > 0) ? true : false, measurement.getNetwork().getCellType(),
            Integer.parseInt(measurement.getNetwork().getSignalStrength()));
    try {//from  ww  w. j  a  va  2  s  . co  m
        status.put("id", measurement.getDeviceId());
        status.put("manufacturer", Build.MANUFACTURER);
        status.put("model", Build.MODEL);
        status.put("os", getVersionStr());
        status.put("properties", MeasurementJsonConvertor.encodeToJson(dp));

        List<MeasurementResult> resultList = new ArrayList<MeasurementResult>();
        Device device = measurement.getDevice();
        Network network = measurement.getNetwork();
        Battery battery = measurement.getBattery();
        Sim sim = measurement.getSim();
        State state = measurement.getState();
        List<Ping> pings = measurement.getPings();
        WarmupExperiment we = measurement.getWarmupExperiment();
        List<LastMile> lm = measurement.getLastMiles();
        Usage usage = measurement.getUsage();
        GPS gps = measurement.getGps(); // NOT READY
        JSONObject devicejson;
        JSONObject networkjson;
        JSONObject batteryjson;
        JSONObject simjson;
        JSONObject statejson;
        JSONArray pingsarray;
        JSONObject wejson;
        JSONArray lastarray;
        JSONObject usagejson;
        JSONObject gpsjson;

        if (device != null) {
            devicejson = device.toJSON();
            resultList.add(createResultList("device_info", dp, measurement, devicejson));
        }
        if (network != null) {
            networkjson = network.toJSON();
            resultList.add(createResultList("network_info", dp, measurement, networkjson));// networkjson));            
        }
        if (battery != null) {
            batteryjson = battery.toJSON();
            resultList.add(createResultList("battery_info", dp, measurement, batteryjson));
        }
        if (sim != null) {
            simjson = sim.toJSON();
            resultList.add(createResultList("sim_info", dp, measurement, simjson));
        }
        if (state != null) {
            statejson = state.toJSON();
            resultList.add(createResultList("state_info", dp, measurement, statejson));
        }
        //         if (pings != null) { 
        //            pingsarray = new JSONArray();
        //            for (Ping p : pings) {
        //               pingsarray.put(p.toJSON());
        //            }
        //            //resultList.add(createResultList("pings_info", dp, measurement, pingsarray));
        //         }
        //         if (we != null) {
        //            wejson = we.toJSON();
        //            resultList.add(createResultList("warmup_info", dp, measurement, wejson));            
        //         }
        //         if (lm != null) {
        //            lastarray = new JSONArray();
        //            for (LastMile l : lm) {
        //               lastarray.put(l.toJSON());
        //            }            
        //            resultList.add(createResultList("lastmile_info", dp, measurement, lastarray));
        //         }
        if (usage != null) {
            usagejson = usage.toJSON();
            resultList.add(createResultListUsage("usage_info", dp, measurement, usagejson));
        }
        if (gps != null) {
            gpsjson = gps.toJSON();
            //resultList.add(createResultList("gps_info", dp, measurement, gpsjson));
        }

        // For each of the measurements create a status to send         

        JSONArray resultArray = new JSONArray();
        for (MeasurementResult result : resultList) {
            resultArray.put(MeasurementJsonConvertor.encodeToJson(result));
        }
        String response = serviceRequest("postmeasurement", resultArray.toString());
        System.out.println(response);

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:com.rbsoftware.pfm.personalfinancemanager.utils.Utils.java

/**
 * Checks if current device is buggy samsung
 *
 * @return true if current device is buggy samsung
 *///from w  ww.ja v  a  2  s  . c om
public static boolean isBrokenSamsungDevice() {
    return (Build.MANUFACTURER.equalsIgnoreCase("samsung") && Build.MODEL.toLowerCase().contains("j5")
            && isBetweenAndroidVersions(Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.LOLLIPOP_MR1));
}

From source file:it.mb.whatshare.PairOutboundActivity.java

private String generateRandomSeed() {
    StringBuilder builder = new StringBuilder();
    String whitespace = "";
    Random gen = new Random();
    // I know, it's 4 (half) bytes so I could stuff them into a single int,
    // but I'm lazy and er.. it's open to future larger keys?
    randomSeed = new ArrayList<Integer>();
    for (int i = 0; i < 4; i++) {
        builder.append(whitespace);//from   w w w  .  j  a  v  a2 s .c  o m
        int nextInt = gen.nextInt(128);
        builder.append(nextInt);
        randomSeed.add(nextInt);
        whitespace = " ";
    }
    builder.append(String.format(" %s %s", Utils.capitalize(Build.MANUFACTURER), Build.MODEL));
    Utils.debug("stuffing this into the QR code: %s", builder.toString());
    return builder.toString();
}

From source file:org.thoughtcrime.securesms.logsubmit.SubmitLogFragment.java

private static String buildDescription(Context context) {
    final PackageManager pm = context.getPackageManager();
    final StringBuilder builder = new StringBuilder();

    builder.append("Time    : ").append(System.currentTimeMillis()).append('\n');
    builder.append("Device  : ").append(Build.MANUFACTURER).append(" ").append(Build.MODEL).append(" (")
            .append(Build.PRODUCT).append(")\n");
    builder.append("Android : ").append(VERSION.RELEASE).append(" (").append(VERSION.INCREMENTAL).append(", ")
            .append(Build.DISPLAY).append(")\n");
    builder.append("ABIs    : ").append(TextUtils.join(", ", getSupportedAbis())).append("\n");
    builder.append("Memory  : ").append(getMemoryUsage(context)).append("\n");
    builder.append("Memclass: ").append(getMemoryClass(context)).append("\n");
    builder.append("OS Host : ").append(Build.HOST).append("\n");
    builder.append("App     : ");
    try {//  ww w  . ja v a 2 s.c  o  m
        builder.append(pm.getApplicationLabel(pm.getApplicationInfo(context.getPackageName(), 0))).append(" ")
                .append(pm.getPackageInfo(context.getPackageName(), 0).versionName).append("\n");
    } catch (PackageManager.NameNotFoundException nnfe) {
        builder.append("Unknown\n");
    }

    return builder.toString();
}

From source file:com.ternup.caddisfly.fragment.DetailsFragment.java

public void postResult(String folderName) {

    RequestParams params = new RequestParams();
    TimeZone tz = TimeZone.getTimeZone("UTC");
    final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
    df.setTimeZone(tz);/*from  ww w .ja  v  a 2 s .  c om*/

    final ArrayList<String> filePaths = FileUtils.getFilePaths(getActivity(), folderName, "/small/",
            mLocationId);
    File myFile = new File(filePaths.get(0));
    String date = df.format(DateUtils.getDateFromFilename(myFile.getName()));

    params.put("date", date);
    String deviceId = Build.MANUFACTURER + " " + Build.MODEL;
    if (deviceId.length() > 32) {
        deviceId = deviceId.substring(1, 32);
    }
    params.put("deviceId", deviceId);
    params.put("type", String.valueOf(mTestTypeId + 1));

    if (wakeLock == null || !wakeLock.isHeld()) {
        PowerManager pm = (PowerManager) getActivity().getApplicationContext()
                .getSystemService(Context.POWER_SERVICE);
        wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
                | PowerManager.ON_AFTER_RELEASE, "MyWakeLock");
        wakeLock.acquire();
    }

    WebClient.post("tests", params, new AsyncHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
            String response = responseBody == null ? null : new String(responseBody);
            try {
                JSONObject json = new JSONObject(response);
                final int newId = json.getInt("id");
                if (filePaths.size() > 0) {
                    count = 0;
                    totalCount = filePaths.size();
                    postItem(newId, filePaths);
                }

            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, byte[] responseBody, final Throwable error) {
            Log.d(Globals.DEBUG_TAG, "fail: " + error.getMessage());

            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    if (progressDialog != null) {
                        progressDialog.dismiss();
                    }

                    if (wakeLock != null && wakeLock.isHeld()) {
                        wakeLock.release();
                    }
                    AlertUtils.showAlert(getActivity(), R.string.error, error.getMessage(), R.string.ok, null,
                            null);
                }
            });
        }
    });
}

From source file:com.aujur.ebookreader.Configuration.java

public String getDeviceName() {
    return settings.getString(KEY_DEVICE_NAME, Build.MODEL);
}