Search in sources :

Example 61 with SubscriptionInfo

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

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(getSubscriptionDisplayName(sir));
        // 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 62 with SubscriptionInfo

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

the class SimSettings method updateCallValues.

private void updateCallValues() {
    final Preference simPref = findPreference(KEY_CALLS);
    final SubscriptionInfo sir = mSubscriptionManager.getDefaultVoiceSubscriptionInfo();
    final TelecomManager telecomManager = TelecomManager.from(mContext);
    final PhoneAccountHandle phoneAccount = telecomManager.getUserSelectedOutgoingPhoneAccount();
    final List<PhoneAccountHandle> allPhoneAccounts = telecomManager.getCallCapablePhoneAccounts();
    simPref.setTitle(R.string.calls_title);
    if (sir != null) {
        simPref.setSummary(phoneAccount == null ? mContext.getResources().getString(R.string.sim_calls_ask_first_prefs_title) : getSubscriptionDisplayName(sir));
        // Enable data preference in msim mode and call state idle
        simPref.setEnabled(allPhoneAccounts.size() > 1);
    } else {
        simPref.setSummary(phoneAccount == null ? mContext.getResources().getString(R.string.sim_calls_ask_first_prefs_title) : (String) telecomManager.getPhoneAccount(phoneAccount).getLabel());
        simPref.setEnabled(allPhoneAccounts.size() > 1);
    }
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) Preference(android.support.v7.preference.Preference) SubscriptionInfo(android.telephony.SubscriptionInfo) TelecomManager(android.telecom.TelecomManager)

Example 63 with SubscriptionInfo

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

the class DataUsageList method updateBody.

/**
 * Update body content based on current tab. Loads
 * {@link NetworkStatsHistory} and {@link NetworkPolicy} from system, and
 * binds them to visible controls.
 */
private void updateBody() {
    if (!isAdded())
        return;
    final Context context = getActivity();
    // kick off loader for network history
    // TODO: consider chaining two loaders together instead of reloading
    // network history when showing app detail.
    getLoaderManager().restartLoader(LOADER_CHART_DATA, ChartDataLoader.buildArgs(mTemplate, null), mChartDataCallbacks);
    // detail mode can change visible menus, invalidate
    getActivity().invalidateOptionsMenu();
    int seriesColor = context.getColor(R.color.sim_noitification);
    if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
        final SubscriptionInfo sir = services.mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
        if (sir != null) {
            seriesColor = sir.getIconTint();
        }
    }
    final int secondaryColor = Color.argb(127, Color.red(seriesColor), Color.green(seriesColor), Color.blue(seriesColor));
    mChart.setColors(seriesColor, secondaryColor);
}
Also used : Context(android.content.Context) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 64 with SubscriptionInfo

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

the class DataUsageList method hasReadyMobileRadio.

/**
 * Test if device has a mobile data radio with SIM in ready state.
 */
public static boolean hasReadyMobileRadio(Context context) {
    if (DataUsageUtils.TEST_RADIOS) {
        return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile");
    }
    final ConnectivityManager conn = ConnectivityManager.from(context);
    final TelephonyManager tele = TelephonyManager.from(context);
    final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(context).getActiveSubscriptionInfoList();
    // No activated Subscriptions
    if (subInfoList == null) {
        if (LOGD)
            Log.d(TAG, "hasReadyMobileRadio: subInfoList=null");
        return false;
    }
    // require both supported network and ready SIM
    boolean isReady = true;
    for (SubscriptionInfo subInfo : subInfoList) {
        isReady = isReady & tele.getSimState(subInfo.getSimSlotIndex()) == SIM_STATE_READY;
        if (LOGD)
            Log.d(TAG, "hasReadyMobileRadio: subInfo=" + subInfo);
    }
    boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady;
    if (LOGD) {
        Log.d(TAG, "hasReadyMobileRadio:" + " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE) + " isReady=" + isReady);
    }
    return retVal;
}
Also used : TelephonyManager(android.telephony.TelephonyManager) ConnectivityManager(android.net.ConnectivityManager) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 65 with SubscriptionInfo

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

the class DataUsageSummary method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    final Context context = getContext();
    NetworkPolicyManager policyManager = NetworkPolicyManager.from(context);
    mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    mPolicyEditor = new NetworkPolicyEditor(policyManager);
    boolean hasMobileData = DataUsageUtils.hasMobileData(context);
    mDataUsageController = new DataUsageController(context);
    mDataInfoController = new DataUsageInfoController();
    addPreferencesFromResource(R.xml.data_usage);
    int defaultSubId = DataUsageUtils.getDefaultSubscriptionId(context);
    if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
        hasMobileData = false;
    }
    mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, defaultSubId);
    mSummaryPreference = (SummaryPreference) findPreference(KEY_STATUS_HEADER);
    if (!hasMobileData || !isAdmin()) {
        removePreference(KEY_RESTRICT_BACKGROUND);
    }
    if (hasMobileData) {
        mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
        List<SubscriptionInfo> subscriptions = services.mSubscriptionManager.getActiveSubscriptionInfoList();
        if (subscriptions == null || subscriptions.size() == 0) {
            addMobileSection(defaultSubId);
        }
        for (int i = 0; subscriptions != null && i < subscriptions.size(); i++) {
            SubscriptionInfo subInfo = subscriptions.get(i);
            if (subscriptions.size() > 1) {
                addMobileSection(subInfo.getSubscriptionId(), subInfo);
            } else {
                addMobileSection(subInfo.getSubscriptionId());
            }
        }
        mSummaryPreference.setSelectable(true);
    } else {
        removePreference(KEY_LIMIT_SUMMARY);
        mSummaryPreference.setSelectable(false);
    }
    boolean hasWifiRadio = DataUsageUtils.hasWifiRadio(context);
    if (hasWifiRadio) {
        addWifiSection();
    }
    if (hasEthernet(context)) {
        addEthernetSection();
    }
    mDataUsageTemplate = hasMobileData ? R.string.cell_data_template : hasWifiRadio ? R.string.wifi_data_template : R.string.ethernet_data_template;
    setHasOptionsMenu(true);
}
Also used : Context(android.content.Context) NetworkPolicyEditor(com.android.settingslib.NetworkPolicyEditor) NetworkPolicyManager(android.net.NetworkPolicyManager) DataUsageController(com.android.settingslib.net.DataUsageController) SubscriptionInfo(android.telephony.SubscriptionInfo)

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