Java Code Examples for android.telephony.TelephonyManager#getSimCountryIso()

The following examples show how to use android.telephony.TelephonyManager#getSimCountryIso() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeviceUtils.java    From Android-utils with Apache License 2.0 6 votes vote down vote up
/**
 * Return the phone status.
 * <p>Must hold
 * {@code <uses-permission android:name="android.permission.READ_PHONE_STATE" />}</p>
 *
 * @return DeviceId = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中国电信<br>
 * NetworkType = 6<br>
 * PhoneType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中国电信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
@SuppressLint("HardwareIds")
@RequiresPermission(READ_PHONE_STATE)
public static String getPhoneStatus() {
    TelephonyManager tm =
            (TelephonyManager) UtilsApp.getApp().getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    //noinspection ConstantConditions
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "PhoneType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber();
    return str;
}
 
Example 2
Source File: PhoneUtils.java    From DevUtils with Apache License 2.0 6 votes vote down vote up
/**
 * 获取 SIM 卡运营商的国家代码
 * @return SIM 卡运营商的国家代码
 */
public static String getSimCountry() {
    try {
        TelephonyManager telephonyManager = AppUtils.getTelephonyManager();
        // SIM 卡运营商的国家代码
        String simCountry = telephonyManager.getSimCountryIso();
        // 注册的网络运营商的国家代码
        String networkCountry = telephonyManager.getNetworkCountryIso();
        if (simCountry != null && simCountry.trim().length() != 0) {
            return simCountry.trim();
        } else if (networkCountry != null && networkCountry.trim().length() != 0) {
            return networkCountry.trim();
        }
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "getSimCountry");
    }
    return null;
}
 
Example 3
Source File: CountryCode.java    From Intra with Apache License 2.0 6 votes vote down vote up
private static @NonNull String countryFromSim(TelephonyManager telephonyManager) {
  String simCountry = telephonyManager.getSimCountryIso();
  if (!simCountry.isEmpty()) {
    return simCountry;
  }
  // User appears to be non-GSM.  Try CDMA.
  try {
    // Get the system properties by reflection.
    Class<?> systemPropertiesClass = Class.forName("android.os.SystemProperties");
    Method get = systemPropertiesClass.getMethod("get", String.class);
    String cdmaOperator = (String)get.invoke(systemPropertiesClass,
        "ro.cdma.home.operator.numeric");
    if (cdmaOperator == null || cdmaOperator.isEmpty()) {
      // System is neither GSM nor CDMA.
      return "";
    }
    String mcc = cdmaOperator.substring(0, 3);
    Class<?> mccTableClass = Class.forName("com.android.internal.telephony.MccTable");
    Method countryCodeForMcc = mccTableClass.getMethod("countryCodeForMcc", String.class);
    return (String)countryCodeForMcc.invoke(mccTableClass, mcc);
  } catch (Exception e) {
    LogWrapper.logException(e);
    return "";
  }
}
 
Example 4
Source File: PhoneUtils.java    From Android-UtilCode with Apache License 2.0 6 votes vote down vote up
/**
 * 获取手机状态信息
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @return DeviceId(IMEI) = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中国电信<br>
 * NetworkType = 6<br>
 * honeType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中国电信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
@SuppressLint("HardwareIds")
public static String getPhoneStatus() {
    TelephonyManager tm = (TelephonyManager) Utils.getContext()
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "PhoneType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
Example 5
Source File: FakeOperatorTile.java    From LocationReportEnabler with GNU General Public License v3.0 6 votes vote down vote up
private void updateTile() {
    TelephonyManager manager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    String code = manager.getSimOperator();
    String country = manager.getSimCountryIso();

    SharedPreferences preferences = PropUtil.getProtecredSharedPreferences(this);

    Tile tile = getQsTile();
    tile.setLabel(String.format("%s %s", code, country));
    if (preferences.getBoolean(PropUtil.PREFERENCE_ENABLED, PropUtil.PREFERENCE_ENABLED_DEFAULT)) {
        tile.setState(Tile.STATE_ACTIVE);
    }
    else {
        tile.setState(Tile.STATE_INACTIVE);
    }
    tile.updateTile();
}
 
Example 6
Source File: RxDeviceTool.java    From RxTools-master with Apache License 2.0 6 votes vote down vote up
/**
 * 获取手机状态信息
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
 *
 * @param context 上下文
 * @return DeviceId(IMEI) = 99000311726612<br>
 * DeviceSoftwareVersion = 00<br>
 * Line1Number =<br>
 * NetworkCountryIso = cn<br>
 * NetworkOperator = 46003<br>
 * NetworkOperatorName = 中国电信<br>
 * NetworkType = 6<br>
 * honeType = 2<br>
 * SimCountryIso = cn<br>
 * SimOperator = 46003<br>
 * SimOperatorName = 中国电信<br>
 * SimSerialNumber = 89860315045710604022<br>
 * SimState = 5<br>
 * SubscriberId(IMSI) = 460030419724900<br>
 * VoiceMailNumber = *86<br>
 */
public static String getPhoneStatus(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "honeType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
Example 7
Source File: TelephonyUtil.java    From android-perftracking with MIT License 6 votes vote down vote up
/**
 * Returns the country code from the device SIM card if present,
 * or the device's Locale country code if there is no SIM card.
 *
 * @param context application context
 * @return country code
 */
public static String getCountryCode(Context context) {
  String country = null;

  TelephonyManager tm = telephonyManager(context);
  if (tm != null) {
    country = tm.getSimCountryIso();
  }

  if (country == null || "".equals(country)) {
    country = Locale.getDefault().getCountry();
  }

  if (country != null) {
    country = country.toUpperCase();
  }

  return country;
}
 
Example 8
Source File: CountryCodePicker.java    From CountryCodePickerProject with Apache License 2.0 6 votes vote down vote up
/**
 * This will detect country from SIM info and then load it into CCP.
 *
 * @param loadDefaultWhenFails true if want to reset to default country when sim country cannot be detected. if false, then it
 *                             will not change currently selected country
 * @return true if it successfully sets country, false otherwise
 */
public boolean detectSIMCountry(boolean loadDefaultWhenFails) {
    try {
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String simCountryISO = telephonyManager.getSimCountryIso();
        if (simCountryISO == null || simCountryISO.isEmpty()) {
            if (loadDefaultWhenFails) {
                resetToDefaultCountry();
            }
            return false;
        }
        setSelectedCountry(CCPCountry.getCountryForNameCodeFromLibraryMasterList(getContext(), getLanguageToApply(), simCountryISO));
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        if (loadDefaultWhenFails) {
            resetToDefaultCountry();
        }
        return false;
    }
}
 
Example 9
Source File: LocationProvider.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
public static String getUserCountry(Context context) {
    try {
        final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        final String simCountry = tm.getSimCountryIso();
        if (simCountry != null && simCountry.length() == 2) { // SIM country code is available
            return simCountry.toUpperCase(Locale.US);
        } else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { // device is not 3G (would be unreliable)
            String networkCountry = tm.getNetworkCountryIso();
            if (networkCountry != null && networkCountry.length() == 2) { // network country code is available
                return networkCountry.toUpperCase(Locale.US);
            }
        }
    } catch (Exception e) {
        // fallthrough
    }
    Locale locale = Locale.getDefault();
    return locale.getCountry();
}
 
Example 10
Source File: Helper.java    From smartcoins-wallet with MIT License 6 votes vote down vote up
/**
 * Get ISO 3166-1 alpha-2 country code for this device (or null if not available)
 *
 * @param context Context reference to get the TelephonyManager instance from
 * @return country code or null
 */
public static String getDeviceCountry(Context context) {
    try {
        final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        final String simCountry = tm.getSimCountryIso();
        if (simCountry != null && simCountry.length() == 2) { // SIM country code is available
            return simCountry.toLowerCase(Locale.US);
        } else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { // device is not 3G (would be unreliable)
            String networkCountry = tm.getNetworkCountryIso();
            if (networkCountry != null && networkCountry.length() == 2) { // network country code is available
                return networkCountry.toLowerCase(Locale.US);
            }
        }
    } catch (Exception e) {
    }
    return null;
}
 
Example 11
Source File: Util.java    From tracker-control-android with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isNational(Context context) {
    try {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return (tm != null && tm.getSimCountryIso() != null && tm.getSimCountryIso().equals(tm.getNetworkCountryIso()));
    } catch (Throwable ignored) {
        return false;
    }
}
 
Example 12
Source File: Global.java    From Favorite-Android-Client with Apache License 2.0 5 votes vote down vote up
public static String getCountryValue() {
	String countryCode;

	TelephonyManager systemService = (TelephonyManager) mod
			.getSystemService(Context.TELEPHONY_SERVICE);
	countryCode = systemService.getSimCountryIso();

	if (countryCode.matches(""))
		countryCode = mod.getString(R.string.default_country);

	// Log.i("Country", countryCode + "df");
	return countryCode;
}
 
Example 13
Source File: DeviceInfo.java    From clevertap-android-sdk with MIT License 5 votes vote down vote up
private String getCountryCode() {
    try {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        if (tm != null) {
            return tm.getSimCountryIso();
        }
    } catch (Throwable ignore) {
        return "";
    }
    return "";
}
 
Example 14
Source File: Phone.java    From Android-Commons with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the ISO alpha-2 country code for the current device from the SIM card
 *
 * @param context a context reference
 * @param defaultCountry the default country to return
 * @return the country code or the value from `defaultCountry` if not available
 */
public static String getCountry(final ContextWrapper context, final String defaultCountry) {
	try {
		final TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
		final String country = telephony.getSimCountryIso();

		if (country != null && country.length() == 2) {
			return country;
		}
	}
	catch (Exception e) { }

	return defaultCountry;
}
 
Example 15
Source File: ContextualSearchPolicy.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return The ISO country code for the user's home country, or an empty string if not
 *         available or privacy-enabled.
 */
String getHomeCountry(Context context) {
    if (ContextualSearchFieldTrial.isSendHomeCountryDisabled()) return "";

    TelephonyManager telephonyManager =
            (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager == null) return "";

    String simCountryIso = telephonyManager.getSimCountryIso();
    if (TextUtils.isEmpty(simCountryIso)) return "";

    return simCountryIso;
}
 
Example 16
Source File: Util.java    From NetGuard with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isNational(Context context) {
    try {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return (tm != null && tm.getSimCountryIso() != null && tm.getSimCountryIso().equals(tm.getNetworkCountryIso()));
    } catch (Throwable ignored) {
        return false;
    }
}
 
Example 17
Source File: Util.java    From kcanotify with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isInternational(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return (tm != null && tm.getSimCountryIso() != null && !tm.getSimCountryIso().equals(tm.getNetworkCountryIso()));
}
 
Example 18
Source File: PhoneNumberUtils.java    From FirebaseUI-Android with Apache License 2.0 4 votes vote down vote up
private static Locale getSimBasedLocale(@NonNull Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String countryIso = tm != null ? tm.getSimCountryIso() : null;
    return TextUtils.isEmpty(countryIso) ? null : new Locale("", countryIso);
}
 
Example 19
Source File: PhoneUtils.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
/**
 * 获取手机状态信息
 * <p>需添加权限<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 * <p>返回如下
 * <pre>
 * DeviceId(IMEI) = 99000311726612
 * DeviceSoftwareVersion = 00
 * Line1Number =
 * NetworkCountryIso = cn
 * NetworkOperator = 46003
 * NetworkOperatorName = 中国电信
 * NetworkType = 6
 * honeType = 2
 * SimCountryIso = cn
 * SimOperator = 46003
 * SimOperatorName = 中国电信
 * SimSerialNumber = 89860315045710604022
 * SimState = 5
 * SubscriberId(IMSI) = 460030419724900
 * VoiceMailNumber = *86
 * <pre/>
 */
public static String getPhoneStatus(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    String str = "";
    str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
    str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
    str += "Line1Number = " + tm.getLine1Number() + "\n";
    str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
    str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
    str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
    str += "NetworkType = " + tm.getNetworkType() + "\n";
    str += "honeType = " + tm.getPhoneType() + "\n";
    str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
    str += "SimOperator = " + tm.getSimOperator() + "\n";
    str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
    str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
    str += "SimState = " + tm.getSimState() + "\n";
    str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
    str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
    return str;
}
 
Example 20
Source File: DeviceUtil.java    From OpenWeatherPlus-Android with Apache License 2.0 4 votes vote down vote up
/**
 * 获取系统的其他信息,组成json
 */
public static String getOther(Context context) {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    try {
        sb.append("\"kvn\":\"").append(BuildConfig.VERSION_NAME).append("\"").append(",");
        sb.append("\"kvc\":\"").append(BuildConfig.VERSION_CODE).append("\"").append(",");
        sb.append("\"sid\":\"").append(object2String(Build.ID)).append("\"").append(",");
        sb.append("\"sdv\":\"").append(object2String(Build.DEVICE)).append("\"").append(",");
        sb.append("\"sbr\":\"").append(object2String(Build.BRAND)).append("\"").append(",");
        sb.append("\"smo\":\"").append(object2String(Build.MODEL)).append("\"").append(",");
        sb.append("\"spd\":\"").append(object2String(Build.PRODUCT)).append("\"").append(",");
        sb.append("\"smf\":\"").append(object2String(Build.MANUFACTURER)).append("\"").append(",");
        sb.append("\"shw\":\"").append(object2String(Build.HARDWARE)).append("\"").append(",");
        sb.append("\"sfp\":\"").append(object2String(Build.FINGERPRINT)).append("\"").append(",");
        sb.append("\"stp\":\"").append(object2String(Build.TYPE)).append("\"").append(",");
        sb.append("\"shs\":\"").append(object2String(Build.HOST)).append("\"").append(",");
        sb.append("\"sbd\":\"").append(object2String(Build.BOARD)).append("\"").append(",");
        sb.append("\"stm\":\"").append(object2String(Build.TIME)).append("\"").append(",");
        sb.append("\"sca\":\"").append(object2String(Build.CPU_ABI)).append("\"").append(",");
        sb.append("\"sbl\":\"").append(object2String(Build.BOOTLOADER)).append("\"").append(",");
        sb.append("\"sdp\":\"").append(object2String(Build.DISPLAY)).append("\"").append(",");
        sb.append("\"stg\":\"").append(object2String(Build.TAGS)).append("\"").append(",");
        sb.append("\"svr\":\"").append(object2String(Build.VERSION.RELEASE)).append("\"").append(",");
        sb.append("\"svs\":\"").append(object2String(Build.VERSION.SDK_INT)).append("\"").append(",");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            sb.append("\"svb\":\"").append(object2String(Build.VERSION.BASE_OS)).append("\"").append(",");
        }
        sb.append("\"svc\":\"").append(object2String(Build.VERSION.CODENAME)).append("\"").append(",");
        sb.append("\"svi\":\"").append(object2String(Build.VERSION.INCREMENTAL)).append("\"").append(",");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            sb.append("\"svs\":\"").append(object2String(Build.VERSION.SECURITY_PATCH)).append("\"").append(",");
        }

        if (context != null) {
            TelephonyManager phone = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

            sb.append("\"avc\":\"").append(context.getPackageName()).append("\"").append(",");
            sb.append("\"avn\":\"").append(getVersionName(context)).append("\"").append(",");
            sb.append("\"aan\":\"").append(getAppName(context)).append("\"").append(",");
            if (phone != null) {
                if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
                    @SuppressLint("HardwareIds") String telephone = phone.getSimSerialNumber();
                    if (!TextUtils.isEmpty(telephone)) {
                        sb.append("\"psn\":\"").append(object2String(telephone)).append("\"").append(",");
                    }
                    @SuppressLint("HardwareIds") String subscriberId = phone.getSubscriberId();
                    if (!TextUtils.isEmpty(subscriberId)) {
                        sb.append("\"psi\":\"").append(object2String(subscriberId)).append("\"").append(",");
                    }
                }
                int phoneType = phone.getPhoneType();
                sb.append("\"ppt\":\"").append(object2String(phoneType)).append("\"").append(",");
                String simCountryIso = phone.getSimCountryIso();
                if (!TextUtils.isEmpty(simCountryIso)) {
                    sb.append("\"psc\":\"").append(object2String(simCountryIso)).append("\"").append(",");
                }
                String simOperator = phone.getSimOperator();
                if (!TextUtils.isEmpty(simOperator)) {
                    sb.append("\"pso\":\"").append(object2String(simOperator)).append("\"").append(",");
                }
                String simOperatorName = phone.getSimOperatorName();
                if (!TextUtils.isEmpty(simOperatorName)) {
                    sb.append("\"psn\":\"").append(object2String(simOperatorName)).append("\"").append(",");
                }
            }

            if (context.getResources() != null) {
                DisplayMetrics metrics = context.getResources().getDisplayMetrics();
                if (metrics != null) {
                    sb.append("\"dmd\":\"").append(object2String(metrics.density)).append("\"").append(",");
                    sb.append("\"ddp\":\"").append(object2String(metrics.densityDpi)).append("\"").append(",");
                    sb.append("\"dmx\":\"").append(object2String(metrics.xdpi)).append("\"").append(",");
                    sb.append("\"dmy\":\"").append(object2String(metrics.ydpi)).append("\"").append(",");
                    sb.append("\"dsd\":\"").append(object2String(metrics.scaledDensity)).append("\"").append(",");
                }
            }
        }

        sb = sb.deleteCharAt(sb.length() - 1);
    } catch (Exception ignored) {
    }
    sb.append("}");
    return sb.toString();
}