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: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.// w w w  . j  a  v a2s. com
 * 
 * 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.telegram.android.MessagesController.java

public void registerForPush(final String regid) {
    if (regid == null || regid.length() == 0 || registeringForPush || UserConfig.getClientUserId() == 0) {
        return;/*from   w w  w .j  av a 2s . 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 = 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.mozilla.gecko.BrowserApp.java

@Override
public boolean onPrepareOptionsMenu(Menu aMenu) {
    if (aMenu == null)
        return false;

    // Hide the tab history panel when hardware menu button is pressed.
    TabHistoryFragment frag = (TabHistoryFragment) getSupportFragmentManager()
            .findFragmentByTag(TAB_HISTORY_FRAGMENT_TAG);
    if (frag != null) {
        frag.dismiss();/*from  w  ww. j av  a  2 s  .c  o m*/
    }

    if (!GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
        aMenu.findItem(R.id.settings).setEnabled(false);
        aMenu.findItem(R.id.help).setEnabled(false);
    }

    Tab tab = Tabs.getInstance().getSelectedTab();
    final MenuItem bookmark = aMenu.findItem(R.id.bookmark);
    final MenuItem reader = aMenu.findItem(R.id.reading_list);
    final MenuItem back = aMenu.findItem(R.id.back);
    final MenuItem forward = aMenu.findItem(R.id.forward);
    final MenuItem share = aMenu.findItem(R.id.share);
    final MenuItem quickShare = aMenu.findItem(R.id.quickshare);
    final MenuItem saveAsPDF = aMenu.findItem(R.id.save_as_pdf);
    final MenuItem charEncoding = aMenu.findItem(R.id.char_encoding);
    final MenuItem findInPage = aMenu.findItem(R.id.find_in_page);
    final MenuItem desktopMode = aMenu.findItem(R.id.desktop_mode);
    final MenuItem enterGuestMode = aMenu.findItem(R.id.new_guest_session);
    final MenuItem exitGuestMode = aMenu.findItem(R.id.exit_guest_session);

    // Only show the "Quit" menu item on pre-ICS, television devices,
    // or if the user has explicitly enabled the clear on shutdown pref.
    // (We check the pref last to save the pref read.)
    // In ICS+, it's easy to kill an app through the task switcher.
    final boolean visible = Versions.preICS || HardwareUtils.isTelevision() || !PrefUtils
            .getStringSet(GeckoSharedPrefs.forProfile(this), ClearOnShutdownPref.PREF, new HashSet<String>())
            .isEmpty();
    aMenu.findItem(R.id.quit).setVisible(visible);
    aMenu.findItem(R.id.logins).setVisible(AppConstants.NIGHTLY_BUILD);

    if (tab == null || tab.getURL() == null) {
        bookmark.setEnabled(false);
        reader.setEnabled(false);
        back.setEnabled(false);
        forward.setEnabled(false);
        share.setEnabled(false);
        quickShare.setEnabled(false);
        saveAsPDF.setEnabled(false);
        findInPage.setEnabled(false);

        // NOTE: Use MenuUtils.safeSetEnabled because some actions might
        // be on the BrowserToolbar context menu.
        if (Versions.feature11Plus) {
            // There is no page menu prior to v11 resources.
            MenuUtils.safeSetEnabled(aMenu, R.id.page, false);
        }
        MenuUtils.safeSetEnabled(aMenu, R.id.subscribe, false);
        MenuUtils.safeSetEnabled(aMenu, R.id.add_search_engine, false);
        MenuUtils.safeSetEnabled(aMenu, R.id.site_settings, false);
        MenuUtils.safeSetEnabled(aMenu, R.id.add_to_launcher, false);

        return true;
    }

    final boolean inGuestMode = GeckoProfile.get(this).inGuestMode();

    final boolean isAboutReader = AboutPages.isAboutReader(tab.getURL());
    bookmark.setEnabled(!isAboutReader);
    bookmark.setVisible(!inGuestMode);
    bookmark.setCheckable(true);
    bookmark.setChecked(tab.isBookmark());
    bookmark.setIcon(resolveBookmarkIconID(tab.isBookmark()));
    bookmark.setTitle(resolveBookmarkTitleID(tab.isBookmark()));

    reader.setEnabled(isAboutReader || !AboutPages.isAboutPage(tab.getURL()));
    reader.setVisible(!inGuestMode);
    reader.setCheckable(true);
    final boolean isPageInReadingList = tab.isInReadingList();
    reader.setChecked(isPageInReadingList);
    reader.setIcon(resolveReadingListIconID(isPageInReadingList));
    reader.setTitle(resolveReadingListTitleID(isPageInReadingList));

    back.setEnabled(tab.canDoBack());
    forward.setEnabled(tab.canDoForward());
    desktopMode.setChecked(tab.getDesktopMode());
    desktopMode.setIcon(
            tab.getDesktopMode() ? R.drawable.ic_menu_desktop_mode_on : R.drawable.ic_menu_desktop_mode_off);

    View backButtonView = MenuItemCompat.getActionView(back);

    if (backButtonView != null) {
        backButtonView.setOnLongClickListener(new Button.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                Tab tab = Tabs.getInstance().getSelectedTab();
                if (tab != null) {
                    closeOptionsMenu();
                    return tabHistoryController.showTabHistory(tab, TabHistoryController.HistoryAction.BACK);
                }
                return false;
            }
        });
    }

    View forwardButtonView = MenuItemCompat.getActionView(forward);

    if (forwardButtonView != null) {
        forwardButtonView.setOnLongClickListener(new Button.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                Tab tab = Tabs.getInstance().getSelectedTab();
                if (tab != null) {
                    closeOptionsMenu();
                    return tabHistoryController.showTabHistory(tab, TabHistoryController.HistoryAction.FORWARD);
                }
                return false;
            }
        });
    }

    String url = tab.getURL();
    if (AboutPages.isAboutReader(url)) {
        String urlFromReader = ReaderModeUtils.getUrlFromAboutReader(url);
        if (urlFromReader != null) {
            url = urlFromReader;
        }
    }

    // Disable share menuitem for about:, chrome:, file:, and resource: URIs
    final boolean shareVisible = RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_SHARE);
    share.setVisible(shareVisible);
    final boolean shareEnabled = StringUtils.isShareableUrl(url) && shareVisible;
    share.setEnabled(shareEnabled);
    MenuUtils.safeSetEnabled(aMenu, R.id.downloads,
            RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_DOWNLOADS));

    // NOTE: Use MenuUtils.safeSetEnabled because some actions might
    // be on the BrowserToolbar context menu.
    if (Versions.feature11Plus) {
        MenuUtils.safeSetEnabled(aMenu, R.id.page, !isAboutHome(tab));
    }
    MenuUtils.safeSetEnabled(aMenu, R.id.subscribe, tab.hasFeeds());
    MenuUtils.safeSetEnabled(aMenu, R.id.add_search_engine, tab.hasOpenSearch());
    MenuUtils.safeSetEnabled(aMenu, R.id.site_settings, !isAboutHome(tab));
    MenuUtils.safeSetEnabled(aMenu, R.id.add_to_launcher, !isAboutHome(tab));

    // Action providers are available only ICS+.
    if (Versions.feature14Plus) {
        quickShare.setVisible(shareVisible);
        quickShare.setEnabled(shareEnabled);

        // This provider also applies to the quick share menu item.
        final GeckoActionProvider provider = ((GeckoMenuItem) share).getGeckoActionProvider();
        if (provider != null) {
            Intent shareIntent = provider.getIntent();

            // For efficiency, the provider's intent is only set once
            if (shareIntent == null) {
                shareIntent = new Intent(Intent.ACTION_SEND);
                shareIntent.setType("text/plain");
                provider.setIntent(shareIntent);
            }

            // Replace the existing intent's extras
            shareIntent.putExtra(Intent.EXTRA_TEXT, url);
            shareIntent.putExtra(Intent.EXTRA_SUBJECT, tab.getDisplayTitle());
            shareIntent.putExtra(Intent.EXTRA_TITLE, tab.getDisplayTitle());
            shareIntent.putExtra(ShareDialog.INTENT_EXTRA_DEVICES_ONLY, true);

            // Clear the existing thumbnail extras so we don't share an old thumbnail.
            shareIntent.removeExtra("share_screenshot_uri");

            // Include the thumbnail of the page being shared.
            BitmapDrawable drawable = tab.getThumbnail();
            if (drawable != null) {
                Bitmap thumbnail = drawable.getBitmap();

                // Kobo uses a custom intent extra for sharing thumbnails.
                if (Build.MANUFACTURER.equals("Kobo") && thumbnail != null) {
                    File cacheDir = getExternalCacheDir();

                    if (cacheDir != null) {
                        File outFile = new File(cacheDir, "thumbnail.png");

                        try {
                            java.io.FileOutputStream out = new java.io.FileOutputStream(outFile);
                            thumbnail.compress(Bitmap.CompressFormat.PNG, 90, out);
                        } catch (FileNotFoundException e) {
                            Log.e(LOGTAG, "File not found", e);
                        }

                        shareIntent.putExtra("share_screenshot_uri", Uri.parse(outFile.getPath()));
                    }
                }
            }
        }
    }

    final boolean privateTabVisible = RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_PRIVATE_BROWSING);
    MenuUtils.safeSetVisible(aMenu, R.id.new_private_tab, privateTabVisible);

    // Disable save as PDF for about:home and xul pages.
    saveAsPDF.setEnabled(!(isAboutHome(tab) || tab.getContentType().equals("application/vnd.mozilla.xul+xml")
            || tab.getContentType().startsWith("video/")));

    // Disable find in page for about:home, since it won't work on Java content.
    findInPage.setEnabled(!isAboutHome(tab));

    charEncoding.setVisible(GeckoPreferences.getCharEncodingState());

    if (mProfile.inGuestMode()) {
        exitGuestMode.setVisible(true);
    } else {
        enterGuestMode.setVisible(true);
    }

    if (!RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_GUEST_BROWSING)) {
        MenuUtils.safeSetVisible(aMenu, R.id.new_guest_session, false);
    }

    if (!RestrictedProfiles.isAllowed(this, Restriction.DISALLOW_INSTALL_EXTENSION)) {
        MenuUtils.safeSetVisible(aMenu, R.id.addons, false);
    }

    return true;
}

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   w ww  . j  ava2s .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/*  ww  w  . j  a v  a 2 s .  c  o  m*/
 * @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));
}