Partial config update for alerts/subscriptions

Preserves alerts if the definition didn't change and the underlying
metric didnt change.

All alerts need to be readded to the metric b/c metrics will always
clear the alerts on config updates. In the existing code, the metric
producer created the AnomalyTracker (since duration metrics need
DurationAnomalyTrackers). Preserved alerts already have an
AnomalyTracker. Therefore, we need a second overload of
addAnomalyTracker within MetricProducer to add existing ones. Note that
we don't need to worry about the type of AnomlayTracker, since if the
alert is preserved, both the AnomalyTracker and metric must not have
changed, so they will both be the correct type.

Subscriptions are also redone - alerts will clear their subscriptions,
and all subscriptions will be readded.

For duration metric, we now need to propagate adding anomaly trackers to
the DurationTrackers since it's now possible to add anomaly trackers
after the durationTrackers have been created.

Test: atest statsd_test
Bug: 162323547
Bug: 176249205
Bug: 176248686
Merged-In: I751e2c7c8bbbd819f216821cbf4f0ec315c4563b
Change-Id: Id3afa04b252f3a3523114407a389be25b9171a97
19 files changed
tree: 05e140205e652a638e8178ed4ec1c1b3235d66f4
  1. aidl/
  2. apex/
  3. bin/
  4. framework/
  5. lib/
  6. service/
  7. tests/
  8. OWNERS