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

The following examples show how to use android.telephony.TelephonyManager#getSimSerialNumber() . 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: Android.java    From KlyphMessenger with MIT License 6 votes vote down vote up
public static String getDeviceUDID(Context ctx)
{
	final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);

	final String tmDevice, tmSerial, androidId;

	PackageManager pm = ctx.getPackageManager();
	int hasPerm = pm.checkPermission(android.Manifest.permission.READ_PHONE_STATE, ctx.getPackageName());
	if (hasPerm == PackageManager.PERMISSION_GRANTED)
	{
		tmDevice = "" + tm.getDeviceId();
		tmSerial = "" + tm.getSimSerialNumber();
	}
	else
	{
		tmDevice = Settings.Secure.ANDROID_ID;
		tmSerial = android.os.Build.SERIAL;
	}

	androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);

	UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
	String deviceId = deviceUuid.toString();

	return deviceId;
}
 
Example 3
Source File: MainActivity.java    From SQLite-sync.com with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private String getSubscriberId() {
    final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);

    final String tmDevice, tmSerial, androidId;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (checkSelfPermission(Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    Activity#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for Activity#requestPermissions for more details.
            //return "Permission READ_PHONE_STATE needed.";
        }
    }
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "" + tm.getSimSerialNumber();
    androidId = "" + Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);

    UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());
    return deviceUuid.toString();
}
 
Example 4
Source File: Android.java    From Klyph with MIT License 6 votes vote down vote up
public static String getDeviceUDID(Context ctx)
{
	final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);

	final String tmDevice, tmSerial, androidId;

	PackageManager pm = ctx.getPackageManager();
	int hasPerm = pm.checkPermission(android.Manifest.permission.READ_PHONE_STATE, ctx.getPackageName());
	if (hasPerm == PackageManager.PERMISSION_GRANTED)
	{
		tmDevice = "" + tm.getDeviceId();
		tmSerial = "" + tm.getSimSerialNumber();
	}
	else
	{
		tmDevice = Settings.Secure.ANDROID_ID;
		tmSerial = android.os.Build.SERIAL;
	}

	androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);

	UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
	String deviceId = deviceUuid.toString();

	return deviceId;
}
 
Example 5
Source File: Android.java    From Klyph with MIT License 6 votes vote down vote up
public static String getDeviceUDID(Context ctx)
{
	final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);

	final String tmDevice, tmSerial, androidId;

	PackageManager pm = ctx.getPackageManager();
	int hasPerm = pm.checkPermission(android.Manifest.permission.READ_PHONE_STATE, ctx.getPackageName());
	if (hasPerm == PackageManager.PERMISSION_GRANTED)
	{
		tmDevice = "" + tm.getDeviceId();
		tmSerial = "" + tm.getSimSerialNumber();
	}
	else
	{
		tmDevice = Settings.Secure.ANDROID_ID;
		tmSerial = android.os.Build.SERIAL;
	}

	androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);

	UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
	String deviceId = deviceUuid.toString();

	return deviceId;
}
 
Example 6
Source File: Android.java    From Contacts with MIT License 6 votes vote down vote up
public static String getDeviceUDID(Context ctx)
{
	final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);

	final String tmDevice, tmSerial, androidId;

	PackageManager pm = ctx.getPackageManager();
	int hasPerm = pm.checkPermission(android.Manifest.permission.READ_PHONE_STATE, ctx.getPackageName());
	if (hasPerm == PackageManager.PERMISSION_GRANTED)
	{
		tmDevice = "" + tm.getDeviceId();
		tmSerial = "" + tm.getSimSerialNumber();
	}
	else
	{
		tmDevice = Settings.Secure.ANDROID_ID;
		tmSerial = android.os.Build.SERIAL;
	}

	androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);

	UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
	String deviceId = deviceUuid.toString();

	return deviceId;
}
 
Example 7
Source File: AppUtils.java    From SmartChart with Apache License 2.0 6 votes vote down vote up
/**
 * 获取设备唯一标识
 *
 * @param context
 * @return
 */
public static String getUUID(Context context) {
    final TelephonyManager tm = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);

    final String tmDevice, tmSerial, tmPhone, androidId;
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "" + tm.getSimSerialNumber();
    androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);

    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    String uniqueId = deviceUuid.toString();
    if (BuildConfig.DEBUG)
        Log.d(TAG, "uuid=" + uniqueId);

    return uniqueId;
}
 
Example 8
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 9
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 10
Source File: DroippUtil.java    From lockit with Apache License 2.0 5 votes vote down vote up
public static String deviceId(Context context) {
    final TelephonyManager tm =
            (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    final String tmDevice, tmSerial, androidId;
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "" + tm.getSimSerialNumber();
    androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(),
            android.provider.Settings.Secure.ANDROID_ID);

    UUID deviceUuid = new UUID(androidId.hashCode(),
            ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    return deviceUuid.toString();
}
 
Example 11
Source File: SimChangeReceiver.java    From MobileGuard with MIT License 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    // check all services when system startup
    ServiceManagerEngine.checkAndAutoStart(context);

    // check the service is on
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    boolean phoneSafe = sp.getBoolean(Constant.KEY_CB_PHONE_SAFE, false);
    boolean bindSim = sp.getBoolean(Constant.KEY_CB_BIND_SIM, false);
    // haven't start bind sim or phone safe service
    if(!bindSim || !phoneSafe) {
        return;
    }
    // get old sim info
    String oldSimInfo = ConfigUtils.getString(context, Constant.KEY_SIM_INFO, "");
    // get current sim info
    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String currentSimInfo = manager.getSimSerialNumber();
    // the two sim info equal
    if(currentSimInfo.equals(oldSimInfo)) {
        return;
    }
    // send alarm info to safe phone number
    String safePhone = ConfigUtils.getString(context, Constant.KEY_SAFE_PHONE, "");
    if(TextUtils.isEmpty(safePhone)) {
        Log.e(TAG, "safe phone is empty");
        return;
    }
    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(safePhone, null, context.getString(R.string.tips_sim_changed), null, null);
    System.out.println("success send a sms to " + safePhone + ":\n" + context.getString(R.string.tips_sim_changed));
}
 
Example 12
Source File: PhoneSafeFragment.java    From MobileGuard with MIT License 5 votes vote down vote up
private void getSimInfoAndSave(Context context) {
    // get sim info
    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String simSerialNumber = manager.getSimSerialNumber();
    // save sim info
    ConfigUtils.putString(context, Constant.KEY_SIM_INFO, simSerialNumber);
}
 
Example 13
Source File: PhoneSafeSetting1Activity.java    From MobileGuard with MIT License 5 votes vote down vote up
/**
 * save the safe phone and sim info
 */
private void saveConfig() {
    // get safe phone
    String safePhone = etSafePhone.getText().toString().trim();
    if(TextUtils.isEmpty(safePhone)) {
        Toast.makeText(this, R.string.safe_phone_can_not_be_empty, Toast.LENGTH_SHORT).show();
        return;
    }

    // save safe phone to file
    ConfigUtils.putString(this, Constant.KEY_SAFE_PHONE, safePhone);

    // get sim info
    TelephonyManager manager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    String simSerialNumber = manager.getSimSerialNumber();
    // save sim info
    ConfigUtils.putString(this, Constant.KEY_SIM_INFO, simSerialNumber);

    // set service on in config
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor edit = sp.edit();
    edit.putBoolean(Constant.KEY_CB_PHONE_SAFE, true)
            .putBoolean(Constant.KEY_CB_BIND_SIM, true)
            .commit();
    // start the service
    ActivityManagerUtils.checkService(this, PhoneSafeService.class);

    // goto PhoneSafeActivity
    startActivity(PhoneSafeActivity.class);
    finish();
}
 
Example 14
Source File: DeviceIdentifier.java    From android-device-identification with Apache License 2.0 5 votes vote down vote up
/**
 * getSimSerialNumber() function Returns the unique sim card ID,
 * for example, the SIM Card ID for a GSM phone.
 */
@Override
String getId(Context ctx) {
    final TelephonyManager tm = (TelephonyManager) ctx
            .getSystemService(Context.TELEPHONY_SERVICE);
    if (tm == null) {
        w("Telephony Manager not available");
        return null;
    }
    assertPermission(ctx, permission.READ_PHONE_STATE);
    return tm.getSimSerialNumber();
}
 
Example 15
Source File: Utils.java    From BatteryFu with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generate a unique ID for this device. TODO - should this id change when
 * device is reset, SIM card swopped, or google user account changed? Also,
 * can we do this without requiring Telephony as tablets don't have this?
 * 
 * @param context
 * @return
 */
public static String getDeviceIdOld(Context context) {
   final TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);

   // String imsi = tm.getSubscriberId();
   // String imei = tm.getDeviceId();

   String tmDevice, tmSerial, tmPhone, androidId;
   tmDevice = "" + tm.getDeviceId();
   tmSerial = "" + tm.getSimSerialNumber();
   androidId = ""
            + android.provider.Settings.Secure.getString(context.getContentResolver(),
                     android.provider.Settings.Secure.ANDROID_ID);
   if ("9774d56d682e549c".equalsIgnoreCase(androidId)) {
      // Android 2.2 bug, use wifi mac address rather
      try {
         WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
         if (wm.getConnectionInfo().getMacAddress() != null) {
            androidId = wm.getConnectionInfo().getMacAddress();
         }
      } catch (Exception e) {
         // wifi off or no permission
      }
   }

   UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32)
            | tmSerial.hashCode());
   return deviceUuid.toString();
}
 
Example 16
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 17
Source File: BasicInfoUtils.java    From QPM with Apache License 2.0 4 votes vote down vote up
@SuppressLint("MissingPermission")
private static String getOCCID() {
    TelephonyManager tm =
            (TelephonyManager) Utils.getApp().getSystemService(Context.TELEPHONY_SERVICE);
    return tm != null ? tm.getSimSerialNumber() : null;
}
 
Example 18
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();
}
 
Example 19
Source File: RxDeviceTool.java    From RxTools-master with Apache License 2.0 2 votes vote down vote up
/**
 * 获取SIM卡的序列号
 *
 * @param context
 * @return
 */
public static String getSimSerialNumber(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    return tm.getSimSerialNumber();
}
 
Example 20
Source File: UID.java    From cordova-plugin-uid with MIT License 2 votes vote down vote up
/**
 * Get the sim's Integrated Circuit Card Identifier (ICCID).
 *
 * @param context The context of the main Activity.
 * @return
 */
public String getIccid(Context context) {
	final TelephonyManager mTelephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
	String iccid = mTelephony.getSimSerialNumber();
	return iccid;
}