Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1b7e624 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Add a new API to query SIM call manager per subid

The old getSimCallManager API would use the default
subscription ID to resolve the SIM call manager.
For MSIM devices, this caused issues where the
default voice subscription setting would cause incorrect
settings to be displayed.

Introduce a per subId variant of the API.

Test: manual; atest TelecomUnitTests
Bug: 131627085
Merged-In: I9c2d589f81e4796e6ba339b1a5cd58d1e722dbfd
Change-Id: I5656c7fe098785f4a9ee9f2bcb233eb91b459fa5
parent d6af61e3
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -374,10 +374,14 @@ public class PhoneAccountRegistrar {
    }

    public ComponentName getSystemSimCallManagerComponent() {
        return getSystemSimCallManagerComponent(SubscriptionManager.getDefaultSubscriptionId());
    }

    public ComponentName getSystemSimCallManagerComponent(int subId) {
        String defaultSimCallManager = null;
        CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(
                Context.CARRIER_CONFIG_SERVICE);
        PersistableBundle configBundle = configManager.getConfig();
        PersistableBundle configBundle = configManager.getConfigForSubId(subId);
        if (configBundle != null) {
            defaultSimCallManager = configBundle.getString(
                    CarrierConfigManager.KEY_DEFAULT_SIM_CALL_MANAGER_STRING);
@@ -391,8 +395,10 @@ public class PhoneAccountRegistrar {
    }

    /**
     * Returns the {@link PhoneAccountHandle} corresponding to the currently active SIM Call
     * Manager. SIM Call Manager returned corresponds to the following priority order:
     * Returns the {@link PhoneAccountHandle} corresponding to the SIM Call Manager associated with
     * the default Telephony Subscription ID (see
     * {@link SubscriptionManager#getDefaultSubscriptionId()}). SIM Call Manager returned
     * corresponds to the following priority order:
     * 1. If a SIM Call Manager {@link PhoneAccount} is registered for the same package as the
     * default dialer, then that one is returned.
     * 2. If there is a SIM Call Manager {@link PhoneAccount} registered which matches the
@@ -400,12 +406,22 @@ public class PhoneAccountRegistrar {
     * 3. Otherwise, we return null.
     */
    public PhoneAccountHandle getSimCallManager(UserHandle userHandle) {
        return getSimCallManager(SubscriptionManager.getDefaultSubscriptionId(), userHandle);
    }

    /**
     * Queries the SIM call manager associated with a specific subscription ID.
     *
     * @see #getSimCallManager(UserHandle) for more information.
     */
    public PhoneAccountHandle getSimCallManager(int subId, UserHandle userHandle) {

        // Get the default dialer in case it has a connection manager associated with it.
        String dialerPackage = mDefaultDialerCache
                .getDefaultDialerApplication(userHandle.getIdentifier());

        // Check carrier config.
        ComponentName systemSimCallManagerComponent = getSystemSimCallManagerComponent();
        ComponentName systemSimCallManagerComponent = getSystemSimCallManagerComponent(subId);

        PhoneAccountHandle dialerSimCallManager = null;
        PhoneAccountHandle systemSimCallManager = null;
+18 −10
Original line number Diff line number Diff line
@@ -395,21 +395,29 @@ public class TelecomServiceImpl {
        }

        @Override
        public PhoneAccountHandle getSimCallManager() {
        public PhoneAccountHandle getSimCallManager(int subId) {
            synchronized (mLock) {
                try {
                    Log.startSession("TSI.gSCM");
                    final int user = ActivityManager.getCurrentUser();
                    final int callingUid = Binder.getCallingUid();
                    long token = Binder.clearCallingIdentity();
                int user;
                    try {
                    user = ActivityManager.getCurrentUser();
                    return getSimCallManagerForUser(user);
                        if (user != ActivityManager.getCurrentUser()) {
                            enforceCrossUserPermission(callingUid);
                        }
                        return mPhoneAccountRegistrar.getSimCallManager(subId, UserHandle.of(user));
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                } catch (Exception e) {
                    Log.e(this, e, "getSimCallManager");
                    throw e;
                } finally {
                    Log.endSession();
                }
            }
        }

        @Override
        public PhoneAccountHandle getSimCallManagerForUser(int user) {