Merge "onTrustChanged callback triggered before onTrustGrantedForCurrentUser" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
348bb0e22c
@@ -522,6 +522,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
FACE_AUTH_TRIGGERED_TRUST_DISABLED);
|
||||
}
|
||||
|
||||
mLogger.logTrustChanged(wasTrusted, enabled, userId);
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||
if (cb != null) {
|
||||
cb.onTrustChanged(userId);
|
||||
}
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
String message = null;
|
||||
if (KeyguardUpdateMonitor.getCurrentUser() == userId
|
||||
@@ -560,14 +568,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mLogger.logTrustChanged(wasTrusted, enabled, userId);
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||
if (cb != null) {
|
||||
cb.onTrustChanged(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -151,7 +151,9 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.InOrder;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.MockitoSession;
|
||||
import org.mockito.internal.util.reflection.FieldSetter;
|
||||
@@ -2737,6 +2739,36 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
verifyFingerprintAuthenticateCall();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onTrustChangedCallbacksCalledBeforeOnTrustGrantedForCurrentUserCallback() {
|
||||
// GIVEN device is interactive
|
||||
deviceIsInteractive();
|
||||
|
||||
// GIVEN callback is registered
|
||||
KeyguardUpdateMonitorCallback callback = mock(KeyguardUpdateMonitorCallback.class);
|
||||
mKeyguardUpdateMonitor.registerCallback(callback);
|
||||
|
||||
// WHEN onTrustChanged enabled=true
|
||||
mKeyguardUpdateMonitor.onTrustChanged(
|
||||
true /* enabled */,
|
||||
true /* newlyUnlocked */,
|
||||
getCurrentUser() /* userId */,
|
||||
TrustAgentService.FLAG_GRANT_TRUST_DISMISS_KEYGUARD /* flags */,
|
||||
null /* trustGrantedMessages */);
|
||||
|
||||
// THEN onTrustChanged is called FIRST
|
||||
final InOrder inOrder = Mockito.inOrder(callback);
|
||||
inOrder.verify(callback).onTrustChanged(eq(getCurrentUser()));
|
||||
|
||||
// AND THEN onTrustGrantedForCurrentUser callback called
|
||||
inOrder.verify(callback).onTrustGrantedForCurrentUser(
|
||||
eq(true) /* dismissKeyguard */,
|
||||
eq(true) /* newlyUnlocked */,
|
||||
eq(new TrustGrantFlags(TrustAgentService.FLAG_GRANT_TRUST_DISMISS_KEYGUARD)),
|
||||
eq(null) /* message */
|
||||
);
|
||||
}
|
||||
|
||||
private void verifyFingerprintAuthenticateNeverCalled() {
|
||||
verify(mFingerprintManager, never()).authenticate(any(), any(), any(), any(), any());
|
||||
verify(mFingerprintManager, never()).authenticate(any(), any(), any(), any(), anyInt(),
|
||||
|
||||
Reference in New Issue
Block a user