Commit graph

9940 commits

Author SHA1 Message Date
Eric House
aa420ce4d1 notify remote when BT game deleted 2016-12-05 07:12:22 -08:00
Eric House
ef0eeaae2e improve dead game notification
When contacting opponents, iterate over opponent addresses rather than
information cached in the summary. Start implementing for BT, but that
needs more work. Change enum names in WiDirService state machine.  P2p
opponent notification untested because apparently an open hotspot, which
you can't prevent devices from connecting to, breaks P2P connectivity.
2016-12-03 10:28:24 -08:00
Eric House
bc9baa2e79 wifi: don't crash when don't have permissions 2016-12-03 08:15:08 -08:00
Eric House
eecae536ec add missing log levels: was dropping before 2016-12-02 20:03:44 -08:00
Eric House
f9d352cb25 wifi: notify when game deleted 2016-12-02 08:17:03 -08:00
Eric House
54ed327406 wifi: notify when game missing
Rewrite to use new XWPacket class that wraps JSONObject but could later
support a binary format, and reply with new message when packet arrives
for a game that does not exist. Code already present turns that into an
invitation to delete the game.
2016-12-01 07:48:03 -08:00
Eric House
54d02e0fb2 wifi: update status on first connect
And remove the hack pretending on lack of permission that support was
compiled out.
2016-12-01 06:11:51 -08:00
Eric House
bf83741393 track and log failure counts
Later will likely want to restart when get above some threshold
2016-11-30 07:55:25 -08:00
Eric House
0a26496e73 wifi: tweaks
fix race condition in accept thread; only call wifimgr.connect() on
guest side. Connectivity now works reliably if the guest starts, or is
restarted, when the group owner is running. If owner is restarted the
guest seems never to connect (without restart.)
2016-11-30 07:06:59 -08:00
Eric House
a686541f96 merge recent manifest changes 2016-11-30 06:58:56 -08:00
Eric House
a3bc4f0a75 fix compile error from merge 2016-11-28 20:21:40 -08:00
Eric House
0237403a26 Merge branch 'android_release' into android_branch
This will probably not compile...
2016-11-28 20:19:54 -08:00
Eric House
6171d9ce90 prep a quick-fix release, with string changes
Two crashes reported on the Google Play store in the 112 version have at
least easy work-arounds: catching exceptions and doing nothing. In both
cases that should be harmless, so assuming the causes are rare it's a
good move.
2016-11-28 20:02:38 -08:00
Eric House
f415cf22ca change strings for next release 2016-11-28 19:19:03 -08:00
Eric House
1a513e8b02 add a bit of logging 2016-11-28 07:40:09 -08:00
Eric House
2fa47f057d use TAG instead of class for logging
Moving to the traditional use of Log class, with TAG defined in every
class that logs. It's just easier to use all the facilities built into
logcat.
2016-11-27 21:24:21 -08:00
Eric House
49d75d5d91 converting to use standard TAG-based logging
First files done manually: add TAG to file and pass it rather than class
to log wrapper. Rest will be done with a script.
2016-11-27 21:22:51 -08:00
Eric House
97c1091d0c add TAG everywhere
results of running a script that adds TAG to every top-level class. It
compiles, but I'm not using them yet.
2016-11-22 22:10:05 -08:00
Eric House
927c181ccc rename variable
TAG has conventional meaning I'm about to take advantage of, so rename
the one variable that would conflict.
2016-11-22 21:46:42 -08:00
Eric House
b8844a0e2d rewrite connection logic
Make it a trivial state machine that implements Runnable and
ActionListener so it can be scheduled and notified easily. Removes a
bunch of code. Connecting still happens unreliably, but it should be
easier to tweak things now.
2016-11-22 19:28:10 -08:00
Eric House
bff03617e5 wifi: hide unused buttons
Refactoring isn't perfect. Need to hide in subclass buttons that other
subclasses assume.
2016-11-22 00:17:49 -08:00
Eric House
e0f0666b1c wifi: make invitations work
Add UI, minor thanks to recent refactoring, to allow invitations via
wifi direct. Uses a mapping of all currently known device mac addresses
to names, with only the latter shown to users. Works well, though
something I changed seems to have causes devices to start losing track
of their connections to each other.
2016-11-21 21:10:16 -08:00
Eric House
3f0bef48f6 refactor invite UI
In order that wifi direct invitation dialog isn't another near-copy of
an existing file move a bunch of stuff into the common superclass.
2016-11-21 20:54:29 -08:00
Eric House
a67f2205bb log thread starts/stops 2016-11-18 20:13:48 -08:00
Eric House
930146cf11 wifi tweaks
Show net status as failing when no sockets available, and notice when
they're closed.
2016-11-17 23:22:28 -08:00
Eric House
4389c63718 wifi: fix compile; do less work on release build
The group info stuff I'm polling for is used only to log interesting
information, so drop it.
2016-11-17 22:22:08 -08:00
Eric House
14c34f3e70 wifi: get rematch working
required hooking up invitations, so the user-visible part of that should
be easy to do once device names are being communicated.
2016-11-17 22:14:36 -08:00
Eric House
9cfbb3c45b wifi: add status update on successful write 2016-11-17 20:17:13 -08:00
Eric House
822f34ac48 wifi: forward packets through group owner
Simple fix to the problem that a group owner may not be in the role of
game host: if I'm a guest and don't have a socket for the mac address to
which I need to send, slap src and dest addresses into the message and
send it to the group owner. That device can then forward it.
2016-11-17 20:03:02 -08:00
Eric House
5659fe9096 include wifi device name in status 2016-11-16 21:27:14 -08:00
Eric House
6f29b78456 wifidirect make connections much more reliable
Found a recipe for service discovery that at least in the bit of testing
I've done is much more reliable. Devices connect almost
immediately. Basically everything chains through onSuccess() handlers.
URL to recipe is in code.
2016-11-16 21:23:46 -08:00
Eric House
491432a3bb toward having debug-only component to net state for p2p 2016-11-16 20:55:32 -08:00
Eric House
93f23dd87c wifi: shorten class name 2016-11-16 08:23:25 -08:00
Eric House
1dd28855cb wifi stop service request once it's done its work
Examples kill it before calling connect(), so do the same. Seems to make
connection more reliable. (Pending: handle case where more than one
two devices are in the group!!!)
2016-11-16 08:10:51 -08:00
Eric House
d45635273d wifi start adding network status updates 2016-11-15 21:12:59 -08:00
Eric House
239beafcfa wifi: can now play a full game
Made WifiDirectService into an actual service in order to better process
incoming packets. Now works for game messages from comms, and posts
notifications when app's in background. The latter requires using the
app context from XWApp since unlike the other transports this one
doesn't involve the OS invoking us with a Context.
2016-11-15 20:50:29 -08:00
Eric House
1c4ae5fcfd wifi snapshot
Got to the point where I have an open socket for the packet I want to
send! Lots of changes to how discovery works seem to have improved
reliability though I'm still unimpressed. Much to learn.
2016-11-15 07:49:06 -08:00
Eric House
33326d38a7 wifi direct: harvest and send mac address
Grab and store the local device's mac address. Add p2p as a type of
address, represented by the mac address of the recipient. Include the
local device's address in invitations sent when specified by user. Now
the WifiDirectService class is being passed a packet and the address of
the recipient; it will next need to set up sockets with every device it
encounters and map them to their mac addresses so that it can do a send.
2016-11-14 08:06:53 -08:00
Eric House
7d8708b8fa don't crash if don't have wifi permissions
For now, -dbg version will have and non-dbg won't, so catch exception
first time we try to do wifi stuff and disable if that exception is thrown.
2016-11-13 20:48:08 -08:00
Eric House
7a1965aeaf fix Nougat-only draw bug
Starting with the release of Nougat there have been cases where the
board would not correctly redraw. It's been most evident when using the
hit feature many times in a row, with something going wrong every fifth
time or so (but not that consistently.) It's as if modifications of the
bitmap backing BoardCanvas were being done asynchronously and not
necessarily all completed when I blit the canvas to the screen via
canvas.drawBitmap(). (As evidence of this I confirmed that a tap on a
tile in the tray after a bad draw would cause the screen to correct
itself even though the only additional rendering was to the tray. So by
the time that second drawBitmap() call happened the bitmap data was
correct: all draws that hadn't completed earlier had done so by now.)

The fix is to call Bitmap.createBitmap(bitmap) and to use the copy as
the source of the canvas.drawBitmap() blit operation. I suspect that
createBitmap() waits for any pending draws into its source to complete
before making the copy. Regardless, if this hasn't fixed the problem
it's made it so rare that I'm not seeing it, and since I'm only doing
the copy on Nougat there's little risk in the change. And I can't detect
any problems coming from the considerable additional memory being used
and immediately marked available for gc.
2016-11-13 13:29:20 -08:00
Eric House
de00a6c87a fix Nougat-only draw bug
Starting with the release of Nougat there have been cases where the
board would not correctly redraw. It's been most evident when using the
hit feature many times in a row, with something going wrong every fifth
time or so (but not that consistently.) It's as if modifications of the
bitmap backing BoardCanvas were being done asynchronously and not
necessarily all completed when I blit the canvas to the screen via
canvas.drawBitmap(). (As evidence of this I confirmed that a tap on a
tile in the tray after a bad draw would cause the screen to correct
itself even though the only additional rendering was to the tray. So by
the time that second drawBitmap() call happened the bitmap data was
correct: all draws that hadn't completed earlier had done so by now.)

The fix is to call Bitmap.createBitmap(bitmap) and to use the copy as
the source of the canvas.drawBitmap() blit operation. I suspect that
createBitmap() waits for any pending draws into its source to complete
before making the copy. Regardless, if this hasn't fixed the problem
it's made it so rare that I'm not seeing it, and since I'm only doing
the copy on Nougat there's little risk in the change. And I can't detect
any problems coming from the considerable additional memory being used
and immediately marked available for gc.
2016-11-13 13:20:00 -08:00
Eric House
e6561cbcac debugging aids
commented-out logging of drawCell, with flags; debug-build checks that
static rects passed to java draw code aren't being used by multiple
threads at once.
2016-11-12 07:20:28 -08:00
Eric House
41581cbddb cleanup: remove unused variable, unnecessary final 2016-11-12 07:07:19 -08:00
Eric House
92e413fa06 make boardBegin() a no-op in C
instead of a no-op in java, which takes more work to get to.
2016-11-12 06:57:05 -08:00
Eric House
f394bcef64 use max backoff time if no relay games 2016-11-11 06:31:54 -08:00
Eric House
edcafe1c45 housekeeping
gitignore new files; try to limit projectile searches
2016-11-11 06:30:55 -08:00
Eric House
7087ae96ff cleanup: resolve diffs between AndroidManifest.xml versions 2016-11-09 08:40:17 -08:00
Eric House
6d1d4abdd5 add backoff to relay pings
Current code is hitting the relay every 60 seconds, at least on
non-google-play installs like f-droid. Switch to using a backoff timer
that maxes out at once per hour. Eventually may want to not run the
timer at all when there aren't any unfinished relay games present.
2016-11-09 07:53:24 -08:00
Eric House
9cd76d887d fix weird double-bang thing 2016-11-09 07:45:39 -08:00
Eric House
55d86d5ca2 don't try drawing snapshot in curses mode
Was crashing on game save. Add to main launchParams struct whether we're
in curses or gtk mode and only save snapshot in latter case.
2016-11-09 07:38:41 -08:00