Fix a deadlock that occurs when an activity is destroyed without process
termination, such as when an activity is destroyed and recreated due to
a configuration change.
The deadlock occurs because `notify_destroyed` blocks until `destroyed`
is set to `true`. This only occurs when `WaitableNativeActivityState` is
dropped, but the `WaitableNativeActivityState` instance is the very
thing being used to await for destruction, resulting in a deadlock.
Instead of waiting for the `WaitableNativeActivityState` to be dropped
we now wait until the native `android_main` thread has stopped.
So we can tell the difference between the thread not running because it
hasn't started or because it has finished (in case `android_main`
returns immediately) this replaces the `running` boolean with a
tri-state enum.
Co-authored-by: Robert Bragg <robert@sixbynine.org>
I was trying to quickly get to the documentation of this crate and had
the GitHub page open... but there was no link on the front-page: let's
fix that.
When splitting out the rust-android-examples we kept the agdk-mainloop
and na-mainloop examples in part so we would have some simple code we
can build as integration tests.
Since it's less likely that these will be referenced directly as
examples now, compared to those in rust-android-examples this removes
the lock files so we will instead always build against the latest semver
compatible dependencies.
Considering the simplicity of these examples, and minimal dependencies
these lock files probably weren't that worthwhile before either.
Most of the examples weren't strictly just demonstrating how to use the
android-activity API - rather they demonstrated using other libraries
in conjunction with android-activity.
Most of the examples have now been split into a standalone repository
under: https://github.com/rust-mobile/rust-android-examples
The na-mainloop and agdk-mainloop examples have been kept here since
they can be built against the local/in-tree version of android-activity
and are useful to keep for CI purposes.
This also runs `cargo update` for the na-mainloop and agdk-mainloop.
In a raw string [no escaping is processed] nor are these quotes treated
specially unless it was postfixed with `#`; the backslashes show up in
the compiler error displayed to the user instead.
For consistency the string this was likely copied from is now also
turned into a raw string literal, with backslashes equivalently removed.
[no escaping is processed]: https://doc.rust-lang.org/reference/tokens.html#raw-string-literals
Ideally information - especially when spamming per `Looper` poll - used
for debugging `android-activity` doesn't show to the user unless they
use the `Trace` level (eventually for this specific crate/module). This
is already adhered to in most places of the code but there were a few
high-volume cases still remaining.