Example usage for android.telephony SubscriptionInfo getSubscriptionId

List of usage examples for android.telephony SubscriptionInfo getSubscriptionId

Introduction

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

Prototype

public int getSubscriptionId() 

Source Link

Usage

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 {/*  w w w. ja v  a 2  s.  co  m*/
        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 boolean isLocalNumber(String number) {
    if (number == null) {
        return false;
    }/*from w w  w  .  ja  v  a 2 s. c  o  m*/

    // we don't use Mms.isEmailAddress() because it is too strict for comparing addresses like
    // "foo+caf_=6505551212=tmomail.net@gmail.com",
    // which is the 'from' address from a forwarded email
    // message from Gmail. We don't want to treat "foo+caf
    // =6505551212=tmomail.net@gmail.com" and
    // "6505551212" to be the same.
    if (number.indexOf('@') >= 0) {
        return false;
    }

    List<SubscriptionInfo> subInfoList;
    subInfoList = SubscriptionManager.from(MmsApp.getApplication()).getActiveSubscriptionInfoList();
    if (subInfoList == null || subInfoList.size() == 0) {
        MmsLog.d(TAG, "isLocalNumber SIM not insert");
        return false;
    }
    for (SubscriptionInfo subInfoRecord : subInfoList) {
        // modify BUG_ID:JWYYL-16 chenweihua 20141216 (start)
        /*
        if (PhoneNumberUtils.compare(number, getLocalNumber(subInfoRecord.getSubscriptionId()))) {
           return true;
        }
        */
        if (android.os.SystemProperties.getInt("ro.rgk_brazil_number_match", 0) == 1) {
            if (PhoneNumberUtils.compareWithAreaCode(number,
                    getLocalNumber(subInfoRecord.getSubscriptionId()))) {
                return true;
            }
        } else {
            if (PhoneNumberUtils.compare(number, getLocalNumber(subInfoRecord.getSubscriptionId()))) {
                return true;
            }
        }
        // modify BUG_ID:JWYYL-16 chenweihua 20141216 (end)
    }
    return false;
}