From 793928c33896ab153585497466d3aee81f327daa Mon Sep 17 00:00:00 2001 From: Malcolm Chen Date: Tue, 17 Sep 2019 12:02:19 -0700 Subject: [PATCH] Add APIs to return max possible active phones. This is first step towards reboot free single SIM to DSDS switch. As getPhoneCount returns active phone count based on current configuration, getMaxPhoneCount (subject to renaming) will return max possible active phones(logical modems). Bug: 141023026 Test: manual Change-Id: Icc6e7da7c065eb3f72ec85a99ccc148639c574da Merged-In: Icc6e7da7c065eb3f72ec85a99ccc148639c574da --- .../android/telephony/TelephonyManager.java | 26 ++++++++++++++++++- .../telephony/TelephonyProperties.java | 7 +++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index ee254d7d2b9fb..020fe2e6c9dcc 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -362,7 +362,6 @@ public class TelephonyManager { } } - /** * Returns the number of phones available. * Returns 0 if none of voice, sms, data is not supported @@ -395,6 +394,31 @@ public class TelephonyManager { return phoneCount; } + /** + * + * Return how many phone / logical modem can be active simultaneously, in terms of device + * capability. + * For example, for a dual-SIM capable device, it always returns 2, even if only one logical + * modem / SIM is active (aka in single SIM mode). + * + * TODO: b/139642279 publicize and rename. + * @hide + */ + public static int getMaxPhoneCount() { + // TODO: b/139642279 when turning on this feature, remove dependency of + // PROPERTY_REBOOT_REQUIRED_ON_MODEM_CHANGE and always return result based on + // PROPERTY_MAX_ACTIVE_MODEMS. + String rebootRequired = SystemProperties.get( + TelephonyProperties.PROPERTY_REBOOT_REQUIRED_ON_MODEM_CHANGE); + if (rebootRequired.equals("false")) { + // If no reboot is required, return max possible active modems. + return SystemProperties.getInt( + TelephonyProperties.PROPERTY_MAX_ACTIVE_MODEMS, getDefault().getPhoneCount()); + } else { + return getDefault().getPhoneCount(); + } + } + /** {@hide} */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static TelephonyManager from(Context context) { diff --git a/telephony/java/com/android/internal/telephony/TelephonyProperties.java b/telephony/java/com/android/internal/telephony/TelephonyProperties.java index dd9b2421a333b..bf5c0a18cc964 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyProperties.java +++ b/telephony/java/com/android/internal/telephony/TelephonyProperties.java @@ -231,4 +231,11 @@ public interface TelephonyProperties String DISPLAY_OPPORTUNISTIC_SUBSCRIPTION_CARRIER_TEXT_PROPERTY_NAME = "persist.radio.display_opportunistic_carrier"; + /** + * How many logical modems can be active simultaneously. For example, if a device is dual-SIM + * capable but currently only one SIM slot and one logical modem is active, this value is still + * two. + * Type: int + */ + static final String PROPERTY_MAX_ACTIVE_MODEMS = "ro.telephony.max.active.modems"; }