Search in sources :

Example 11 with SubscriptionManager

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);
}
Also used : SubscriptionManager(android.telephony.SubscriptionManager)

Example 12 with SubscriptionManager

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();
}
Also used : SubscriptionManager(android.telephony.SubscriptionManager)

Example 13 with SubscriptionManager

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;
}
Also used : NetworkTemplate(android.net.NetworkTemplate) JSONObject(org.json.JSONObject) TelephonyManager(android.telephony.TelephonyManager) ConnectivityManager(android.net.ConnectivityManager) DataUsageController(com.android.settingslib.net.DataUsageController) JSONArray(org.json.JSONArray) SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager)

Example 14 with SubscriptionManager

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();
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager) TargetApi(android.annotation.TargetApi)

Example 15 with SubscriptionManager

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);
    }
}
Also used : TelephonyManager(android.telephony.TelephonyManager) SubscriptionManager(android.telephony.SubscriptionManager) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Aggregations

SubscriptionManager (android.telephony.SubscriptionManager)32 TelephonyManager (android.telephony.TelephonyManager)20 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)15 SubscriptionInfo (android.telephony.SubscriptionInfo)13 NetworkIdentity (android.net.NetworkIdentity)10 ContentResolver (android.content.ContentResolver)4 Intent (android.content.Intent)4 RemoteException (android.os.RemoteException)4 PersistentDataBlockManager (android.service.persistentdata.PersistentDataBlockManager)4 TargetApi (android.annotation.TargetApi)2 Preference (android.support.v7.preference.Preference)2 PreferenceScreen (android.support.v7.preference.PreferenceScreen)2 AlertDialog (android.app.AlertDialog)1 Dialog (android.app.Dialog)1 PendingIntent (android.app.PendingIntent)1 DialogInterface (android.content.DialogInterface)1 IntentFilter (android.content.IntentFilter)1 SharedPreferences (android.content.SharedPreferences)1 ConnectivityManager (android.net.ConnectivityManager)1 NetworkTemplate (android.net.NetworkTemplate)1