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

Commit d368c31a authored by Hall Liu's avatar Hall Liu
Browse files

Add additional permission check

Check READ_PRIVILEGED_PHONE_STATE in getCallCapablePhoneAccounts if the
caller is requesting that disabled accounts be listed as well.

Bug: 141576153
Test: CTS
Change-Id: Ic8d1a9e37531ca8aeebac2aab9bfecd10b27f732
parent 29cbb62d
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -181,7 +181,12 @@ public class TelecomServiceImpl {
                boolean includeDisabledAccounts, String callingPackage) {
            try {
                Log.startSession("TSI.gCCPA");
                if (!canReadPhoneState(callingPackage, "getDefaultOutgoingPhoneAccount")) {
                if (includeDisabledAccounts &&
                        !canReadPrivilegedPhoneState(
                                callingPackage, "getCallCapablePhoneAccounts")) {
                    return Collections.emptyList();
                }
                if (!canReadPhoneState(callingPackage, "getCallCapablePhoneAccounts")) {
                    return Collections.emptyList();
                }
                synchronized (mLock) {
@@ -2027,6 +2032,17 @@ public class TelecomServiceImpl {
        }
    }

    private boolean canReadPrivilegedPhoneState(String callingPackage, String message) {
        // The system/default dialer can always read phone state - so that emergency calls will
        // still work.
        if (isPrivilegedDialerCalling(callingPackage)) {
            return true;
        }

        mContext.enforceCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE, message);
        return true;
    }

    private boolean isDialerOrPrivileged(String callingPackage, String message) {
        // The system/default dialer can always read phone state - so that emergency calls will
        // still work.