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

Commit 824069b5 authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge "Add additional permission check" am: a58ac65d

am: 253b2d18

Change-Id: I127c9ecf35209d2c7f373e3884dc06531d9eb1dc
parents 002e7b50 253b2d18
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.