From ea3633c855860cd01b30673444d26a0b0488b8b5 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Mon, 5 Sep 2022 14:02:37 -0400 Subject: [PATCH 3/4] 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 --- .../SubscriptionManagerService.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java b/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java index bedc20e..8acca40 100644 --- a/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java +++ b/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java @@ -88,6 +88,7 @@ import android.util.Base64; import android.util.EventLog; import android.util.IndentingPrintWriter; import android.util.LocalLog; +import android.util.Log; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; @@ -3291,7 +3292,22 @@ public class SubscriptionManagerService extends ISub.Stub { TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class); if (telecomManager != null) { - telecomManager.setUserSelectedOutgoingPhoneAccount(newHandle); + PhoneAccountHandle currentHandle = telecomManager.getUserSelectedOutgoingPhoneAccount(); + log("[setDefaultVoiceSubId] current phoneAccountHandle=" + currentHandle); + + 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; + + if (!shouldKeepOutgoingAccount) { + telecomManager.setUserSelectedOutgoingPhoneAccount(newHandle); + log("[setDefaultVoiceSubId] change to phoneAccountHandle=" + newHandle); + } else { + log("[setDefaultVoiceSubId] default phoneAccountHandle not changed."); + } } updateDefaultSubId(); -- 2.48.1