downgraded android target version

This commit is contained in:
Thibault Deckers 2023-08-28 22:47:16 +02:00
parent 6979af70b9
commit af2380ec1e
4 changed files with 26 additions and 5 deletions

View file

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
## <a id="unreleased"></a>[Unreleased] ## <a id="unreleased"></a>[Unreleased]
### Changed
- target API 33 to prevent foreground service crashes with Android 14 beta 5
## <a id="v1.9.2"></a>[v1.9.2] - 2023-08-24 ## <a id="v1.9.2"></a>[v1.9.2] - 2023-08-24
### Changed ### Changed

View file

@ -83,7 +83,7 @@ android {
// which implementation `DocumentBuilderImpl` is provided by the OS and is not customizable on Android, // which implementation `DocumentBuilderImpl` is provided by the OS and is not customizable on Android,
// but the implementation on API <19 is not robust enough and fails to build XMP documents // but the implementation on API <19 is not robust enough and fails to build XMP documents
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 34 targetSdkVersion 33
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
manifestPlaceholders = [googleApiKey: keystoreProperties["googleApiKey"] ?: "<NONE>", manifestPlaceholders = [googleApiKey: keystoreProperties["googleApiKey"] ?: "<NONE>",

View file

@ -32,6 +32,11 @@
<!-- to access media with original metadata with scoped storage (API >=29) --> <!-- to access media with original metadata with scoped storage (API >=29) -->
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<!-- to provide a foreground service type, as required by Android 14 (API 34) -->
<!-- TODO TLAD revisit with Android 14 >beta5 -->
<!-- <uses-permission-->
<!-- android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"-->
<!-- tools:ignore="SystemPermissionTypo" />-->
<!-- TODO TLAD still needed to fetch map tiles / reverse geocoding / else ? check in release mode --> <!-- TODO TLAD still needed to fetch map tiles / reverse geocoding / else ? check in release mode -->
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<!-- from Android 12 (API 31), users can optionally grant access to the media management special permission --> <!-- from Android 12 (API 31), users can optionally grant access to the media management special permission -->

View file

@ -3,6 +3,7 @@ package deckers.thibault.aves
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.ServiceInfo
import android.os.Build import android.os.Build
import android.util.Log import android.util.Log
import androidx.core.app.NotificationChannelCompat import androidx.core.app.NotificationChannelCompat
@ -148,16 +149,27 @@ class AnalysisWorker(context: Context, parameters: WorkerParameters) : Coroutine
WorkManager.getInstance(applicationContext).createCancelPendingIntent(id) WorkManager.getInstance(applicationContext).createCancelPendingIntent(id)
).build() ).build()
val icon = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) R.drawable.ic_notification else R.mipmap.ic_launcher_round val icon = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) R.drawable.ic_notification else R.mipmap.ic_launcher_round
val contentTitle = title ?: applicationContext.getText(R.string.analysis_notification_default_title)
val notification = NotificationCompat.Builder(applicationContext, NOTIFICATION_CHANNEL) val notification = NotificationCompat.Builder(applicationContext, NOTIFICATION_CHANNEL)
.setContentTitle(title ?: applicationContext.getText(R.string.analysis_notification_default_title)) .setContentTitle(contentTitle)
.setTicker(contentTitle)
.setContentText(message) .setContentText(message)
.setBadgeIconType(NotificationCompat.BADGE_ICON_NONE)
.setSmallIcon(icon) .setSmallIcon(icon)
.setOngoing(true)
.setContentIntent(openAppIntent) .setContentIntent(openAppIntent)
.setPriority(NotificationCompat.PRIORITY_LOW)
.addAction(stopAction) .addAction(stopAction)
.build() .build()
return ForegroundInfo(NOTIFICATION_ID, notification) // TODO TLAD revisit with Android 14 >beta5
return ForegroundInfo(NOTIFICATION_ID, notification);
// return if (Build.VERSION.SDK_INT >= 34) {
// // as of Android 14 beta 5, foreground service type is mandatory
// // despite the sample code omitting it at:
// // https://developer.android.com/guide/background/persistent/how-to/long-running
// val type = ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
// ForegroundInfo(NOTIFICATION_ID, notification, type)
// } else {
// ForegroundInfo(NOTIFICATION_ID, notification)
// }
} }
companion object { companion object {