Commit graph

9963 commits

Author SHA1 Message Date
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
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
da9ee4195c re-add lollipop-friendly notification icon
This one looks better white-on-black, but still needs work! Had been
added before, in ref 885b375a55.
2016-10-31 08:00:04 -07:00
Eric House
b56c4d13b4 build with SDK version 23
Meant using NotificationCompat, dropping FloatMath, and changing a bunch
of build config stuff. Not done for gradle builds yet. Currently crashes
on a new install until you go into Apps/Crosswords/Permissions and turn
on the four "dangerous" ones it's using. Now the work is to check for
and request missing permissions on demand.
2016-10-31 07:46:04 -07:00
Eric House
832ff8e850 Merge branch 'android_branch' into android_translate 2016-10-25 20:28:05 -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
naofum
3db6abba30 Translated using Weblate (Japanese)
Currently translated at 75.8% (566 of 746 strings)
2016-10-14 18:45:24 +02:00
Sylvia van Os
953ea6aa15 Translated using Weblate (Dutch)
Currently translated at 75.2% (561 of 746 strings)
2016-10-14 15:44:27 +02: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
Eric House
5742c5cb12 gtk: save game on every turn change
Idea is to have the games list stay in sync, but in fact it stays one
move behind, at least in a typical standalone human-vs-robot game. So
this is incomplete.
2016-09-19 09:12:23 -07:00
Eric House
a6992c373f fix broken notagain alert
I screwed up when converting to using builder.
2016-09-15 21:32:25 -07:00
Eric House
7994c42691 allow board cells to be wider than tall
There are some screen dimensions, especially with dual-pane mode, where
the board is just bit narrower than the screen. Rather than have narrow
white borders, allow the cells to take up the slack. The API takes an
upper bound on the ratio of width to height so things shouldn't get too
odd looking.
2016-09-15 20:37:29 -07:00