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

Commit 7bc8ad39 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Make TelecomManager#addNewIncomingCall DSDS aware.

Modify the isCallerSimCallManager logic in the addNewIncomingCall method to
look up the sim call manager for the target phone account.  This will
ensure that if the target phone account is not the default outgoing call
account that we'll stlil get the correct sim call manager and allow the
caller to add the incoming call.

Bug: 133873542
Test: Manual test with FI incoming WIFI calls; verify it has permission to
add an incoming call when its not the default calling account.

Change-Id: I106f1fe410de976be11e2ee3819092df41894c08
parent 1a2f2b89
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -472,17 +472,32 @@ public class PhoneAccountRegistrar {
        if (userHandle == null) {
            userHandle = call.getTargetPhoneAccount().getUserHandle();
        }
        int subId = getSubscriptionIdForPhoneAccount(call.getTargetPhoneAccount());
        PhoneAccountHandle targetPhoneAccount = call.getTargetPhoneAccount();
        Log.d(this, "getSimCallManagerFromCall: callId=%s, targetPhac=%s",
                call.getId(), targetPhoneAccount);
        return getSimCallManagerFromHandle(targetPhoneAccount,userHandle);
    }

    /**
     * Given a target phone account and user, determines the sim call manager (if any) which is
     * associated with that {@link PhoneAccountHandle}.
     * @param targetPhoneAccount The target phone account to check.
     * @param userHandle The user handle.
     * @return The {@link PhoneAccountHandle} of the connection manager.
     */
    public PhoneAccountHandle getSimCallManagerFromHandle(PhoneAccountHandle targetPhoneAccount,
            UserHandle userHandle) {
        int subId = getSubscriptionIdForPhoneAccount(targetPhoneAccount);
        if (SubscriptionManager.isValidSubscriptionId(subId)
                 && subId != SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
            PhoneAccountHandle callManagerHandle = getSimCallManager(subId, userHandle);
            Log.d(this, "getSimCallManagerFromCall: callId=%s, targetPhac=%s, subId=%d, scm=%s",
                    call.getId(), call.getTargetPhoneAccount(), subId, callManagerHandle);
            Log.d(this, "getSimCallManagerFromHandle: targetPhac=%s, subId=%d, scm=%s",
                    targetPhoneAccount, subId, callManagerHandle);
            return callManagerHandle;
        } else {
            PhoneAccountHandle callManagerHandle = getSimCallManager(userHandle);
            Log.d(this, "getSimCallManagerFromCall: callId=%s, targetPhac=%s, subId(d)=%d, scm=%s",
                    call.getId(), call.getTargetPhoneAccount(), subId, callManagerHandle);
            Log.d(this, "getSimCallManagerFromHandle: targetPhac=%s, subId(d)=%d, scm=%s",
                    targetPhoneAccount, subId, callManagerHandle);
            return callManagerHandle;
        }
    }
+6 −6
Original line number Diff line number Diff line
@@ -1071,9 +1071,8 @@ public class TelecomServiceImpl {
                            phoneAccountHandle);
                    if (phoneAccountHandle != null &&
                            phoneAccountHandle.getComponentName() != null) {
                        // TODO(sail): Add unit tests for adding incoming calls from a SIM call
                        // manager.
                        if (isCallerSimCallManager() && TelephonyUtil.isPstnComponentName(
                        if (isCallerSimCallManager(phoneAccountHandle)
                                && TelephonyUtil.isPstnComponentName(
                                        phoneAccountHandle.getComponentName())) {
                            Log.v(this, "Allowing call manager to add incoming call with PSTN" +
                                    " handle");
@@ -1989,11 +1988,12 @@ public class TelecomServiceImpl {
                Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED;
    }

    private boolean isCallerSimCallManager() {
    private boolean isCallerSimCallManager(PhoneAccountHandle targetPhoneAccount) {
        long token = Binder.clearCallingIdentity();
        PhoneAccountHandle accountHandle = null;
        try {
             accountHandle = mPhoneAccountRegistrar.getSimCallManagerOfCurrentUser();
            accountHandle = mPhoneAccountRegistrar.getSimCallManagerFromHandle(targetPhoneAccount,
                    mCallsManager.getCurrentUserHandle());
        } finally {
            Binder.restoreCallingIdentity(token);
        }