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

Commit 52d270de authored by Achim Thesmann's avatar Achim Thesmann
Browse files

Log source of BAL verdict

Test: atest BackgroundActivityLaunchTest
Flag: EXEMPT logging only
Change-Id: Ie5aa224b18f7cb38ac6eacb111aebd545ff6503f
parent 82e4c14d
Loading
Loading
Loading
Loading
+34 −18
Original line number Diff line number Diff line
@@ -616,7 +616,6 @@ public class BackgroundActivityStartController {
    }

    static class BalVerdict {

        static final BalVerdict BLOCK = new BalVerdict(BAL_BLOCK, false, "Blocked");
        static final BalVerdict ALLOW_BY_DEFAULT =
                new BalVerdict(BAL_ALLOW_DEFAULT, false, "Default");
@@ -640,6 +639,9 @@ public class BackgroundActivityStartController {
        }

        public BalVerdict withProcessInfo(String msg, WindowProcessController process) {
            if (this == BLOCK || this == ALLOW_BY_DEFAULT || this == ALLOW_PRIVILEGED) {
                return this;
            }
            mProcessInfo = msg + " (uid=" + process.mUid + ",pid=" + process.getPid() + ")";
            return this;
        }
@@ -653,6 +655,10 @@ public class BackgroundActivityStartController {
        }

        void setOnlyCreatorAllows(boolean onlyCreatorAllows) {
            if (this == BLOCK) {
                // do not modify BLOCK constant
                return;
            }
            mOnlyCreatorAllows = onlyCreatorAllows;
        }

@@ -662,6 +668,10 @@ public class BackgroundActivityStartController {

        @VisibleForTesting
        BalVerdict setBasedOnRealCaller() {
            if (this == BLOCK) {
                // do not modify BLOCK constant
                return this;
            }
            mBasedOnRealCaller = true;
            return this;
        }
@@ -669,6 +679,12 @@ public class BackgroundActivityStartController {
        public String toString() {
            StringBuilder builder = new StringBuilder();
            builder.append(balCodeToString(mCode));
            if (this != BLOCK) {
                if (mOnlyCreatorAllows) {
                    builder.append(" [onlyCaller]");
                } else if (mBasedOnRealCaller) {
                    builder.append(" [realCaller]");
                }
                if (DEBUG_ACTIVITY_STARTS) {
                    builder.append(" (");
                    if (mBackground) {
@@ -686,6 +702,7 @@ public class BackgroundActivityStartController {
                    }
                    builder.append(")");
                }
            }
            return builder.toString();
        }

@@ -785,9 +802,8 @@ public class BackgroundActivityStartController {
                        .setBasedOnRealCaller();
        state.setResultForRealCaller(resultForRealCaller);

        if (state.isPendingIntent()) {
            resultForCaller.setOnlyCreatorAllows(
                    resultForCaller.allows() && resultForRealCaller.blocks());
        if (state.isPendingIntent() && resultForCaller.allows() && resultForRealCaller.blocks()) {
            resultForCaller.setOnlyCreatorAllows(true);
        }

        // Handle cases with explicit opt-in