Example usage for android.os Build PRODUCT

List of usage examples for android.os Build PRODUCT

Introduction

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

Prototype

String PRODUCT

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

Click Source Link

Document

The name of the overall product.

Usage

From source file:nl.nikhef.eduroam.WiFiEduroam.java

private void postData(String username, String password, String csr) throws RuntimeException {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(CONF_HTTP_URL);

    String android_id = Secure.getString(getBaseContext().getContentResolver(), Secure.ANDROID_ID);

    try {//from   ww w.jav a  2 s  . co m
        // Add the post data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("username", username));
        nameValuePairs.add(new BasicNameValuePair("password", password));
        nameValuePairs.add(new BasicNameValuePair("csr", csr));
        nameValuePairs.add(new BasicNameValuePair("device_id", android_id));
        nameValuePairs.add(new BasicNameValuePair("device_serial", android.os.Build.SERIAL));
        nameValuePairs.add(new BasicNameValuePair("device_description", android.os.Build.MANUFACTURER + " "
                + android.os.Build.MODEL + " / " + android.os.Build.PRODUCT));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP POST request synchronously
        HttpResponse response = httpclient.execute(httppost);
        if (!response.getStatusLine().toString().endsWith("200 OK")) {
            updateStatus("HTTP Error: " + response.getStatusLine());
        }

        // Convert input to JSON object
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
        StringBuilder builder = new StringBuilder();
        for (String line = null; (line = reader.readLine()) != null;) {
            builder.append(line).append("\n");
        }
        String json = builder.toString();
        JSONObject obj = new JSONObject(json);

        if (!obj.getString("status").equals("ok")) {
            updateStatus("JSON Status Error: " + obj.getString("error"));
            throw new RuntimeException(obj.getString("error"));
        }
        // Grab the information
        certificate = obj.getString("certificate");
        ca = obj.getString("ca");
        ca_name = obj.getString("ca_name");
        realm = obj.getString("realm");
        subject_match = obj.getString("subject_match");
        ssid = obj.getString("ssid");
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (UnknownHostException e) {
        e.printStackTrace();
        throw new RuntimeException("Please check your connection!");
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        throw new RuntimeException("JSON: " + e.getMessage());
    }
}

From source file:com.pimp.companionforband.activities.main.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    sContext = getApplicationContext();//from ww  w .j  a va 2 s  .c  om
    sActivity = this;

    sharedPreferences = getApplicationContext().getSharedPreferences("MyPrefs", 0);
    editor = sharedPreferences.edit();

    bandSensorData = new BandSensorData();

    mDestinationUri = Uri.fromFile(new File(getCacheDir(), SAMPLE_CROPPED_IMAGE_NAME));

    SectionsPagerAdapter mSectionsPagerAdapter;
    ViewPager mViewPager;

    if (!checkCameraPermission(true))
        requestCameraPermission(true);
    if (!checkCameraPermission(false))
        requestCameraPermission(false);

    FiveStarsDialog fiveStarsDialog = new FiveStarsDialog(this, "pimplay69@gmail.com");
    fiveStarsDialog.setTitle(getString(R.string.rate_dialog_title))
            .setRateText(getString(R.string.rate_dialog_text)).setForceMode(false).setUpperBound(4)
            .setNegativeReviewListener(this).showAfter(5);

    AnalyticsApplication application = (AnalyticsApplication) getApplication();
    mTracker = application.getDefaultTracker();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOffscreenPageLimit(2);
    mViewPager.setPageTransformer(true, new ZoomOutPageTransformer());
    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            String name;
            switch (position) {
            case 0:
                name = "THEME";
                break;
            case 1:
                name = "SENSORS";
                break;
            case 2:
                name = "EXTRAS";
                break;
            default:
                name = "CfB";
            }

            mTracker.setScreenName("Image~" + name);
            mTracker.send(new HitBuilders.ScreenViewBuilder().build());

            logSwitch = (Switch) findViewById(R.id.log_switch);
            backgroundLogSwitch = (Switch) findViewById(R.id.backlog_switch);
            logStatus = (TextView) findViewById(R.id.logStatus);
            backgroundLogStatus = (TextView) findViewById(R.id.backlogStatus);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    Drawable headerBackground = null;
    String encoded = sharedPreferences.getString("me_tile_image", "null");
    if (!encoded.equals("null")) {
        byte[] imageAsBytes = Base64.decode(encoded.getBytes(), Base64.DEFAULT);
        headerBackground = new BitmapDrawable(
                BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length));
    }

    AccountHeader accountHeader = new AccountHeaderBuilder().withActivity(this).withCompactStyle(true)
            .withHeaderBackground((headerBackground == null) ? getResources().getDrawable(R.drawable.pipboy)
                    : headerBackground)
            .addProfiles(new ProfileDrawerItem()
                    .withName(sharedPreferences.getString("device_name", "Companion For Band"))
                    .withEmail(sharedPreferences.getString("device_mac", "pimplay69@gmail.com"))
                    .withIcon(getResources().getDrawable(R.drawable.band)))
            .build();

    result = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withActionBarDrawerToggleAnimated(true)
            .withAccountHeader(accountHeader)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName(getString(R.string.drawer_cloud))
                            .withIcon(GoogleMaterial.Icon.gmd_cloud).withIdentifier(1),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName(getString(R.string.rate))
                            .withIcon(GoogleMaterial.Icon.gmd_rate_review).withIdentifier(2),
                    new PrimaryDrawerItem().withName(getString(R.string.feedback))
                            .withIcon(GoogleMaterial.Icon.gmd_feedback).withIdentifier(3),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName(getString(R.string.share))
                            .withIcon(GoogleMaterial.Icon.gmd_share).withIdentifier(4),
                    new PrimaryDrawerItem().withName(getString(R.string.other))
                            .withIcon(GoogleMaterial.Icon.gmd_apps).withIdentifier(5),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName(getString(R.string.report))
                            .withIcon(GoogleMaterial.Icon.gmd_bug_report).withIdentifier(6),
                    new PrimaryDrawerItem().withName(getString(R.string.translate))
                            .withIcon(GoogleMaterial.Icon.gmd_translate).withIdentifier(9),
                    new DividerDrawerItem(),
                    new PrimaryDrawerItem().withName(getString(R.string.support))
                            .withIcon(GoogleMaterial.Icon.gmd_attach_money).withIdentifier(7),
                    new PrimaryDrawerItem().withName(getString(R.string.aboutLib))
                            .withIcon(GoogleMaterial.Icon.gmd_info).withIdentifier(8))
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    boolean flag;
                    if (drawerItem != null) {
                        flag = true;
                        switch ((int) drawerItem.getIdentifier()) {
                        case 1:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Cloud").build());

                            if (!sharedPreferences.getString("access_token", "hi").equals("hi"))
                                startActivity(new Intent(getApplicationContext(), CloudActivity.class));
                            else
                                startActivity(new Intent(getApplicationContext(), WebviewActivity.class));
                            break;
                        case 2:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Rate and Review").build());
                            String MARKET_URL = "https://play.google.com/store/apps/details?id=";
                            String PlayStoreListing = getPackageName();
                            Intent rate = new Intent(Intent.ACTION_VIEW,
                                    Uri.parse(MARKET_URL + PlayStoreListing));
                            startActivity(rate);
                            break;
                        case 3:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Feedback").build());
                            final StringBuilder emailBuilder = new StringBuilder();
                            Intent intent = new Intent(Intent.ACTION_VIEW,
                                    Uri.parse("mailto:pimplay69@gmail.com"));
                            intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.app_name));

                            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;
                            try {
                                appInfo = getPackageManager().getPackageInfo(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());
                            startActivity(Intent.createChooser(intent, "Send via"));
                            break;
                        case 4:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Share").build());
                            Intent i = new AppInviteInvitation.IntentBuilder(
                                    getString(R.string.invitation_title))
                                            .setMessage(getString(R.string.invitation_message))
                                            .setCallToActionText(getString(R.string.invitation_cta)).build();
                            startActivityForResult(i, REQUEST_INVITE);
                            break;
                        case 5:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Other Apps").build());
                            String PlayStoreDevAccount = "https://play.google.com/store/apps/developer?id=P.I.M.P.";
                            Intent devPlay = new Intent(Intent.ACTION_VIEW, Uri.parse(PlayStoreDevAccount));
                            startActivity(devPlay);
                            break;
                        case 6:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Report Bugs").build());
                            startActivity(new Intent(MainActivity.this, GittyActivity.class));
                            break;
                        case 7:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Donate").build());

                            String base64EncodedPublicKey = getString(R.string.base64);
                            mHelper = new IabHelper(getApplicationContext(), base64EncodedPublicKey);
                            mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
                                public void onIabSetupFinished(IabResult result) {
                                    if (!result.isSuccess()) {
                                        Toast.makeText(MainActivity.this,
                                                "Problem setting up In-app Billing: " + result,
                                                Toast.LENGTH_LONG).show();
                                    }
                                }
                            });

                            final Dialog dialog = new Dialog(MainActivity.this);
                            dialog.setContentView(R.layout.dialog_donate);
                            dialog.setTitle("Donate");

                            String[] title = { "Coke", "Coffee", "Burger", "Pizza", "Meal" };
                            String[] price = { "Rs. 10.00", "Rs. 50.00", "Rs. 100.00", "Rs. 500.00",
                                    "Rs. 1,000.00" };

                            ListView listView = (ListView) dialog.findViewById(R.id.list);
                            listView.setAdapter(new DonateListAdapter(MainActivity.this, title, price));
                            listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                                @Override
                                public void onItemClick(AdapterView<?> parent, View view, int position,
                                        long id) {
                                    switch (position) {
                                    case 0:
                                        mHelper.launchPurchaseFlow(MainActivity.this, SKU_COKE, 1,
                                                mPurchaseFinishedListener, "payload");
                                        break;
                                    case 1:
                                        mHelper.launchPurchaseFlow(MainActivity.this, SKU_COFFEE, 1,
                                                mPurchaseFinishedListener, "payload");
                                        break;
                                    case 2:
                                        mHelper.launchPurchaseFlow(MainActivity.this, SKU_BURGER, 1,
                                                mPurchaseFinishedListener, "payload");
                                        break;
                                    case 3:
                                        mHelper.launchPurchaseFlow(MainActivity.this, SKU_PIZZA, 1,
                                                mPurchaseFinishedListener, "payload");
                                        break;
                                    case 4:
                                        mHelper.launchPurchaseFlow(MainActivity.this, SKU_MEAL, 1,
                                                mPurchaseFinishedListener, "payload");
                                        break;
                                    }
                                }
                            });

                            dialog.show();
                            break;
                        case 8:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("About").build());
                            new LibsBuilder().withLicenseShown(true).withVersionShown(true)
                                    .withActivityStyle(Libs.ActivityStyle.DARK).withAboutVersionShown(true)
                                    .withActivityTitle(getString(R.string.app_name)).withAboutIconShown(true)
                                    .withListener(libsListener).start(MainActivity.this);
                            break;
                        case 9:
                            mTracker.send(new HitBuilders.EventBuilder().setCategory("Action")
                                    .setAction("Translate").build());
                            Intent translate = new Intent(Intent.ACTION_VIEW,
                                    Uri.parse("https://poeditor.com/join/project/AZQxDV2440"));
                            startActivity(translate);
                            break;
                        default:
                            break;
                        }
                    } else {
                        flag = false;
                    }
                    return flag;
                }
            }).withSavedInstance(savedInstanceState).build();

    AppUpdater appUpdater = new AppUpdater(this);
    appUpdater.start();

    final DirectoryChooserConfig config = DirectoryChooserConfig.builder()
            .allowNewDirectoryNameModification(true).newDirectoryName("CfBCamera")
            .initialDirectory(
                    sharedPreferences.getString("pic_location", "/storage/emulated/0/CompanionForBand/Camera"))
            .build();
    mDialog = DirectoryChooserFragment.newInstance(config);

    new BandUtils().execute();

    CustomActivityOnCrash.install(this);
}

From source file:com.wbtech.ums.UmsAgent.java

private static JSONObject getClientDataJSONObject(Context context) {
    TelephonyManager tm = (TelephonyManager) (context.getSystemService(Context.TELEPHONY_SERVICE));
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics displaysMetrics = new DisplayMetrics();
    manager.getDefaultDisplay().getMetrics(displaysMetrics);
    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    JSONObject clientData = new JSONObject();
    try {//from ww  w. j av a 2  s.  co m
        clientData.put("os_version", CommonUtil.getOsVersion(context));
        clientData.put("platform", "android");
        clientData.put("language", Locale.getDefault().getLanguage());
        clientData.put("deviceid", tm.getDeviceId() == null ? "" : tm.getDeviceId());//
        clientData.put("appkey", CommonUtil.getAppKey(context));
        clientData.put("resolution", displaysMetrics.widthPixels + "x" + displaysMetrics.heightPixels);
        clientData.put("ismobiledevice", true);
        clientData.put("phonetype", tm.getPhoneType());//
        clientData.put("imsi", tm.getSubscriberId());
        clientData.put("network", CommonUtil.getNetworkTypeWIFI2G3G(context));
        clientData.put("time", CommonUtil.getTime());
        clientData.put("version", CommonUtil.getVersion(context));
        clientData.put(UserIdentifier, CommonUtil.getUserIdentifier(context));

        SCell sCell = CommonUtil.getCellInfo(context);

        clientData.put("mccmnc", sCell != null ? "" + sCell.MCCMNC : "");
        clientData.put("cellid", sCell != null ? sCell.CID + "" : "");
        clientData.put("lac", sCell != null ? sCell.LAC + "" : "");
        clientData.put("modulename", Build.PRODUCT);
        clientData.put("devicename", CommonUtil.getDeviceName());
        clientData.put("wifimac", wifiManager.getConnectionInfo().getMacAddress());
        clientData.put("havebt", adapter == null ? false : true);
        clientData.put("havewifi", CommonUtil.isWiFiActive(context));
        clientData.put("havegps", locationManager == null ? false : true);
        clientData.put("havegravity", CommonUtil.isHaveGravity(context));//

        LatitudeAndLongitude coordinates = CommonUtil.getLatitudeAndLongitude(context,
                UmsAgent.mUseLocationService);
        clientData.put("latitude", coordinates.latitude);
        clientData.put("longitude", coordinates.longitude);
        CommonUtil.printLog("clientData---------->", clientData.toString());
    } catch (JSONException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return clientData;
}

From source file:xj.property.ums.UmsAgent.java

public static JSONObject getClientDataJSONObject(Context context) {
    TelephonyManager tm = (TelephonyManager) (context.getSystemService(Context.TELEPHONY_SERVICE));
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics displaysMetrics = new DisplayMetrics();
    manager.getDefaultDisplay().getMetrics(displaysMetrics);
    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    JSONObject clientData = new JSONObject();
    try {//from   w  ww . j  av  a  2 s .  c o m
        clientData.put("os_version", CommonUtil.getOsVersion(context));
        clientData.put("platform", "android");
        clientData.put("language", Locale.getDefault().getLanguage());
        clientData.put("deviceid", tm.getDeviceId() == null ? "" : tm.getDeviceId());//
        clientData.put("appkey", CommonUtil.getAppKey(context));
        clientData.put("resolution", displaysMetrics.widthPixels + "x" + displaysMetrics.heightPixels);
        clientData.put("ismobiledevice", true);
        clientData.put("phonetype", tm.getPhoneType());//
        clientData.put("imsi", tm.getSubscriberId());
        clientData.put("network", CommonUtil.getNetworkTypeWIFI2G3G(context));
        clientData.put("time", CommonUtil.getTime());
        clientData.put("version", CommonUtil.getVersion(context));
        clientData.put(UserIdentifier, CommonUtil.getUserIdentifier(context));

        SCell sCell = CommonUtil.getCellInfo(context);

        clientData.put("mccmnc", sCell != null ? "" + sCell.MCCMNC : "");
        clientData.put("cellid", sCell != null ? sCell.CID + "" : "");
        clientData.put("lac", sCell != null ? sCell.LAC + "" : "");
        clientData.put("modulename", Build.PRODUCT);
        clientData.put("devicename", CommonUtil.getDeviceName());
        clientData.put("wifimac", wifiManager.getConnectionInfo().getMacAddress());
        clientData.put("havebt", adapter == null ? false : true);
        clientData.put("havewifi", CommonUtil.isWiFiActive(context));
        clientData.put("havegps", locationManager == null ? false : true);
        clientData.put("havegravity", CommonUtil.isHaveGravity(context));//

        LatitudeAndLongitude coordinates = CommonUtil.getLatitudeAndLongitude(context,
                UmsAgent.mUseLocationService);
        clientData.put("latitude", coordinates.latitude);
        clientData.put("longitude", coordinates.longitude);
        CommonUtil.printLog("clientData---------->", clientData.toString());
    } catch (JSONException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return clientData;
}

From source file:com.chummy.jezebel.material.dark.activities.Main.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    switch (item.getItemId()) {
    case R.id.share:
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        String shareBody = "Check out " + getResources().getString(R.string.theme_name) + " by "
                + getResources().getString(R.string.nicholas_short) + "!\n\nDownload it here!: "
                + getResources().getString(R.string.play_store_link);
        sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
        startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title))));
        break;//from   w  w w .  j  ava  2  s. co m

    case R.id.sendemail:
        StringBuilder emailBuilder = new StringBuilder();
        Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("mailto:" + getResources().getString(R.string.email_id)));
        if (!isAppInstalled("org.cyanogenmod.theme.chooser")) {
            if (!isAppInstalled("com.cyngn.theme.chooser")) {
                if (!isAppInstalled("com.lovejoy777.rroandlayersmanager")) {
                    intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject));
                } else {
                    intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_rro));
                }
            } else {
                intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_cos));
            }
        } else {
            intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_cm));
        }
        emailBuilder.append("\n \n \nOS Version: " + System.getProperty("os.version") + "("
                + Build.VERSION.INCREMENTAL + ")");
        emailBuilder.append("\nOS API Level: " + Build.VERSION.SDK_INT + " (" + Build.VERSION.RELEASE + ") "
                + "[" + Build.ID + "]");
        emailBuilder.append("\nDevice: " + Build.DEVICE);
        emailBuilder.append("\nManufacturer: " + Build.MANUFACTURER);
        emailBuilder.append("\nModel (and Product): " + Build.MODEL + " (" + Build.PRODUCT + ")");
        if (!isAppInstalled("org.cyanogenmod.theme.chooser")) {
            if (!isAppInstalled("com.cyngn.theme.chooser")) {
                if (!isAppInstalled("com.lovejoy777.rroandlayersmanager")) {
                    emailBuilder.append("\nTheme Engine: Not Available");
                } else {
                    emailBuilder.append("\nTheme Engine: Layers Manager (RRO)");
                }
            } else {
                emailBuilder.append("\nTheme Engine: Cyanogen OS Theme Engine");
            }
        } else {
            emailBuilder.append("\nTheme Engine: CyanogenMod Theme Engine");
        }
        PackageInfo appInfo = null;
        try {
            appInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        emailBuilder.append("\nApp Version Name: " + appInfo.versionName);
        emailBuilder.append("\nApp Version Code: " + appInfo.versionCode);

        intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString());
        startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title))));
        break;

    case R.id.changelog:
        changelog();
        break;

    case R.id.hide_launcher:
        boolean checked = item.isChecked();
        if (!checked) {
            new MaterialDialog.Builder(this).title(R.string.warning).content(R.string.hide_action)
                    .positiveText(R.string.nice).show();
        }
        item.setChecked(!checked);
        setLauncherIconEnabled(checked);
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
    return true;
}

From source file:org.brandroid.openmanager.fragments.DialogHandler.java

public static String getDeviceInfo() {
    String ret = "";
    String sep = "\n";
    ret += sep + "Build Info:" + sep;
    ret += "SDK: " + Build.VERSION.SDK_INT + sep;
    if (OpenExplorer.SCREEN_WIDTH > -1)
        ret += "Screen: " + OpenExplorer.SCREEN_WIDTH + "x" + OpenExplorer.SCREEN_HEIGHT + sep;
    if (OpenExplorer.SCREEN_DPI > -1)
        ret += "DPI: " + OpenExplorer.SCREEN_DPI + sep;
    ret += "Lang: " + getLangCode() + sep;
    ret += "Fingerprint: " + Build.FINGERPRINT + sep;
    ret += "Manufacturer: " + Build.MANUFACTURER + sep;
    ret += "Model: " + Build.MODEL + sep;
    ret += "Product: " + Build.PRODUCT + sep;
    ret += "Brand: " + Build.BRAND + sep;
    ret += "Board: " + Build.BOARD + sep;
    ret += "Bootloader: " + Build.BOOTLOADER + sep;
    ret += "Hardware: " + Build.HARDWARE + sep;
    ret += "Display: " + Build.DISPLAY + sep;
    ret += "Language: " + Locale.getDefault().getDisplayLanguage() + sep;
    ret += "Country: " + Locale.getDefault().getDisplayCountry() + sep;
    ret += "Tags: " + Build.TAGS + sep;
    ret += "Type: " + Build.TYPE + sep;
    ret += "User: " + Build.USER + sep;
    if (Build.UNKNOWN != null)
        ret += "Unknown: " + Build.UNKNOWN + sep;
    ret += "ID: " + Build.ID;
    return ret;//from w w w .  j  a  v  a  2  s . co m
}

From source file:RhodesService.java

public static Object getProperty(String name) {
    try {//from w ww . j ava  2  s  .  c o m
        if (name.equalsIgnoreCase("platform"))
            return "ANDROID";
        else if (name.equalsIgnoreCase("locale"))
            return getCurrentLocale();
        else if (name.equalsIgnoreCase("country"))
            return getCurrentCountry();
        else if (name.equalsIgnoreCase("screen_width"))
            return Integer.valueOf(getScreenWidth());
        else if (name.equalsIgnoreCase("screen_height"))
            return Integer.valueOf(getScreenHeight());
        else if (name.equalsIgnoreCase("screen_orientation")) {
            int orientation = getScreenOrientation();
            if ((orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
                    || (orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE))
                return "landscape";
            else
                return "portrait";
        } else if (name.equalsIgnoreCase("has_network"))
            return Boolean.valueOf(hasNetwork());
        else if (name.equalsIgnoreCase("has_wifi_network"))
            return Boolean.valueOf(hasWiFiNetwork());
        else if (name.equalsIgnoreCase("has_cell_network"))
            return Boolean.valueOf(hasCellNetwork());
        else if (name.equalsIgnoreCase("ppi_x"))
            return Float.valueOf(getScreenPpiX());
        else if (name.equalsIgnoreCase("ppi_y"))
            return Float.valueOf(getScreenPpiY());
        else if (name.equalsIgnoreCase("phone_number")) {
            Context context = ContextFactory.getContext();
            String number = "";
            if (context != null) {
                TelephonyManager manager = (TelephonyManager) context
                        .getSystemService(Context.TELEPHONY_SERVICE);
                number = manager.getLine1Number();
                Logger.I(TAG, "Phone number: " + number + "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
            }
            return number;
        } else if (name.equalsIgnoreCase("device_owner_name")) {
            return AndroidFunctionalityManager.getAndroidFunctionality()
                    .AccessOwnerInfo_getUsername(getContext());
        } else if (name.equalsIgnoreCase("device_owner_email")) {
            return AndroidFunctionalityManager.getAndroidFunctionality().AccessOwnerInfo_getEmail(getContext());
        } else if (name.equalsIgnoreCase("device_name")) {
            return Build.MANUFACTURER + " " + Build.DEVICE;
        } else if (name.equalsIgnoreCase("is_emulator")) {
            String strDevice = Build.DEVICE;
            return Boolean.valueOf(strDevice != null && strDevice.equalsIgnoreCase("generic"));
        } else if (name.equalsIgnoreCase("os_version")) {
            return Build.VERSION.RELEASE;
        } else if (name.equalsIgnoreCase("has_calendar")) {
            return Boolean.valueOf(EventStore.hasCalendar());
        } else if (name.equalsIgnoreCase("phone_id")) {
            RhodesService service = RhodesService.getInstance();
            if (service != null) {
                PhoneId phoneId = service.getPhoneId();
                return phoneId.toString();
            } else {
                return "";
            }
        } else if (name.equalsIgnoreCase("webview_framework")) {
            return RhodesActivity.safeGetInstance().getMainView().getWebView(-1).getEngineId();
        } else if (name.equalsIgnoreCase("is_motorola_device")) {
            return isMotorolaDevice();
        } else if (name.equalsIgnoreCase("oem_info")) {
            return Build.PRODUCT;
        } else if (name.equalsIgnoreCase("uuid")) {
            return fetchUUID();
        } else if (name.equalsIgnoreCase("has_camera")) {
            return Boolean.TRUE;
        } else {
            return RhoExtManager.getImplementationInstance().getProperty(name);
        }
    } catch (Exception e) {
        Logger.E(TAG, "Can't get property \"" + name + "\": " + e);
    }

    return null;
}

From source file:android_network.hetnet.vpn_service.Util.java

public static void sendLogcat(final Uri uri, final Context context) {
    AsyncTask task = new AsyncTask<Object, Object, Intent>() {
        @Override//from   w  w  w  .ja  va 2s  .  c  om
        protected Intent doInBackground(Object... objects) {
            StringBuilder sb = new StringBuilder();
            sb.append(context.getString(R.string.msg_issue));
            sb.append("\r\n\r\n\r\n\r\n");

            // Get version info
            String version = getSelfVersionName(context);
            sb.append(String.format("NetGuard: %s/%d\r\n", version, getSelfVersionCode(context)));
            sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
            sb.append("\r\n");

            // Get device info
            sb.append(String.format("Brand: %s\r\n", Build.BRAND));
            sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER));
            sb.append(String.format("Model: %s\r\n", Build.MODEL));
            sb.append(String.format("Product: %s\r\n", Build.PRODUCT));
            sb.append(String.format("Device: %s\r\n", Build.DEVICE));
            sb.append(String.format("Host: %s\r\n", Build.HOST));
            sb.append(String.format("Display: %s\r\n", Build.DISPLAY));
            sb.append(String.format("Id: %s\r\n", Build.ID));
            sb.append(String.format("Fingerprint: %B\r\n", hasValidFingerprint(context)));

            String abi;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
                abi = Build.CPU_ABI;
            else
                abi = (Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "?");
            sb.append(String.format("ABI: %s\r\n", abi));

            sb.append("\r\n");

            sb.append(String.format("VPN dialogs: %B\r\n",
                    isPackageInstalled("com.android.vpndialogs", context)));
            try {
                sb.append(String.format("Prepared: %B\r\n", VpnService.prepare(context) == null));
            } catch (Throwable ex) {
                sb.append("Prepared: ").append((ex.toString())).append("\r\n")
                        .append(Log.getStackTraceString(ex));
            }
            sb.append(String.format("Permission: %B\r\n", hasPhoneStatePermission(context)));
            sb.append("\r\n");

            sb.append(getGeneralInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getNetworkInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getSubscriptionInfo(context));
            sb.append("\r\n\r\n");

            // Get settings
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            Map<String, ?> all = prefs.getAll();
            for (String key : all.keySet())
                sb.append("Setting: ").append(key).append('=').append(all.get(key)).append("\r\n");
            sb.append("\r\n");

            // Write logcat
            OutputStream out = null;
            try {
                Log.i(TAG, "Writing logcat URI=" + uri);
                out = context.getContentResolver().openOutputStream(uri);
                out.write(getLogcat().toString().getBytes());
                out.write(getTrafficLog(context).toString().getBytes());
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                sb.append(ex.toString()).append("\r\n").append(Log.getStackTraceString(ex)).append("\r\n");
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ignored) {
                    }
            }

            // Build intent
            Intent sendEmail = new Intent(Intent.ACTION_SEND);
            sendEmail.setType("message/rfc822");
            sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "marcel+netguard@faircode.eu" });
            sendEmail.putExtra(Intent.EXTRA_SUBJECT, "NetGuard " + version + " logcat");
            sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString());
            sendEmail.putExtra(Intent.EXTRA_STREAM, uri);
            return sendEmail;
        }

        @Override
        protected void onPostExecute(Intent sendEmail) {
            if (sendEmail != null)
                try {
                    context.startActivity(sendEmail);
                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        }
    };
    task.execute();
}

From source file:eu.faircode.netguard.Util.java

public static void sendLogcat(final Uri uri, final Context context) {
    AsyncTask task = new AsyncTask<Object, Object, Intent>() {
        @Override//from  www . ja  va 2 s .  c o m
        protected Intent doInBackground(Object... objects) {
            StringBuilder sb = new StringBuilder();
            sb.append(context.getString(R.string.msg_issue));
            sb.append("\r\n\r\n\r\n\r\n");

            // Get version info
            String version = getSelfVersionName(context);
            sb.append(String.format("NetGuard: %s/%d\r\n", version, getSelfVersionCode(context)));
            sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
            sb.append("\r\n");

            // Get device info
            sb.append(String.format("Brand: %s\r\n", Build.BRAND));
            sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER));
            sb.append(String.format("Model: %s\r\n", Build.MODEL));
            sb.append(String.format("Product: %s\r\n", Build.PRODUCT));
            sb.append(String.format("Device: %s\r\n", Build.DEVICE));
            sb.append(String.format("Host: %s\r\n", Build.HOST));
            sb.append(String.format("Display: %s\r\n", Build.DISPLAY));
            sb.append(String.format("Id: %s\r\n", Build.ID));
            sb.append(String.format("Fingerprint: %B\r\n", hasValidFingerprint(context)));

            String abi;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
                abi = Build.CPU_ABI;
            else
                abi = (Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "?");
            sb.append(String.format("ABI: %s\r\n", abi));

            sb.append("\r\n");

            sb.append(String.format("VPN dialogs: %B\r\n",
                    isPackageInstalled("com.android.vpndialogs", context)));
            try {
                sb.append(String.format("Prepared: %B\r\n", VpnService.prepare(context) == null));
            } catch (Throwable ex) {
                sb.append("Prepared: ").append((ex.toString())).append("\r\n")
                        .append(Log.getStackTraceString(ex));
            }
            sb.append("\r\n");

            sb.append(getGeneralInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getNetworkInfo(context));
            sb.append("\r\n\r\n");

            // Get DNS
            sb.append("DNS system:\r\n");
            for (String dns : getDefaultDNS(context))
                sb.append("- ").append(dns).append("\r\n");
            sb.append("DNS VPN:\r\n");
            for (InetAddress dns : ServiceSinkhole.getDns(context))
                sb.append("- ").append(dns).append("\r\n");
            sb.append("\r\n");

            // Get TCP connection info
            String line;
            BufferedReader in;
            try {
                sb.append("/proc/net/tcp:\r\n");
                in = new BufferedReader(new FileReader("/proc/net/tcp"));
                while ((line = in.readLine()) != null)
                    sb.append(line).append("\r\n");
                in.close();
                sb.append("\r\n");

                sb.append("/proc/net/tcp6:\r\n");
                in = new BufferedReader(new FileReader("/proc/net/tcp6"));
                while ((line = in.readLine()) != null)
                    sb.append(line).append("\r\n");
                in.close();
                sb.append("\r\n");

            } catch (IOException ex) {
                sb.append(ex.toString()).append("\r\n");
            }

            // Get settings
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            Map<String, ?> all = prefs.getAll();
            for (String key : all.keySet())
                sb.append("Setting: ").append(key).append('=').append(all.get(key)).append("\r\n");
            sb.append("\r\n");

            // Write logcat
            OutputStream out = null;
            try {
                Log.i(TAG, "Writing logcat URI=" + uri);
                out = context.getContentResolver().openOutputStream(uri);
                out.write(getLogcat().toString().getBytes());
                out.write(getTrafficLog(context).toString().getBytes());
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                sb.append(ex.toString()).append("\r\n").append(Log.getStackTraceString(ex)).append("\r\n");
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ignored) {
                    }
            }

            // Build intent
            Intent sendEmail = new Intent(Intent.ACTION_SEND);
            sendEmail.setType("message/rfc822");
            sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "marcel+netguard@faircode.eu" });
            sendEmail.putExtra(Intent.EXTRA_SUBJECT, "NetGuard " + version + " logcat");
            sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString());
            sendEmail.putExtra(Intent.EXTRA_STREAM, uri);
            return sendEmail;
        }

        @Override
        protected void onPostExecute(Intent sendEmail) {
            if (sendEmail != null)
                try {
                    context.startActivity(sendEmail);
                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        }
    };
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

From source file:com.droid.app.fotobot.FotoBot.java

/**
 *   ?  ? ? //from ww  w.j  a v  a  2 s.  c o  m
 *
 * @param h
 * @param str
 */
public void SendMail(Handler h, String str, String fc_str, String bc_video, String fc_video) {

    //        final FotoBot fb = (FotoBot) getApplicationContext();

    Mail m = new Mail(getApplicationContext(), EMail_Sender, EMail_Sender_Password, SMTP_Host, SMTP_Port);

    String[] toArr = { EMail_Recepient };

    String s = "Debug-infos:";
    s += "\n OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL
            + ")";
    s += "\n OS API Level: " + android.os.Build.VERSION.SDK_INT;
    s += "\n Device: " + android.os.Build.DEVICE;
    s += "\n Model (and Product): " + android.os.Build.MODEL + " (" + android.os.Build.PRODUCT + ")";

    s += "\n RELEASE: " + android.os.Build.VERSION.RELEASE;
    s += "\n BRAND: " + android.os.Build.BRAND;
    s += "\n DISPLAY: " + android.os.Build.DISPLAY;
    s += "\n CPU_ABI: " + android.os.Build.CPU_ABI;
    s += "\n CPU_ABI2: " + android.os.Build.CPU_ABI2;
    s += "\n UNKNOWN: " + android.os.Build.UNKNOWN;
    s += "\n HARDWARE: " + android.os.Build.HARDWARE;
    s += "\n Build ID: " + android.os.Build.ID;
    s += "\n MANUFACTURER: " + android.os.Build.MANUFACTURER;
    s += "\n SERIAL: " + android.os.Build.SERIAL;
    s += "\n USER: " + android.os.Build.USER;
    s += "\n HOST: " + android.os.Build.HOST;

    m.setTo(toArr);
    m.setFrom(EMail_Sender);
    m.setSubject("Fotobot v" + versionName + " " + Camera_Name);

    String email_body = "";

    email_body = "Fotobot v" + versionName + "\n" + "---------------------------------------------\n"
            + "Camera Name" + ": " + Camera_Name + "\n" + getResources().getString(R.string.battery_charge)
            + ": " + battery_level + "%" + "\n" + getResources().getString(R.string.battery_temperature) + ": "
            + battery_temperature + "C" + "\n";

    if (Attached_Info_Detailisation.equals("Normal") || Attached_Info_Detailisation.equals("Detailed")) {

        email_body = email_body + getResources().getString(R.string.gsm) + ": " + GSM_Signal + "ASU    "
                + (2.0 * GSM_Signal - 113) + "dBm" + "\n" + "-50 -82 dbm   -   very good" + "\n"
                + "-83 -86 dbm   -   good" + "\n" + "-87 -91 dbm   -   normal" + "\n" + "-92 -95 dbm   -   bad"
                + "\n" + "-96 -100 dbm   -  almost no signal" + "\n"
                + "---------------------------------------------\n" + "Image Index:" + Image_Index + "\n"
                + "---------------------------------------------\n"
                + getResources().getString(R.string.phone_memory) + ":" + "\n" + "totalMemory: " + totalMemory
                + "\n" + "usedMemory: " + usedMemory + "\n" + "freeMemory: " + freeMemory + "\n"
                + "---------------------------------------------\n"
                + getResources().getString(R.string.email_sending_time) + ": " + email_sending_time + "\n"
                + "---------------------------------------------\n"
                + getResources().getString(R.string.Fotobot_settings) + ":\n" + "Network_Channel: "
                + Network_Channel + "\n" + "Network_Connection_Method: " + Network_Connection_Method + "\n"
                + "Use_Flash: " + Use_Flash + "\n" + "JPEG_Compression: " + JPEG_Compression + "\n"
                + "Photo_Frequency: " + Photo_Frequency + "\n" + "process_delay: " + process_delay + "\n"
                + "Image_Scale: " + Image_Scale + "\n" + "Image_Size: " + Image_Size + "\n" + "EMail_Sender: "
                + EMail_Sender + "\n" + "EMail_Sender_Password: *********" + "\n" + "EMail_Recepient: "
                + EMail_Recepient + "\n" + "Log_Font_Size: " + Log_Font_Size + "\n" + "Config_Font_Size: "
                + Config_Font_Size + "\n" + "Photo_Post_Processing_Method: " + Photo_Post_Processing_Method
                + "\n" + "SMTP_Host: " + SMTP_Host + "\n" + "SMTP_Port: " + SMTP_Port + "\n" + "Log length: "
                + loglength + "\n" + "FLog length: " + floglength + "\n" + "wake_up_interval: "
                + wake_up_interval + "\n" + "---------------------------------------------\n"
                + getResources().getString(R.string.hardware_info) + ":\n" + "Android: " + Build.VERSION.SDK_INT
                + "\n" + s + "\n" + "---------------------------------------------\n"
                + "Available SMS commands: " + "\n" + sms_commands_list() + "\n";
        ;
        if (Attached_Info_Detailisation.equals("Detailed")) {
            email_body = email_body + "\n\n\nActive tasks:\n" + Top + "\n\n\nBack Camera Properties:\n"
                    + Camera_Properties + "\n\n\nFront Camera Properties:\n" + fc_Camera_Properties;
        }

    }

    m.setBody(email_body);

    File attach_file;

    if (make_photo_bc && bc_image_attach) {

        attach_file = new File(str);
        boolean fileExists = attach_file.isFile();

        if (fileExists) {

        } else {
            SendMessage("ERROR: image doesn't exist for attaching to email.", MSG_FAIL);
        }
    }

    if (make_video_bc && bc_video_attach) {

        attach_file = new File(bc_video);
        boolean fileExists = attach_file.isFile();

        if (fileExists) {

        } else {
            SendMessage("ERROR: video " + bc_video + " doesn't exist for attaching to email.", MSG_FAIL);
        }
    }

    if (front_camera && make_photo_fc && fc_image_attach) {

        attach_file = new File(fc_str);
        boolean fc_fileExists = attach_file.isFile();

        if (front_camera && fc_fileExists && make_photo_fc) {

        } else {
            SendMessage("ERROR: front camera image doesn't exist for attaching to email.", MSG_FAIL);
        }
    }

    if (front_camera && make_video_fc && fc_video_attach) {

        attach_file = new File(fc_video);
        boolean fc_fileExists = attach_file.isFile();

        if (front_camera && fc_fileExists && make_photo_fc) {

        } else {
            SendMessage("ERROR: video " + fc_video + " doesn't exist for attaching to email.", MSG_FAIL);
        }
    }

    if (attach_log) {
        attach_file = new File((work_dir + "/logfile.txt"));
        boolean fileExists = attach_file.isFile();

        if (fileExists) {

        } else {
            SendMessage("ERROR: log doesn't exist for attaching to email.", MSG_FAIL);
        }

    }
    try {

        if (make_photo_bc && bc_image_attach) {
            m.addAttachment(str);
        }

        if (front_camera && make_photo_fc && fc_image_attach) {
            m.addAttachment(fc_str);
        }

        if (make_video_bc && bc_image_attach) {
            m.addAttachment(bc_video);
        }

        if (front_camera && make_video_fc && fc_image_attach) {
            m.addAttachment(fc_video);
        }

        if (attach_log) {
            m.addAttachment(work_dir + "/logfile.txt");
        }
        fbpause(h, process_delay);

        if (m.send()) {

            SendMessage(getResources().getString(R.string.foto_sent), MSG_PASS);

            SaveSettings();

        } else {
            SendMessage("ERROR: ?   ", MSG_FAIL);
        }
    } catch (Exception e) {
        SendMessage("Could not send email", MSG_FAIL);
        Log.e("MailApp", "Could not send email", e);
    }

}