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

Commit 4b0ec7e9 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Trust Agents: Withhold trust until user has authenticated"

parents dc0d5d18 7046bfd0
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.service.trust.TrustAgentService;
import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.Slog;
import android.util.SparseBooleanArray;
import android.util.Xml;

import java.io.IOException;
@@ -85,6 +86,7 @@ public class TrustManagerService extends SystemService {
    private final ArraySet<AgentInfo> mActiveAgents = new ArraySet<AgentInfo>();
    private final ArrayList<ITrustListener> mTrustListeners = new ArrayList<ITrustListener>();
    private final DevicePolicyReceiver mDevicePolicyReceiver = new DevicePolicyReceiver();
    private final SparseBooleanArray mUserHasAuthenticatedSinceBoot = new SparseBooleanArray();
    private final Context mContext;

    private UserManager mUserManager;
@@ -268,6 +270,9 @@ public class TrustManagerService extends SystemService {
    // Agent dispatch and aggregation

    private boolean aggregateIsTrusted(int userId) {
        if (!mUserHasAuthenticatedSinceBoot.get(userId)) {
            return false;
        }
        for (int i = 0; i < mActiveAgents.size(); i++) {
            AgentInfo info = mActiveAgents.valueAt(i);
            if (info.userId == userId) {
@@ -286,6 +291,11 @@ public class TrustManagerService extends SystemService {
                info.agent.onUnlockAttempt(successful);
            }
        }

        if (successful && !mUserHasAuthenticatedSinceBoot.get(userId)) {
            mUserHasAuthenticatedSinceBoot.put(userId, true);
            updateTrust(userId);
        }
    }

    // Listeners