Search in sources :

Example 46 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by LineageOS.

the class SimSettings method updateCellularDataValues.

private void updateCellularDataValues() {
    final Preference simPref = findPreference(KEY_CELLULAR_DATA);
    final SubscriptionInfo sir = mSubscriptionManager.getDefaultDataSubscriptionInfo();
    simPref.setTitle(R.string.cellular_data_title);
    if (DBG)
        log("[updateCellularDataValues] mSubInfoList=" + mSubInfoList);
    boolean callStateIdle = isCallStateIdle();
    final boolean ecbMode = SystemProperties.getBoolean(TelephonyProperties.PROPERTY_INECM_MODE, false);
    if (sir != null) {
        simPref.setSummary(sir.getDisplayName());
        // Enable data preference in msim mode and call state idle
        simPref.setEnabled((mSelectableSubInfos.size() > 1) && callStateIdle && !ecbMode);
    } else if (sir == null) {
        simPref.setSummary(R.string.sim_selection_required_pref);
        // Enable data preference in msim mode and call state idle
        simPref.setEnabled((mSelectableSubInfos.size() >= 1) && callStateIdle && !ecbMode);
    }
}
Also used : Preference(android.support.v7.preference.Preference) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 47 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by LineageOS.

the class SimSettings method updateSubscriptions.

private void updateSubscriptions() {
    mSubInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
    for (int i = 0; i < mNumSlots; ++i) {
        Preference pref = mSimCards.findPreference("sim" + i);
        if (pref instanceof SimPreference) {
            mSimCards.removePreference(pref);
        }
    }
    mAvailableSubInfos.clear();
    mSelectableSubInfos.clear();
    for (int i = 0; i < mNumSlots; ++i) {
        final SubscriptionInfo sir = mSubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(i);
        SimPreference simPreference = new SimEnablerPreference(getPrefContext(), sir, i);
        simPreference.setOrder(i - mNumSlots);
        mSimCards.addPreference(simPreference);
        mAvailableSubInfos.add(sir);
        if (sir != null && mUiccProvisionStatus[i] == PROVISIONED) {
            mSelectableSubInfos.add(sir);
        }
    }
    updateAllOptions();
}
Also used : Preference(android.support.v7.preference.Preference) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 48 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by LineageOS.

the class SimSettings method updateSmsValues.

private void updateSmsValues() {
    final Preference simPref = findPreference(KEY_SMS);
    final SubscriptionInfo sir = mSubscriptionManager.getDefaultSmsSubscriptionInfo();
    simPref.setTitle(R.string.sms_messages_title);
    if (DBG)
        log("[updateSmsValues] mSubInfoList=" + mSubInfoList);
    if (sir != null) {
        simPref.setSummary(sir.getDisplayName());
        simPref.setEnabled(mSelectableSubInfos.size() > 1);
    } else if (sir == null) {
        simPref.setSummary(R.string.sim_selection_required_pref);
        simPref.setEnabled(mSelectableSubInfos.size() >= 1);
    }
}
Also used : Preference(android.support.v7.preference.Preference) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 49 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by LineageOS.

the class DataUsageUtils method getDefaultSubscriptionId.

/**
 * Returns the default subscription if available else returns
 * SubscriptionManager#INVALID_SUBSCRIPTION_ID
 */
public static int getDefaultSubscriptionId(Context context) {
    SubscriptionManager subManager = SubscriptionManager.from(context);
    if (subManager == null) {
        return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    }
    SubscriptionInfo subscriptionInfo = subManager.getDefaultDataSubscriptionInfo();
    if (subscriptionInfo == null) {
        List<SubscriptionInfo> list = subManager.getAllSubscriptionInfoList();
        if (list.size() == 0) {
            return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
        }
        subscriptionInfo = list.get(0);
    }
    return subscriptionInfo.getSubscriptionId();
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager)

Example 50 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by omnirom.

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)

Aggregations

SubscriptionInfo (android.telephony.SubscriptionInfo)335 TelephonyManager (android.telephony.TelephonyManager)64 SubscriptionManager (android.telephony.SubscriptionManager)63 ArrayList (java.util.ArrayList)53 Test (org.junit.Test)49 Context (android.content.Context)38 Intent (android.content.Intent)38 Preference (android.support.v7.preference.Preference)27 PhoneAccountHandle (android.telecom.PhoneAccountHandle)18 IntentFilter (android.content.IntentFilter)16 Resources (android.content.res.Resources)16 ConnectivityManager (android.net.ConnectivityManager)15 Preference (androidx.preference.Preference)15 AlertDialog (android.app.AlertDialog)14 DialogInterface (android.content.DialogInterface)14 DataUsageController (com.android.settingslib.net.DataUsageController)14 View (android.view.View)13 PhoneAccount (android.telecom.PhoneAccount)11 TelecomManager (android.telecom.TelecomManager)11 PendingIntent (android.app.PendingIntent)9