-
public class NetworkTypeCheckerA 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumNetworkTypeChecker.ConnectionTypeRepresents the type of network connection.
-
Field Summary
Fields Modifier and Type Field Description public static volatile booleanSTOP_TCP_LOG_SHARING
-
Method Summary
Modifier and Type Method Description static voidregister(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 booleanshouldStopLogSharing()Determines if log sharing over TCP should be stopped. static NetworkTypeChecker.ConnectionTypegetConnectionType(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. -
-
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.
-
-
-
-