patches/frameworks/opt/telephony/0005-SubscriptionController-Do-not-override-default-calli.patch
2023-10-07 19:36:35 -04:00

59 lines
2.9 KiB
Diff

From 2685c843046fcfb12b42f530ed4d5b8fa28cdc9e Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Mon, 5 Sep 2022 14:02:37 -0400
Subject: [PATCH 5/5] 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 8e773c072d..1efe9ba3b4 100644
--- a/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
+++ b/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
@@ -78,6 +78,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;
@@ -2839,7 +2840,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.41.0