Commit graph

10764 commits

Author SHA1 Message Date
Eric House
c4ac96ede8 fix NPE (race condition around deletion?)
Check for null. Not sure how I got it there, but there's little harm in
failing silently.
2018-12-09 18:26:59 -08:00
Eric House
95c11eec07 don't try to connect to non-phones
When a device is paired but not a phone (or computer, which is how
tablets identify), don't bother trying to scan it.
2018-12-09 18:26:59 -08:00
Eric House
051aeba57c fix crash by not creating Handler until on UI thread
Receiver is created and installed by a non-UI thread sometimes so can't
create the Handler there. onReceive() is called on an ok thread however
so create it there on demand. Fixes crash that showed when receiving
relay messages in background.
2018-12-09 18:26:59 -08:00
Eric House
68ae9790b4 launch service from ACTION_ACL_CONNECTED
Fire up the receiver thread, and start the service, on receipt of this
ACTION (if they're not already running.) On start, the service takes
over the thread and begins dispatching messages. Works to launch the app
when it's not running and in most cases, though messages received before
the service launches are currently dropped, things seem to work.
2018-12-09 18:26:59 -08:00
Eric House
3dbec328af fix NPE
It happened when too many timers were firing, but I think this code's
better anyway.
2018-12-09 18:26:59 -08:00
Eric House
271d43808f kill foreground service on a timer
reset timer on receiving meaningful data and on moving app to
background. If it fires and we're in background, kill the service.
(There's currently no way to restart it except bringing the app into the
foreground. Fixing that's coming.)
2018-12-09 18:26:59 -08:00
Eric House
c8fe57cc78 make listener thread static
remove relationship with BTService so it can be created independently.
2018-12-09 18:26:59 -08:00
Eric House
e984b10fea remove option of disabling foreground service
Since it's not going to be running all the time any more.
2018-12-09 18:26:59 -08:00
Eric House
d94821feb4 btinvite dlg shows results of scan not all paired devs
Moving toward a better BT invite experience: use BTService to scan for
ourselves on all paired devices, and only allow selecting from among
those on which we're running (and so likely to respond to an
invitation.)
2018-12-09 18:26:59 -08:00
Eric House
ece125c5dc change foreground-service notification text 2018-12-09 18:26:59 -08:00
Eric House
1e42156f4a remove assert
Constructor is called from JNI code and so not on the UI thread.
2018-12-09 18:26:59 -08:00
Eric House
faeaa60f87 replace junit's assert with my own
And have it log before throwing. Should be easier to track down asserts
coming from jni callbacks this way than in the C code.
2018-12-09 18:26:59 -08:00
Eric House
eaae9ed1c1 Always call startForeground after startForegroundService
It's an error to e.g. stopSelf() without having called startForeground,
so do it even when about to exit.
2018-12-09 18:26:59 -08:00
Eric House
0a0bd54ec7 include new permission to install third-party apks
Fixed upgrade of Dbg variant not working on Oreo.
2018-12-09 18:26:59 -08:00
Eric House
8bd4613c2a include X86 native library again
It's a pain to have to change code to run in Genymotion, and to have
upgrade not testable using Genymotion. Consider verting this change
before next release.
2018-12-09 18:26:59 -08:00
Eric House
50f448bb1f fix to contact relay in foreground on Oreo+
Background still needs a lot of work.
2018-12-09 18:26:59 -08:00
Eric House
ff2192f659 fix path name string causing JNI crash on emulator
And catch NPE that also seems to be emulator-only
2018-12-09 18:26:59 -08:00
Eric House
5284dce9b8 decouple networking threads from RelayService
Oreo's creating a new service instance for every single intent passed to
enqueueWork, meaning a brand new set of threads with a new queue, empty
set of messages to be retried, etc. was created every time, and all
attempts to optimize and retry were broken. So: make the threads a
static singleton that are given a Service instance from onCreate() and
told to drop it from onDestroy(). The threads proceed until they need an
instance, then block until one's available. Seems to work on Oreo and an
older Android as well.
2018-12-09 18:21:30 -08:00
Eric House
450c39ed57 new DebugUtils method 2018-12-09 17:11:38 -08:00
Eric House
18e29a74ed make RelayService descend from JobIntentService
Required moving most of XWService into a class to which all services
could delegate what they used to inherit.

squash me
2018-12-07 17:17:01 -08:00
Eric House
e614ba697d refactor a tiny bit 2018-12-07 11:22:07 -08:00
Eric House
b983b5abb6 get RECEIVE_SMS permission with SEND_SMS
Apparently one of the newer Android SDK levels adds the requirement to
have RECEIVE_SMS permission in order for a broadcast receiver to get
called. Meaning receipt didn't work even if SEND_SMS had been
granted. Since they're both in the same group (for now) the OS will
grant the second silently if the first has been granted, but it still
has to be requested. So request both at the same time. This still leaves
the problem that a user who's never tried to create an SMS game won't
have been asked for either permission and so won't receive SMS
invitations, but fixing that is for a later release.
2018-12-07 11:12:49 -08:00
Eric House
2cdd50b5fd use TAG format that doesn't break logcat filtering 2018-12-07 11:03:08 -08:00
Eric House
b58e121246 include flavor in logged TAG
Tired of not being to tell variants' logs apart.
2018-12-07 10:32:59 -08:00
Eric House
a86250ca36 don't drop potential duplicate invitations after 5 seconds
Other code will take care of duplicates. This was meant to avoid a race
condition, for which 5 seconds is enough. Blocking forever complicates
testing.
2018-12-06 19:12:32 -08:00
Eric House
c172a0aa0c fix NPE (race condition around deletion?)
Check for null. Not sure how I got it there, but there's little harm in
failing silently.
2018-12-06 06:23:40 -08:00
Eric House
fdf27e901a don't try to connect to non-phones
When a device is paired but not a phone (or computer, which is how
tablets identify), don't bother trying to scan it.
2018-12-05 20:36:25 -08:00
Eric House
ba95432e44 fix crash by not creating Handler until on UI thread
Receiver is created and installed by a non-UI thread sometimes so can't
create the Handler there. onReceive() is called on an ok thread however
so create it there on demand. Fixes crash that showed when receiving
relay messages in background.
2018-12-05 20:17:13 -08:00
Eric House
390370c07a launch service from ACTION_ACL_CONNECTED
Fire up the receiver thread, and start the service, on receipt of this
ACTION (if they're not already running.) On start, the service takes
over the thread and begins dispatching messages. Works to launch the app
when it's not running and in most cases, though messages received before
the service launches are currently dropped, things seem to work.
2018-12-05 20:14:57 -08:00
Eric House
83d0914145 fix NPE
It happened when too many timers were firing, but I think this code's
better anyway.
2018-12-04 19:59:42 -08:00
Eric House
95cd6d084d kill foreground service on a timer
reset timer on receiving meaningful data and on moving app to
background. If it fires and we're in background, kill the service.
(There's currently no way to restart it except bringing the app into the
foreground. Fixing that's coming.)
2018-12-04 19:58:19 -08:00
Eric House
d87b81f6d7 make listener thread static
remove relationship with BTService so it can be created independently.
2018-12-04 17:13:35 -08:00
Eric House
546e5416dc remove option of disabling foreground service
Since it's not going to be running all the time any more.
2018-12-04 06:37:44 -08:00
Eric House
9537100399 btinvite dlg shows results of scan not all paired devs
Moving toward a better BT invite experience: use BTService to scan for
ourselves on all paired devices, and only allow selecting from among
those on which we're running (and so likely to respond to an
invitation.)
2018-12-04 06:17:47 -08:00
Eric House
4540f9c077 change foreground-service notification text 2018-12-04 05:18:29 -08:00
Eric House
ff51dd7830 remove assert
Constructor is called from JNI code and so not on the UI thread.
2018-12-04 05:10:05 -08:00
Eric House
683bb38402 replace junit's assert with my own
And have it log before throwing. Should be easier to track down asserts
coming from jni callbacks this way than in the C code.
2018-12-03 08:26:47 -08:00
Eric House
af7b9fcba0 Always call startForeground after startForegroundService
It's an error to e.g. stopSelf() without having called startForeground,
so do it even when about to exit.
2018-11-29 18:02:06 -08:00
Eric House
3fe1289a8d include new permission to install third-party apks
Fixed upgrade of Dbg variant not working on Oreo.
2018-11-29 17:07:14 -08:00
Eric House
813669fafb include X86 native library again
It's a pain to have to change code to run in Genymotion, and to have
upgrade not testable using Genymotion. Consider verting this change
before next release.
2018-11-29 12:55:35 -08:00
Eric House
0a0107dd7f fix to contact relay in foreground on Oreo+
Background still needs a lot of work.
2018-11-29 09:35:08 -08:00
Eric House
b23b837009 fix path name string causing JNI crash on emulator
And catch NPE that also seems to be emulator-only
2018-11-29 09:34:07 -08:00
Eric House
9eec5c37ef fix path name string causing JNI crash on emulator 2018-11-29 09:30:14 -08:00
Eric House
91828cb851 add more google()
still trying to fix travis builds
2018-11-28 21:21:48 -08:00
Eric House
b2bf3a6e80 move google() above maven (to fix travis?) 2018-11-28 20:38:43 -08:00
Eric House
3f7d36e214 trying to fix travis build 2018-11-28 20:14:49 -08:00
Eric House
ce3cb62f02 add reversed version of btservice notification icon
For the Dbg variant to match its normal notification icon.
2018-11-28 19:35:24 -08:00
Eric House
fc699caaa8 ensure channel id always setup before use 2018-11-28 19:27:32 -08:00
Eric House
7eb278033a revert change setting notifiction priority low 2018-11-28 19:20:43 -08:00
Eric House
843c95e7ae new icon for omnipresent BTService notification 2018-11-27 11:27:18 -08:00