Example usage for android.telephony SubscriptionInfo getDisplayName

List of usage examples for android.telephony SubscriptionInfo getDisplayName

Introduction

In this page you can find the example usage for android.telephony SubscriptionInfo getDisplayName.

Prototype

public CharSequence getDisplayName() 

Source Link

Usage

From source file:com.android.messaging.datamodel.ParticipantRefresh.java

/**
 * Ensure that there is a self participant corresponding to every active SIM. Also, ensure
 * that any other older SIM self participants are marked as inactive.
 *//* ww  w.j  a  v a  2  s .com*/
private static void refreshSelfParticipantList() {
    if (!OsUtil.isAtLeastL_MR1()) {
        return;
    }

    final DatabaseWrapper db = DataModel.get().getDatabase();

    final List<SubscriptionInfo> subInfoRecords = PhoneUtils.getDefault().toLMr1()
            .getActiveSubscriptionInfoList();
    final ArrayMap<Integer, SubscriptionInfo> activeSubscriptionIdToRecordMap = new ArrayMap<Integer, SubscriptionInfo>();
    db.beginTransaction();
    final Set<Integer> existingSubIds = getExistingSubIds();

    try {
        if (subInfoRecords != null) {
            for (final SubscriptionInfo subInfoRecord : subInfoRecords) {
                final int subId = subInfoRecord.getSubscriptionId();
                // If its a new subscription, add it to the database.
                if (!existingSubIds.contains(subId)) {
                    db.execSQL(DatabaseHelper.getCreateSelfParticipantSql(subId));
                    // Add it to the local set to guard against duplicated entries returned
                    // by subscription manager.
                    existingSubIds.add(subId);
                }
                activeSubscriptionIdToRecordMap.put(subId, subInfoRecord);

                if (subId == PhoneUtils.getDefault().getDefaultSmsSubscriptionId()) {
                    // This is the system default subscription, so update the default self.
                    activeSubscriptionIdToRecordMap.put(ParticipantData.DEFAULT_SELF_SUB_ID, subInfoRecord);
                }
            }
        }

        // For subscriptions already in the database, refresh ParticipantColumns.SIM_SLOT_ID.
        for (final Integer subId : activeSubscriptionIdToRecordMap.keySet()) {
            final SubscriptionInfo record = activeSubscriptionIdToRecordMap.get(subId);
            final String displayName = DatabaseUtils.sqlEscapeString(record.getDisplayName().toString());
            db.execSQL(getUpdateSelfParticipantSubscriptionInfoSql(record.getSimSlotIndex(),
                    record.getIconTint(), displayName, ParticipantColumns.SUB_ID + " = " + subId));
        }
        db.execSQL(getUpdateSelfParticipantSubscriptionInfoSql(ParticipantData.INVALID_SLOT_ID,
                Color.TRANSPARENT, "''", ParticipantColumns.SUB_ID + " NOT IN ("
                        + Joiner.on(", ").join(activeSubscriptionIdToRecordMap.keySet()) + ")"));
        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
    }
    // Fix up conversation self ids by reverting to default self for conversations whose self
    // ids are no longer active.
    refreshConversationSelfIds();
}

From source file:com.android.settings.datausage.CellDataPreference.java

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);
}

From source file:com.android.mms.ui.MessageUtils.java

public static String getMainCardDisplayName() {
    String mainSubDisplayName = "";
    Context ct = MmsApp.getApplication();
    int mainSubId = (int) Settings.System.getLong(ct.getContentResolver(), Settings.System.SMS_SIM_SETTING,
            Settings.System.DEFAULT_SIM_NOT_SET);
    if (mainSubId != Settings.System.DEFAULT_SIM_SETTING_ALWAYS_ASK
            && mainSubId != Settings.System.DEFAULT_SIM_NOT_SET) {
        SubscriptionInfo info = SubscriptionManager.from(MmsApp.getApplication())
                .getActiveSubscriptionInfo(mainSubId);
        mainSubDisplayName = info.getDisplayName().toString();
    } else {//from   ww  w.  jav  a  2s  . c om
        SubscriptionInfo info = SubscriptionManager.from(MmsApp.getApplication())
                .getActiveSubscriptionInfo(mainSubId);
        if (info != null && info.getSubscriptionId() > 0) {
            mainSubDisplayName = info.getDisplayName().toString();
        } else {
            info = SubscriptionManager.from(MmsApp.getApplication()).getActiveSubscriptionInfo(mainSubId);
            if (info != null && info.getSubscriptionId() > 0) {
                mainSubDisplayName = info.getDisplayName().toString();
            } else {
                MmsLog.e(TAG, "error to get main sub display name");
            }
        }
    }
    return mainSubDisplayName;
}

From source file:com.android.mms.ui.MessageUtils.java

public static void setSubIconAndLabel(int subId, String subName, TextView subView) {
    Log.i(TAG, "setSubIconAndLabel subId=" + subId);
    int textColor = 0;
    if (subView == null) {
        return;/*from   w  w w.  j a  va 2 s.  co  m*/
    }
    int activeSubCount = SubscriptionManager.from(MmsApp.getApplication()).getActiveSubscriptionInfoCount();

    if (subName == null && activeSubCount > 1) {
        SubscriptionInfo subInfo = SubscriptionManager.from(MmsApp.getApplication())
                .getActiveSubscriptionInfo(subId);
        Log.d(TAG, "subInfo=" + subInfo);
        if (null != subInfo) {
            if ((subInfo.getSimSlotIndex() == SubscriptionManager.SIM_NOT_INSERTED)
                    || (subInfo.getSimSlotIndex() == SubscriptionManager.INVALID_SUBSCRIPTION_ID)) {
                Log.i(TAG, "current not insert sim card");
            } else {
                subName = subInfo.getDisplayName().toString();
                textColor = subInfo.getIconTint();
            }
        } else {
            Log.i(TAG, "subInfo is null ");
        }
    }

    if (subName == null || activeSubCount <= 1) {
        subView.setVisibility(View.GONE);
    } else {
        subView.setVisibility(View.VISIBLE);
        subView.setTextColor(textColor);
        subView.setText(subName);
    }
}