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

Commit 2e11a63a authored by Brad Ebinger's avatar Brad Ebinger Committed by The Android Automerger
Browse files

DO NOT MERGE Check PAH in addNewIncomingCall

Check to be sure that the PhoneAccountHandle in addNewIncomingCall
corresponds to an existing registered PhoneAccount in Telecom and that
the PhoneAccount is enabled. Otherwise, throw a SecurityException.

Bug: 26864502
Change-Id: I6bbd8a1ece821b62bee2c94decde87a41afbf8b0
parent d9f9006e
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.telecom.TelecomManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.EventLog;

// TODO: Needed for move to system service: import com.android.internal.R;
import com.android.internal.telecom.ITelecomService;
@@ -742,6 +743,7 @@ public class TelecomServiceImpl {
                                phoneAccountHandle.getComponentName().getPackageName());
                        // Make sure it doesn't cross the UserHandle boundary
                        enforceUserHandleMatchesCaller(phoneAccountHandle);
                        enforcePhoneAccountIsRegisteredEnabled(phoneAccountHandle);
                    }

                    long token = Binder.clearCallingIdentity();
@@ -777,6 +779,7 @@ public class TelecomServiceImpl {

                    // Make sure it doesn't cross the UserHandle boundary
                    enforceUserHandleMatchesCaller(phoneAccountHandle);
                    enforcePhoneAccountIsRegisteredEnabled(phoneAccountHandle);
                    long token = Binder.clearCallingIdentity();

                    try {
@@ -1056,6 +1059,21 @@ public class TelecomServiceImpl {
        return false;
    }

    // Enforce that the PhoneAccountHandle being passed in is both registered to the current user
    // and enabled.
    private void enforcePhoneAccountIsRegisteredEnabled(PhoneAccountHandle phoneAccountHandle) {
        PhoneAccount phoneAccount = mPhoneAccountRegistrar.getPhoneAccountCheckCallingUser(
                phoneAccountHandle);
        if (phoneAccount == null) {
            EventLog.writeEvent(0x534e4554, "26864502", Binder.getCallingUid(), "R");
            throw new SecurityException("This PhoneAccountHandle is not registered for this user!");
        }
        if (!phoneAccount.isEnabled()) {
            EventLog.writeEvent(0x534e4554, "26864502", Binder.getCallingUid(), "E");
            throw new SecurityException("This PhoneAccountHandle is not enabled for this user!");
        }
    }

    private void enforcePhoneAccountModificationForPackage(String packageName) {
        // TODO: Use a new telecomm permission for this instead of reusing modify.