diff --git a/android/app/build.gradle b/android/app/build.gradle index 2a01cf432..3818aed2a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -168,6 +168,7 @@ dependencies { implementation 'androidx.core:core-ktx:1.9.0' implementation 'androidx.exifinterface:exifinterface:1.3.5' + implementation 'androidx.lifecycle:lifecycle-process:2.5.1' implementation 'androidx.multidex:multidex:2.0.1' implementation 'com.caverock:androidsvg-aar:1.4' diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/AnalysisHandler.kt b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/AnalysisHandler.kt index 75fa2a306..1b38997c6 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/AnalysisHandler.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/AnalysisHandler.kt @@ -9,6 +9,8 @@ import android.content.ServiceConnection import android.os.Build import android.os.IBinder import android.util.Log +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.ProcessLifecycleOwner import deckers.thibault.aves.AnalysisService import deckers.thibault.aves.AnalysisServiceBinder import deckers.thibault.aves.AnalysisServiceListener @@ -63,6 +65,11 @@ class AnalysisHandler(private val activity: Activity, private val onAnalysisComp .putExtra(AnalysisService.KEY_ENTRY_IDS, entryIds?.toIntArray()) .putExtra(AnalysisService.KEY_FORCE, force) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + val appState = ProcessLifecycleOwner.get().lifecycle.currentState + if (!appState.isAtLeast(Lifecycle.State.STARTED)) { + result.error("startAnalysis-background", "cannot start foreground service from background", null) + return + } activity.startForegroundService(intent) } else { activity.startService(intent) diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index d1ccb2b34..de4ca5cfc 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -75,28 +75,16 @@ class Constants { static const String mit = 'MIT License'; static const List androidDependencies = [ - Dependency( - name: 'AndroidX Core-KTX', - license: apache2, - licenseUrl: 'https://android.googlesource.com/platform/frameworks/support/+/androidx-main/LICENSE.txt', - sourceUrl: 'https://android.googlesource.com/platform/frameworks/support/+/androidx-main/core/core-ktx', - ), - Dependency( - name: 'AndroidX Exifinterface', - license: apache2, - licenseUrl: 'https://android.googlesource.com/platform/frameworks/support/+/androidx-main/LICENSE.txt', - sourceUrl: 'https://android.googlesource.com/platform/frameworks/support/+/androidx-main/exifinterface/exifinterface', - ), Dependency( name: 'AndroidSVG', license: apache2, sourceUrl: 'https://github.com/BigBadaboom/androidsvg', ), Dependency( - name: 'Android-TiffBitmapFactory (Aves fork)', - license: mit, - licenseUrl: 'https://github.com/deckerst/Android-TiffBitmapFactory/blob/master/license.txt', - sourceUrl: 'https://github.com/deckerst/Android-TiffBitmapFactory', + name: 'AndroidX (Core Kotlin, Exifinterface, Lifecycle Process, Multidex)', + license: apache2, + licenseUrl: 'https://android.googlesource.com/platform/frameworks/support/+/androidx-main/LICENSE.txt', + sourceUrl: 'https://android.googlesource.com/platform/frameworks/support/+/androidx-main/core/core-ktx', ), Dependency( name: 'CWAC-Document', @@ -123,6 +111,12 @@ class Constants { license: eclipse1, sourceUrl: 'https://github.com/deckerst/pixymeta-android', ), + Dependency( + name: 'Tiff Bitmap Factory (Aves fork)', + license: mit, + licenseUrl: 'https://github.com/deckerst/Android-TiffBitmapFactory/blob/master/license.txt', + sourceUrl: 'https://github.com/deckerst/Android-TiffBitmapFactory', + ), ]; static const List _flutterPluginsCommon = [