Package 

Class NetworkTypeChecker


  • 
    public class NetworkTypeChecker
    
                        

    A utility class for checking the type of network connection. This class provides methods to determine the current network connection type, such as WiFi, mobile data, or VPN. It also includes functionality to control log sharing behavior based on the network type.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      public static volatile boolean STOP_TCP_LOG_SHARING
    • Method Summary

      Modifier and Type Method Description
      static void register(Context context) Registers the ConnectivityManager to monitor network changes.This method should be called once during application initialization, typically in the Application class's onCreate() method.It retrieves the ConnectivityManager system service and stores it for later use.
      static boolean shouldStopLogSharing() Determines if log sharing over TCP should be stopped.
      static NetworkTypeChecker.ConnectionType getConnectionType(ConnectivityManager manager) Determines the current network connection type.This method checks for active network interfaces and their types to determine the connection type.It prioritizes VPN connections, followed by WiFi and mobile data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • register

         static void register(Context context)

        Registers the ConnectivityManager to monitor network changes.This method should be called once during application initialization, typically in the Application class's onCreate() method.It retrieves the ConnectivityManager system service and stores it for later use.

        Parameters:
        context - The application context.
      • shouldStopLogSharing

         static boolean shouldStopLogSharing()

        Determines if log sharing over TCP should be stopped.Log sharing is stopped if the following conditions are met:- STOP_TCP_LOG_SHARING is true.- The device is connected to a VPN, WiFi, or is rooted.This method checks the current connection type and device root statusto make the determination.

      • getConnectionType

         static NetworkTypeChecker.ConnectionType getConnectionType(ConnectivityManager manager)

        Determines the current network connection type.This method checks for active network interfaces and their types to determine the connection type.It prioritizes VPN connections, followed by WiFi and mobile data.

        Parameters:
        manager - The ConnectivityManager instance used to obtain network information.