Rename and publicize getMaxPhoneCount; and deprecate getPhoneCount.

To have better names reflecting what getPhoneCount / getMaxPhoneCount
actually represent, we replace them with getActiveModemCount and
getSupportedModemCount. As getPhoneCount is public API, we mark
it as @Deprecated.

Bug: 141388730
Test: build
Change-Id: If086c50ae803b384691f709057bceeac2fc1d9d5
Merged-In: If086c50ae803b384691f709057bceeac2fc1d9d5
This commit is contained in:
Malcolm Chen
2019-10-08 18:11:22 -07:00
parent 64ff73fe4d
commit 387dc0efd1
6 changed files with 55 additions and 23 deletions

View File

@@ -44970,6 +44970,7 @@ package android.telephony {
method @Nullable public android.telephony.TelephonyManager createForPhoneAccountHandle(android.telecom.PhoneAccountHandle);
method public android.telephony.TelephonyManager createForSubscriptionId(int);
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public boolean doesSwitchMultiSimConfigTriggerReboot();
method public int getActiveModemCount();
method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public java.util.List<android.telephony.CellInfo> getAllCellInfo();
method public int getCallState();
method public int getCardIdForDefaultEuicc();
@@ -45002,7 +45003,7 @@ package android.telephony {
method public String getNetworkOperatorName();
method public String getNetworkSpecifier();
method @Deprecated @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public int getNetworkType();
method public int getPhoneCount();
method @Deprecated public int getPhoneCount();
method public int getPhoneType();
method @RequiresPermission(anyOf={"android.permission.READ_PRIVILEGED_PHONE_STATE", android.Manifest.permission.READ_PHONE_STATE}) public int getPreferredOpportunisticDataSubscription();
method @RequiresPermission(allOf={android.Manifest.permission.READ_PHONE_STATE, android.Manifest.permission.ACCESS_COARSE_LOCATION}) public android.telephony.ServiceState getServiceState();
@@ -45018,6 +45019,7 @@ package android.telephony {
method public int getSimState();
method public int getSimState(int);
method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public String getSubscriberId();
method public int getSupportedModemCount();
method @Nullable public String getTypeAllocationCode();
method @Nullable public String getTypeAllocationCode(int);
method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") @NonNull public java.util.List<android.telephony.UiccCardInfo> getUiccCardsInfo();
@@ -45122,6 +45124,10 @@ package android.telephony {
field public static final String EXTRA_SUBSCRIPTION_ID = "android.telephony.extra.SUBSCRIPTION_ID";
field public static final String EXTRA_VOICEMAIL_NUMBER = "android.telephony.extra.VOICEMAIL_NUMBER";
field public static final String METADATA_HIDE_VOICEMAIL_SETTINGS_MENU = "android.telephony.HIDE_VOICEMAIL_SETTINGS_MENU";
field public static final int MODEM_COUNT_DUAL_MODEM = 2; // 0x2
field public static final int MODEM_COUNT_NO_MODEM = 0; // 0x0
field public static final int MODEM_COUNT_SINGLE_MODEM = 1; // 0x1
field public static final int MODEM_COUNT_TRI_MODEM = 3; // 0x3
field public static final int MULTISIM_ALLOWED = 0; // 0x0
field public static final int MULTISIM_NOT_SUPPORTED_BY_CARRIER = 2; // 0x2
field public static final int MULTISIM_NOT_SUPPORTED_BY_HARDWARE = 1; // 0x1

View File

@@ -172,7 +172,7 @@ public class CarrierTextController {
mSeparator = separator;
mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
mSimSlotsNumber = ((TelephonyManager) context.getSystemService(
Context.TELEPHONY_SERVICE)).getMaxPhoneCount();
Context.TELEPHONY_SERVICE)).getSupportedModemCount();
mSimErrorState = new boolean[mSimSlotsNumber];
updateDisplayOpportunisticSubscriptionCarrierText(SystemProperties.getBoolean(
TelephonyProperties.DISPLAY_OPPORTUNISTIC_SUBSCRIPTION_CARRIER_TEXT_PROPERTY_NAME,

View File

@@ -119,7 +119,7 @@ public class CarrierTextControllerTest extends SysuiTestCase {
mCarrierTextCallbackInfo = new CarrierTextController.CarrierTextCallbackInfo("",
new CharSequence[]{}, false, new int[]{});
when(mTelephonyManager.getMaxPhoneCount()).thenReturn(3);
when(mTelephonyManager.getSupportedModemCount()).thenReturn(3);
mCarrierTextController = new TestCarrierTextController(mContext, SEPARATOR, true, true,
mKeyguardUpdateMonitor);

View File

@@ -382,7 +382,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mContext = context;
mBatteryStats = BatteryStatsService.getService();
int numPhones = TelephonyManager.getDefault().getMaxPhoneCount();
int numPhones = TelephonyManager.getDefault().getSupportedModemCount();
if (DBG) log("TelephonyRegistry: ctor numPhones=" + numPhones);
mNumPhones = numPhones;
mCallState = new int[numPhones];

View File

@@ -2095,13 +2095,13 @@ public class SubscriptionManager {
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public static boolean isValidSlotIndex(int slotIndex) {
return slotIndex >= 0 && slotIndex < TelephonyManager.getDefault().getMaxPhoneCount();
return slotIndex >= 0 && slotIndex < TelephonyManager.getDefault().getSupportedModemCount();
}
/** @hide */
@UnsupportedAppUsage
public static boolean isValidPhoneId(int phoneId) {
return phoneId >= 0 && phoneId < TelephonyManager.getDefault().getMaxPhoneCount();
return phoneId >= 0 && phoneId < TelephonyManager.getDefault().getSupportedModemCount();
}
/** @hide */

View File

@@ -288,6 +288,21 @@ public class TelephonyManager {
UNKNOWN
};
/** @hide */
@IntDef(prefix = {"MODEM_COUNT_"},
value = {
MODEM_COUNT_NO_MODEM,
MODEM_COUNT_SINGLE_MODEM,
MODEM_COUNT_DUAL_MODEM,
MODEM_COUNT_TRI_MODEM
})
public @interface ModemCount {}
public static final int MODEM_COUNT_NO_MODEM = 0;
public static final int MODEM_COUNT_SINGLE_MODEM = 1;
public static final int MODEM_COUNT_DUAL_MODEM = 2;
public static final int MODEM_COUNT_TRI_MODEM = 3;
/** @hide */
@UnsupportedAppUsage
public TelephonyManager(Context context) {
@@ -365,12 +380,26 @@ public class TelephonyManager {
/**
* Returns the number of phones available.
* 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)
* 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).
* @deprecated Use {@link #getActiveModemCount} instead.
*/
@Deprecated
public int getPhoneCount() {
int phoneCount = 1;
return getActiveModemCount();
}
/**
* Returns the number of logical modems currently configured to be activated.
*
* 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 @ModemCount int getActiveModemCount() {
int modemCount = 1;
switch (getMultiSimConfiguration()) {
case UNKNOWN:
ConnectivityManager cm = mContext == null ? null : (ConnectivityManager) mContext
@@ -378,33 +407,30 @@ public class TelephonyManager {
// check for voice and data support, 0 if not supported
if (!isVoiceCapable() && !isSmsCapable() && cm != null
&& !cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) {
phoneCount = 0;
modemCount = MODEM_COUNT_NO_MODEM;
} else {
phoneCount = 1;
modemCount = MODEM_COUNT_SINGLE_MODEM;
}
break;
case DSDS:
case DSDA:
phoneCount = PhoneConstants.MAX_PHONE_COUNT_DUAL_SIM;
modemCount = MODEM_COUNT_DUAL_MODEM;
break;
case TSTS:
phoneCount = PhoneConstants.MAX_PHONE_COUNT_TRI_SIM;
modemCount = MODEM_COUNT_TRI_MODEM;
break;
}
return phoneCount;
return modemCount;
}
/**
*
* Return how many phone / logical modem can be active simultaneously, in terms of device
* Return how many logical modem can be potentially active simultaneously, in terms of hardware
* 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
* It might return different value from {@link #getActiveModemCount}. For example, for a
* dual-SIM capable device operating in single SIM mode (only one logical modem is turned on),
* {@link #getActiveModemCount} returns 1 while this API returns 2.
*/
public int getMaxPhoneCount() {
public @ModemCount int getSupportedModemCount() {
// 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.