Example usage for android.telephony SubscriptionInfo getIconTint

List of usage examples for android.telephony SubscriptionInfo getIconTint

Introduction

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

Prototype

public int getIconTint() 

Source Link

Document

A highlight color to use in displaying information about this PhoneAccount .

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.
 *///  w w w . j a v  a2s.co  m
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.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  ww . ja va2  s  . c  o 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);
    }
}