diff options
| author | 2019-10-15 11:35:57 -0700 | |
|---|---|---|
| committer | 2019-10-15 11:35:57 -0700 | |
| commit | fd12f3d9bc4e7bbe848d57a4618ab23e8ea2f6fc (patch) | |
| tree | ad490b7fd58bcb61961249c24c8a3eaf1b62fffd | |
| parent | cb6f65bc926a7e496e99cdfad144242b0739d3ae (diff) | |
| parent | cc2d8d495d9d8536fc0e5d84a4fdde992239d012 (diff) | |
Merge changes from topic "141388730" am: 50c4313058
am: cc2d8d495d
Change-Id: I921654c18376d2854e001ec6118355075d46e5a6
5 files changed, 21 insertions, 8 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java index 10d132ad2763..a15c035fdd3a 100644 --- a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java +++ b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java @@ -172,7 +172,7 @@ public class CarrierTextController { mSeparator = separator; mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class); mSimSlotsNumber = ((TelephonyManager) context.getSystemService( - Context.TELEPHONY_SERVICE)).getPhoneCount(); + Context.TELEPHONY_SERVICE)).getMaxPhoneCount(); mSimErrorState = new boolean[mSimSlotsNumber]; updateDisplayOpportunisticSubscriptionCarrierText(SystemProperties.getBoolean( TelephonyProperties.DISPLAY_OPPORTUNISTIC_SUBSCRIPTION_CARRIER_TEXT_PROPERTY_NAME, diff --git a/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java index 0044ca7c0409..e74e955cd7a0 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextControllerTest.java @@ -119,7 +119,7 @@ public class CarrierTextControllerTest extends SysuiTestCase { mCarrierTextCallbackInfo = new CarrierTextController.CarrierTextCallbackInfo("", new CharSequence[]{}, false, new int[]{}); - when(mTelephonyManager.getPhoneCount()).thenReturn(3); + when(mTelephonyManager.getMaxPhoneCount()).thenReturn(3); mCarrierTextController = new TestCarrierTextController(mContext, SEPARATOR, true, true, mKeyguardUpdateMonitor); diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 2269e6a3ed1c..0269579e3e07 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -382,7 +382,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mContext = context; mBatteryStats = BatteryStatsService.getService(); - int numPhones = TelephonyManager.getDefault().getPhoneCount(); + int numPhones = TelephonyManager.getDefault().getMaxPhoneCount(); if (DBG) log("TelephonyRegistry: ctor numPhones=" + numPhones); mNumPhones = numPhones; mCallState = new int[numPhones]; diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index bd0f225f2180..e7af7ee2c682 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -2085,13 +2085,26 @@ public class SubscriptionManager { /** @hide */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) public static boolean isValidSlotIndex(int slotIndex) { - return slotIndex >= 0 && slotIndex < TelephonyManager.getDefault().getSimCount(); + return slotIndex >= 0 && slotIndex < TelephonyManager.getDefault().getMaxPhoneCount(); } /** @hide */ @UnsupportedAppUsage public static boolean isValidPhoneId(int phoneId) { - return phoneId >= 0 && phoneId < TelephonyManager.getDefault().getPhoneCount(); + return phoneId >= 0 && phoneId < TelephonyManager.getDefault().getMaxPhoneCount(); + } + + /** + * When getPhoneCount and getMaxPhoneCount return different value, isValidPhoneId being true + * doesn't mean the phoneId has a corresponding active slot / logical modem. If a DSDS capable + * device is in single SIM mode, phoneId=1 is valid but not active. + * + * TODO: b/139642279 combine with SubscriptionManager#isValidPhoneId when phone objects + * are dynamically allocated instead of always based on getMaxPhoneCount. + * @hide + */ + public static boolean isActivePhoneId(int slotIndex) { + return slotIndex < TelephonyManager.getDefault().getPhoneCount(); } /** @hide */ diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 7be97b085c09..9d77a561ec72 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -404,7 +404,7 @@ public class TelephonyManager { * TODO: b/139642279 publicize and rename. * @hide */ - public static int getMaxPhoneCount() { + public 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. @@ -413,9 +413,9 @@ public class TelephonyManager { if (rebootRequired.equals("false")) { // If no reboot is required, return max possible active modems. return SystemProperties.getInt( - TelephonyProperties.PROPERTY_MAX_ACTIVE_MODEMS, getDefault().getPhoneCount()); + TelephonyProperties.PROPERTY_MAX_ACTIVE_MODEMS, getPhoneCount()); } else { - return getDefault().getPhoneCount(); + return getPhoneCount(); } } |