Skip to content

Commit

Permalink
Merge pull request #420 from RADAR-base/release-1.2.4
Browse files Browse the repository at this point in the history
Release 1.2.4
  • Loading branch information
Bdegraaf1234 authored May 8, 2024
2 parents f62557c + 03f8fa7 commit 23f0a3b
Show file tree
Hide file tree
Showing 65 changed files with 556 additions and 196 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,35 @@ To only build plugins that are of interest to you, add a `gradle.skip` file in a

If you want to contribute a feature or fix browse our [issues](https://github.com/RADAR-base/radar-commons-android/issues), and please make a pull request.

## Publishing Schemas to Maven Local

While the plugin is in development phase schemas are not published centrally. To access the java generated file from avro schemas first publish them to maven local.
To publish schemas locally to Maven, please follow these steps:

1. Change your working directory to java-sdk in RADAR-Schemas.

2. Run the following commands in your terminal:
```shell
./gradlew build
./gradlew publishToMavenLocal
```

3. In your build.gradle file, add the following to your repositories block:
```gradle
repositories {
mavenLocal()
}
```

4. In the same build.gradle file, add the following to your dependencies block, replacing `$radarSchemasVersion` with its corresponding value:
```gradle
dependencies {
implementation "org.radarbase:radar-schemas-commons:$radarSchemasVersion"
}
```

You can find the version value in the metadata of your local Maven repository. It should end in `SNAPSHOT`.

## Licensing

Code made in the RADAR-base platform is licensed under the Apache License 2.0, as listed in see the LICENSE file in this directory. Plugins that have additional licensing requirements list them in their README.
1 change: 1 addition & 0 deletions avro-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

<manifest/>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ allprojects {
ext.issueUrl = 'https://github.com/' + githubRepoName + '/issues'
ext.website = 'http://radar-base.org'

version = "1.2.3"
version = "1.2.4"
group = 'org.radarbase'

ext.versionCode = 51
ext.versionCode = 52
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<service android:name=".ApplicationStatusService"/>
<service android:name=".ApplicationStatusService"
android:exported="false"
android:description="@string/application_status_description" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<resources>
<string name="applicationServiceDisplayName">Application</string>
<string name="application_status_description">Monitors how much data the app is collecting and
server status.
</string>
<string name="application_status_description">Monitors how much data the app is collecting and server status.</string>
</resources>
3 changes: 0 additions & 3 deletions plugins/radar-android-audio/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ android {
ndk {
moduleName rootProject.name
}
packagingOptions {
doNotStrip '**.so'
}
}

// Encapsulates your external native build configurations.
Expand Down
4 changes: 3 additions & 1 deletion plugins/radar-android-audio/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

<application>
<service android:name=".OpenSmileAudioService"
android:foregroundServiceType="microphone"/>
android:foregroundServiceType="microphone"
android:exported="false"
android:description="@string/audio_description" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class OpenSmileAudioService : SourceService<BaseSourceState>() {
manager as OpensmileAudioManager
manager.setRecordRate(config.getLong(AUDIO_RECORD_RATE_S, DEFAULT_RECORD_RATE))
manager.config = OpensmileAudioManager.AudioConfiguration(
config.getString(AUDIO_CONFIG_FILE, "ComParE_2016.conf"),
config.getLong(AUDIO_DURATION_S, 15L),
TimeUnit.SECONDS
config.getString(AUDIO_CONFIG_FILE, "ComParE_2016.conf"),
config.getLong(AUDIO_DURATION_S, 15L),
TimeUnit.SECONDS,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class OpensmileAudioManager constructor(service: OpenSmileAudioService) : Abstra
?.list { _, name -> name.startsWith("audio_") && name.endsWith(".bin") }
?.forEach { File(audioDir.parentFile, it).delete() }

audioDir.walk().filter { it.startsWith("audio_") && it.endsWith(".bin") }
audioDir.walk().filter { it.startsWith("audio_") && it.path.endsWith(".bin") }
.forEach { it.delete() }
}
}
Expand Down
20 changes: 14 additions & 6 deletions plugins/radar-android-empatica/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
android:minSdkVersion="31"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"
android:minSdkVersion="31"/>

<application android:allowBackup="true">
<service
android:name=".E4Service"
android:foregroundServiceType="location"/>
android:foregroundServiceType="location"
android:exported="false"
android:description="@string/empatica_e4_explanation" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.empatica.empalink.config.EmpaStatus
import com.empatica.empalink.delegate.EmpaDataDelegate
import com.empatica.empalink.delegate.EmpaSessionManagerDelegate
import com.empatica.empalink.delegate.EmpaStatusDelegate
import org.radarbase.android.RadarApplication.Companion.radarApp
import org.radarbase.android.source.AbstractSourceManager
import org.radarbase.android.source.SourceStatusListener
import org.radarbase.android.util.BluetoothStateReceiver.Companion.bluetoothIsEnabled
Expand All @@ -46,6 +45,9 @@ class E4Manager(
EmpaDataDelegate,
EmpaStatusDelegate,
EmpaSessionManagerDelegate {
private val notificationHandler: NotificationHandler by lazy {
NotificationHandler(service)
}
private var doNotify: Boolean = false
private val accelerationTopic = createCache("android_empatica_e4_acceleration", EmpaticaE4Acceleration())
private val batteryLevelTopic = createCache("android_empatica_e4_battery_level", EmpaticaE4BatteryLevel())
Expand Down Expand Up @@ -122,7 +124,7 @@ class E4Manager(
EmpaStatus.CONNECTING -> hasBeenConnecting = true
EmpaStatus.CONNECTED -> {
status = SourceStatusListener.Status.CONNECTED
service.radarApp.notificationHandler.manager?.cancel(EMPATICA_DISCONNECTED_NOTIFICATION_ID)
notificationHandler.manager?.cancel(EMPATICA_DISCONNECTED_NOTIFICATION_ID)
}
EmpaStatus.DISCONNECTED ->
// The device manager disconnected from a device. Before it ever makes a connection,
Expand Down Expand Up @@ -230,10 +232,11 @@ class E4Manager(

override fun disconnect() {
if (status != SourceStatusListener.Status.UNAVAILABLE && !isClosed && doNotify) {
service.radarApp.notificationHandler.notify(
id = EMPATICA_DISCONNECTED_NOTIFICATION_ID,
channel = NotificationHandler.NOTIFICATION_CHANNEL_ALERT,
includeStartIntent = true) {
notificationHandler.notify(
id = EMPATICA_DISCONNECTED_NOTIFICATION_ID,
channel = NotificationHandler.NOTIFICATION_CHANNEL_ALERT,
includeStartIntent = true,
) {
setContentTitle(service.getString(R.string.notification_empatica_disconnected_title))
setContentText(service.getString(R.string.notification_empatica_disconnected_text))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.content.pm.PackageManager
import android.os.Build
import org.radarbase.android.RadarService
import org.radarbase.android.source.SourceProvider
import org.radarbase.android.util.BluetoothStateReceiver.Companion.bluetoothPermissionList

open class E4Provider(radarService: RadarService) : SourceProvider<E4State>(radarService) {
override val serviceClass = E4Service::class.java
Expand All @@ -32,19 +33,7 @@ open class E4Provider(radarService: RadarService) : SourceProvider<E4State>(rada
"org.radarbase.passive.empatica.E4Provider",
"org.radarcns.empatica.E4ServiceProvider")

override val permissionsNeeded = buildList {
add(ACCESS_COARSE_LOCATION)
add(ACCESS_FINE_LOCATION)
add(BLUETOOTH)
add(BLUETOOTH_ADMIN)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
add(BLUETOOTH_SCAN)
add(BLUETOOTH_CONNECT)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
add(ACCESS_BACKGROUND_LOCATION)
}
}
override val permissionsNeeded = bluetoothPermissionList

override val featuresNeeded = listOf(PackageManager.FEATURE_BLUETOOTH, PackageManager.FEATURE_BLUETOOTH_LE)

Expand Down
18 changes: 13 additions & 5 deletions plugins/radar-android-faros/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@

<uses-feature android:name="android.hardware.bluetooth" android:required="false"/>

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
android:minSdkVersion="31"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"
android:minSdkVersion="31"/>

<application>
<service android:name=".FarosService"
android:foregroundServiceType="location"/>
android:foregroundServiceType="location"
android:exported="false"
android:description="@string/farosDescription"/>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class FarosManager internal constructor(
private val farosFactory: FarosSdkFactory,
private val handler: SafeHandler
) : AbstractSourceManager<FarosService, FarosState>(service), FarosDeviceListener, FarosSdkListener {
private val notificationHandler by lazy {
NotificationHandler(this.service)
}
private var doNotify: Boolean = false
private val accelerationTopic: DataCache<ObservationKey, BittiumFarosAcceleration> = createCache("android_bittium_faros_acceleration", BittiumFarosAcceleration())
private val ecgTopic: DataCache<ObservationKey, BittiumFarosEcg> = createCache("android_bittium_faros_ecg", BittiumFarosEcg())
Expand Down Expand Up @@ -78,7 +81,7 @@ class FarosManager internal constructor(
startMeasurements()
}
}
service.radarApp.notificationHandler.manager?.cancel(FAROS_DISCONNECTED_NOTIFICATION_ID)
notificationHandler.manager?.cancel(FAROS_DISCONNECTED_NOTIFICATION_ID)
SourceStatusListener.Status.CONNECTED
}
FarosDeviceListener.CONNECTING -> SourceStatusListener.Status.CONNECTING
Expand Down Expand Up @@ -194,10 +197,11 @@ class FarosManager internal constructor(

override fun disconnect() {
if (!isClosed && doNotify) {
service.radarApp.notificationHandler.notify(
id = FAROS_DISCONNECTED_NOTIFICATION_ID,
channel = NotificationHandler.NOTIFICATION_CHANNEL_ALERT,
includeStartIntent = true) {
notificationHandler.notify(
id = FAROS_DISCONNECTED_NOTIFICATION_ID,
channel = NotificationHandler.NOTIFICATION_CHANNEL_ALERT,
includeStartIntent = true,
) {
setContentTitle(service.getString(R.string.notification_faros_disconnected_title))
setContentText(service.getString(R.string.notification_faros_disconnected_text))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

package org.radarbase.passive.bittium

import android.Manifest.permission.*
import android.content.pm.PackageManager
import android.os.Build
import org.radarbase.android.BuildConfig
import org.radarbase.android.RadarService
import org.radarbase.android.source.SourceProvider
import org.radarbase.android.util.BluetoothStateReceiver.Companion.bluetoothPermissionList

class FarosProvider(radarService: RadarService) : SourceProvider<FarosState>(radarService) {
override val description: String?
Expand All @@ -38,19 +37,7 @@ class FarosProvider(radarService: RadarService) : SourceProvider<FarosState>(rad

override val hasDetailView: Boolean = true

override val permissionsNeeded: List<String> = buildList {
add(ACCESS_COARSE_LOCATION)
add(ACCESS_FINE_LOCATION)
add(BLUETOOTH)
add(BLUETOOTH_ADMIN)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
add(BLUETOOTH_SCAN)
add(BLUETOOTH_CONNECT)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
add(ACCESS_BACKGROUND_LOCATION)
}
}
override val permissionsNeeded: List<String> = bluetoothPermissionList

override val featuresNeeded: List<String> = listOf(PackageManager.FEATURE_BLUETOOTH)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ class FarosState : BaseSourceState() {
this.acceleration[2] = z
}

override fun toString(): String {
return "FarosDeviceStatus{" +
"batteryLevel=" + batteryLevel +
", heartRate=" + heartRate +
", temperature=" + temperature +
", acceleration=" + Arrays.toString(acceleration) +
'}'.toString()
}
override fun toString(): String = "FarosDeviceStatus{" +
"batteryLevel=" + batteryLevel +
", heartRate=" + heartRate +
", temperature=" + temperature +
", acceleration=" + acceleration.contentToString() +
'}'
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ import android.app.Activity
import org.json.JSONException
import org.radarbase.android.RadarApplication.Companion.radarApp
import org.radarbase.android.auth.*
import org.radarbase.android.auth.portal.ManagementPortalLoginManager
import org.radarbase.producer.AuthenticationException

/**
* Authenticates against the RADAR Management Portal.
*/
class OAuth2LoginManager(
private val service: AuthService,
private val projectIdClaim: String,
private val userIdClaim: String
private val service: AuthService,
private val projectIdClaim: String,
private val userIdClaim: String
) : LoginManager, LoginListener {
private val stateManager: OAuth2StateManager = OAuth2StateManager(service)

Expand All @@ -55,16 +56,8 @@ class OAuth2LoginManager(
return true
}

override fun invalidate(authState: AppAuthState, disableRefresh: Boolean): AppAuthState? {
return when {
authState.tokenType != LoginManager.AUTH_TYPE_BEARER -> return null
disableRefresh -> authState.alter {
attributes -= LOGIN_REFRESH_TOKEN
isPrivacyPolicyAccepted = false
}
else -> authState
}
}
override fun invalidate(authState: AppAuthState, disableRefresh: Boolean): AppAuthState? =
authState.takeIf { it.authenticationSource == OAUTH2_SOURCE_TYPE }

override val sourceTypes: List<String> = OAUTH2_SOURCE_TYPES

Expand All @@ -89,16 +82,16 @@ class OAuth2LoginManager(
override fun loginSucceeded(manager: LoginManager?, authState: AppAuthState) {
val token = authState.token
if (token == null) {
this.service.loginFailed(this,
loginFailed(this,
IllegalArgumentException("Cannot login using OAuth2 without a token"))
return
}
try {
processJwt(authState, Jwt.parse(token)).let {
this.service.loginSucceeded(this, it)
service.loginSucceeded(this, it)
}
} catch (ex: JSONException) {
this.service.loginFailed(this, ex)
loginFailed(this, ex)
}

}
Expand Down
Loading

0 comments on commit 23f0a3b

Please sign in to comment.