SubId is not included in extra for carrier config change intent for SIM2
If SIM status is not ready, SubId is not included in extra for carrier
config change intent. TelephonyManager#getSimApplicationState is used
to check the SIM status but it always checks default SIM's.
To solve the issue, checks correct SIM's status.
Test: manual - Checked that can get SIM2 status on Multi-SIM device.
Bug: 134549235
Change-Id: I97c734a38dc8b37cc4996862d696351063fafd58
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index da478fa..8b74af4 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -57,6 +57,7 @@
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.SubscriptionInfoUpdater;
import com.android.internal.telephony.TelephonyPermissions;
+import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.IndentingPrintWriter;
@@ -572,15 +573,22 @@
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT |
Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND |
Intent.FLAG_RECEIVER_FOREGROUND);
- // Include subId/carrier id extra only if SIM records are loaded
- TelephonyManager telephonyManager = TelephonyManager.from(mContext);
- int simApplicationState = telephonyManager.getSimApplicationState();
- if (addSubIdExtra && (simApplicationState != TelephonyManager.SIM_STATE_UNKNOWN
- && simApplicationState != TelephonyManager.SIM_STATE_NOT_READY)) {
- SubscriptionManager.putPhoneIdAndSubIdExtra(intent, phoneId);
- intent.putExtra(TelephonyManager.EXTRA_SPECIFIC_CARRIER_ID,
- getSpecificCarrierIdForPhoneId(phoneId));
- intent.putExtra(TelephonyManager.EXTRA_CARRIER_ID, getCarrierIdForPhoneId(phoneId));
+ if (addSubIdExtra) {
+ int simApplicationState = TelephonyManager.SIM_STATE_UNKNOWN;
+ int[] subIds = SubscriptionManager.getSubId(phoneId);
+ if (!ArrayUtils.isEmpty(subIds)) {
+ TelephonyManager telMgr = TelephonyManager.from(mContext)
+ .createForSubscriptionId(subIds[0]);
+ simApplicationState = telMgr.getSimApplicationState();
+ }
+ // Include subId/carrier id extra only if SIM records are loaded
+ if (simApplicationState != TelephonyManager.SIM_STATE_UNKNOWN
+ && simApplicationState != TelephonyManager.SIM_STATE_NOT_READY) {
+ SubscriptionManager.putPhoneIdAndSubIdExtra(intent, phoneId);
+ intent.putExtra(TelephonyManager.EXTRA_SPECIFIC_CARRIER_ID,
+ getSpecificCarrierIdForPhoneId(phoneId));
+ intent.putExtra(TelephonyManager.EXTRA_CARRIER_ID, getCarrierIdForPhoneId(phoneId));
+ }
}
intent.putExtra(CarrierConfigManager.EXTRA_SLOT_INDEX, phoneId);
log("Broadcast CARRIER_CONFIG_CHANGED for phone " + phoneId);