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

Commit e566b575 authored by Sailesh Nepal's avatar Sailesh Nepal Committed by Android Git Automerger
Browse files

am 2a98c97e: Allow PSTN phone account for incoming calls from connection manager

* commit '2a98c97e':
  Allow PSTN phone account for incoming calls from connection manager
parents 0713dbc1 2a98c97e
Loading
Loading
Loading
Loading
+23 −5
Original line number Diff line number Diff line
@@ -657,11 +657,16 @@ public class TelecomService extends Service {
        public void addNewIncomingCall(PhoneAccountHandle phoneAccountHandle, Bundle extras) {
            Log.i(this, "Adding new incoming call with phoneAccountHandle %s", phoneAccountHandle);
            if (phoneAccountHandle != null && phoneAccountHandle.getComponentName() != null) {
                mAppOpsManager.checkPackage(
                        Binder.getCallingUid(), phoneAccountHandle.getComponentName().getPackageName());

                // TODO(sail): Add unit tests for adding incoming calls from a SIM call manager.
                if (isCallerSimCallManager() && TelephonyUtil.isPstnComponentName(
                        phoneAccountHandle.getComponentName())) {
                    Log.v(this, "Allowing call manager to add incoming call with PSTN handle");
                } else {
                    mAppOpsManager.checkPackage(Binder.getCallingUid(),
                            phoneAccountHandle.getComponentName().getPackageName());
                    // Make sure it doesn't cross the UserHandle boundary
                    enforceUserHandleMatchesCaller(phoneAccountHandle);
                }

                Intent intent = new Intent(TelecomManager.ACTION_INCOMING_CALL);
                intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
@@ -932,6 +937,19 @@ public class TelecomService extends Service {
        }
    }

    private boolean isCallerSimCallManager() {
        PhoneAccountHandle accountHandle = mPhoneAccountRegistrar.getSimCallManager();
        if (accountHandle != null) {
            try {
                mAppOpsManager.checkPackage(
                        Binder.getCallingUid(), accountHandle.getComponentName().getPackageName());
                return true;
            } catch (SecurityException e) {
            }
        }
        return false;
    }

    private boolean isDefaultDialerCalling() {
        ComponentName defaultDialerComponent = getDefaultPhoneAppInternal();
        if (defaultDialerComponent != null) {