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

Commit 0630e5d3 authored by Ryan Mitchell's avatar Ryan Mitchell Committed by Automerger Merge Worker
Browse files

Merge "Log when enforceActor fails" into sc-dev am: 75073250

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13606036

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I973cca93b33f2ca9b05ead330ebe0fc83d48ba1b
parents b7b1245c 75073250
Loading
Loading
Loading
Loading
+8 −9
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import android.net.Uri;
import android.os.Process;
import android.os.Process;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Pair;
import android.util.Pair;
import android.util.Slog;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ArrayUtils;
@@ -42,9 +43,6 @@ import java.util.Map;
 */
 */
public class OverlayActorEnforcer {
public class OverlayActorEnforcer {


    // By default, the reason is not logged to prevent leaks of why it failed
    private static final boolean DEBUG_REASON = false;

    private final PackageManagerHelper mPackageManager;
    private final PackageManagerHelper mPackageManager;


    /**
    /**
@@ -85,17 +83,18 @@ public class OverlayActorEnforcer {


    void enforceActor(@NonNull OverlayInfo overlayInfo, @NonNull String methodName,
    void enforceActor(@NonNull OverlayInfo overlayInfo, @NonNull String methodName,
            int callingUid, int userId) throws SecurityException {
            int callingUid, int userId) throws SecurityException {
        ActorState actorState = isAllowedActor(methodName, overlayInfo, callingUid, userId);
        final ActorState actorState = isAllowedActor(methodName, overlayInfo, callingUid, userId);
        if (actorState == ActorState.ALLOWED) {
        if (actorState == ActorState.ALLOWED) {
            return;
            return;
        }
        }


        String targetOverlayableName = overlayInfo.targetOverlayableName;
        final String targetOverlayableName = overlayInfo.targetOverlayableName;
        throw new SecurityException("UID" + callingUid + " is not allowed to call "
        final String errorMessage = "UID" + callingUid + " is not allowed to call " + methodName
                + methodName + " for "
                + " for "
                + (TextUtils.isEmpty(targetOverlayableName) ? "" : (targetOverlayableName + " in "))
                + (TextUtils.isEmpty(targetOverlayableName) ? "" : (targetOverlayableName + " in "))
                + overlayInfo.targetPackageName + (DEBUG_REASON ? (" because " + actorState) : "")
                + overlayInfo.targetPackageName + " for user " + userId;
        );
        Slog.w(OverlayManagerService.TAG, errorMessage + " because " + actorState);
        throw new SecurityException(errorMessage);
    }
    }


    /**
    /**