summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nazanin Bakhshi <nazaninb@google.com> 2019-01-31 03:44:15 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2019-01-31 03:44:15 +0000
commit602df1aa8c6d3bef54f9bed1d8593f3cf78e6351 (patch)
treedd4b695b45536809302202254abd0d554e32d8d2
parent8b194fe9d8e113712d5005e6c1405734ed5b4996 (diff)
parent458a474998ea7355009d8b49965fda380e1953ee (diff)
Merge "Add telephony API to switch multi sim config"
-rwxr-xr-xapi/current.txt1
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java79
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl11
-rw-r--r--telephony/java/com/android/internal/telephony/RILConstants.java1
4 files changed, 60 insertions, 32 deletions
diff --git a/api/current.txt b/api/current.txt
index a2de4cf1e75a..4363b6e753f9 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -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";
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index d8add3c2752e..41c43f5cf35c 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;
}
@@ -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);
+ }
+ }
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index a12792a8cfa6..80f4070d631e 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -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();
}
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index f901c0e29f9b..08e30dedca74 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -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;