Closed PavlosTze closed 2 months ago
Hi, I saw that on our end as well. In my opinion this can happen when you close the app while the DFU is in progress and at some point, the service tries to upload the second part or retry in case of an error. It has been implemented in a way that the service just restarts itself. This is not possible with the current limitations. For now, I would recommend disabling foreground service, like you do for Android O+. I think a background service can still start a background service. They are just limited to some short period after the app have been closed.
I see, will there be any more limitations if I disable foreground services at the happy path?
Here you may find more information: https://developer.android.com/about/versions/oreo/background#services
There are 2 fragments worth quoting:
When an app goes into the background, it has a window of several minutes in which it is still allowed to create and use services. At the end of that window, the app is considered to be idle. At this time, the system stops the app's background services, just as if the app had called the services' [Service.stopSelf()](https://developer.android.com/reference/android/app/Service#stopSelf()) methods.
and:
With Android 8.0, there is a complication; the system doesn't allow a background app to create a background service.
I know that an app cannot create a foreground service even if it was sent to background a second before. However, the first paragraph says, that for "services" there is a window of few minutes when it should be able to start background services, with short lifespan. I guess we are in this territory. DFU doesn't take longer than a minute.
I see, thank you. I'll implement it and we will see how it goes, hopefully nothing breaks. I think we can close this issue now. Thanks again!
Please, share your findings! I never tried it, actually.
We may need to rewrite the library to use WorkManager
, or at least the deprecated JobIntentService
, but don't have resources :(
So far so good @philips77 , no issues with that.
Where do you suspect the issue?
Issue related to Android version or specific device
Version
2.4.1 (Latest)
Describe the issue
We have integrated DFU Library in our app and we had some fresh crashes yesterday. 2 of them were with Android 14 and one of them was with Android 13.
Our code to launch the update process is the following:
How shall we handle it in newer versions of Android?
Relevant log output
Log of first crash:
Log of second crash: