From 9990507a53c8bc7ac154f78ed260fea6be30f252 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Mon, 5 Sep 2022 14:02:37 -0400 Subject: [PATCH] SubscriptionController: Do not override default calling account from third-party apps When the user has selected a calling account from a third-party app as default, it should not be overridden by the rest of the telephony subsystem (e.g. SIM subcription updates, or default SIM slot selection). Otherwise, it creates a somewhat annoying situation where the user has to keep re-selecting the desired calling account after every reboot. Test: manual Change-Id: Iccab64e9b3b3ab4773bd8944d47c2006f229d472 --- .../internal/telephony/SubscriptionController.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java index 82799bea8b..5105d3a183 100644 --- a/src/java/com/android/internal/telephony/SubscriptionController.java +++ b/src/java/com/android/internal/telephony/SubscriptionController.java @@ -2855,8 +2855,17 @@ public class SubscriptionController extends ISub.Stub { subId); TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class); + PhoneAccountHandle currentHandle = telecomManager.getUserSelectedOutgoingPhoneAccount(); + String currentPackageName = + currentHandle == null ? null : currentHandle.getComponentName().getPackageName(); + boolean currentIsSim = "com.android.phone".equals(currentPackageName); + // Do not override user selected outgoing calling account + // if the user has selected a third-party app as default + boolean shouldKeepOutgoingAccount = currentHandle != null && !currentIsSim; - telecomManager.setUserSelectedOutgoingPhoneAccount(newHandle); + if (!shouldKeepOutgoingAccount) { + telecomManager.setUserSelectedOutgoingPhoneAccount(newHandle); + } logd("[setDefaultVoiceSubId] requesting change to phoneAccountHandle=" + newHandle); if (previousDefaultSub != getDefaultSubId()) { -- 2.39.2