Just keep a thread for each
phone we're sending to or receiving from, and pass them packets and
other things to send or (incoming case) process. So far the threads
don't die, but they will soon once there's nothing in their queues. Just
need to be sure there's no racing there.
This is to work around the frequent failure of the OS to pass enqeued work
into the service within a reasonable amount of time (I expect seconds, but see
delays of minutes or even hours.)
I'm seeing my simultaneous access assert fail, so might as well break
fix it the foolproof way. It's background threads only that are calling
this stuff on Android so blocking them shouldn't hurt.
Theory is that the store's buggy site is presenting its
banned-permissions interface because it's detecting a Receiver that
requires SMS_RECEIVE permission even though the permissions themselves
aren't there any more.
I can't reproduce this, but while testing recovery from DatagramSocket
recreation in RelayService got enough to know that somehow a timer's
procptr's not set. So test before calling, and log instead of crashing.
Fix longstanding bug triggered by something as simple as putting device
into and out of airplane mode. Once the class-variable socket was
created it was never replaced. Now respond to exceptions that mean it's
useless and set it to null so existing logic will recreate it.
When enqueuing Intents for any of the three services, cache the
Intent. When onHandleWork() is called, remove the equivalent cached
intent. Then periodically check for intents that have been stored for
more than 60 seconds, and post a Notification alerting user to
stall. The user will likely have noticed that messages aren't flowing,
so this will simply explain the problem. Includes an "email author"
button.
Move some work into superclass where instrumentation can be added to
greater effect. And remove from BTService an earlier attempt (at stall
detection.)
toward tracking down relay stalls, log a bit more in resend process and
add UI to support an option where there's no reliance on
polling (i.e. FCM only)