public static void invokeFinishActivityOnUiThread(final Activity activity) {
    runOnMainSyncWithTimeout(
        new Callable<Void>() {
          @Override
          public Void call() {
            activity.finish();
            return null;
          }
        });
  }
Invokes the {@link Activity}'s {@code finish()} on the UI thread and blocks (with a timeout)
the calling thread until the invocation completes. If the calling thread is the UI thread, the
{@code finish} is invoked directly and without a timeout.
javatests/com/google/android/apps/authenticator/testing/TestUtilities.java