Example usage for android.os Build MANUFACTURER

List of usage examples for android.os Build MANUFACTURER

Introduction

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

Prototype

String MANUFACTURER

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

Click Source Link

Document

The manufacturer of the product/hardware.

Usage

From source file:com.silentcircle.silenttext.util.DeviceUtils.java

public static JSONObject getDebugInformationJSON(Context context) {

    try {//from  www  . ja  v  a 2  s  .c o m

        JSONObject json = new JSONObject();

        json.put("timestamp", JSONUtils.getDate(System.currentTimeMillis()));

        JSONObject android = new JSONObject();

        android.put("version", Build.VERSION.RELEASE);
        android.put("api", Build.VERSION.SDK_INT);
        android.put("build", Build.FINGERPRINT);

        json.put("android", android);

        JSONObject application = new JSONObject();

        try {

            PackageInfo pinfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);

            application.put("version_name", pinfo.versionName);
            application.put("version_code", pinfo.versionCode);
            setInstallAndUpdateTimes(pinfo, application);

        } catch (NameNotFoundException impossible) {
            throw new RuntimeException(impossible);
        }

        json.put("application", application);

        JSONObject device = new JSONObject();

        Configuration resourceConfiguration = context.getResources().getConfiguration();

        device.put("locale", resourceConfiguration.locale);
        device.put("orientation",
                resourceConfiguration.orientation == Configuration.ORIENTATION_LANDSCAPE ? "landscape"
                        : "portrait");
        device.put("density", getScreenDensity(resourceConfiguration));
        device.put("screen", getScreenDimensions(resourceConfiguration));

        device.put("manufacturer", Build.MANUFACTURER);
        device.put("model", Build.MODEL);

        JSONObject encryption = new JSONObject();

        encryption.put("supported", isFullDiskEncryptionSupported(context));
        encryption.put("enabled", isEncrypted(context));

        device.put("encryption", encryption);

        json.put("device", device);

        JSONObject build = new JSONObject();

        build.put("date", context.getString(R.string.build_date));
        build.put("version", context.getString(R.string.build_version));
        build.put("commit", context.getString(R.string.build_commit));

        json.put("build", build);

        JSONObject connection = new JSONObject();

        SilentTextApplication global = SilentTextApplication.from(context);

        XMPPTransport client = global.getXMPPTransport();

        JSONObject xmpp = new JSONObject();

        xmpp.put("status", global.getXMPPTransportConnectionStatus());

        if (client != null) {

            boolean online = client.isConnected();

            xmpp.put("online", online);

            if (online) {
                xmpp.put("host", client.getServerHost());
                xmpp.put("port", client.getServerPort());
            }

        }

        connection.put("xmpp", xmpp);

        json.put("connection", connection);

        ServiceConfiguration serviceConfig = ServiceConfiguration.getInstance();

        JSONObject services = new JSONObject();

        services.put("debug", serviceConfig.debug);
        services.put("experimental", serviceConfig.experimental);
        services.put("logging_enabled", serviceConfig.loggingEnabled);
        services.put("environment", serviceConfig.environment);
        services.put("dns.use_custom_server", serviceConfig.useCustomDNS);
        if (serviceConfig.useCustomDNS) {
            services.put("dns.custom_server", serviceConfig.customDNS);
        }
        services.put("validate_certificates", serviceConfig.shouldValidateCertificates);
        services.put("api.override", serviceConfig.api.override);
        services.put("api.perform_srv_lookup", serviceConfig.api.performSRVLookup);
        services.put("api.host", serviceConfig.api.host);
        services.put("api.port", serviceConfig.api.port);
        services.put("api.service_name", serviceConfig.api.serviceName);
        services.put("feature.check_user_availability", serviceConfig.features.checkUserAvailability);
        services.put("feature.generate_default_avatars", serviceConfig.features.generateDefaultAvatars);
        services.put("gcm.sender_id", serviceConfig.gcm.senderID);
        services.put("gcm.target", serviceConfig.gcm.target);
        services.put("scimp.enable_pki", serviceConfig.scimp.enablePKI);
        services.put("scloud.url", serviceConfig.scloud.url);
        services.put("xmpp.override", serviceConfig.xmpp.override);
        services.put("xmpp.perform_srv_lookup", serviceConfig.xmpp.performSRVLookup);
        services.put("xmpp.host", serviceConfig.xmpp.host);
        services.put("xmpp.port", serviceConfig.xmpp.port);
        services.put("xmpp.service_name", serviceConfig.xmpp.serviceName);
        services.put("xmpp.background", serviceConfig.xmpp.background);
        services.put("passcode_set", !OptionsDrawer.isEmptyPasscode(context));
        services.put("silent_contacts_v1", SilentContactRepositoryV1.supports(context));
        services.put("silent_contacts_v2", SilentContactRepositoryV2.supports(context));
        services.put("silent_phone", SilentPhone.supports(context));

        json.put("configuration", services);

        return json;

    } catch (JSONException impossible) {
        throw new RuntimeException(impossible);
    }

}

From source file:com.cc.signalinfo.fragments.SignalFragment.java

/**
 * Set the phone model, OS version, carrier name on the screen
 *///from  w  w  w.  j  a  va 2s.c  o m
private void setPhoneInfo() {
    setTextViewText(R.id.deviceName, String.format("%s %s", Build.MANUFACTURER, Build.MODEL));
    setTextViewText(R.id.deviceModel, String.format("%s/%s (%s) ", Build.PRODUCT, Build.DEVICE, Build.ID));
    setTextViewText(R.id.androidVersion, String.format(activity.getString(R.string.androidVersion),
            Build.VERSION.RELEASE, Build.VERSION.SDK_INT));

    setTextViewText(R.id.carrierName, tm.getNetworkOperatorName());
    setTextViewText(R.id.buildHost, Build.HOST);
    setNetworkTypeText();
}

From source file:net.olejon.spotcommander.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Settings// w w  w.jav  a 2 s . c  o  m
    PreferenceManager.setDefaultValues(mContext, R.xml.settings, false);

    // Allow landscape?
    if (!mTools.allowLandscape())
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // Google API client
    mGoogleApiClient = new GoogleApiClient.Builder(mContext).addApiIfAvailable(Wearable.API).build();

    // Database
    mDatabase = new MainSQLiteHelper(mContext).getWritableDatabase();

    // Layout
    setContentView(R.layout.activity_main);

    // Toolbar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
    toolbar.setTitle(getString(R.string.main_title));

    setSupportActionBar(toolbar);

    // Listview
    mListView = (ListView) findViewById(R.id.main_list);

    final View listViewHeader = getLayoutInflater().inflate(R.layout.activity_main_subheader, mListView, false);
    mListView.addHeaderView(listViewHeader, null, false);

    final View listViewEmpty = findViewById(R.id.main_empty);
    mListView.setEmptyView(listViewEmpty);

    mListView.setLongClickable(true);

    mListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            openComputer(id);
        }
    });

    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, final long id) {
            new MaterialDialog.Builder(mContext).title(R.string.main_remove_computer_dialog_title)
                    .content(getString(R.string.main_remove_computer_dialog_message))
                    .positiveText(R.string.main_remove_computer_dialog_positive_button)
                    .negativeText(R.string.main_remove_computer_dialog_negative_button)
                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                        @Override
                        public void onClick(@NonNull MaterialDialog materialDialog,
                                @NonNull DialogAction dialogAction) {
                            removeComputer(id);

                            listComputers();
                        }
                    }).contentColorRes(R.color.black).negativeColorRes(R.color.black).show();

            return true;
        }
    });

    // Floating action button
    mFloatingActionButton = (FloatingActionButton) findViewById(R.id.main_fab);

    mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(mContext, AddComputerActivity.class);
            startActivity(intent);
        }
    });

    // Donate button
    final Button button = (Button) findViewById(R.id.main_make_donation_button);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(mContext, DonateActivity.class);
            startActivity(intent);
        }
    });

    // Information dialog
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        if (!mTools.getSharedPreferencesBoolean("HIDE_INFORMATION_DIALOG_75")) {
            new MaterialDialog.Builder(mContext).title(R.string.main_information_dialog_title)
                    .content(getString(R.string.main_information_dialog_message))
                    .positiveText(R.string.main_information_dialog_positive_button)
                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                        @Override
                        public void onClick(@NonNull MaterialDialog materialDialog,
                                @NonNull DialogAction dialogAction) {
                            mTools.setSharedPreferencesBoolean("HIDE_INFORMATION_DIALOG_75", true);
                        }
                    }).contentColorRes(R.color.black).show();
        }
    }

    // Message dialog
    String version = mTools.getProjectVersionName();
    String device = "";

    try {
        device = (Build.MANUFACTURER == null || Build.MODEL == null || Build.VERSION.SDK_INT < 1) ? ""
                : URLEncoder.encode(Build.MANUFACTURER + " " + Build.MODEL + " " + Build.VERSION.SDK_INT,
                        "utf-8");
    } catch (Exception e) {
        Log.e("MainActivity", Log.getStackTraceString(e));
    }

    final Cache cache = new DiskBasedCache(getCacheDir(), 0);

    final Network network = new BasicNetwork(new HurlStack());

    final RequestQueue requestQueue = new RequestQueue(cache, network);

    requestQueue.start();

    final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET,
            getString(R.string.project_website) + "api/1/android/message/?version_name=" + version + "&device="
                    + device,
            null, new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    requestQueue.stop();

                    try {
                        final long id = response.getLong("id");
                        final String title = response.getString("title");
                        final String message = response.getString("message");

                        final long lastId = mTools.getSharedPreferencesLong("LAST_MESSAGE_ID");

                        if (lastId == 0) {
                            mTools.setSharedPreferencesLong("LAST_MESSAGE_ID", id);
                        } else if (id != lastId) {
                            new MaterialDialog.Builder(mContext).title(title).content(message)
                                    .positiveText(R.string.main_message_dialog_positive_button)
                                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                                        @Override
                                        public void onClick(@NonNull MaterialDialog materialDialog,
                                                @NonNull DialogAction dialogAction) {
                                            mTools.setSharedPreferencesLong("LAST_MESSAGE_ID", id);
                                        }
                                    }).contentColorRes(R.color.black).show();
                        }
                    } catch (Exception e) {
                        Log.e("MainActivity", Log.getStackTraceString(e));
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    requestQueue.stop();

                    Log.e("MainActivity", error.toString());
                }
            });

    jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

    requestQueue.add(jsonObjectRequest);

    // Google analytics
    final GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(mContext);
    final Tracker tracker = googleAnalytics.newTracker(R.xml.app_tracker);
    tracker.send(new HitBuilders.ScreenViewBuilder().build());
}

From source file:com.vinexs.tool.Utility.java

public static String getUserDeviceModel() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;/*from  w  ww .  j  a v a 2 s.com*/
    if (model.startsWith(manufacturer)) {
        return model;
    }
    return manufacturer + " " + model;
}

From source file:jahirfiquitiva.iconshowcase.utilities.Utils.java

public static void sendEmailWithDeviceInfo(Context context) {
    StringBuilder emailBuilder = new StringBuilder();
    Intent intent = new Intent(Intent.ACTION_VIEW,
            Uri.parse("mailto:" + context.getResources().getString(R.string.email_id)));
    intent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getString(R.string.email_subject));
    emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version")).append("(")
            .append(Build.VERSION.INCREMENTAL).append(")");
    emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT);
    emailBuilder.append("\nDevice: ").append(Build.DEVICE);
    emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER);
    emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (").append(Build.PRODUCT)
            .append(")");
    PackageInfo appInfo = null;//from  w ww .j a  v a2  s  .c o  m
    try {
        appInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    assert appInfo != null;
    emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName);
    emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode);
    intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString());
    context.startActivity(
            Intent.createChooser(intent, (context.getResources().getString(R.string.send_title))));
}

From source file:com.sitewhere.android.example.MainActivity.java

private Map<String, String> buildRegistrationMetadata() {
    Map<String, String> metadata = new HashMap<>();

    WifiManager wm = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
    String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());

    String reqString = Build.MANUFACTURER + " " + Build.MODEL + " " + Build.VERSION.RELEASE + " "
            + Build.VERSION_CODES.class.getFields()[android.os.Build.VERSION.SDK_INT].getName();

    metadata.put("ipaddress", ip);
    metadata.put("android.os.version", Build.VERSION.BASE_OS);
    metadata.put("android.os.description", reqString);

    return metadata;
}

From source file:org.apache.cordova.CordovaWebView.java

private void exposeJsInterface() {
    // addJavascriptInterface crashes on the 2.3 emulator.
    if (Build.VERSION.RELEASE.startsWith("2.3") && Build.MANUFACTURER.equals("unknown")) {
        Log.i(TAG, "Disabled addJavascriptInterface() bridge callback due to a bug on the 2.3 emulator");
        return;/*from w w w. jav a  2s .c o  m*/
    }
    this.addJavascriptInterface(new Object() {
        @SuppressWarnings("unused")
        public String exec(String service, String action, String callbackId, String arguments)
                throws JSONException {
            return pluginManager.exec(service, action, callbackId, arguments, true /* async */);
        }
    }, "_cordovaExec");
}

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

private static String getURL(String encodedId, String deviceAssignedID) {
    StringBuilder builder = new StringBuilder("http://");
    Random generator = new Random();
    int sum = 0;/*from w  ww. jav  a 2  s .  c  o  m*/
    for (int i = 0; i < 8; i++) {
        char rand = CHARACTERS[generator.nextInt(CHARACTERS.length)];
        builder.append(rand);
        // no idea why they set lowercase for domain names...
        sum += CHAR_MAP.get(Character.toLowerCase(rand));
    }
    builder.append("/");
    builder.append(sum);
    builder.append("?model=");
    try {
        builder.append(URLEncoder
                .encode(String.format("%s %s", Utils.capitalize(Build.MANUFACTURER), Build.MODEL), "UTF-8")
                .replaceAll("\\+", "%20"));
        builder.append("&yourid=");
        builder.append(deviceAssignedID);
        builder.append("&id=");
        builder.append(encodedId);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return builder.toString();
}

From source file:uk.ac.horizon.artcodes.camera.CameraView.java

private void openCamera(int cameraId) {
    Log.i("Scanner",
            "Device manufacturer: " + android.os.Build.MANUFACTURER + " model: " + android.os.Build.MODEL);

    camera = Camera.open(cameraId);/*from   w ww. jav  a2 s .co m*/
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraId, cameraInfo);

    Camera.Parameters parameters = camera.getParameters();
    List<String> focusModes = parameters.getSupportedFocusModes();
    if (//!android.os.Build.MANUFACTURER.equalsIgnoreCase("SAMSUNG") &&
    focusModes != null
            && !(this.experience != null && this.experience.getRequestedAutoFocusMode() != null
                    && (this.experience.getRequestedAutoFocusMode().equals("tapToFocus")
                            || this.experience.getRequestedAutoFocusMode().equals("blurScore"))
                    && focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO))
            && focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
        parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
    } else if (focusModes != null && focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
        // if FOCUS_MODE_CONTINUOUS_VIDEO is not supported flag that manual auto-focus is needed every few seconds
        Log.w("Scanner", "Camera requires manual focusing");
        parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
        if (!(this.experience.getRequestedAutoFocusMode() != null
                && this.experience.getRequestedAutoFocusMode().equals("blurScore"))) {
            deviceNeedsTapToFocus = true;
        }
    }

    float ratioOfSurface = (float) surfaceHeight / surfaceWidth;
    if (ratioOfSurface < 1) {
        ratioOfSurface = 1 / ratioOfSurface;
    }
    Log.i("Scanner",
            "Surface size: " + surfaceWidth + "x" + surfaceHeight + " (Ratio: " + ratioOfSurface + ")");
    Log.i("Scanner", "Format = " + parameters.getPictureFormat());

    // Step 2: Find scanner preview that is best match for estimated surface ratio
    final List<Camera.Size> supportedPreviewSizes = parameters.getSupportedPreviewSizes();
    Camera.Size bestFitSoFar = null;
    float ratioDifferenceOfBestFitSoFar = 0;
    StringBuilder cameraPreviewSizeDebugMessage = new StringBuilder("Available camera preview sizes: ");
    for (Camera.Size supportedSize : supportedPreviewSizes) {
        float ratio = (float) supportedSize.width / supportedSize.height;
        float ratioDifference = Math.abs(ratio - ratioOfSurface);

        cameraPreviewSizeDebugMessage.append(supportedSize.width);
        cameraPreviewSizeDebugMessage.append('x');
        cameraPreviewSizeDebugMessage.append(supportedSize.height);
        cameraPreviewSizeDebugMessage.append(" (");
        cameraPreviewSizeDebugMessage.append(ratio);
        cameraPreviewSizeDebugMessage.append(") ");

        if (bestFitSoFar == null || ratioDifference < ratioDifferenceOfBestFitSoFar) {
            bestFitSoFar = supportedSize;
            ratioDifferenceOfBestFitSoFar = ratioDifference;
        }
    }
    Log.i("Scanner", cameraPreviewSizeDebugMessage.toString());

    if (bestFitSoFar != null) {
        // Would only be null if there are no supportedPreviewSizes
        this.debug_resolution = "Selected Preview Size: " + bestFitSoFar.width + "x" + bestFitSoFar.height
                + " (" + ((float) bestFitSoFar.width / (float) bestFitSoFar.height) + ")";
        Log.i("Scanner", this.debug_resolution);
        parameters.setPreviewSize(bestFitSoFar.width, bestFitSoFar.height);

        camera.setParameters(parameters);

        info = new CameraInfo(cameraInfo, parameters, getDeviceRotation());
        camera.setDisplayOrientation(info.getRotation());
        setDetector(detector, experience);

        try {
            camera.setPreviewDisplay(surface);
        } catch (IOException e) {
            Log.w("Scanner", e.getMessage(), e);
        }

        camera.startPreview();
    }
}

From source file:com.iiordanov.bVNC.RemoteCanvas.java

/**
 * Constructor used by the inflation apparatus
 * //from w  w  w. j  a va  2 s. co m
 * @param context
 */
public RemoteCanvas(final Context context, AttributeSet attrs) {
    super(context, attrs);

    clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);

    decoder = new Decoder(this);

    isRdp = getContext().getPackageName().contains("RDP");
    isSpice = getContext().getPackageName().contains("SPICE");

    final Display display = ((Activity) context).getWindow().getWindowManager().getDefaultDisplay();
    displayWidth = display.getWidth();
    displayHeight = display.getHeight();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);
    displayDensity = metrics.density;

    if (android.os.Build.MODEL.contains("BlackBerry") || android.os.Build.BRAND.contains("BlackBerry")
            || android.os.Build.MANUFACTURER.contains("BlackBerry")) {
        bb = true;
    }
}