Upgrade kotlin to 1.7.20, coroutines to 1.6.4 and compose compiler to 1.3.2.
Replace deprecated Xopt-in with op-in.
Replace deprecated Xjvm-default=enable with Xjvm-default=all.
Remove useIR property that is now default true.
The `FxaPushSupportFeature` needs to generate, read and write a push
scope (identifier) to disk. This work was meant to be done lazily and
not during app startup. However, if a Sync account is setup then the IO
work is done immediately during the initial account manager
initialization at startup.
In this patch, we delegate this IO work to a new `PushScopeProperty`
that retrieves the value from disk using a provided `CoroutineScope`.
Used `runTestOnMain` where `MainCoroutineRule` was used or needed to be used,
`runTest` elsewhere.
Extra effort for removing all `runBlocking` occurrences in unit tests.
`kotlinx.coroutines.test.runTest` is a test specific API that seems like a more
appropriate way for running tests in a coroutine than the general
`kotlinx.coroutines.runBlocking` api.
- Refactor out all usages of TestCoroutineDispatcher and TestCoroutineScope
- Refactor MainCoroutineRule to now use UnconfinedTestDispatcher by default.
This dispatcher will eagerly enter all launch or async blocks being more suited
to our codebase.
This should fix push for FxA.
I also made a number of other push cleanups - in particular,
we are far more aggressive about subscribing - we no longer
do it on login, but instead on every startup. Note that
the Rust component will not hit the server if a subscription
already exists, so this is still relatively fast, and will pick up
missing subscriptions)
This may not fix broken, non-FxA devices - they don't know they need a new
FCM token. It's not even clear if that's a thing though - but either
`renewRegistration` is not necessary, or it is and non FxA push
will remain broken.
We observed via Sentry that we were hitting a bunch of 'url without
base' exceptions coming out of metadata observation API. One of these
cases where we'll end-up trying to process a URL without a base (e.g.
without a scheme) is when we're processing external intent and see
something like "example.com", instead of "https://example.com".
In our toolbar, we use String.toNormalizedUrl to handle this case.
In this patch, we now do the same for URLs we encounter in external
intents, as well.
* Ensure we notice and repair a missing or expired push endpoint.
The core problem is that the device constellation's observer is registered
after we've updated the devices, so the code that checks if re-subscribing is
necessary is never hit.
The easiest way of fixing this was to move the `refreshDevices` call to the
account state state-machine, rather than the authentication state-machine,
meaning we can ensure the `onAuthenticated` notification is delivered before
we refresh the devices.
Note that I also removed the special-case for "SEND_TAB" devices - push is
also used for account-related notifications, such as being disconnected.
* Address CI failures (hopefully!)
* Update comments about push renewal
* Tweak suggested by Grisha for when to call refreshDevices
* More CI failures
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
These follow a few more simple patterns I was able to find:
- the testDispatcher is not used anywhere else: remove it
- the testDispatcher is used to set a main dispatcher: this is redundant
to the test rule so remove it both the dispatcher & the main dispatcher
- the testDispatcher is actually used elsewhere: for simplicity, change
the reference to point at the MainCoroutineRule.
Running ./gradlew ktlint locally reports a lot of stuff like:
/home/emilio/src/moz/android-components/components/support/migration/src/test/java/mozilla/components/support/migration/MigrationIntentProcessorTest.kt:1:1: File must end with a newline (\n)
This fixes it with:
for f in $(cat files | cut -d : -f 1); do echo "" >> $f; done
Making ./gradlew ktlint pass.
This is a workaround fix to re-enable Send Tab when we are notified
about the subscriptionExpired flag. Until https://github.com/mozilla-mobile/android-components/issues/7143 is fixed, we need to
avoid calling `registrationRenewal` to avoid going into an unfixable
state.
In the context of the FxaPushSupportFeature, we know that our end goal
is to call `push.subscribe(fxaPushScope)`, so we can by pass the
`verifyConnection` call **assuming** that our native push client is
always has the latest push token and knows how to invalidate the
endpoint with the Autopush server.
When debugging push, it can be quite tedious to manually reset the
state of our DDOS protection code. Here, we introduce an override flag
into the `PushConfig` that can be used by the `PushFeature` and
`FxaPushSupportFeature`.
We're caching the `fxaPushScope` in memory and also saving it to our
prefs. When we log out, we delete the pref, but the in-memory isn't
removed.
We could always fetch from the prefs instead of using an in-memory
caching, however this could be a bit expensive to always read from prefs
since we need to do this check when receiving any push message.
An easier solution would be to never remove the scope in prefs once
generated. It is safe to persist the push scope across different
accounts since the combination of scope + UAID is unique per install.