EventConditionProvider: Ensure that reloadTrackers precedes evaluateSubscriptions

A previous (luckily, flagged) change to this class delayed the first call to reloadTrackers() to onUserSwitched(). This works well on HSUM devices; however on devices where user 0 is also a proper user and has event-based Zen Rules, we would try to do the first evaluation when onSubscribe() is called, before creating the trackers, which would eventually NPE.

Therefore we change the approach slightly:
* We restore the call to reloadTrackers() for the system user. This is pointless on HSUM (but also harmless, because user 0 will have no event rules).
* We only reload trackers on user switch when actually switching to a different user. This prevents wasting work during boot on non-HSUM devices.
* Although it should no longer be triggered, we early-exit when no trackers produced a result from the evaluation.

Fixes: 374683409
Test: atest EventConditionProviderTest + manual on non-HSUM and HSUM devices
Flag: android.app.modes_hsum
Change-Id: I543bdec20ec2858c2cbe7c7a6bc4e7f19a728ab0
2 files changed