Fix cloud media changed event notification delay

We throttled cloud media change event notifications by 1s such that we
sync at *most* once a second regardless of the number of
notifications.

There was a bug with the earlier implementation which created a lambda
each time as the Handler callback. This meant that we removed a 'new
callback' from the handler postDelayed method and the 1s throttle
wasn't actually respected.

Now we cache the sync delay handler and re-use that each time. We also
extended the default sync delay to 5s since 1s was short enough to
have frequent syncs while syncing a lot of db items. In the future, we
can add an exponential backoff and start with no delay.

Test: Manually verified that we re-use the callback on each
notification
Bug: 218791501

Change-Id: I07d41e9240c8198aa263638c800d10c13b42bfa6
2 files changed