Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #1076: Refactored RealtimeService using WorkManager #1161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Adithya-hv
Copy link
Contributor

@Adithya-hv Adithya-hv commented Mar 11, 2024

Refactor

RealtimeServices for OTP Trip Results hasn't been functioning since Android 8.0 (API level 26) due to the background execution limits it introduces. This was fixed by refactoring Intent Service using Work Manager, swapping out WakefulBroadcastReceiver & Alarm Manager with WorkManager & Workers for all persistent work.

RealTimeService

RealTimeService was refactored to handle all the checks the old service was doing, it then converts and simplifies the bundle into a Data object which is passed into PeriodicWorkRequest which runs the RealTimeWorker class every 15 minutes. PeriodicWorkRequest is also started with an initial delay, it is only started an hour before the scheduled trip time which is the same as the old RealtimeService.

RealTimeWorker

RealTimeWorker is the new Worker class that only checks for any changes in the itineraries and responds to it accordingly, this logic was not changed and functions the same as the old RealtimeService. It returns the result as success if it was not canceled and failure if it was.

Empty Bundle

The old RealtimeService checked if the function receives an empty Bundle, and disables RealtimeServices if it's empty. The refactor includes this but it should be removed when issues #790 and #791 are resolved.

Core Functionality Change

The only major difference change in the refactor was the number of times the service polls, the old RealtimeService polls the OTP server every minute while the new one polls it every 15 minutes. This is due to a limitation on PeriodicWorkRequest whose minimum repeat interval is 15 minutes. WorkManager was used as it was recommended by the issue(#1076) and Android to schedule deferrable, asynchronous tasks that must be run reliably.

Issues Affected

Closes #1076
Could affect / close #977

Pull Request Requirements

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Apply the AndroidStyle.xml style template to your code in Android Studio.

  • Run the unit tests with gradlew connectedObaGoogleDebugAndroidTest to make sure you didn't break anything

  • If you have multiple commits please combine them into one commit by squashing them for the initial submission of the pull request. When addressing comments on a pull request, please push a new commit per comment when possible (reviewers will squash and merge using GitHub merge tool)

@Adithya-hv Adithya-hv marked this pull request as ready for review March 11, 2024 01:38
@amrhossamdev
Copy link
Member

Hi @Adithya-hv, good work!

I have questions polling will check if we have new data every 15 minutes, does this affect real-time changes when the trip status changes like the trip was delayed?

@amrhossamdev
Copy link
Member

amrhossamdev commented May 19, 2024

I think also it's not related to #977 updating reminder notifications because it's still shown, we need to investigate that

image

@aaronbrethorst
Copy link
Member

This feature is going away with #1260

@aaronbrethorst
Copy link
Member

I have been informed that I am wrong 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IntentService deprecated in Android 11 Ghost notification "Updating reminders"
3 participants