OSDN Git Service

Trust Agents: Withhold trust until user has authenticated
authorAdrian Roos <roosa@google.com>
Fri, 16 May 2014 19:20:54 +0000 (21:20 +0200)
committerAdrian Roos <roosa@google.com>
Fri, 16 May 2014 19:24:29 +0000 (21:24 +0200)
Bug: 14229695
Change-Id: I40d9fa442aa05437c20081c007ed64f984042418

services/core/java/com/android/server/trust/TrustManagerService.java

index 44af41c..c1b9a33 100644 (file)
@@ -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