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

Commit 65fa9249 authored by Thomas Stuart's avatar Thomas Stuart
Browse files

Revert "enforceCallingPackage for getCallStateUsingPackage"

This reverts commit f71af6af.

Reason for revert: decent amount of crash reports coming from what I suspect to be a result of this CL

Change-Id: Ic6146f8843166965505d3070f796b5a83274baa0
parent f71af6af
Loading
Loading
Loading
Loading
+4 −26
Original line number Diff line number Diff line
@@ -1001,17 +1001,6 @@ public class TelecomServiceImpl {
        public int getCallStateUsingPackage(String callingPackage, String callingFeatureId) {
            try {
                Log.startSession("TSI.getCallStateUsingPackage");

                boolean privilegedUid = ((Binder.getCallingUid() == Process.ROOT_UID)
                        || (Binder.getCallingUid() == Process.SHELL_UID));

                // enforceCallingPackage but allow SHELL_UID
                if (!privilegedUid && !callingUidMatchesPackageManagerRecords(callingPackage)) {
                    EventLog.writeEvent(0x534e4554, "236813210", Binder.getCallingUid(),
                            "getCallStateUsingPackage");
                    throw new SecurityException("getCallStateUsingPackage: enforceCallingPackage");
                }

                if (CompatChanges.isChangeEnabled(
                        TelecomManager.ENABLE_GET_CALL_STATE_PERMISSION_PROTECTION, callingPackage,
                        Binder.getCallingUserHandle())) {
@@ -2393,20 +2382,6 @@ public class TelecomServiceImpl {
    }

    private void enforceCallingPackage(String packageName, String message) {
        int callingUid = Binder.getCallingUid();

        if (callingUid != Process.ROOT_UID &&
                !callingUidMatchesPackageManagerRecords(packageName)) {
            throw new SecurityException(message + ": Package " + packageName
                    + " does not belong to " + callingUid);
        }
    }

    /**
     * helper method that determines whether the passed packageName uid matches the
     * Binder.callingUid
     */
    private boolean callingUidMatchesPackageManagerRecords(String packageName) {
        int packageUid = -1;
        int callingUid = Binder.getCallingUid();
        PackageManager pm = mContext.createContextAsUser(
@@ -2418,7 +2393,10 @@ public class TelecomServiceImpl {
                // packageUid is -1
            }
        }
        return packageUid == callingUid;
        if (packageUid != callingUid && callingUid != Process.ROOT_UID) {
            throw new SecurityException(message + ": Package " + packageName
                + " does not belong to " + callingUid);
        }
    }

    private void enforceTelecomFeature() {