Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
feat: upgrade to SDK version 1.6.1 (#274)
Browse files Browse the repository at this point in the history
* feat: upgrade to SDK version 1.6.1 in order to use the deviceSupportsLocationlessScanning() method

* #build-release
  • Loading branch information
marcouberti authored Sep 21, 2020
1 parent 6851dfd commit 4318a24
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class ExposureManager(

val lastSuccessfulCheckDate = exposureReportingRepository.lastSuccessfulCheckDate

fun deviceSupportsLocationlessScanning() = exposureNotificationManager.deviceSupportsLocationlessScanning()

suspend fun updateAndGetServiceIsActive(): Boolean {
exposureNotificationManager.update()
return exposureNotificationManager.areExposureNotificationsEnabled.value ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class OnboardingViewModel(
val isOnboardingComplete
get() = userManager.isOnboardingComplete.value

val deviceSupportsLocationlessScanning
get() = exposureManager.deviceSupportsLocationlessScanning()

fun completeOnboarding() {
userManager.setOnboardingComplete(true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@

package it.ministerodellasalute.immuni.ui.onboarding.fragments.viewpager

import android.os.Build
import android.os.Bundle
import android.view.View
import androidx.lifecycle.Observer
import androidx.navigation.fragment.findNavController
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import it.ministerodellasalute.immuni.R
import it.ministerodellasalute.immuni.extensions.utils.DeviceUtils
import it.ministerodellasalute.immuni.extensions.view.gone
import it.ministerodellasalute.immuni.extensions.view.setSafeOnClickListener
import it.ministerodellasalute.immuni.ui.onboarding.fragments.ViewPagerFragmentDirections
Expand Down Expand Up @@ -68,7 +66,7 @@ class ExposureNotificationFragment :

knowMore.setSafeOnClickListener {
// EN on Android 11 don't require active location
if (DeviceUtils.androidVersionAPI >= Build.VERSION_CODES.R) {
if (viewModel.deviceSupportsLocationlessScanning) {
val action = ViewPagerFragmentDirections.actionHowitworks(false)
findNavController().navigate(action)
} else {
Expand All @@ -84,7 +82,7 @@ class ExposureNotificationFragment :

private fun checkLocalisationRequired() {
// EN on Android 11 don't require active location
if (DeviceUtils.androidVersionAPI >= Build.VERSION_CODES.R) {
if (viewModel.deviceSupportsLocationlessScanning) {
extendedMessage.gone()
}
}
Expand Down
Binary file removed extensions/libs/play-services-nearby-18.0.3-eap.aar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ interface ExposureNotificationClient {

suspend fun isEnabled(): Boolean

fun deviceSupportsLocationlessScanning(): Boolean

suspend fun getTemporaryExposureKeyHistory(): List<TemporaryExposureKey>

suspend fun provideDiagnosisKeys(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class ExposureNotificationClientWrapper(
client.stop().await()
}

override fun deviceSupportsLocationlessScanning(): Boolean = client.deviceSupportsLocationlessScanning()

override suspend fun isEnabled(): Boolean = client.isEnabled.await()

override suspend fun getTemporaryExposureKeyHistory(): List<ExposureNotificationClient.TemporaryExposureKey> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.IntentSender
import android.os.Build
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.nearby.Nearby
import com.google.android.gms.nearby.exposurenotification.ExposureNotificationStatusCodes
import it.ministerodellasalute.immuni.extensions.bluetooth.BluetoothStateFlow
import it.ministerodellasalute.immuni.extensions.lifecycle.AppLifecycleObserver
import it.ministerodellasalute.immuni.extensions.location.LocationStateFlow
import it.ministerodellasalute.immuni.extensions.nearby.ExposureNotificationClient.*
import it.ministerodellasalute.immuni.extensions.utils.DeviceUtils
import it.ministerodellasalute.immuni.extensions.utils.log
import java.io.File
import java.util.*
Expand Down Expand Up @@ -76,6 +74,8 @@ class ExposureNotificationManager(
private val _isBroadcastingActive = MutableStateFlow<Boolean?>(null)
val isBroadcastingActive: StateFlow<Boolean?> = _isBroadcastingActive

fun deviceSupportsLocationlessScanning() = exposureNotificationClient.deviceSupportsLocationlessScanning()

private lateinit var delegate: Delegate

fun setup(delegate: Delegate) {
Expand All @@ -92,7 +92,7 @@ class ExposureNotificationManager(
when {
areExposureNotificationsEnabled == null -> null
// EN on Android 11 don't require active location
DeviceUtils.androidVersionAPI >= Build.VERSION_CODES.R -> isBluetoothActive && (areExposureNotificationsEnabled == true)
deviceSupportsLocationlessScanning() -> isBluetoothActive && (areExposureNotificationsEnabled == true)
else -> isLocationActive && isBluetoothActive && (areExposureNotificationsEnabled == true)
}
}.conflate().onEach {
Expand Down

0 comments on commit 4318a24

Please sign in to comment.