Example usage for android.os Build BRAND

List of usage examples for android.os Build BRAND

Introduction

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

Prototype

String BRAND

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

Click Source Link

Document

The consumer-visible brand with which the product/hardware will be associated, if any.

Usage

From source file:com.by_syk.lib.nanoiconpack.fragment.AppsFragment.java

private void copyOrShareAppCode(AppBean bean, boolean toCopyOrShare) {
    if (bean == null || bean.getPkg().equals(bean.getLauncher())) {
        GlobalToast.show(getContext(), R.string.toast_code_copy_failed);
        return;// w w  w .j  a  v a  2  s .co m
    }

    String label = bean.getLabel();
    String labelEn = PkgUtil.getAppLabelEn(getContext(), bean.getPkg(), null);
    String iconName = ExtraUtil.codeAppName(labelEn);
    if (iconName.isEmpty()) {
        iconName = ExtraUtil.codeAppName(label);
    }
    boolean isSysApp = PkgUtil.isSysApp(getContext(), bean.getPkg());
    String code = String.format(Locale.US, C.APP_CODE_LABEL, label, labelEn);
    code += "\n" + String.format(Locale.US, C.APP_CODE_COMPONENT, bean.getPkg(), bean.getLauncher(), iconName);
    if (isSysApp) {
        code = String.format(Locale.US, C.APP_CODE_BUILD, Build.BRAND, Build.MODEL) + "\n" + code;
    }

    if (toCopyOrShare) {
        ExtraUtil.copy2Clipboard(getContext(), code);
        GlobalToast.show(getContext(), R.string.toast_code_copied);
    } else {
        ExtraUtil.shareText(getContext(), code, getString(R.string.send_code));
    }
}

From source file:conversandroid.SimpleASR.java

/**
 * Sets up the listener for the button that the user
 * must click to start talking/*from w  ww. ja va2  s . co m*/
 */
@SuppressLint("DefaultLocale")
private void setSpeakButton() {
    //Gain reference to speak button
    Button speak = (Button) findViewById(R.id.speech_btn);

    final PackageManager packM = getPackageManager();

    //Set up click listener
    speak.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            //Speech recognition does not currently work on simulated devices,
            //it the user is attempting to run the app in a simulated device
            //they will get a Toast
            if ("generic".equals(Build.BRAND.toLowerCase())) {
                Toast toast = Toast.makeText(getApplicationContext(), "ASR is not supported on virtual devices",
                        Toast.LENGTH_SHORT);
                toast.show();
                Log.d(LOGTAG, "ASR attempt on virtual device");
            } else {
                // find out whether speech recognition is supported
                List<ResolveInfo> intActivities = packM
                        .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
                if (intActivities.size() != 0) {
                    setRecognitionParams(); //Read speech recognition parameters from GUI
                    listen(); //Set up the recognizer with the parameters and start listening
                } else {
                    Toast toast = Toast.makeText(getApplicationContext(), "ASR not supported",
                            Toast.LENGTH_SHORT);
                    toast.show();
                    Log.d(LOGTAG, "ASR not supported");
                }
            }
        }
    });
}

From source file:com.undatech.opaque.RemoteCanvas.java

public RemoteCanvas(final Context context, AttributeSet attrSet) {
    super(context, attrSet);
    clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    final Display display = ((Activity) context).getWindow().getWindowManager().getDefaultDisplay();
    displayWidth = display.getWidth();/*from   ww  w .  j a v  a 2 s.  c o m*/
    displayHeight = display.getHeight();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);
    displayDensity = metrics.density;

    canvasZoomer = new CanvasZoomer(this);
    setScaleType(ImageView.ScaleType.MATRIX);

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

From source file:com.liato.bankdroid.Helpers.java

public static String getAppUserAgentString(Context context) {
    if (USER_AGENT != null)
        return USER_AGENT;
    String appName = context.getResources().getString(R.string.app_name);
    String appVersion = "";
    int height = 0;
    int width = 0;
    DisplayMetrics display = context.getResources().getDisplayMetrics();
    Configuration config = context.getResources().getConfiguration();

    // Always send screen dimension for portrait mode
    if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        height = display.widthPixels;// w w  w.  j  a  va2  s . com
        width = display.heightPixels;
    } else {
        width = display.widthPixels;
        height = display.heightPixels;
    }

    try {
        PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(),
                PackageManager.GET_CONFIGURATIONS);
        appVersion = packageInfo.versionName;
    } catch (PackageManager.NameNotFoundException ignore) {
        // this should never happen, we are looking up ourself
    }

    // Tries to conform to default android UA string without the Safari / webkit noise, plus adds the screen dimensions
    USER_AGENT = String.format(
            "%1$s/%2$s (%3$s; U; Android %4$s; %5$s-%6$s; %12$s Build/%7$s; %8$s) %9$dX%10$d %11$s %12$s",
            appName, appVersion, System.getProperty("os.name", "Linux"), Build.VERSION.RELEASE,
            config.locale.getLanguage().toLowerCase(), config.locale.getCountry().toLowerCase(), Build.ID,
            Build.BRAND, width, height, Build.MANUFACTURER, Build.MODEL);
    return USER_AGENT;
}

From source file:info.papdt.blacklight.support.Utility.java

public static boolean isChrome() {
    return Build.BRAND.equals("chromium") || Build.BRAND.equals("chrome");
}

From source file:de.schildbach.wallet.ui.ReportIssueDialogFragment.java

private static void appendDeviceInfo(final Appendable report, final Context context) throws IOException {
    final Resources res = context.getResources();
    final android.content.res.Configuration config = res.getConfiguration();
    final ActivityManager activityManager = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    final DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context
            .getSystemService(Context.DEVICE_POLICY_SERVICE);

    report.append("Device Model: " + Build.MODEL + "\n");
    report.append("Android Version: " + Build.VERSION.RELEASE + "\n");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
        report.append("Android security patch level: ").append(Build.VERSION.SECURITY_PATCH).append("\n");
    report.append("ABIs: ")
            .append(Joiner.on(", ").skipNulls()
                    .join(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? supportedAbisLollipop()
                            : supportedAbisKitKat()))
            .append("\n");
    report.append("Board: " + Build.BOARD + "\n");
    report.append("Brand: " + Build.BRAND + "\n");
    report.append("Device: " + Build.DEVICE + "\n");
    report.append("Display: " + Build.DISPLAY + "\n");
    report.append("Finger Print: " + Build.FINGERPRINT + "\n");
    report.append("Host: " + Build.HOST + "\n");
    report.append("ID: " + Build.ID + "\n");
    report.append("Product: " + Build.PRODUCT + "\n");
    report.append("Tags: " + Build.TAGS + "\n");
    report.append("Time: " + Build.TIME + "\n");
    report.append("Type: " + Build.TYPE + "\n");
    report.append("User: " + Build.USER + "\n");
    report.append("Configuration: " + config + "\n");
    report.append("Screen Layout: size "
            + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK) + " long "
            + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_LONG_MASK) + "\n");
    report.append("Display Metrics: " + res.getDisplayMetrics() + "\n");
    report.append(//from  www  .  ja  v a2 s .c  o  m
            "Memory Class: " + activityManager.getMemoryClass() + "/" + activityManager.getLargeMemoryClass()
                    + (activityManager.isLowRamDevice() ? " (low RAM device)" : "") + "\n");
    report.append("Storage Encryption Status: " + devicePolicyManager.getStorageEncryptionStatus() + "\n");
    report.append("Bluetooth MAC: " + bluetoothMac() + "\n");
    report.append("Runtime: ").append(System.getProperty("java.vm.name")).append(" ")
            .append(System.getProperty("java.vm.version")).append("\n");
}

From source file:com.bt.download.android.gui.Librarian.java

public Finger finger(boolean local) {
    Finger finger = new Finger();

    finger.uuid = ConfigurationManager.instance().getUUIDString();
    finger.nickname = ConfigurationManager.instance().getNickname();
    finger.frostwireVersion = Constants.FROSTWIRE_VERSION_STRING;
    finger.totalShared = getNumFiles();/* w w w. ja  v a  2 s .  c o  m*/

    finger.deviceVersion = Build.VERSION.RELEASE;
    finger.deviceModel = Build.MODEL;
    finger.deviceProduct = Build.PRODUCT;
    finger.deviceName = Build.DEVICE;
    finger.deviceManufacturer = Build.MANUFACTURER;
    finger.deviceBrand = Build.BRAND;
    finger.deviceScreen = readScreenMetrics();

    finger.numSharedAudioFiles = getNumFiles(Constants.FILE_TYPE_AUDIO, true);
    finger.numSharedVideoFiles = getNumFiles(Constants.FILE_TYPE_VIDEOS, true);
    finger.numSharedPictureFiles = getNumFiles(Constants.FILE_TYPE_PICTURES, true);
    finger.numSharedDocumentFiles = getNumFiles(Constants.FILE_TYPE_DOCUMENTS, true);
    finger.numSharedApplicationFiles = getNumFiles(Constants.FILE_TYPE_APPLICATIONS, true);
    finger.numSharedRingtoneFiles = getNumFiles(Constants.FILE_TYPE_RINGTONES, true);

    if (local) {
        finger.numTotalAudioFiles = getNumFiles(Constants.FILE_TYPE_AUDIO, false);
        finger.numTotalVideoFiles = getNumFiles(Constants.FILE_TYPE_VIDEOS, false);
        finger.numTotalPictureFiles = getNumFiles(Constants.FILE_TYPE_PICTURES, false);
        finger.numTotalDocumentFiles = getNumFiles(Constants.FILE_TYPE_DOCUMENTS, false);
        finger.numTotalApplicationFiles = getNumFiles(Constants.FILE_TYPE_APPLICATIONS, false);
        finger.numTotalRingtoneFiles = getNumFiles(Constants.FILE_TYPE_RINGTONES, false);
    } else {
        finger.numTotalAudioFiles = finger.numSharedAudioFiles;
        finger.numTotalVideoFiles = finger.numSharedVideoFiles;
        finger.numTotalPictureFiles = finger.numSharedPictureFiles;
        finger.numTotalDocumentFiles = finger.numSharedDocumentFiles;
        finger.numTotalApplicationFiles = finger.numSharedApplicationFiles;
        finger.numTotalRingtoneFiles = finger.numSharedRingtoneFiles;
    }

    return finger;
}

From source file:com.www.avtovokzal.org.MainActivity.java

private void sendPhoneInformationToServer() {
    String version = null;//  w  ww .  j a  va2  s  .co  m
    PackageInfo packageInfo = null;

    try {
        packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    String manufacturer = Uri.encode(Build.MANUFACTURER);
    String model = Uri.encode(Build.MODEL);
    String device = Uri.encode(Build.DEVICE);
    String board = Uri.encode(Build.BOARD);
    String brand = Uri.encode(Build.BRAND);
    String display = Uri.encode(Build.DISPLAY);
    String id = Uri.encode(Build.ID);
    String product = Uri.encode(Build.PRODUCT);
    String release = Uri.encode(Build.VERSION.RELEASE);

    if (packageInfo != null) {
        version = Uri.encode(packageInfo.versionName);
    }

    if (Constants.LOG_ON) {
        Log.v(TAG, "1: " + manufacturer + " 2: " + model + " 3: " + device + " 4: " + board + " 5: " + brand
                + " 6: " + display + " 7: " + id + " 8: " + product + " 9: " + release + " 10: " + version);
    }

    String url = "http://www.avtovokzal.org/php/app/sendPhoneInformation.php?manufacturer=" + manufacturer
            + "&model=" + model + "&device=" + device + "&board=" + board + "&brand=" + brand + "&display="
            + display + "&build_id=" + id + "&product=" + product + "&release_number=" + release + "&version="
            + version;

    if (isOnline()) {
        StringRequest strReq = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                if (Constants.LOG_ON)
                    VolleyLog.d(TAG, "Error: " + error.getMessage());
            }
        });
        // ? TimeOut, Retry
        strReq.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS, 3,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        // ? ?  
        AppController.getInstance().addToRequestQueue(strReq);
    } else {
        callErrorActivity();
    }
}

From source file:org.protocoderrunner.apprunner.api.PDevice.java

@ProtoMethod(description = "Get some device information", example = "")
@ProtoMethodParam(params = { "" })
public DeviceInfo info() {
    DeviceInfo deviceInfo = new DeviceInfo();

    // density dpi
    DisplayMetrics metrics = new DisplayMetrics();

    //TODO reenable this
    //contextUi.get().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    deviceInfo.screenDpi = metrics.densityDpi;

    // id/*from   w  w  w .  j av  a2s .c  om*/
    deviceInfo.androidId = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID);

    // imei
    deviceInfo.imei = ((TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE))
            .getDeviceId();

    deviceInfo.versionRelease = Build.VERSION.RELEASE;
    deviceInfo.versionRelease = Build.VERSION.INCREMENTAL;
    deviceInfo.sdk = Build.VERSION.SDK;
    deviceInfo.board = Build.BOARD;
    deviceInfo.brand = Build.BRAND;
    deviceInfo.device = Build.DEVICE;
    deviceInfo.fingerPrint = Build.FINGERPRINT;
    deviceInfo.host = Build.HOST;
    deviceInfo.id = Build.ID;
    deviceInfo.cpuAbi = Build.CPU_ABI;
    deviceInfo.cpuAbi2 = Build.CPU_ABI2;

    return deviceInfo;
}

From source file:com.clough.android.androiddbviewer.ADBVApplication.java

@Override
public void onCreate() {
    super.onCreate();

    // Getting user configured(custom) SQLiteOpenHelper instance.
    sqliteOpenHelper = getDataBase();//w w w . j  a  v  a2 s .  c om

    // getDataBase() could return a null
    if (sqliteOpenHelper != null) {

        // Background operation of creating the server socket.
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {

                    // Server socket re create when device is being disconnected or
                    // when AndroidDBViewer desktop application is being closed.
                    // Creating server socket will exit when
                    // android application runs in low memory or when
                    // android application being terminated due some reasons.
                    l1: while (flag) {
                        serverSocket = new ServerSocket(1993);
                        socket = serverSocket.accept();
                        br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                        pw = new PrintWriter(socket.getOutputStream(), true);

                        // Keeps a continuous communication between android application and
                        // AndroidDBViewer desktop application through IO streams of the accepted socket connection.
                        // There will be continuous data parsing between desktop application and android application.
                        // Identification of device being disconnected or desktop application being closed will be determined
                        // only when there is a NULL data being received.
                        l2: while (flag) {

                            // Format of the parsing data string is JSON, a content of a 'Data' instance
                            String requestJSONString = br.readLine();

                            if (requestJSONString == null) {

                                // Received a null response from desktop application, due to disconnecting the
                                // device or closing the AndroidDBViewer desktop application.
                                // Therefore, closing all current connections and streams to re create the server
                                // socket so that desktop application can connect in it's next run.

                                // Device disconnection doesn't produce an IOException.
                                // Also, even after calling
                                // socket.close(), socket.shutdownInput() and socket.shutdownOutput()
                                // within a shutdown hook in desktop application, the socket connection
                                // in this async task always gives
                                // socket.isConnected() as 'true' ,
                                // socket.isClosed() as 'false' ,
                                // socket.isInputShutdown() as 'false' and
                                // socket.isOutputShutdown() as 'false' .
                                // But, bufferedReader.readLine() starts returning 'null' continuously.
                                // So, inorder to desktop application to connect with the device again,
                                // there should be a ServerSocket waiting to accept a socket connection, in device.
                                closeConnection();
                                continue l1;
                            } else {

                                // Received a valid response from the desktop application.
                                Data data;
                                try {

                                    // Converting received request to a 'Data' instance.
                                    data = new Data(new JSONObject(requestJSONString));
                                    int status = data.getStatus();
                                    if (status == Data.CONNECTION_REQUEST) {

                                        // Very first request from desktop application to
                                        // establish the connection and setting the response as
                                        // connection being accepted.
                                        data.setStatus(Data.CONNECTION_ACCEPTED);
                                    } else if (status == Data.LIVE_CONNECTION) {

                                        // When there is no user interaction in desktop application,
                                        // data being passed from desktop application to android
                                        // application with the status of LIVE_CONNECTION, and the
                                        // same data send again to the desktop application from android application,
                                        // to notify that connection is still alive.
                                        // This exchange won't change until  there is a request from
                                        // desktop application with a different status.
                                    } else if (status == Data.QUERY) {

                                        // Requesting to perform a query execution.

                                        String result = "No result";
                                        try {

                                            // Performing select, insert, delete and update queries.
                                            Cursor cursor = sqliteOpenHelper.getWritableDatabase()
                                                    .rawQuery(data.getQuery(), null);

                                            // Flag to identify the firs move of the cursor
                                            boolean firstTime = true;

                                            int columnCount = 0;

                                            // JSONArray to hold the all JSONObjects, created per every row
                                            // of the result returned, executing the given query.
                                            JSONArray jsonArray = new JSONArray();

                                            // Moving the cursor to the next row of retrieved result
                                            // after executing the requested query.
                                            while (cursor.moveToNext()) {

                                                if (firstTime) {

                                                    // Column count of the result returned, executing the given query.
                                                    columnCount = cursor.getColumnCount();
                                                    firstTime = false;
                                                }

                                                // JOSNObject to hold the values of a single row
                                                JSONObject jsonObject = new JSONObject();
                                                for (int i = 0; i < columnCount; i++) {
                                                    int columnType = cursor.getType(i);
                                                    String columnName = cursor.getColumnName(i);
                                                    if (columnType == Cursor.FIELD_TYPE_STRING) {
                                                        jsonObject.put(columnName, cursor.getString(i));
                                                    } else if (columnType == Cursor.FIELD_TYPE_BLOB) {
                                                        jsonObject.put(columnName,
                                                                cursor.getBlob(i).toString());
                                                    } else if (columnType == Cursor.FIELD_TYPE_FLOAT) {
                                                        jsonObject.put(columnName,
                                                                String.valueOf(cursor.getFloat(i)));
                                                    } else if (columnType == Cursor.FIELD_TYPE_INTEGER) {
                                                        jsonObject.put(columnName,
                                                                String.valueOf(cursor.getInt(i)));
                                                    } else if (columnType == Cursor.FIELD_TYPE_NULL) {
                                                        jsonObject.put(columnName, "NULL");
                                                    } else {
                                                        jsonObject.put(columnName, "invalid type");
                                                    }
                                                }
                                                jsonArray.put(jsonObject);
                                            }
                                            result = jsonArray.toString();
                                            cursor.close();
                                        } catch (Exception e) {

                                            // If SQL error is occurred when executing the requested query,
                                            // error content will be the response to the desktop application.
                                            StringWriter sw = new StringWriter();
                                            PrintWriter epw = new PrintWriter(sw);
                                            e.printStackTrace(epw);
                                            result = sw.toString();
                                            epw.close();
                                            sw.close();
                                        } finally {
                                            data.setResult(result);
                                        }
                                    } else if (status == Data.DEVICE_NAME) {

                                        // Requesting device information
                                        data.setResult(Build.BRAND + " " + Build.MODEL);
                                    } else if (status == Data.APPLICATION_ID) {

                                        // Requesting application id (package name)
                                        data.setResult(getPackageName());
                                    } else if (status == Data.DATABASE_NAME) {

                                        // Requesting application database name.
                                        // Will provide the database name according
                                        // to the SQLiteOpenHelper user provided
                                        data.setResult(sqliteOpenHelper.getDatabaseName());
                                    } else {

                                        // Unidentified request state.
                                        closeConnection();
                                        continue l1;
                                    }
                                    String responseJSONString = data.toJSON().toString();
                                    pw.println(responseJSONString);
                                } catch (JSONException e) {

                                    // Response couldn't convert to a 'Data' instance.
                                    // Desktop application will be notified to close the application.
                                    closeConnection();
                                    continue l1;
                                }
                            }
                        }
                    }
                } catch (IOException e) {
                    // Cannot create a server socket. Letting background process to end.
                }
            }
        }).start();
    }
}