cts: Test ForegroundService restrictions

Test following improper behavior: unnecessary killing of
ForegroundService processes, breaking their wake locks, preventing
starting ForegroundServices from AlarmManager alarms and other
restrictions in execution of threads in a ForegroundService context.
See #202410207 https://bit.ly/3oHUmWg

Start a ForegroundService with a wake lock and schedule repetitive
tasks on the main thread, a custom thread executor and schedule
regular alarms using AlarmManager.setExactAndAllowWhileIdle(). Then
calculate the score by comparing executed vs. expected. Scores close
to 100% are good results. Over 90% is considered test passed.

Test: using cts-tradefed
Signed-off-by: Petr Nalevka <petr.nalevka@gmail.com>
Change-Id: I19d4f200a53ff4b731e5a61f38985693b7836849
10 files changed