Search in sources :

Example 96 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project platform_packages_apps_Settings by BlissRoms.

the class ResetNetwork method establishInitialState.

/**
 * In its initial state, the activity presents a button for the user to
 * click in order to initiate a confirmation sequence.  This method is
 * called from various other points in the code to reset the activity to
 * this base state.
 *
 * <p>Reinflating views from resources is expensive and prevents us from
 * caching widget pointers, so we use a single-inflate pattern:  we lazy-
 * inflate each view, caching all of the widget pointers we'll need at the
 * time, then simply reuse the inflated views directly whenever we need
 * to change contents.
 */
private void establishInitialState() {
    mSubscriptionSpinner = (Spinner) mContentView.findViewById(R.id.reset_network_subscription);
    mSubscriptions = SubscriptionManager.from(getActivity()).getActiveSubscriptionInfoList();
    if (mSubscriptions != null && mSubscriptions.size() > 0) {
        // Get the default subscription in the order of data, voice, sms, first up.
        int defaultSubscription = SubscriptionManager.getDefaultDataSubscriptionId();
        if (!SubscriptionManager.isUsableSubIdValue(defaultSubscription)) {
            defaultSubscription = SubscriptionManager.getDefaultVoiceSubscriptionId();
        }
        if (!SubscriptionManager.isUsableSubIdValue(defaultSubscription)) {
            defaultSubscription = SubscriptionManager.getDefaultSmsSubscriptionId();
        }
        if (!SubscriptionManager.isUsableSubIdValue(defaultSubscription)) {
            defaultSubscription = SubscriptionManager.getDefaultSubscriptionId();
        }
        int selectedIndex = 0;
        int size = mSubscriptions.size();
        List<String> subscriptionNames = new ArrayList<>();
        for (SubscriptionInfo record : mSubscriptions) {
            if (record.getSubscriptionId() == defaultSubscription) {
                // Set the first selected value to the default
                selectedIndex = subscriptionNames.size();
            }
            String name = record.getDisplayName().toString();
            if (TextUtils.isEmpty(name)) {
                name = record.getNumber();
            }
            if (TextUtils.isEmpty(name)) {
                name = record.getCarrierName().toString();
            }
            if (TextUtils.isEmpty(name)) {
                name = String.format("MCC:%s MNC:%s Slot:%s Id:%s", record.getMcc(), record.getMnc(), record.getSimSlotIndex(), record.getSubscriptionId());
            }
            subscriptionNames.add(name);
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, subscriptionNames);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mSubscriptionSpinner.setAdapter(adapter);
        mSubscriptionSpinner.setSelection(selectedIndex);
        if (mSubscriptions.size() > 1) {
            mSubscriptionSpinner.setVisibility(View.VISIBLE);
        } else {
            mSubscriptionSpinner.setVisibility(View.INVISIBLE);
        }
    } else {
        mSubscriptionSpinner.setVisibility(View.INVISIBLE);
    }
    mInitiateButton = (Button) mContentView.findViewById(R.id.initiate_reset_network);
    mInitiateButton.setOnClickListener(mInitiateListener);
}
Also used : ArrayList(java.util.ArrayList) SubscriptionInfo(android.telephony.SubscriptionInfo) ArrayAdapter(android.widget.ArrayAdapter)

Example 97 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project platform_packages_apps_Settings by BlissRoms.

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

use of android.telephony.SubscriptionInfo in project platform_packages_apps_Settings by BlissRoms.

the class SecuritySettings method isSimReady.

/* Return true if a SIM is ready for locking.
     * TODO: consider adding to TelephonyManager or SubscritpionManasger.
     */
private boolean isSimReady() {
    int simState = TelephonyManager.SIM_STATE_UNKNOWN;
    final List<SubscriptionInfo> subInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
    if (subInfoList != null) {
        for (SubscriptionInfo subInfo : subInfoList) {
            simState = TelephonyManager.getDefault().getSimState(subInfo.getSimSlotIndex());
            if ((simState != TelephonyManager.SIM_STATE_ABSENT) && (simState != TelephonyManager.SIM_STATE_UNKNOWN)) {
                return true;
            }
        }
    }
    return false;
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 99 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project platform_packages_apps_Settings by BlissRoms.

the class IccLockSettings method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final TelephonyManager tm = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
    final int numSims = tm.getSimCount();
    if (numSims > 1) {
        View view = inflater.inflate(R.layout.icc_lock_tabs, container, false);
        final ViewGroup prefs_container = (ViewGroup) view.findViewById(R.id.prefs_container);
        Utils.prepareCustomPreferencesList(container, view, prefs_container, false);
        View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState);
        prefs_container.addView(prefs);
        mTabHost = (TabHost) view.findViewById(android.R.id.tabhost);
        mTabWidget = (TabWidget) view.findViewById(android.R.id.tabs);
        mListView = (ListView) view.findViewById(android.R.id.list);
        mTabHost.setup();
        mTabHost.setOnTabChangedListener(mTabListener);
        mTabHost.clearAllTabs();
        SubscriptionManager sm = SubscriptionManager.from(getContext());
        for (int i = 0; i < numSims; ++i) {
            final SubscriptionInfo subInfo = sm.getActiveSubscriptionInfoForSimSlotIndex(i);
            mTabHost.addTab(buildTabSpec(String.valueOf(i), String.valueOf(subInfo == null ? getContext().getString(R.string.sim_editor_title, i + 1) : subInfo.getDisplayName())));
        }
        final SubscriptionInfo sir = sm.getActiveSubscriptionInfoForSimSlotIndex(0);
        mPhone = (sir == null) ? null : PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId()));
        return view;
    } else {
        mPhone = PhoneFactory.getDefaultPhone();
        return super.onCreateView(inflater, container, savedInstanceState);
    }
}
Also used : TelephonyManager(android.telephony.TelephonyManager) ViewGroup(android.view.ViewGroup) SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager) View(android.view.View) ListView(android.widget.ListView)

Example 100 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project platform_packages_apps_Settings by BlissRoms.

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)

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