private void waitForSomeNetworkToConnect() throws Exception {
    final SettableFuture<Void> future = SettableFuture.create();

    ConnectivityManager.NetworkCallback cb =
        new ConnectivityManager.NetworkCallback() {
          @Override
          public void onAvailable(Network network) {
            NetworkInfo netInfo = connManager.getNetworkInfo(network);
            if (netInfo != null && netInfo.isConnected()) {
              future.set(null);
            }
          }
        };

    connManager.requestNetwork(
        new NetworkRequest.Builder().addCapability(NET_CAPABILITY_INTERNET).build(), cb);

    try {
      future.get(NETWORK_STATE_CHANGE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
    } finally {
      connManager.unregisterNetworkCallback(cb);
    }
  }
How long we're willing to wait for a job to run after it becomes eligible.
jobdispatcher/src/androidTest/java/com/firebase/jobdispatcher/AirplaneModeAndroidTest.java