Search in sources :

Example 71 with SubscriptionInfo

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

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

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

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

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

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

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

the class CellDataPreference method performClick.

@Override
protected void performClick(View view) {
    final Context context = getContext();
    FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(context, MetricsEvent.ACTION_CELL_DATA_TOGGLE, !mChecked);
    final SubscriptionInfo currentSir = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
    final SubscriptionInfo nextSir = mSubscriptionManager.getDefaultDataSubscriptionInfo();
    if (mChecked) {
        // the pop-up.
        if (!Utils.showSimCardTile(getContext()) || (nextSir != null && currentSir != null && currentSir.getSubscriptionId() == nextSir.getSubscriptionId())) {
            setMobileDataEnabled(false);
            if (nextSir != null && currentSir != null && currentSir.getSubscriptionId() == nextSir.getSubscriptionId()) {
                disableDataForOtherSubscriptions(mSubId);
            }
            return;
        }
        // disabling data; show confirmation dialog which eventually
        // calls setMobileDataEnabled() once user confirms.
        mMultiSimDialog = false;
        super.performClick(view);
    } else {
        // If we are showing the Sim Card tile then we are a Multi-Sim device.
        if (Utils.showSimCardTile(getContext())) {
            mMultiSimDialog = true;
            if (nextSir != null && currentSir != null && currentSir.getSubscriptionId() == nextSir.getSubscriptionId()) {
                setMobileDataEnabled(true);
                disableDataForOtherSubscriptions(mSubId);
                return;
            }
            super.performClick(view);
        } else {
            setMobileDataEnabled(true);
        }
    }
}
Also used : Context(android.content.Context) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 75 with SubscriptionInfo

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

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