-
- All Implemented Interfaces:
-
io.sentry.IConnectionStatusProvider,io.sentry.android.core.AppState.AppStateListener,java.io.Closeable,java.lang.AutoCloseable
@ApiStatus.Internal() public final class AndroidConnectionStatusProvider implements IConnectionStatusProvider, AppState.AppStateListener
Note: ConnectivityManager sometimes throws SecurityExceptions on Android 11. Hence all relevant calls are guarded with try/catch. see https://issuetracker.google.com/issues/175055271 for more details
-
-
Field Summary
Fields Modifier and Type Field Description private volatile ConnectivityManager.NetworkCallbacknetworkCallbackprivate final static List<ConnectivityManager.NetworkCallback>childCallbacksprivate volatile NetworkCapabilitiescachedNetworkCapabilities
-
Constructor Summary
Constructors Constructor Description AndroidConnectionStatusProvider(Context context, SentryOptions options, BuildInfoProvider buildInfoProvider, ICurrentDateProvider timeProvider)
-
Method Summary
Modifier and Type Method Description ConnectivityManager.NetworkCallbackgetNetworkCallback()static List<ConnectivityManager.NetworkCallback>getChildCallbacks()NetworkCapabilitiesgetCachedNetworkCapabilities()Get the cached NetworkCapabilities for advanced use cases. IConnectionStatusProvider.ConnectionStatusgetConnectionStatus()StringgetConnectionType()booleanaddConnectionStatusObserver(@NotNull() IConnectionStatusProvider.IConnectionStatusObserver observer)voidremoveConnectionStatusObserver(@NotNull() IConnectionStatusProvider.IConnectionStatusObserver observer)voidclose()Clean up resources - should be called when the provider is no longer needed voidonForeground()voidonBackground()static StringgetConnectionType(@NotNull() Context context, @NotNull() ILogger logger, @NotNull() BuildInfoProvider buildInfoProvider)Check the connection type of the active network static StringgetConnectionType(@NotNull() NetworkCapabilities networkCapabilities)Check the connection type of the active network static booleanaddNetworkCallback(@NotNull() Context context, @NotNull() ILogger logger, @NotNull() BuildInfoProvider buildInfoProvider, @NotNull() ConnectivityManager.NetworkCallback networkCallback)static voidremoveNetworkCallback(@NotNull() ConnectivityManager.NetworkCallback networkCallback)List<IConnectionStatusProvider.IConnectionStatusObserver>getStatusObservers()-
Methods inherited from class io.sentry.IConnectionStatusProvider
addConnectionStatusObserver, getConnectionStatus, getConnectionType, removeConnectionStatusObserver -
Methods inherited from class java.io.Closeable
close -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
AndroidConnectionStatusProvider
AndroidConnectionStatusProvider(Context context, SentryOptions options, BuildInfoProvider buildInfoProvider, ICurrentDateProvider timeProvider)
-
-
Method Detail
-
getNetworkCallback
@TestOnly()@Nullable() ConnectivityManager.NetworkCallback getNetworkCallback()
-
getChildCallbacks
@TestOnly()@NotNull() static List<ConnectivityManager.NetworkCallback> getChildCallbacks()
-
getCachedNetworkCapabilities
@TestOnly()@Nullable() NetworkCapabilities getCachedNetworkCapabilities()
Get the cached NetworkCapabilities for advanced use cases. Returns null if cache is stale or nocapabilities are available.
-
getConnectionStatus
@NotNull() IConnectionStatusProvider.ConnectionStatus getConnectionStatus()
-
getConnectionType
@Nullable() String getConnectionType()
-
addConnectionStatusObserver
boolean addConnectionStatusObserver(@NotNull() IConnectionStatusProvider.IConnectionStatusObserver observer)
-
removeConnectionStatusObserver
void removeConnectionStatusObserver(@NotNull() IConnectionStatusProvider.IConnectionStatusObserver observer)
-
close
void close()
Clean up resources - should be called when the provider is no longer needed
-
onForeground
void onForeground()
-
onBackground
void onBackground()
-
getConnectionType
@Nullable() static String getConnectionType(@NotNull() Context context, @NotNull() ILogger logger, @NotNull() BuildInfoProvider buildInfoProvider)
Check the connection type of the active network
- Parameters:
context- the App.logger- the logger from optionsbuildInfoProvider- the BuildInfoProvider provider
-
getConnectionType
@Nullable() static String getConnectionType(@NotNull() NetworkCapabilities networkCapabilities)
Check the connection type of the active network
- Parameters:
networkCapabilities- the NetworkCapabilities to check the transport type
-
addNetworkCallback
static boolean addNetworkCallback(@NotNull() Context context, @NotNull() ILogger logger, @NotNull() BuildInfoProvider buildInfoProvider, @NotNull() ConnectivityManager.NetworkCallback networkCallback)
-
removeNetworkCallback
static void removeNetworkCallback(@NotNull() ConnectivityManager.NetworkCallback networkCallback)
-
getStatusObservers
@TestOnly()@NotNull() List<IConnectionStatusProvider.IConnectionStatusObserver> getStatusObservers()
-
-
-
-