Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidSchuppa committed May 4, 2022
2 parents 3e37ee9 + 0d343f7 commit b6a3872
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 51 deletions.
10 changes: 6 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# What's fixed
### [Config](https://github.com/emartech/android-emarsys-sdk/wiki/Config#changeapplicationcode)
* Fixed an issue when changing appcode would not clear the push token.
### [Geofence](https://github.com/emartech/android-emarsys-sdk/wiki#8-geofence)
* Fixed an issue when enabling the feature without last known location could cause a crash.
### [EmarsysSDK](https://github.com/emartech/android-emarsys-sdk/wiki)
* Fixed an issue what potentially can happen on Android 11 when apps could crash due to a known Android issue what could happen during network connection change

# What's changed
### [Push](https://github.com/emartech/android-emarsys-sdk/wiki#2-push)
* HuaweiMessagingServiceUtils was made more easily available from Java
Original file line number Diff line number Diff line change
Expand Up @@ -37,53 +37,64 @@ class ConnectionWatchDog(

val connectionState: ConnectionState
get() {
val activeNetwork =
connectivityManager.activeNetwork ?: return ConnectionState.DISCONNECTED
val networkCapabilities =
connectivityManager.getNetworkCapabilities(activeNetwork)
?: return ConnectionState.DISCONNECTED
return when {
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> ConnectionState.CONNECTED
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN) -> ConnectionState.CONNECTED
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> ConnectionState.CONNECTED
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> ConnectionState.CONNECTED_MOBILE_DATA
return try {
val activeNetwork =
connectivityManager.activeNetwork ?: return ConnectionState.DISCONNECTED
val networkCapabilities =
connectivityManager.getNetworkCapabilities(activeNetwork)
?: return ConnectionState.DISCONNECTED
when {
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> ConnectionState.CONNECTED
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN) -> ConnectionState.CONNECTED
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> ConnectionState.CONNECTED
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> ConnectionState.CONNECTED_MOBILE_DATA

else -> ConnectionState.DISCONNECTED
else -> ConnectionState.DISCONNECTED
}
} catch (ignored: Exception) {
ConnectionState.DISCONNECTED
}
}
val isConnected: Boolean
get() {
val network = connectivityManager.activeNetwork ?: return false
val networkCapabilities =
connectivityManager.getNetworkCapabilities(network) ?: return false
return when {
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN) -> true
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true
else -> false
return try {
val network = connectivityManager.activeNetwork ?: return false
val networkCapabilities =
connectivityManager.getNetworkCapabilities(network) ?: return false
return when {
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN) -> true
networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true
else -> false
}
} catch (ignored: Exception) {
false
}
}


fun registerReceiver(connectionChangeListener: ConnectionChangeListener) {
if (AndroidVersionUtils.isOreoOrAbove()) {
this.connectionChangeListener = connectionChangeListener
connectivityManager.registerNetworkCallback(
networkRequest,
this,
concurrentHandlerHolder.coreHandler.handler
)
} else {
if (receiver != null) {
receiver =
ConnectivityChangeReceiver(
connectionChangeListener,
this,
concurrentHandlerHolder
)
context.registerReceiver(receiver, intentFilter)
try {
if (AndroidVersionUtils.isOreoOrAbove()) {
this.connectionChangeListener = connectionChangeListener
connectivityManager.registerNetworkCallback(
networkRequest,
this,
concurrentHandlerHolder.coreHandler.handler
)
} else {
if (receiver != null) {
receiver =
ConnectivityChangeReceiver(
connectionChangeListener,
this,
concurrentHandlerHolder
)
context.registerReceiver(receiver, intentFilter)
}
}
} catch (ignored: Exception) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.emarsys.mobileengage.service.MessagingServiceUtils
import com.huawei.hms.push.RemoteMessage

object EmarsysHuaweiMessagingServiceUtils {

@JvmStatic
fun handleMessage(context: Context, remoteMessage: RemoteMessage): Boolean {
val handlerHolder: ConcurrentHandlerHolder = mobileEngage().concurrentHandlerHolder

Expand Down
22 changes: 11 additions & 11 deletions testWithAllDevices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ core-api:
version: 26
locale: 'en'
orientation: portrait
- model: HWCOR
- model: walleye
version: 27
locale: 'en'
orientation: portrait
Expand Down Expand Up @@ -41,7 +41,7 @@ core:
version: 26
locale: 'en'
orientation: portrait
- model: HWCOR
- model: walleye
version: 27
locale: 'en'
orientation: portrait
Expand Down Expand Up @@ -71,7 +71,7 @@ mobile-engage-api:
version: 26
locale: 'en'
orientation: portrait
- model: HWCOR
- model: walleye
version: 27
locale: 'en'
orientation: portrait
Expand Down Expand Up @@ -101,7 +101,7 @@ mobile-engage:
version: 26
locale: 'en'
orientation: portrait
- model: HWCOR
- model: walleye
version: 27
locale: 'en'
orientation: portrait
Expand Down Expand Up @@ -131,7 +131,7 @@ predict-api:
version: 26
locale: 'en'
orientation: portrait
- model: HWCOR
- model: walleye
version: 27
locale: 'en'
orientation: portrait
Expand Down Expand Up @@ -161,7 +161,7 @@ predict:
version: 26
locale: 'en'
orientation: portrait
- model: HWCOR
- model: walleye
version: 27
locale: 'en'
orientation: portrait
Expand Down Expand Up @@ -191,7 +191,7 @@ emarsys-sdk:
version: 26
locale: 'en'
orientation: portrait
- model: HWCOR
- model: walleye
version: 27
locale: 'en'
orientation: portrait
Expand Down Expand Up @@ -221,7 +221,7 @@ emarsys:
version: 26
locale: 'en'
orientation: portrait
- model: HWCOR
- model: walleye
version: 27
locale: 'en'
orientation: portrait
Expand Down Expand Up @@ -251,7 +251,7 @@ common:
version: 26
locale: 'en'
orientation: portrait
- model: HWCOR
- model: walleye
version: 27
locale: 'en'
orientation: portrait
Expand Down Expand Up @@ -281,7 +281,7 @@ emarsys-firebase:
version: 26
locale: 'en'
orientation: portrait
- model: HWCOR
- model: walleye
version: 27
locale: 'en'
orientation: portrait
Expand Down Expand Up @@ -311,7 +311,7 @@ emarsys-huawei:
version: 26
locale: 'en'
orientation: portrait
- model: HWCOR
- model: walleye
version: 27
locale: 'en'
orientation: portrait
Expand Down

0 comments on commit b6a3872

Please sign in to comment.