-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
185 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...com/spruceid/wallet/sdk/BaseCredential.kt → ...com/spruceid/mobile/sdk/BaseCredential.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ava/com/spruceid/wallet/sdk/BleCentral.kt → ...ava/com/spruceid/mobile/sdk/BleCentral.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...spruceid/wallet/sdk/BleCentralCallback.kt → ...spruceid/mobile/sdk/BleCentralCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.spruceid.wallet.sdk | ||
package com.spruceid.mobile.sdk | ||
|
||
import android.bluetooth.le.ScanResult | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
.../com/spruceid/wallet/sdk/BlePeripheral.kt → .../com/spruceid/mobile/sdk/BlePeripheral.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../spruceid/wallet/sdk/BleSessionManager.kt → .../spruceid/mobile/sdk/BleSessionManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...java/com/spruceid/wallet/sdk/BleStates.kt → ...java/com/spruceid/mobile/sdk/BleStates.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
MobileSdk/src/main/java/com/spruceid/mobile/sdk/ConnectionLiveData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.spruceid.mobile.sdk | ||
|
||
import android.content.Context | ||
import android.content.Context.CONNECTIVITY_SERVICE | ||
import android.net.ConnectivityManager | ||
import android.net.Network | ||
import android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET | ||
import android.net.NetworkCapabilities.TRANSPORT_CELLULAR | ||
import android.net.NetworkCapabilities.TRANSPORT_WIFI | ||
import android.net.NetworkRequest | ||
import androidx.lifecycle.LiveData | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.withContext | ||
import java.io.IOException | ||
import java.net.InetSocketAddress | ||
import javax.net.SocketFactory | ||
|
||
class ConnectionLiveData(context: Context) : LiveData<Boolean>() { | ||
|
||
private lateinit var networkCallback: ConnectivityManager.NetworkCallback | ||
private val connectivityManager = | ||
context.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager | ||
private val validNetworks: MutableSet<Network> = HashSet() | ||
|
||
private fun checkValidNetworks() { | ||
postValue(validNetworks.size > 0) | ||
} | ||
|
||
override fun onActive() { | ||
networkCallback = createNetworkCallback() | ||
val networkRequest = NetworkRequest.Builder() | ||
.addCapability(NET_CAPABILITY_INTERNET) | ||
.addTransportType(TRANSPORT_WIFI) | ||
.addTransportType(TRANSPORT_CELLULAR) | ||
.build() | ||
connectivityManager.registerNetworkCallback(networkRequest, networkCallback) | ||
} | ||
|
||
override fun onInactive() { | ||
connectivityManager.unregisterNetworkCallback(networkCallback) | ||
} | ||
|
||
private fun createNetworkCallback() = object : ConnectivityManager.NetworkCallback() { | ||
|
||
override fun onAvailable(network: Network) { | ||
val networkCapabilities = connectivityManager.getNetworkCapabilities(network) | ||
val hasInternetCapability = networkCapabilities?.hasCapability(NET_CAPABILITY_INTERNET) | ||
|
||
if (hasInternetCapability == true) { | ||
// Check if this network actually has internet | ||
CoroutineScope(Dispatchers.IO).launch { | ||
val hasInternet = DoesNetworkHaveInternet.execute(network.socketFactory) | ||
if (hasInternet) { | ||
withContext(Dispatchers.Main) { | ||
validNetworks.add(network) | ||
checkValidNetworks() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun onLost(network: Network) { | ||
validNetworks.remove(network) | ||
checkValidNetworks() | ||
} | ||
} | ||
|
||
object DoesNetworkHaveInternet { | ||
suspend fun execute(socketFactory: SocketFactory): Boolean { | ||
// Make sure to execute this on a background thread. | ||
delay(1000) | ||
return try { | ||
val socket = socketFactory.createSocket() ?: throw IOException("Socket is null.") | ||
socket.connect(InetSocketAddress("8.8.8.8", 53), 1500) | ||
socket.close() | ||
true | ||
} catch (e: IOException) { | ||
false | ||
} | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...com/spruceid/wallet/sdk/CredentialPack.kt → ...com/spruceid/mobile/sdk/CredentialPack.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ruceid/wallet/sdk/CredentialsViewModel.kt → ...ruceid/mobile/sdk/CredentialsViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ava/com/spruceid/wallet/sdk/GattClient.kt → ...ava/com/spruceid/mobile/sdk/GattClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...spruceid/wallet/sdk/GattClientCallback.kt → ...spruceid/mobile/sdk/GattClientCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ava/com/spruceid/wallet/sdk/GattServer.kt → ...ava/com/spruceid/mobile/sdk/GattServer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.spruceid.wallet.sdk | ||
package com.spruceid.mobile.sdk | ||
|
||
|
||
import android.bluetooth.* | ||
|
2 changes: 1 addition & 1 deletion
2
...spruceid/wallet/sdk/GattServerCallback.kt → ...spruceid/mobile/sdk/GattServerCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ava/com/spruceid/wallet/sdk/KeyManager.kt → ...ava/com/spruceid/mobile/sdk/KeyManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...uceid/wallet/sdk/KeyManagerEnvironment.kt → ...uceid/mobile/sdk/KeyManagerEnvironment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...main/java/com/spruceid/wallet/sdk/MDoc.kt → ...main/java/com/spruceid/mobile/sdk/MDoc.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...java/com/spruceid/wallet/sdk/Transport.kt → ...java/com/spruceid/mobile/sdk/Transport.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...a/com/spruceid/wallet/sdk/TransportBle.kt → ...a/com/spruceid/mobile/sdk/TransportBle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...et/sdk/TransportBleCentralClientHolder.kt → ...le/sdk/TransportBleCentralClientHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...sdk/TransportBlePeripheralServerHolder.kt → ...sdk/TransportBlePeripheralServerHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ain/java/com/spruceid/wallet/sdk/W3CVC.kt → ...ain/java/com/spruceid/mobile/sdk/W3CVC.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.spruceid.wallet.sdk | ||
package com.spruceid.mobile.sdk | ||
|
||
import org.json.JSONObject | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...id/wallet/sdk/ui/GenericCameraXScanner.kt → ...id/mobile/sdk/ui/GenericCameraXScanner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../com/spruceid/wallet/sdk/ui/MRZScanner.kt → .../com/spruceid/mobile/sdk/ui/MRZScanner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...m/spruceid/wallet/sdk/ui/PDF417Scanner.kt → ...m/spruceid/mobile/sdk/ui/PDF417Scanner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...m/spruceid/wallet/sdk/ui/QRCodeScanner.kt → ...m/spruceid/mobile/sdk/ui/QRCodeScanner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...com/spruceid/wallet/sdk/KeyManagerTest.kt → ...com/spruceid/mobile/sdk/KeyManagerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.spruceid.wallet.sdk | ||
package com.spruceid.mobile.sdk | ||
|
||
import org.junit.Test | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.