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

Commit 4d59aca5 authored by Jacob Hobbie's avatar Jacob Hobbie
Browse files

Better logging for Device Policy Changes in trust

Only log DevicePolicyChanged if it actually changes in a way that
affects trust. Log when lockUser is called with what Trustagent called
it.

FLAG: EXEMPT logging change
BUG=426276010
Test: manually running Extend Unlock & Device Policy workflows
Change-Id: I287f07b354948d38e2c99c2506450b661899b588
parent c299c67c
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -309,6 +309,7 @@ public class TrustAgentWrapper {
                    mTrusted = false;
                    mTrustable = false;
                    mTrustManagerService.updateTrust(mUserId, 0 /* flags */);
                    mTrustManagerService.mArchive.logUserLocked(mUserId, mName);
                    mTrustManagerService.lockUser(mUserId);
                    break;
                }
@@ -615,6 +616,11 @@ public class TrustAgentWrapper {
        }
    }

    /**
     * Updates the trust agent's configuration based on the current device policy.
     *
     * @return true if the device policy features changed.
     */
    boolean updateDevicePolicyFeatures() {
        boolean trustDisabled = false;
        if (DEBUG) Slog.d(TAG, "updateDevicePolicyFeatures(" + mName + ")");
@@ -658,8 +664,9 @@ public class TrustAgentWrapper {
        if (mTrustDisabledByDpm != trustDisabled) {
            mTrustDisabledByDpm = trustDisabled;
            mTrustManagerService.updateTrust(mUserId, 0);
            return true;
        }
        return trustDisabled;
        return false;
    }

    public boolean isTrusted() {
+7 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public class TrustArchive {
    private static final int TYPE_AGENT_STOPPED = 5;
    private static final int TYPE_MANAGING_TRUST = 6;
    private static final int TYPE_POLICY_CHANGED = 7;
    private static final int TYPE_USER_LOCKED = 8;

    private static final int HISTORY_LIMIT = 200;

@@ -104,6 +105,10 @@ public class TrustArchive {
        addEvent(new Event(TYPE_POLICY_CHANGED, UserHandle.USER_ALL, null, null, 0, 0, false));
    }

    public void logUserLocked(int userId, ComponentName agent) {
        addEvent(new Event(TYPE_USER_LOCKED, userId, agent, null, 0, 0, false));
    }

    private void addEvent(Event e) {
        if (mEvents.size() >= HISTORY_LIMIT) {
            mEvents.removeFirst();
@@ -191,6 +196,8 @@ public class TrustArchive {
                return "ManagingTrust";
            case TYPE_POLICY_CHANGED:
                return "DevicePolicyChanged";
            case TYPE_USER_LOCKED:
                return "UserLocked";
            default:
                return "Unknown(" + type + ")";
        }
+1 −2
Original line number Diff line number Diff line
@@ -1162,8 +1162,7 @@ public class TrustManagerService extends SystemService {
        for (int i = 0; i < mActiveAgents.size(); i++) {
            AgentInfo info = mActiveAgents.valueAt(i);
            if (info.agent.isConnected()) {
                info.agent.updateDevicePolicyFeatures();
                changed = true;
                changed |= info.agent.updateDevicePolicyFeatures();
            }
        }
        if (changed) {