Loading packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +8 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); } } } /** Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(), Loading Loading
packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +8 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); } } } /** Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(), Loading