SmartLock extends Lock implements CredentialStore, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { void onCredentialsRetrieved(final Activity activity, final Credential credential) { Log.v(TAG, "Credentials : " + credential.getName()); String email = credential.getId(); String password = credential.getPassword(); getAPIClient().login(email, password, getAuthenticationParameters(), new AuthenticationCallback() { @Override public void onSuccess(UserProfile profile, Token token) { Intent result = new Intent(Lock.AUTHENTICATION_ACTION) .putExtra(Lock.AUTHENTICATION_ACTION_PROFILE_PARAMETER, profile) .putExtra(Lock.AUTHENTICATION_ACTION_TOKEN_PARAMETER, token); LocalBroadcastManager.getInstance(activity).sendBroadcast(result); } @Override public void onFailure(Throwable throwable) { LoginAuthenticationErrorBuilder builder = new LoginAuthenticationErrorBuilder(); AuthenticationError error = builder.buildFrom(throwable); ErrorDialogBuilder.showAlertDialog(activity, error); } }); } SmartLock(Context context, APIClient apiClient);   SmartLock(GoogleApiClient credentialClient, APIClient client); void onStart(); void onStop(); @Override void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data); @Override void saveFromActivity(Activity activity, String username, String email, String password, String pictureUrl, CredentialStoreCallback callback); @Override void loginFromActivity(Activity activity); void disableAutoSignIn(); @Override void onConnected(Bundle bundle); @Override void onConnectionSuspended(int i); @Override void onConnectionFailed(ConnectionResult connectionResult); @Override CredentialStore getCredentialStore(); static SmartLock getSmartLock(Activity activity); static final int SMART_LOCK_READ; static final int SMART_LOCK_SAVE; }
@Test public void shouldLoginWhenCredentialsAreRetrievedFromSmartLock() throws Exception { smartLock.onCredentialsRetrieved(activity, credential); verify(apiClient).login(eq(EMAIL), eq(PASSWORD), anyMapOf(String.class, Object.class), any(AuthenticationCallback.class)); }