Commit graph

9807 commits

Author SHA1 Message Date
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
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
Eric House
154e428fa8 more work on wifi direct
Now sends and receives a single packet more often than not. Disabled for
non-DEBUG devices, and new permissions that are required are commented
out so I don't accidentally ship before the sdk-23 permissions stuff
makes additions less scary.
2016-11-07 07:02:27 -08:00
Eric House
85c12d6a85 new file to wrap sockets
Untested class that wraps a bi-directional tcp socket using a
length-plus-data stream format. Just checking it in for now.
2016-11-04 20:36:11 -07:00
Eric House
1c93d908cd progress on wifi direct
group is formed and ip addresses assigned! But fragile: need to reboot
devices occasionally before things will happen again.
2016-11-03 21:20:03 -07:00
Eric House
ff01e78dee first commit on wifi direct
Disabled at compile time, and missing permissions required, but if
enabled is able to discover other devices running same app. Next: try to
open a socket.
2016-11-03 06:25:48 -07:00
Eric House
3ccdd5a6e2 fix printStack()
logi() stuff isn't showing up, so use logd().
2016-11-01 07:51:00 -07:00
Eric House
579f11613f Merge branch 'android_release' into android_branch 2016-10-25 20:15:00 -07:00
Eric House
540a720fb7 up release strings 2016-10-25 20:06:10 -07:00
Eric House
1a43ab0adb fix jni crash on Nexus 9: give boolean default value
Crash occurs when creating new game: because there's no turn set yet the
jboolean has no set value (whatever was on the stack). Apparently the
java runtime accepts only 1 and 0 for jbooleans.
2016-10-25 08:35:11 -07:00
Eric House
c80665bf41 Merge tag 'android_beta_111' into android_release
new release
2016-10-25 08:34:50 -07:00
Eric House
45a6ddf8ec fix jni crash on Nexus 9: give boolean default value
Crash occurs when creating new game: because there's no turn set yet the
jboolean has no set value (whatever was on the stack). Apparently the
java runtime accepts only 1 and 0 for jbooleans.
2016-10-25 08:03:18 -07:00
Eric House
c3c2795f67 Merge remote-tracking branch 'sf/android_branch' into android_branch 2016-10-25 06:14:33 -07:00
Eric House
1a830fbff2 use clang instead of gcc for ndk builds
And make changes to C code to fix resulting warning. The .so file
basically works but is not thoroughly tested.
2016-10-25 06:09:40 -07:00
Eric House
abf4aa4d80 switch to clang
add option, and invoke it, to build jni code with clang rather than gcc.
2016-09-30 11:13:30 -07:00
Eric House
a710bdd46e Merge remote-tracking branch 'maidu2/android_branch' into android_branch 2016-09-28 21:46:17 -07:00
Eric House
123b3007cb get rid of remaining logf calls
This completes moving to using traditional logging. At least to having
each file provide a TAG. Class rather than TAG is passed in, and format
strings are preferred to contatenation, but now adb can work with the
output.
2016-09-28 21:42:16 -07:00
Eric House
59796c59b8 loge -> logex (so loge can be reused) 2016-09-27 19:42:48 -07:00
Eric House
68650ebfea first change toward using traditional TAGs with Log class 2016-09-27 19:35:24 -07:00
Eric House
3174705d63 gtk: remove assertion failure creating new games
I think this was related to changing the order in which save operations
happen and that it's no longer valid to insist that there already be a
rowid at this point, but could be wrong....
2016-09-26 08:24:47 -07:00
Eric House
e07686491c gtk: summarize before saving
Fixes problem with list view always being a move behind, since it's
saving not summarizing that was triggering the refresh, but summarizing
that added the data from which refresh/list view drew.
2016-09-20 08:27:17 -07:00