Skip to content

Commit

Permalink
Add class to manage connection state
Browse files Browse the repository at this point in the history
  • Loading branch information
w4ll3 committed Jul 25, 2024
1 parent 2b12690 commit 063e50b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
21 changes: 0 additions & 21 deletions WalletSdk/src/main/java/com/spruceid/wallet/sdk/Utils.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package com.spruceid.wallet.sdk

import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkCapabilities


fun hexToByteArray(value: String): ByteArray {
val stripped = value.substring(2)
Expand Down Expand Up @@ -32,20 +28,3 @@ enum class PresentmentState {
/// App should display a success message and offer to close the page
SUCCESS,
}

fun isOnline(context: Context): Boolean {
val connectivityManager =
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val capabilities =
connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
if (capabilities != null) {
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
return true
} else if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
return true
} else if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) {
return true
}
}
return false
}
2 changes: 2 additions & 0 deletions example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>


<application
Expand Down

0 comments on commit 063e50b

Please sign in to comment.