Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 602df1aa authored by Nazanin Bakhshi's avatar Nazanin Bakhshi Committed by Gerrit Code Review
Browse files

Merge "Add telephony API to switch multi sim config"

parents 8b194fe9 458a4749
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43097,6 +43097,7 @@ package android.telephony {
    method public boolean setVoiceMailNumber(String, String);
    method @Deprecated public void setVoicemailRingtoneUri(android.telecom.PhoneAccountHandle, android.net.Uri);
    method @Deprecated public void setVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle, boolean);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void switchMultiSimConfig(int);
    method public boolean updateAvailableNetworks(java.util.List<android.telephony.AvailableNetworkInfo>);
    field public static final String ACTION_CONFIGURE_VOICEMAIL = "android.telephony.action.CONFIGURE_VOICEMAIL";
    field public static final String ACTION_NETWORK_COUNTRY_CHANGED = "android.telephony.action.NETWORK_COUNTRY_CHANGED";
+47 −32
Original line number Diff line number Diff line
@@ -349,41 +349,30 @@ public class TelephonyManager {
     * Returns 0 if none of voice, sms, data is not supported
     * Returns 1 for Single standby mode (Single SIM functionality)
     * Returns 2 for Dual standby mode.(Dual SIM functionality)
     * Returns 3 for Tri standby mode.(Tri SIM functionality)
     */
    public int getPhoneCount() {
        int phoneCount = 1;
        switch (getMultiSimConfiguration()) {
            case UNKNOWN:
                // if voice or sms or data is supported, return 1 otherwise 0
                if (isVoiceCapable() || isSmsCapable()) {
                    phoneCount = 1;
                } else {
                    // todo: try to clean this up further by getting rid of the nested conditions
                    if (mContext == null) {
                        phoneCount = 1;
                    } else {
                        // check for data support
        int phoneCount = 0;

        // check for voice and data support, 0 if not supported
        if (!isVoiceCapable() && !isSmsCapable()) {
            ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(
                    Context.CONNECTIVITY_SERVICE);
                        if (cm == null) {
                            phoneCount = 1;
                        } else {
                            if (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) {
                                phoneCount = 1;
                            } else {
                                phoneCount = 0;
            if (cm != null) {
                if (!cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) {
                    return phoneCount;
                }
            }
        }

        phoneCount = 1;
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                phoneCount = telephony.getNumOfActiveSims();
            }
                break;
            case DSDS:
            case DSDA:
                phoneCount = PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM;
                break;
            case TSTS:
                phoneCount = PhoneConstants.MAX_PHONE_COUNT_TRI_SIM;
                break;
        } catch (RemoteException ex) {
            Rlog.e(TAG, "getNumOfActiveSims RemoteException", ex);
        }
        return phoneCount;
    }
@@ -10051,4 +10040,30 @@ public class TelephonyManager {
     */
    public static final String EXTRA_NETWORK_COUNTRY =
            "android.telephony.extra.NETWORK_COUNTRY";
    /**
     * Switch configs to enable multi-sim or switch back to single-sim
     * <p>Requires Permission:
     * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the
     * calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
     * @param numOfSims number of live SIMs we want to switch to
     * @throws android.os.RemoteException
     */
    @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public void switchMultiSimConfig(int numOfSims) {
        //only proceed if multi-sim is not restricted
        if (isMultisimCarrierRestricted()) {
            Rlog.e(TAG, "switchMultiSimConfig not possible. It is restricted.");
            return;
        }

        try {
            ITelephony telephony = getITelephony();
            if (telephony != null) {
                telephony.switchMultiSimConfig(numOfSims);
            }
        } catch (RemoteException ex) {
            Rlog.e(TAG, "switchMultiSimConfig RemoteException", ex);
        }
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -1829,4 +1829,15 @@ interface ITelephony {
     * @hide
     */
    boolean isMultisimCarrierRestricted();
    
    /**
     * Switch configs to enable multi-sim or switch back to single-sim
     * @hide
     */
    void switchMultiSimConfig(int numOfSims);
    /**
     * Get how many modems have been activated on the phone
     * @hide
     */
    int getNumOfActiveSims();
}
+1 −0
Original line number Diff line number Diff line
@@ -404,6 +404,7 @@ public interface RILConstants {
    int RIL_REQUEST_SET_PREFERRED_DATA_MODEM = 204;
    int RIL_REQUEST_EMERGENCY_DIAL = 205;
    int RIL_REQUEST_GET_PHONE_CAPABILITY = 206;
    int RIL_REQUEST_SWITCH_DUAL_SIM_CONFIG = 207;

    /* Responses begin */
    int RIL_RESPONSE_ACKNOWLEDGEMENT = 800;