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

Commit 253b2d18 authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge "Add additional permission check"

am: a58ac65d

Change-Id: I75ddd7a422e412a51bb58339a8feb2c06d369dc5
parents 76296f64 a58ac65d
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.