mhammond Fix UAID and registration_id confusion in the push component. (#4605)
6d33f26 Oct 28, 2021
Fix UAID and registration_id confusion in the push component. (#4605)
There's one UAID and one registration_id per device, not per-subscription.

Fixes #4575

* `uaid`, auth-key and `registration_id` are no longer stored in the database
  against each subscription, but instead stored in the `metadata` table, and
  thus assumed to be the same for all subscriptions.

* If a `subscribe()` call returns a different UAID than we had previously, we
  consider all existing subscriptions dead - we delete all old subscriptions
  and the old UAID, then store the new subscription against the new UAID.

* To help with managing the UAID correctly, the `ConnectHttp` object, which
  holds on to the UAID etc, is now short-lived - it only lives as long as one
  API call (whereas it previously lived for as long as the push manager).
  This means that the UAID persisted in the meta-data table is the canonical
  source of truth.

* The "registration id" (think FCM token) is now ignored in the
  constructor (it should be removed ASAP, but it's there and ignored
  to avoid a breaking change. The only way to supply this is to call
  the `update()` method - but the component will persist this value.

  The end result is that, assuming we've ever called `update()` in the
  past, is that after startup we can still call `subscribe` before we've
  called `update()` as we will use the previous value. This means we can
  avoid some complexity in android-components where we have a complicated
  error prone dance to avoid constructing the component until FCM has
  initialized.
6d33f26