diff options
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 80 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 11 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/RILConstants.java | 1 |
4 files changed, 61 insertions, 32 deletions
diff --git a/api/current.txt b/api/current.txt index a993d7370376..50e883007d36 100644 --- a/api/current.txt +++ b/api/current.txt @@ -45062,6 +45062,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"; diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 36450579c57b..d163556a1654 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -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 - 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; - } - } - } + 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) { + if (!cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) { + return phoneCount; } - break; - case DSDS: - case DSDA: - phoneCount = PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM; - break; - case TSTS: - phoneCount = PhoneConstants.MAX_PHONE_COUNT_TRI_SIM; - break; + } + } + + phoneCount = 1; + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + phoneCount = telephony.getNumOfActiveSims(); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "getNumOfActiveSims RemoteException", ex); } return phoneCount; } @@ -10214,4 +10203,31 @@ public class TelephonyManager { } return true; } + + /** + * 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); + } + } } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index c8fadae442a5..927c676aefe6 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1837,4 +1837,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(); } diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java index d9b206f49dd5..77b797956cf5 100644 --- a/telephony/java/com/android/internal/telephony/RILConstants.java +++ b/telephony/java/com/android/internal/telephony/RILConstants.java @@ -480,6 +480,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; |