Determine the number of single-card / multi-card projects and the number of card slots supported by the phone

Local temporary verification function, set the phone to single or dual card:

adb shell setprop persist.radio.multisim.config ssss (single card) dsds (dual card)
 cannot be restarted after modification! ! !


method one:

This picture is an old version, now:                        
persist.radio.multisim.config  

1. When the SIMCODE value is Dual sim (S2). Dual standby mode (Dual SIM functionality), persist.radio.multisim.config will be set to "dada" or "dsda".
2. The SIMCODE value is Single In sim (S1), Single standby mode (Single SIM functionality), persist.radio.multisim.config will be set to "ssss"
3. When three cards, persist.radio.multisim.config will be set to "tsts "So you can use persist.radio.multisim.config to determine whether the phone is in single-card mode or dual-card mode,


Example:

    import android.os.SystemProperties;

        //+begin, chenhaibing.wt, Single standby mode remove SIM2 ringtone, 20190104
        DefaultRingtonePreference mRingtoneSIM2Preference = (DefaultRingtonePreference)getPreferenceScreen().findPreference(KEY_RINGTONE_SIM2);
        DefaultRingtonePreference mRingtonePreference = (DefaultRingtonePreference)getPreferenceScreen().findPreference(KEY_RINGTONE);
        String mSimConfig =SystemProperties.get("persist.radio.multisim.config");
        if(mSimConfig.equals("ssss")) {
            android.util.Log.d("chenhaibing","Single standby mode (Single SIM functionality) remove SIM2 Ringtone mSimConfig="+mSimConfig);
            getPreferenceScreen().removePreference(mRingtoneSIM2Preference);
            mRingtonePreference.setTitle(R.string.ringtone_title);
        }
        //-end, chenhaibing.wt, Single standby mode remove SIM2 ringtone, 20190104


Method Two:

First, in the PhoneFactory's makeDefaultPhone method, the TelephonyManager.getDefault method is called

int numPhones = TelephonyManager.getDefault().getPhoneCount();


View TelephonyManager's getDefault method

// Leo, 全局变量
    private static TelephonyManager sInstance = new TelephonyManager();
 
    /** @hide
    /* @deprecated - use getSystemService as described above */
    public static TelephonyManager getDefault() {
        return sInstance;
    }


As you can see, it returns a global TelephonyManager object

/**
     * Returns the number of phones available.
     * Returns 1 for Single standby mode (Single SIM functionality)
     * Returns 2 for Dual standby mode.(Dual SIM functionality)
     */
    public int getPhoneCount() {
        int phoneCount = 1;
        switch (getMultiSimConfiguration()) {
            case UNKNOWN:
                phoneCount = 1;
                break;
            case DSDS:
            case DSDA:
                phoneCount = PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM;
                break;
            case TSTS:
                phoneCount = PhoneConstants.MAX_PHONE_COUNT_TRI_SIM;
                break;
        }
        return phoneCount;
    }
/**
     * Returns the multi SIM variant
     * Returns DSDS for Dual SIM Dual Standby
     * Returns DSDA for Dual SIM Dual Active
     * Returns TSTS for Triple SIM Triple Standby
     * Returns UNKNOWN for others
     */
    /** {@hide} */
    public MultiSimVariants getMultiSimConfiguration() {
        String mSimConfig =
            SystemProperties.get(TelephonyProperties.PROPERTY_MULTI_SIM_CONFIG);
        if (mSimConfig.equals("dsds")) {
            return MultiSimVariants.DSDS;
        } else if (mSimConfig.equals("dsda")) {
            return MultiSimVariants.DSDA;
        } else if (mSimConfig.equals("tsts")) {
            return MultiSimVariants.TSTS;
        } else {
            return MultiSimVariants.UNKNOWN;
        }
    }


and so,

int numPhones = TelephonyManager.getDefault().getPhoneCount();


This statement is based on the value of persist.radio.multisim.config preset by the user to determine whether it is a single-card project or a multi-card project, and returns the number of card slots supported by the mobile phone.

Published 31 original articles · Likes6 · Visitors 10,000+

Guess you like

Origin blog.csdn.net/u012824529/article/details/90256828