Search in sources :

Example 51 with SubscriptionInfo

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

the class SecuritySettings method isSimIccReady.

/* Return true if a there is a Slot that has Icc.
     */
private boolean isSimIccReady() {
    TelephonyManager tm = TelephonyManager.getDefault();
    final List<SubscriptionInfo> subInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
    if (subInfoList != null) {
        for (SubscriptionInfo subInfo : subInfoList) {
            if (tm.hasIccCard(subInfo.getSimSlotIndex())) {
                return true;
            }
        }
    }
    return false;
}
Also used : TelephonyManager(android.telephony.TelephonyManager) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 52 with SubscriptionInfo

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

the class CellDataPreference method showMultiSimDialog.

private void showMultiSimDialog(AlertDialog.Builder builder, DialogInterface.OnClickListener listener) {
    final SubscriptionInfo currentSir = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
    final SubscriptionInfo nextSir = mSubscriptionManager.getDefaultDataSubscriptionInfo();
    final String previousName = (nextSir == null) ? getContext().getResources().getString(R.string.sim_selection_required_pref) : nextSir.getDisplayName().toString();
    builder.setTitle(R.string.sim_change_data_title);
    builder.setMessage(getContext().getString(R.string.sim_change_data_message, String.valueOf(currentSir != null ? currentSir.getDisplayName() : null), previousName));
    builder.setPositiveButton(R.string.okay, listener);
    builder.setNegativeButton(R.string.cancel, null);
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 53 with SubscriptionInfo

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

the class DataPlanUsageSummary method addDataPlanSection.

private void addDataPlanSection(int defaultSubId) {
    Context context = getPrefContext();
    addPreferencesFromResource(R.xml.data_plan_usage);
    PreferenceScreen screen = getPreferenceScreen();
    screen.setTitle(context.getString(R.string.data_usage_summary_title));
    PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference(KEY_DATA_PLAN_USAGE);
    screen.addPreference(preferenceCategory);
    Preference dataPlansSyncTimePreference = new Preference(context);
    dataPlansSyncTimePreference.setLayoutResource(R.layout.data_plans_sync_time_preference);
    dataPlansSyncTimePreference.setTitle(MockDataPlanUsage.SYNC_TIME);
    preferenceCategory.addPreference(dataPlansSyncTimePreference);
    mDataPlanSummaryPreferenceList = new ArrayList<>(MockDataPlanUsage.DATA_PLAN_USAGES.length);
    for (int i = 0; i < MockDataPlanUsage.DATA_PLAN_USAGES.length; i++) {
        DataPlanSummaryPreference dataPlanSummaryPreference = new DataPlanSummaryPreference(context);
        dataPlanSummaryPreference.setKey(KEY_STATUS_HEADER + (i + 1));
        mDataPlanSummaryPreferenceList.add(dataPlanSummaryPreference);
        preferenceCategory.addPreference(dataPlanSummaryPreference);
    }
    Preference preference = new Preference(context);
    preference.setLayoutResource(R.layout.manage_data_plans_preference);
    preferenceCategory.addPreference(preference);
    setPreferenceScreen(screen);
    mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
    List<SubscriptionInfo> subscriptions = services.mSubscriptionManager.getActiveSubscriptionInfoList();
    if (subscriptions == null || subscriptions.isEmpty()) {
        addMobileSection(defaultSubId);
    }
    for (int i = 0, subscriptionsSize = subscriptions != null ? subscriptions.size() : 0; i < subscriptionsSize; i++) {
        SubscriptionInfo subInfo = subscriptions.get(i);
        if (subscriptionsSize > 1) {
            addMobileSection(subInfo.getSubscriptionId(), subInfo);
        } else {
            addMobileSection(subInfo.getSubscriptionId());
        }
    }
}
Also used : Context(android.content.Context) PreferenceScreen(android.support.v7.preference.PreferenceScreen) PreferenceCategory(android.support.v7.preference.PreferenceCategory) Preference(android.support.v7.preference.Preference) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 54 with SubscriptionInfo

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

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 55 with SubscriptionInfo

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

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