@Test public void getPushChallengeBlocking_returns_fast_if_no_fcm_token_supplied() { SignalServiceAccountManager signal = mock(SignalServiceAccountManager.class); long startTime = System.currentTimeMillis(); PushChallengeRequest.getPushChallengeBlocking(signal, Optional.absent(), "+123456", 500L); long duration = System.currentTimeMillis() - startTime; assertThat(duration, lessThan(500L)); }
@WorkerThread public static Optional<String> getPushChallengeBlocking(@NonNull SignalServiceAccountManager accountManager, @NonNull Optional<String> fcmToken, @NonNull String e164number, long timeoutMs) { if (!fcmToken.isPresent()) { Log.w(TAG, "Push challenge not requested, as no FCM token was present"); return Optional.absent(); } long startTime = System.currentTimeMillis(); Log.i(TAG, "Requesting a push challenge"); Request request = new Request(accountManager, fcmToken.get(), e164number, timeoutMs); Optional<String> challenge = request.requestAndReceiveChallengeBlocking(); long duration = System.currentTimeMillis() - startTime; if (challenge.isPresent()) { Log.i(TAG, String.format(Locale.US, "Received a push challenge \"%s\" in %d ms", challenge.get(), duration)); } else { Log.w(TAG, String.format(Locale.US, "Did not received a push challenge in %d ms", duration)); } return challenge; }
PushChallengeRequest { @WorkerThread public static Optional<String> getPushChallengeBlocking(@NonNull SignalServiceAccountManager accountManager, @NonNull Optional<String> fcmToken, @NonNull String e164number, long timeoutMs) { if (!fcmToken.isPresent()) { Log.w(TAG, "Push challenge not requested, as no FCM token was present"); return Optional.absent(); } long startTime = System.currentTimeMillis(); Log.i(TAG, "Requesting a push challenge"); Request request = new Request(accountManager, fcmToken.get(), e164number, timeoutMs); Optional<String> challenge = request.requestAndReceiveChallengeBlocking(); long duration = System.currentTimeMillis() - startTime; if (challenge.isPresent()) { Log.i(TAG, String.format(Locale.US, "Received a push challenge \"%s\" in %d ms", challenge.get(), duration)); } else { Log.w(TAG, String.format(Locale.US, "Did not received a push challenge in %d ms", duration)); } return challenge; } }
PushChallengeRequest { @WorkerThread public static Optional<String> getPushChallengeBlocking(@NonNull SignalServiceAccountManager accountManager, @NonNull Optional<String> fcmToken, @NonNull String e164number, long timeoutMs) { if (!fcmToken.isPresent()) { Log.w(TAG, "Push challenge not requested, as no FCM token was present"); return Optional.absent(); } long startTime = System.currentTimeMillis(); Log.i(TAG, "Requesting a push challenge"); Request request = new Request(accountManager, fcmToken.get(), e164number, timeoutMs); Optional<String> challenge = request.requestAndReceiveChallengeBlocking(); long duration = System.currentTimeMillis() - startTime; if (challenge.isPresent()) { Log.i(TAG, String.format(Locale.US, "Received a push challenge \"%s\" in %d ms", challenge.get(), duration)); } else { Log.w(TAG, String.format(Locale.US, "Did not received a push challenge in %d ms", duration)); } return challenge; }  }
PushChallengeRequest { @WorkerThread public static Optional<String> getPushChallengeBlocking(@NonNull SignalServiceAccountManager accountManager, @NonNull Optional<String> fcmToken, @NonNull String e164number, long timeoutMs) { if (!fcmToken.isPresent()) { Log.w(TAG, "Push challenge not requested, as no FCM token was present"); return Optional.absent(); } long startTime = System.currentTimeMillis(); Log.i(TAG, "Requesting a push challenge"); Request request = new Request(accountManager, fcmToken.get(), e164number, timeoutMs); Optional<String> challenge = request.requestAndReceiveChallengeBlocking(); long duration = System.currentTimeMillis() - startTime; if (challenge.isPresent()) { Log.i(TAG, String.format(Locale.US, "Received a push challenge \"%s\" in %d ms", challenge.get(), duration)); } else { Log.w(TAG, String.format(Locale.US, "Did not received a push challenge in %d ms", duration)); } return challenge; }  @WorkerThread static Optional<String> getPushChallengeBlocking(@NonNull SignalServiceAccountManager accountManager,
                                                          @NonNull Optional<String> fcmToken,
                                                          @NonNull String e164number,
                                                          long timeoutMs); static void postChallengeResponse(@NonNull String challenge); }
PushChallengeRequest { @WorkerThread public static Optional<String> getPushChallengeBlocking(@NonNull SignalServiceAccountManager accountManager, @NonNull Optional<String> fcmToken, @NonNull String e164number, long timeoutMs) { if (!fcmToken.isPresent()) { Log.w(TAG, "Push challenge not requested, as no FCM token was present"); return Optional.absent(); } long startTime = System.currentTimeMillis(); Log.i(TAG, "Requesting a push challenge"); Request request = new Request(accountManager, fcmToken.get(), e164number, timeoutMs); Optional<String> challenge = request.requestAndReceiveChallengeBlocking(); long duration = System.currentTimeMillis() - startTime; if (challenge.isPresent()) { Log.i(TAG, String.format(Locale.US, "Received a push challenge \"%s\" in %d ms", challenge.get(), duration)); } else { Log.w(TAG, String.format(Locale.US, "Did not received a push challenge in %d ms", duration)); } return challenge; }  @WorkerThread static Optional<String> getPushChallengeBlocking(@NonNull SignalServiceAccountManager accountManager,
                                                          @NonNull Optional<String> fcmToken,
                                                          @NonNull String e164number,
                                                          long timeoutMs); static void postChallengeResponse(@NonNull String challenge);  }