// Path: Android/app/src/main/java/app/intra/sys/firebase/LogWrapper.java
// public class LogWrapper {
//   public static void logException(Throwable t) {
//     Log.e("LogWrapper", "Error", t);
//     if (BuildConfig.DEBUG) {
//       return;
//     }
//     try {
//       FirebaseCrashlytics.getInstance().recordException(t);
//     } catch (IllegalStateException e) {
//       // This only occurs during unit tests.
//     }
//   }
// 
//   public static void log(int severity, String tag, String message) {
//     Log.println(severity, tag, message);
//     if (BuildConfig.DEBUG) {
//       return;
//     }
//     try {
//       FirebaseCrashlytics.getInstance().log(tag + ": " + message);
//     } catch (IllegalStateException e) {
//       // This only occurs during unit tests.
//     }
//   }
// }


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.Log;
import app.intra.sys.firebase.LogWrapper;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
      return false;
    }
    return networkInfo.isConnectedOrConnecting() && networkInfo.isAvailable();
  }

  /**
   * Post-Lollipop, we can use VpnService.Builder.addDisallowedApplication to exclude Intra from its
   * own VPN.  If for some reason we needed to get the IP address of the non-VPN resolvers, we could
   * use ConnectivityManager.getActiveNetwork().getLinkProperties().getDnsServers().
   *
   * Pre-Lollipop, there is no official way to get the non-VPN DNS servers, but we need them in
   * order to do DNS lookups on protected sockets in Go, in order to resolve DNS server names when
   * the current server connection is broken, without disabling the VPN.  This implementation
   * exposes the hidden version of LinkProperties that was present prior to Lollipop, in order to
   * extract the DNS server IPs.
   *
   * @return The (unencrypted) DNS servers used by the underlying networks.
   */
  List<InetAddress> getSystemResolvers() {
    // This list of network types is in roughly descending priority order, so that the first
    // entries in the returned list are most likely to be the appropriate resolvers.
    int[] networkTypes = new int[]{
        ConnectivityManager.TYPE_ETHERNET,
        ConnectivityManager.TYPE_WIFI,
        ConnectivityManager.TYPE_MOBILE,
        ConnectivityManager.TYPE_WIMAX,
    };

    List<InetAddress> resolvers = new ArrayList<>();
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
// Path: Android/app/src/main/java/app/intra/sys/firebase/LogWrapper.java
// public class LogWrapper {
//   public static void logException(Throwable t) {
//     Log.e("LogWrapper", "Error", t);
//     if (BuildConfig.DEBUG) {
//       return;
//     }
//     try {
//       FirebaseCrashlytics.getInstance().recordException(t);
//     } catch (IllegalStateException e) {
//       // This only occurs during unit tests.
//     }
//   }
// 
//   public static void log(int severity, String tag, String message) {
//     Log.println(severity, tag, message);
//     if (BuildConfig.DEBUG) {
//       return;
//     }
//     try {
//       FirebaseCrashlytics.getInstance().log(tag + ": " + message);
//     } catch (IllegalStateException e) {
//       // This only occurs during unit tests.
//     }
//   }
// }


// Path: Android/app/src/main/java/app/intra/sys/NetworkManager.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.Log;
import app.intra.sys.firebase.LogWrapper;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

      return false;
    }
    return networkInfo.isConnectedOrConnecting() && networkInfo.isAvailable();
  }

  /**
   * Post-Lollipop, we can use VpnService.Builder.addDisallowedApplication to exclude Intra from its
   * own VPN.  If for some reason we needed to get the IP address of the non-VPN resolvers, we could
   * use ConnectivityManager.getActiveNetwork().getLinkProperties().getDnsServers().
   *
   * Pre-Lollipop, there is no official way to get the non-VPN DNS servers, but we need them in
   * order to do DNS lookups on protected sockets in Go, in order to resolve DNS server names when
   * the current server connection is broken, without disabling the VPN.  This implementation
   * exposes the hidden version of LinkProperties that was present prior to Lollipop, in order to
   * extract the DNS server IPs.
   *
   * @return The (unencrypted) DNS servers used by the underlying networks.
   */
  List<InetAddress> getSystemResolvers() {
    // This list of network types is in roughly descending priority order, so that the first
    // entries in the returned list are most likely to be the appropriate resolvers.
    int[] networkTypes = new int[]{
        ConnectivityManager.TYPE_ETHERNET,
        ConnectivityManager.TYPE_WIFI,
        ConnectivityManager.TYPE_MOBILE,
        ConnectivityManager.TYPE_WIMAX,
    };

    List<InetAddress> resolvers = new ArrayList<>();
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
      LogWrapper.log(Log.ASSERT, LOG_TAG, "This function should never be called in L+.");