TeamVanced / VancedManager

Vanced Installer
GNU General Public License v3.0
8.25k stars 1.14k forks source link

[Feature]: Updater compatibility with minimizing app #719

Open ViktorScaletta opened 3 years ago

ViktorScaletta commented 3 years ago

Suggestion

Hello, developers! There's a problem with update processes after minimizing application. Don't you consider using Foreground Services for that kind of work? It would allow resume any update process after returning to app's window. For now it's just freezing at 100% and we have to restart update. I'm pretty sure you know how implement it, but I can help if you don't.

Additional Information

Because sometimes download process takes a lot of time. It's weird to just wait and do nothing while downloading.

Additional checks

X1nto commented 3 years ago

I was thinking of listening for the Activity's onPause method and launching a Foreground Service that displays a notification and keeps the app alive, but we found out that not many ROMs were friendly with this approach while testing.

ViktorScaletta commented 3 years ago

@X1nto but why it stopped you from keeping that functionality? You can put a message in the window, that says something like "Some ROMs can kill app anyway". And about implementing itself. Described approach is okay and it's used by many apps, such file explorers and others, but I suppose it's unnecessary to run the foreground service on onPause. You can do it immediately after starting update process and do all update-related work there(in background thread, indeed). For update progress to be available you can use Broadcast Receivers(context-registered ones, not ones that use manifest declaration) or any other approaches. Actually, there's another approach you can try, but usually it shouldn't be used for such work. I mean WorkManager. All the work can be implemented there and for update progress you can use the same approach I mentioned above. The end of the work can be observed by integrated LiveData functionality.

X1nto commented 3 years ago

@X1nto but why it stopped you from keeping that functionality? You can put a message in the window, that says something like "Some ROMs can kill app anyway". And about implementing itself. Described approach is okay and it's used by many apps, such file explorers and others, but I suppose it's unnecessary to run the foreground service on onPause. You can do it immediately after starting update process and do all update-related work there(in background thread, indeed). For update progress to be available you can use Broadcast Receivers(context-registered ones, not ones that use manifest declaration) or any other approaches. Actually, there's another approach you can try, but usually it shouldn't be used for such work. I mean WorkManager. All the work can be implemented there and for update progress you can use the same approach I mentioned above. The end of the work can be observed by integrated LiveData functionality.

WorkManager actually seems like a good alternative to services, I believe they even provide much more functionality. I'll try to implement this for the upcoming 3.0 that's in the compose branch