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

Commit 5851fa01 authored by Tony Mak's avatar Tony Mak
Browse files

Should check against calling user instead of current user

The bug is introduced in ag/862293.
We should check calling user instead of current user to support work
profile.

BUG: 27313818
Change-Id: I248ed87a71363d9b624013e938391c4fd79977fa
parent 8e131577
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -967,7 +967,8 @@ public class TelecomServiceImpl {
                                    phoneAccountHandle.getComponentName().getPackageName());
                                    phoneAccountHandle.getComponentName().getPackageName());
                            // Make sure it doesn't cross the UserHandle boundary
                            // Make sure it doesn't cross the UserHandle boundary
                            enforceUserHandleMatchesCaller(phoneAccountHandle);
                            enforceUserHandleMatchesCaller(phoneAccountHandle);
                            enforcePhoneAccountIsRegisteredEnabled(phoneAccountHandle);
                            enforcePhoneAccountIsRegisteredEnabled(phoneAccountHandle,
                                    Binder.getCallingUserHandle());
                        }
                        }
                        long token = Binder.clearCallingIdentity();
                        long token = Binder.clearCallingIdentity();
                        try {
                        try {
@@ -1009,7 +1010,8 @@ public class TelecomServiceImpl {


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


                        try {
                        try {
@@ -1296,9 +1298,10 @@ public class TelecomServiceImpl {


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