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

Commit 4e37fc9a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Better logging for Device Policy Changes in trust" into main

parents 27cfa0e8 4d59aca5
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) {