Update Service#onTimeout implementation.
- Time limit information will now be stored on a per-fgs type for each
uid instead of simply relying on fgs-launch-eligibility status.
- If the app has not started an fgs for the specific type in the past
24 hours, reset the time limit for that type.
- If the app has been in the TOP state since the last time the timeout
callback was triggered, reset the time limit for that type. Otherwise,
throw a ForegroundServiceStartNotAllowedException.
- If the app starts a FGS with multiple time-restricted types, apply the
most lenient time limit instead of the most restricted one.
- Also ensure the book-keeping is updated correctly when switching
between time-restricted types.
Bug: 330399444
Test: atest CtsFgsTimeoutTestCases
Test: atest CtsAppTestCases
Change-Id: Ie5dfc1719bc8124e8f3807c2e9095cd141d42819
3 files changed