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

Commit a58ac65d authored by Hall Liu's avatar Hall Liu Committed by Gerrit Code Review
Browse files

Merge "Add additional permission check"

parents 09a13977 d368c31a
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.