Commit graph

9839 commits

Author SHA1 Message Date
Eric House
a3ccce00fa starting requesting permissions
Before writing to storage, ask permission. This adds basic ability to
query and route the OS's callback back to the code that asked.
2016-12-10 13:49:51 -08:00
Eric House
b6194f6986 Merge remote-tracking branch 'maidu2/android_branch' into android_sdk_23_take_3 2016-12-09 22:01:48 -08:00
Eric House
a1e4d4da0e pass TAG to printStack() and logex
So they'll show up when using logcat filtering
2016-12-09 07:34:51 -08:00
Eric House
25c2fd16ef use cmd strings; log discovery running or not
Add a compile-time option to send commands in json as strings rather
than ordinals (ints) for easier reading of logs. And log/keep track of
when discovery's turned off or on in case it's useful for making all
this work.
2016-12-09 07:20:27 -08:00
Eric House
2b120959ae new debug option for games list title: connection method 2016-12-06 19:39:14 -08:00
Eric House
3d5479565e wifi: send for open game too
In handling resend for a newly available transport, if the lock can't be
obtained see if that's because the game's currently open and if so post
to its thread.
2016-12-06 09:03:33 -08:00
Eric House
2c6ce5c1a8 interface name change only 2016-12-06 08:20:58 -08:00
Eric House
dc2cd239a1 wifi: send pending messages on getting connected
Each time we get a socket to a peer, try sending all pending wifi direct
messages. It's a hack, but trying to send isn't that expensive and the
experience is much improved.
2016-12-06 08:15:09 -08:00
Eric House
6eb2a7b71b wifi: pay attention to wifi being enabled
Don't keep trying to connect if wifi's off, and start trying when it's
turned on.
2016-12-05 20:23:52 -08:00
Eric House
19bb3ef7dd check standalone before iterating on addresses
New crash deleting non-networked games: needed to test first.
2016-12-05 07:35:54 -08:00
Eric House
9c14e0e858 rename method: sendResult -> postEvent 2016-12-05 07:24:25 -08:00
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