Skip to content

Commit

Permalink
[STAD-574] Set targetSdkVersion to 34 and upgrade dependencies
Browse files Browse the repository at this point in the history
Task/stad 574 target sdk version 34
  • Loading branch information
hb0 authored Feb 27, 2024
2 parents 3a6fbe9 + baec977 commit f1644bc
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 13 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ext {
cyfaceAndroidBackendVersion = "0.0.0" // Automatically overwritten by CI

// Cyface dependencies
cyfaceUtilsVersion = "4.0.4"
cyfaceUtilsVersion = "4.0.6"
// (!) Match versions `android-app`, `SDK` and `camera-service`.
// When `android-app` is checkout out, `rootProject.uploaderVersion` in the submodules will point
// to `android-app/build.gradle` instead of `submodule/build.gradle`.
Expand All @@ -59,18 +59,18 @@ ext {

// Android SDK versions
minSdkVersion = 21 // device support
targetSdkVersion = 33 // behavioral changes, follow migration guide & test the app against this
targetSdkVersion = 34 // behavioral changes, follow migration guide & test the app against this
compileSdkVersion = 34 // allows newest APIs to be used and to see deprecations, use latest
buildToolsVersion = '34.0.0' // optional, if defined, use latest (SDK Manager > SDK Tools)
// 1.1.0-alpha05: ':persistence:mergeExtDexDebugAndroidTest' fails (transitive dependency)
datastoreVersion = "1.1.0-alpha04" // only 1.1.0 supports multi-process datastore
datastoreVersion = "1.1.0-beta01" // only 1.1.0 supports multi-process datastore
desugaringVersion = "2.0.3"

// Android dependencies
androidxAnnotationVersion = '1.6.0'
androidxAppCompatVersion = "1.6.1"
localbroadcastmanagerVersion = '1.1.0'
roomVersion = "2.5.2"
roomVersion = "2.6.1"

// Kotlin components
coroutinesVersion = "1.6.4"
Expand All @@ -81,7 +81,7 @@ ext {

// Testing
junitVersion = "1.1.5"
mockitoVersion = '5.2.0'
mockitoVersion = '5.7.0'
mockitoKotlinVersion = '4.1.0'
hamcrestVersion = "1.3"
rulesVersion = "1.5.0"
Expand Down
2 changes: 2 additions & 0 deletions datacapturing/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- On Android 12+ we must request both FINE and COARSE, but add a handle to explicitly request FINE -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- On Android 14+ we need this permission for foregroundServiceType location -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<!-- Required to change periodic synchronisation intervals in the background -->
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<!-- Required to read current background synchronisation settings -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Process;
Expand Down Expand Up @@ -137,8 +138,13 @@ public void checkIsRunningAsync(final long timeout, final @NonNull TimeUnit unit
// Run receiver on a different thread so it runs even if calling thread waits for it to return:
pongReceiverThread.start();
Handler receiverHandler = new Handler(pongReceiverThread.getLooper());
context.get().registerReceiver(this, new IntentFilter(pongActionId), null,
receiverHandler);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.get().registerReceiver(this, new IntentFilter(pongActionId), null,
receiverHandler, Context.RECEIVER_NOT_EXPORTED);
} else {
context.get().registerReceiver(this, new IntentFilter(pongActionId), null,
receiverHandler);
}

long currentUptimeInMillis = SystemClock.uptimeMillis();
long offset = unit.toMillis(timeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,18 @@ abstract class DataCapturingService(
startUpFinishedHandler: StartUpFinishedHandler
) {
val context = getContext()
context!!.registerReceiver(
startUpFinishedHandler,
IntentFilter(MessageCodes.GLOBAL_BROADCAST_SERVICE_STARTED)
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context!!.registerReceiver(
startUpFinishedHandler,
IntentFilter(MessageCodes.GLOBAL_BROADCAST_SERVICE_STARTED),
Context.RECEIVER_NOT_EXPORTED
)
} else {
context!!.registerReceiver(
startUpFinishedHandler,
IntentFilter(MessageCodes.GLOBAL_BROADCAST_SERVICE_STARTED)
)
}
Log.d(
StartUpFinishedHandler.TAG,
"DataCapturingService: StartUpFinishedHandler registered for broadcasts."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.SyncResult
import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down Expand Up @@ -122,7 +123,11 @@ class UploadProgressTest {
filter.addAction(CyfaceConnectionStatusListener.SYNC_FINISHED)
filter.addAction(CyfaceConnectionStatusListener.SYNC_PROGRESS)
filter.addAction(CyfaceConnectionStatusListener.SYNC_STARTED)
context!!.registerReceiver(receiver, filter)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context!!.registerReceiver(receiver, filter, Context.RECEIVER_NOT_EXPORTED)
} else {
context!!.registerReceiver(receiver, filter)
}
var client: ContentProviderClient? = null
try {
val (measurementIdentifier) = insertMeasurementEntry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;

import de.cyface.utils.Validate;

Expand Down Expand Up @@ -62,7 +63,11 @@ public ConnectionStatusReceiver(final Context context) {
filter.addAction(SYNC_FINISHED);
filter.addAction(SYNC_PROGRESS);
filter.addAction(SYNC_STARTED);
context.registerReceiver(this, filter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.registerReceiver(this, filter, Context.RECEIVER_NOT_EXPORTED);
} else {
context.registerReceiver(this, filter);
}
}

@Override
Expand Down

0 comments on commit f1644bc

Please sign in to comment.