Replace getPhoneCount with getMaxPhoneCount upon object allocation.
As first step for smooth single SIM to DSDS switch, for DSDS capable
deviced we always allocate objects as if it's in DSDS mode. For example
there will be two Phone objects.
Later we'll evaluate to make the allocations dynamic to save memory.
Bug: 141388730
Test: unittest and manual
Change-Id: I9a99853a22de0a4a78fd4ca622faddcdba3f8e06
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index c5b4875..cdf64c6 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -194,7 +194,7 @@
case EVENT_SYSTEM_UNLOCKED:
{
- for (int i = 0; i < TelephonyManager.from(mContext).getPhoneCount(); ++i) {
+ for (int i = 0; i < TelephonyManager.from(mContext).getMaxPhoneCount(); ++i) {
// When user unlock device, we should only try to send broadcast again if we
// have sent it before unlock. This will avoid we try to load carrier config
// when SIM is still loading when unlock happens.
@@ -211,7 +211,7 @@
// Only update if there are cached config removed to avoid updating config for
// unrelated packages.
if (clearCachedConfigForPackage(carrierPackageName)) {
- int numPhones = TelephonyManager.from(mContext).getPhoneCount();
+ int numPhones = TelephonyManager.from(mContext).getMaxPhoneCount();
for (int i = 0; i < numPhones; ++i) {
updateConfigForPhoneId(i);
}
@@ -523,7 +523,7 @@
pkgFilter.addDataScheme("package");
context.registerReceiver(mPackageReceiver, pkgFilter);
- int numPhones = TelephonyManager.from(context).getPhoneCount();
+ int numPhones = TelephonyManager.from(context).getMaxPhoneCount();
mConfigFromDefaultApp = new PersistableBundle[numPhones];
mConfigFromCarrierApp = new PersistableBundle[numPhones];
mOverrideConfigs = new PersistableBundle[numPhones];