Use E account only when there's no active sim
Bug: 133127033
Test: Build
Change-Id: Ieffb1bbf1c1d4283ed30d416a3cb4f94e9e31ac9
(cherry picked from commit d1c8cd8505b807c8fdc9c649e75e242b2946f985)
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 80ba5b1..6637e19 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -56,6 +56,7 @@
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.PhoneSwitcher;
import com.android.internal.telephony.RIL;
+import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneConnection;
@@ -637,8 +638,11 @@
// Notify Telecom of the new Connection type.
// TODO: Switch out the underlying connection instead of creating a new
// one and causing UI Jank.
+ boolean noActiveSimCard = SubscriptionController.getInstance()
+ .getActiveSubInfoCount(phone.getContext().getOpPackageName()) == 0;
+ // If there's no active sim card and the device is in emergency mode, use E account.
addExistingConnection(PhoneUtils.makePstnPhoneAccountHandleWithPrefix(
- phone, "", isEmergencyNumber), repConnection);
+ phone, "", isEmergencyNumber && noActiveSimCard), repConnection);
// Remove the old connection from Telecom after.
connectionToEvaluate.setDisconnected(
DisconnectCauseUtil.toTelecomDisconnectCause(