From 9eef1ea522340a63f08f3c4471d8dfaf3aadfaed Mon Sep 17 00:00:00 2001 From: Grace Jia Date: Mon, 3 May 2021 14:32:17 -0700 Subject: [PATCH] Provide all active subscriptions when register default app providers. Telecom was using old form SimCallManager getting method which was not MSIM aware. User may found they don't have necessary permissions to call if they have both eSIM and pSIM activated. Provide all SimCallManager for active subscriptions to PermissionManager so that all of them can get proper permissions. Bug: 172880421 Test: Manually test call function on MSIM device Change-Id: I87b26bdb9e99274a8adaa64c72cfac0a61f946bd --- .../server/telecom/TelecomLoaderService.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/telecom/TelecomLoaderService.java b/services/core/java/com/android/server/telecom/TelecomLoaderService.java index 52ad893a9acee..823683655b81b 100644 --- a/services/core/java/com/android/server/telecom/TelecomLoaderService.java +++ b/services/core/java/com/android/server/telecom/TelecomLoaderService.java @@ -31,6 +31,7 @@ import android.telecom.DefaultDialerManager; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telephony.CarrierConfigManager; +import android.telephony.SubscriptionManager; import android.util.IntArray; import android.util.Slog; @@ -44,6 +45,9 @@ import com.android.server.SystemService; import com.android.server.pm.UserManagerService; import com.android.server.pm.permission.PermissionManagerServiceInternal; +import java.util.ArrayList; +import java.util.List; + /** * Starts the telecom component by binding to its ITelecomService implementation. Telecom is setup * to run in the system-server process so once it is loaded into memory it will stay running. @@ -208,13 +212,23 @@ public class TelecomLoaderService extends SystemService { return null; } } + SubscriptionManager subscriptionManager = + mContext.getSystemService(SubscriptionManager.class); + if (subscriptionManager == null) { + return null; + } TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); - PhoneAccountHandle phoneAccount = telecomManager.getSimCallManager(userId); - if (phoneAccount != null) { - return new String[]{phoneAccount.getComponentName().getPackageName()}; + List packages = new ArrayList<>(); + int[] subIds = subscriptionManager.getActiveSubscriptionIdList(); + for (int subId : subIds) { + PhoneAccountHandle phoneAccount = + telecomManager.getSimCallManagerForSubscription(subId); + if (phoneAccount != null) { + packages.add(phoneAccount.getComponentName().getPackageName()); + } } - return null; + return packages.toArray(new String[] {}); }); }