List of usage examples for android.telephony SubscriptionManager getDefaultVoiceSubscriptionId
public static int getDefaultVoiceSubscriptionId()
From source file:android_network.hetnet.vpn_service.Util.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1) public static String getSubscriptionInfo(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) return "Not supported"; if (!hasPhoneStatePermission(context)) return "No permission"; StringBuilder sb = new StringBuilder(); SubscriptionManager sm = SubscriptionManager.from(context); sb.append("Slots ").append(sm.getActiveSubscriptionInfoCount()).append('/') .append(sm.getActiveSubscriptionInfoCountMax()).append("\r\n"); int dataid = -1; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) dataid = sm.getDefaultDataSubscriptionId(); int voiceid = -1; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) voiceid = sm.getDefaultVoiceSubscriptionId(); List<SubscriptionInfo> subscriptions = sm.getActiveSubscriptionInfoList(); if (subscriptions != null) for (SubscriptionInfo si : subscriptions) sb.append("SIM ").append(si.getSimSlotIndex() + 1).append('/').append(si.getSubscriptionId()) .append(' ').append(si.getCountryIso()).append('/').append(si.getMcc()).append(si.getMnc()) .append(' ').append(si.getCarrierName()) .append(si.getSubscriptionId() == dataid ? " D" : "") .append(si.getSubscriptionId() == voiceid ? " V" : "") .append(si.getDataRoaming() == SubscriptionManager.DATA_ROAMING_ENABLE ? " R" : "") .append("\r\n"); if (sb.length() > 2) sb.setLength(sb.length() - 2);/*from w ww .j av a2 s . c o m*/ return sb.toString(); }