use of android.telephony.SubscriptionManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimDialogActivity method setDefaultSmsSubId.
private static void setDefaultSmsSubId(final Context context, final int subId) {
final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
subscriptionManager.setDefaultSmsSubId(subId);
}
use of android.telephony.SubscriptionManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimDialogActivity method setDefaultDataSubId.
private static void setDefaultDataSubId(final Context context, final int subId) {
final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
subscriptionManager.setDefaultDataSubId(subId);
Toast.makeText(context, R.string.data_switch_started, Toast.LENGTH_LONG).show();
}
use of android.telephony.SubscriptionManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsDumpService method dumpDataUsage.
private JSONObject dumpDataUsage() throws JSONException {
JSONObject obj = new JSONObject();
DataUsageController controller = new DataUsageController(this);
ConnectivityManager connectivityManager = getSystemService(ConnectivityManager.class);
SubscriptionManager manager = SubscriptionManager.from(this);
TelephonyManager telephonyManager = TelephonyManager.from(this);
if (connectivityManager.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) {
JSONArray array = new JSONArray();
for (SubscriptionInfo info : manager.getAllSubscriptionInfoList()) {
NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(telephonyManager.getSubscriberId(info.getSubscriptionId()));
final JSONObject usage = dumpDataUsage(mobileAll, controller);
usage.put("subId", info.getSubscriptionId());
array.put(usage);
}
obj.put("cell", array);
}
if (connectivityManager.isNetworkSupported(ConnectivityManager.TYPE_WIFI)) {
obj.put("wifi", dumpDataUsage(NetworkTemplate.buildTemplateWifiWildcard(), controller));
}
if (connectivityManager.isNetworkSupported(ConnectivityManager.TYPE_ETHERNET)) {
obj.put("ethernet", dumpDataUsage(NetworkTemplate.buildTemplateEthernet(), controller));
}
return obj;
}
use of android.telephony.SubscriptionManager in project kcanotify by antest1.
the class Util method getSubscriptionInfo.
@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);
return sb.toString();
}
use of android.telephony.SubscriptionManager in project android_frameworks_base by crdroidandroid.
the class NetworkPolicyManagerService method ensureActiveMobilePolicyNL.
/**
* Once any {@link #mNetworkPolicy} are loaded from disk, ensure that we
* have at least a default mobile policy defined.
*/
private void ensureActiveMobilePolicyNL() {
if (LOGV)
Slog.v(TAG, "ensureActiveMobilePolicyNL()");
if (mSuppressDefaultPolicy)
return;
final TelephonyManager tele = TelephonyManager.from(mContext);
final SubscriptionManager sub = SubscriptionManager.from(mContext);
final int[] subIds = sub.getActiveSubscriptionIdList();
for (int subId : subIds) {
final String subscriberId = tele.getSubscriberId(subId);
ensureActiveMobilePolicyNL(subscriberId);
}
}
Aggregations