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

Commit dcb63d0d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert "enforceCallingPackage for getCallStateUsingPackage""

parents 224907f8 65fa9249
Loading
Loading
Loading
Loading
+4 −26
Original line number Diff line number Diff line
@@ -1007,17 +1007,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())) {
@@ -2399,20 +2388,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(
@@ -2424,7 +2399,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() {