From 4a93281a2d6782e7d421964f2d70ac40fe3fd5fc Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 20 Jan 2017 07:56:03 -0800 Subject: [PATCH 1/4] enable wifidirect in xw4dbg variant As it was before.... Also log rather than assert a common widir packet forwarding error. --- xwords4/android/app/build.gradle | 3 ++- .../main/java/org/eehouse/android/xw4/WiDirService.java | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/xwords4/android/app/build.gradle b/xwords4/android/app/build.gradle index 7af8a65e8..b86f2ba29 100644 --- a/xwords4/android/app/build.gradle +++ b/xwords4/android/app/build.gradle @@ -36,7 +36,6 @@ android { // FIX ME variant.buildConfigField "String", "STRINGS_HASH", "\"00000\"" - variant.buildConfigField "boolean", "WIDIR_ENABLED", "false" def senderID = System.getenv("GCM_SENDER_ID") variant.buildConfigField "String", "GCM_SENDER_ID", "\"$senderID\"" @@ -53,6 +52,7 @@ android { resValue "string", "app_name", "CrossWords" resValue "string", "nbs_port", "3344" resValue "string", "invite_prefix", "/and/" + buildConfigField "boolean", "WIDIR_ENABLED", "false" } xw4dbg { dimension "variant" @@ -61,6 +61,7 @@ android { resValue "string", "app_name", "CrossDbg" resValue "string", "nbs_port", "3345" resValue "string", "invite_prefix", "/anddbg/" + buildConfigField "boolean", "WIDIR_ENABLED", "true" } // WARNING: "all" breaks things. Seems to be a keyword. Need diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/WiDirService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/WiDirService.java index ce45bc4a0..9f20e7262 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/WiDirService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/WiDirService.java @@ -922,9 +922,12 @@ public class WiDirService extends XWService { boolean forwarded = false; String destAddr = packet.getString( KEY_DEST ); if ( null != destAddr && 0 < destAddr.length() ) { - Assert.assertFalse( destAddr.equals( sMacAddress ) ); - forwardPacket( bytes, destAddr ); - forwarded = true; + forwarded = destAddr.equals( sMacAddress ); + if ( forwarded ) { + forwardPacket( bytes, destAddr ); + } else { + DbgUtils.logd( TAG, "addr mismatch: %s vs %s", destAddr, sMacAddress ); + } } return forwarded; } From b96d44393a9066216a7f1200784677ae87a5015d Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 22 Jan 2017 14:15:29 -0800 Subject: [PATCH 2/4] add and use boolToStr Just to make log messages a bit more helpful. Should be no behavior change, and no change in code generated in release builds. --- xwords4/android/jni/xportwrapper.c | 3 ++- xwords4/android/jni/xwjni.c | 5 +++-- xwords4/common/comms.c | 9 ++++++--- xwords4/common/dbgutil.h | 1 + xwords4/common/nli.c | 3 ++- xwords4/linux/gtkboard.c | 3 ++- xwords4/linux/linuxmain.c | 4 ++-- xwords4/linux/linuxudp.c | 2 +- 8 files changed, 19 insertions(+), 11 deletions(-) diff --git a/xwords4/android/jni/xportwrapper.c b/xwords4/android/jni/xportwrapper.c index 6be6482bf..375069949 100644 --- a/xwords4/android/jni/xportwrapper.c +++ b/xwords4/android/jni/xportwrapper.c @@ -20,6 +20,7 @@ #include "xportwrapper.h" #include "andutils.h" +#include "dbgutil.h" #include "paths.h" typedef struct _AndTransportProcs { @@ -145,7 +146,7 @@ and_xport_sendNoConn( const XP_U8* buf, XP_U16 len, const XP_UCHAR* msgNo, jbytes, jMsgNo, jRelayID ); deleteLocalRefs( env, jbytes, jRelayID, jMsgNo, DELETE_NO_REF ); } - LOG_RETURNF( "%d", result ); + LOG_RETURNF( "%s", boolToStr(result) ); return result; } diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index e6809584e..06d8a1c6d 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -1,4 +1,4 @@ -/* -*- compile-command: "find-and-ant.sh debug install"; -*- */ +/* -*- compile-command: "find-and-gradle.sh installXw4Debug"; -*- */ /* * Copyright © 2009 - 2014 by Eric House (xwords@eehouse.org). All rights * reserved. @@ -29,6 +29,7 @@ #include "board.h" #include "mempool.h" #include "strutils.h" +#include "dbgutil.h" #include "dictnry.h" #include "dictiter.h" #include "dictmgr.h" @@ -1507,7 +1508,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1initClientConnection stream_setOnCloseProc( stream, and_send_on_close ); result = server_initClientConnection( state->game.server, stream ); XWJNI_END(); - LOG_RETURNF( "%d", result ); + LOG_RETURNF( "%s", boolToStr(result) ); return result; } diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 8eab853d1..26bea687c 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -30,6 +30,7 @@ #include "memstream.h" #include "xwrelay.h" #include "strutils.h" +#include "dbgutil.h" #define HEARTBEAT_NONE 0 @@ -1812,7 +1813,7 @@ relayPreProcess( CommsCtxt* comms, XWStreamCtxt* stream, XWHostID* senderID ) XP_LOGF( "%s: dropping relay msg with cmd %d", __func__, (XP_U16)cmd ); } - LOG_RETURNF( "%d", consumed ); + LOG_RETURNF( "%s", boolToStr(consumed) ); return consumed; } /* relayPreProcess */ #endif @@ -1893,7 +1894,7 @@ preProcess( CommsCtxt* comms, const CommsAddrRec* useAddr, XP_ASSERT(0); break; } - LOG_RETURNF( "%d", consumed ); + LOG_RETURNF( "%s", boolToStr(consumed) ); return consumed; } /* preProcess */ @@ -1981,6 +1982,7 @@ getRecordFor( CommsCtxt* comms, const CommsAddrRec* addr, static XP_Bool checkChannelNo( CommsCtxt* comms, XP_PlayerAddr* channelNoP ) { + XP_Bool success = XP_TRUE; XP_PlayerAddr channelNo = *channelNoP; if ( 0 == (channelNo & CHANNEL_MASK) ) { channelNo |= ++comms->nextChannelNo; @@ -1990,7 +1992,8 @@ checkChannelNo( CommsCtxt* comms, XP_PlayerAddr* channelNoP ) comms->nextChannelNo = channelNo; } *channelNoP = channelNo; - return XP_TRUE; /* for now */ + LOG_RETURNF( "%s", boolToStr(success) ); + return success; } /* An initial message comes only from a client to a server, and from the diff --git a/xwords4/common/dbgutil.h b/xwords4/common/dbgutil.h index cfbc93917..a9223635f 100644 --- a/xwords4/common/dbgutil.h +++ b/xwords4/common/dbgutil.h @@ -37,6 +37,7 @@ void dbg_logstream( const XWStreamCtxt* stream, const char* func, int line ); # define XP_LOGSTREAM( s ) # endif +#define boolToStr(b) ((b)?"true" : "false") # ifdef DEBUG # define DIRTY_SLOT XP_Bool _isDirty; diff --git a/xwords4/common/nli.c b/xwords4/common/nli.c index 1119def61..e54c72a8f 100644 --- a/xwords4/common/nli.c +++ b/xwords4/common/nli.c @@ -23,6 +23,7 @@ #include "nli.h" #include "comms.h" #include "strutils.h" +#include "dbgutil.h" void nli_init( NetLaunchInfo* nli, const CurGameInfo* gi, const CommsAddrRec* addr, @@ -135,7 +136,7 @@ nli_makeFromStream( NetLaunchInfo* nli, XWStreamCtxt* stream ) nli->osVers = stream_getU32( stream ); } } - LOG_RETURNF( "%d", success ); + LOG_RETURNF( "%s", boolToStr(success) ); return success; } diff --git a/xwords4/linux/gtkboard.c b/xwords4/linux/gtkboard.c index 96ebe5231..6e3aa8ab2 100644 --- a/xwords4/linux/gtkboard.c +++ b/xwords4/linux/gtkboard.c @@ -55,6 +55,7 @@ #include "game.h" #include "movestak.h" #include "strutils.h" +#include "dbgutil.h" #include "gtkask.h" #include "gtkinvit.h" #include "gtkaskm.h" @@ -2819,7 +2820,7 @@ makeNewGame( GtkGameGlobals* globals ) gi->dictName, XP_TRUE ); gi->dictLang = dict_getLangCode( cGlobals->dict ); } - LOG_RETURNF( "%d", success ); + LOG_RETURNF( "%s", boolToStr(success) ); return success; } diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 21a2de343..a79cc4224 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -68,6 +68,7 @@ #include "model.h" #include "util.h" #include "strutils.h" +#include "dbgutil.h" #include "dictiter.h" /* #include "commgr.h" */ /* #include "compipe.h" */ @@ -1052,7 +1053,7 @@ send_or_close( CommonGlobals* cGlobals, const XP_U8* buf, size_t len ) g_slist_free( cGlobals->packetQueue ); cGlobals->packetQueue = NULL; } - LOG_RETURNF( "%d", success ); + LOG_RETURNF( "%s", boolToStr(success) ); return success; } @@ -2664,4 +2665,3 @@ main( int argc, char** argv ) XP_LOGF( "%s exiting main, returning %d", argv[0], result ); return result; } /* main */ - diff --git a/xwords4/linux/linuxudp.c b/xwords4/linux/linuxudp.c index 582df2bfb..926626a96 100644 --- a/xwords4/linux/linuxudp.c +++ b/xwords4/linux/linuxudp.c @@ -195,7 +195,7 @@ remembered( const LinUDPStuff* stuff, int sock ) known = XP_TRUE; } } - LOG_RETURNF( "%d", (int)known ); + LOG_RETURNF( "%s", boolToStr(known) ); return known; } From 15d0f88187f5752e4c8586a2a7247e3f2f9fbf7e Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 22 Jan 2017 14:51:21 -0800 Subject: [PATCH 3/4] add preference to disable wifi direct Looks like there are battery drainage issues with the current half-done implementation, so add option to turn it off. Only takes effect on restart, and only matters on dbg variant now since it's compile-time disabled on the main variant. Also add discovery machine state to ConnState printout, stop running the machine over and over (likely the battery problem), but add ability to restart it triggered by the ConnState's "reconnect" button. Also start persisting the most recently seen set of peers. If service discovery and not connecting is the problem having these available to try to connect to on startup might help. --- .../android/xw4/ConnViaViewLayout.java | 2 +- .../org/eehouse/android/xw4/DlgDelegate.java | 4 +- .../eehouse/android/xw4/PrefsDelegate.java | 4 + .../org/eehouse/android/xw4/WiDirService.java | 102 ++++++++++++++---- .../eehouse/android/xw4/jni/CommsAddrRec.java | 2 +- .../app/src/main/res/values/common_rsrc.xml | 1 + .../app/src/main/res/values/strings.xml | 3 + .../android/app/src/main/res/xml/xwprefs.xml | 5 + 8 files changed, 101 insertions(+), 22 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java index ed765e656..b4f1889ad 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/ConnViaViewLayout.java @@ -124,7 +124,7 @@ public class ConnViaViewLayout extends LinearLayout { enabled = RelayService.relayEnabled( context ); break; case COMMS_CONN_P2P: - enabled = WiDirService.supported(); + enabled = WiDirService.enabled(); break; default: Assert.fail(); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java index 9bf70159c..69c1872d3 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DlgDelegate.java @@ -510,7 +510,7 @@ public class DlgDelegate { if ( (XWApp.SMS_INVITE_ENABLED && Utils.deviceSupportsSMS( m_activity )) || XWPrefs.getNFCToSelfEnabled( m_activity ) || NFCUtils.nfcAvail( m_activity )[0] - || WiDirService.supported() + || WiDirService.enabled() || BTService.BTAvailable() ) { DlgState state = new DlgState( DlgID.INVITE_CHOICES_THEN ) .setAction( action ) @@ -755,7 +755,7 @@ public class DlgDelegate { items.add( getString( R.string.invite_choice_relay ) ); means.add( DlgClickNotify.InviteMeans.RELAY ); } - if ( WiDirService.supported() ) { + if ( WiDirService.enabled() ) { items.add( getString( R.string.invite_choice_p2p ) ); means.add( DlgClickNotify.InviteMeans.WIFIDIRECT ); } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java index f35784650..6f6066f72 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java @@ -350,5 +350,9 @@ public class PrefsDelegate extends DelegateBase if ( Perms23.haveNativePerms() ) { hideOne( R.string.key_enable_sms, R.string.key_network_behavior ); } + + if ( ! BuildConfig.WIDIR_ENABLED ) { + hideOne( R.string.key_enable_p2p, R.string.key_network_behavior ); + } } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/WiDirService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/WiDirService.java index 9f20e7262..df5c2c451 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/WiDirService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/WiDirService.java @@ -45,6 +45,7 @@ import android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceRequest; import android.net.wifi.p2p.nsd.WifiP2pUpnpServiceInfo; import android.os.Handler; import android.os.Looper; +import android.text.TextUtils; import java.io.IOException; import java.net.InetAddress; @@ -77,6 +78,7 @@ public class WiDirService extends XWService { private static final String SERVICE_NAME = "srvc_" + BuildConfig.FLAVOR; private static final String SERVICE_REG_TYPE = "_presence._tcp"; private static final int OWNER_PORT = 5432; + private static final String PEERS_LIST_KEY = TAG + ".peers_key"; private enum P2PAction { _NONE, GOT_MSG, @@ -96,6 +98,7 @@ public class WiDirService extends XWService { private static final String KEY_MAP = "map"; private static final String KEY_RETADDR = "raddr"; + private static boolean s_enabled = false; private static Channel sChannel; private static ServiceDiscoverer s_discoverer; private static IntentFilter sIntentFilter; @@ -119,6 +122,7 @@ public class WiDirService extends XWService { private static String sDeviceName; private static Set s_devListeners = new HashSet(); + private static Set s_peersSet; private P2pMsgSink m_sink; @@ -137,7 +141,7 @@ public class WiDirService extends XWService { { int result; - if ( BuildConfig.WIDIR_ENABLED && null != intent ) { + if ( enabled() && null != intent ) { result = Service.START_STICKY; int ordinal = intent.getIntExtra( KEY_CMD, -1 ); @@ -181,6 +185,20 @@ public class WiDirService extends XWService { public static void init( Context context ) { DbgUtils.logd( TAG, "init()" ); + s_enabled = XWPrefs.getPrefsBoolean( context, R.string.key_enable_p2p, + false ); + + Assert.assertNull( s_peersSet ); + s_peersSet = new HashSet(); + String peers = DBUtils.getStringFor( context, PEERS_LIST_KEY, null ); + if ( null != peers ) { + String[] macs = TextUtils.split( peers, "," ); + for ( String mac : macs ) { + s_peersSet.add( mac ); + } + } + DbgUtils.logd( TAG, "loaded saved peers: %s", s_peersSet.toString() ); + try { ChannelListener listener = new ChannelListener() { @Override @@ -190,7 +208,7 @@ public class WiDirService extends XWService { }; sChannel = getMgr().initialize( context, Looper.getMainLooper(), listener ); - s_discoverer = new ServiceDiscoverer( sChannel ); + s_discoverer = new ServiceDiscoverer(); sHavePermission = true; } catch ( NoClassDefFoundError ndf ) { // old os version sHavePermission = false; @@ -202,22 +220,28 @@ public class WiDirService extends XWService { public static void reset( Context context ) { // Put experimental stuff here that might help get a connection + + if ( null != s_discoverer ) { + s_discoverer.restart(); + } } - public static boolean supported() + public static boolean enabled() { - return BuildConfig.WIDIR_ENABLED; + boolean result = BuildConfig.WIDIR_ENABLED && s_enabled; + return result; } - public static boolean connecting() { - return supported() + public static boolean connecting() + { + return enabled() && 0 < sSocketWrapMap.size() && sSocketWrapMap.values().iterator().next().isConnected(); } public static String getMyMacAddress( Context context ) { - if ( BuildConfig.WIDIR_ENABLED ) { + if ( enabled() ) { if ( null == sMacAddress && null != context ) { sMacAddress = DBUtils.getStringFor( context, MAC_ADDR_KEY, null ); } @@ -230,10 +254,16 @@ public class WiDirService extends XWService { public static String formatNetStateInfo() { + String connectState = ""; + if ( null != s_discoverer ) { + connectState = s_discoverer.stateToString(); + } + String map = mapToString( copyUserMap() ); - return String.format( "role: %s; map: %s nThreads: %d", - sAmGroupOwner ? "owner" : "guest", map, - Thread.activeCount() ); + connectState += String.format( "; role: %s; map: %s nThreads: %d", + sAmGroupOwner ? "owner" : "guest", map, + Thread.activeCount() ); + return connectState; } private static String getMyMacAddress() { return getMyMacAddress(null); } @@ -306,7 +336,7 @@ public class WiDirService extends XWService { public static void activityResumed( Activity activity ) { - if ( BuildConfig.WIDIR_ENABLED && sHavePermission ) { + if ( enabled() && sHavePermission ) { if ( initListeners( activity ) ) { activity.registerReceiver( sReceiver, sIntentFilter ); DbgUtils.logd( TAG, "activityResumed() done" ); @@ -317,7 +347,7 @@ public class WiDirService extends XWService { public static void activityPaused( Activity activity ) { - if ( BuildConfig.WIDIR_ENABLED && sHavePermission ) { + if ( enabled() && sHavePermission ) { Assert.assertNotNull( sReceiver ); // No idea why I'm seeing this exception... try { @@ -346,7 +376,7 @@ public class WiDirService extends XWService { private static boolean initListeners( final Context context ) { boolean succeeded = false; - if ( BuildConfig.WIDIR_ENABLED ) { + if ( enabled() ) { if ( null == sIface ) { try { WifiP2pManager mgr = getMgr(); @@ -447,10 +477,13 @@ public class WiDirService extends XWService { // See: http://stackoverflow.com/questions/26300889/wifi-p2p-service-discovery-works-intermittently private static class ServiceDiscoverer implements Runnable, ActionListener { private State m_curState = State.START; + private State m_lastGoodState = State.START; + private State m_lastBadState = State.START; private Channel m_channel; private Handler m_handler; private WifiP2pManager m_mgr; private int[] m_failures; + private boolean m_lastSucceeded; enum State { START, @@ -463,13 +496,21 @@ public class WiDirService extends XWService { DONE, } - public ServiceDiscoverer( Channel channel ) + public ServiceDiscoverer() { m_mgr = getMgr(); m_channel = sChannel; m_handler = new Handler(); } + public String stateToString() + { + return String.format("last good: %s(%d); last bad: %s(%d); success last: %b", + m_lastGoodState.toString(), m_lastGoodState.ordinal(), + m_lastBadState.toString(), m_lastBadState.ordinal(), + m_lastSucceeded ); + } + public void restart() { m_curState = State.START; @@ -487,6 +528,8 @@ public class WiDirService extends XWService { // ActionListener interface @Override public void onSuccess() { + m_lastSucceeded = true; + m_lastGoodState = m_curState; DbgUtils.logd( TAG, "onSuccess(): state %s done", m_curState.toString() ); m_curState = State.values()[m_curState.ordinal() + 1]; @@ -495,6 +538,9 @@ public class WiDirService extends XWService { @Override public void onFailure( int code ) { + m_lastSucceeded = false; + m_lastBadState = m_curState; + int count = ++m_failures[m_curState.ordinal()]; String codeStr = null; switch ( code ) { @@ -568,8 +614,10 @@ public class WiDirService extends XWService { break; case DONE: - m_curState = State.START; - schedule( /*5 * */ 60 ); + DbgUtils.logd( TAG, "machine done; should I try connecting to: %s?", + s_peersSet.toString() ); + // m_curState = State.START; + // schedule( /*5 * */ 60 ); break; default: @@ -594,7 +642,7 @@ public class WiDirService extends XWService { private static void setDiscoveryListeners( WifiP2pManager mgr ) { - if ( BuildConfig.WIDIR_ENABLED ) { + if ( enabled() ) { DnsSdServiceResponseListener srl = new DnsSdServiceResponseListener() { @Override public void onDnsSdServiceAvailable(String instanceName, @@ -1014,6 +1062,22 @@ public class WiDirService extends XWService { return wrap; } + private static void updatePeersList( WifiP2pDeviceList peerList ) + { + Set newSet = new HashSet(); + for ( WifiP2pDevice device : peerList.getDeviceList() ) { + String macAddress = device.deviceAddress; + newSet.add( macAddress ); + } + + DbgUtils.logd( TAG, "updatePeersList(): old set: %s; new set: %s", + s_peersSet.toString(), newSet.toString() ); + s_peersSet = newSet; + + DBUtils.setStringFor( XWApp.getContext(), PEERS_LIST_KEY, + TextUtils.join( ",", s_peersSet ) ); + } + private static class WFDBroadcastReceiver extends BroadcastReceiver implements WifiP2pManager.ConnectionInfoListener, WifiP2pManager.PeerListListener { @@ -1028,7 +1092,7 @@ public class WiDirService extends XWService { @Override public void onReceive( Context context, Intent intent ) { - if ( BuildConfig.WIDIR_ENABLED ) { + if ( enabled() ) { String action = intent.getAction(); DbgUtils.logd( TAG, "got intent: " + intent.toString() ); @@ -1118,6 +1182,8 @@ public class WiDirService extends XWService { DbgUtils.logd( TAG, "got list of %d peers", peerList.getDeviceList().size() ); + updatePeersList( peerList ); + for ( WifiP2pDevice device : peerList.getDeviceList() ) { // DbgUtils.logd( TAG, "not connecting to: %s", device.toString() ); tryConnect( device ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommsAddrRec.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommsAddrRec.java index 27ed2d53d..96e23b6be 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommsAddrRec.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommsAddrRec.java @@ -123,7 +123,7 @@ public class CommsAddrRec { if ( Utils.isGSMPhone( context ) ) { supported.add( CommsConnType.COMMS_CONN_SMS ); } - if ( WiDirService.supported() ) { + if ( WiDirService.enabled() ) { supported.add( CommsConnType.COMMS_CONN_P2P ); } return supported; diff --git a/xwords4/android/app/src/main/res/values/common_rsrc.xml b/xwords4/android/app/src/main/res/values/common_rsrc.xml index 826fb9a8d..c7e17f623 100644 --- a/xwords4/android/app/src/main/res/values/common_rsrc.xml +++ b/xwords4/android/app/src/main/res/values/common_rsrc.xml @@ -60,6 +60,7 @@ key_disable_relay key_notify_vibrate key_enable_sms + key_enable_p2p key_network_behavior key_keep_screenon key_thumbsize3 diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index 22905342d..314c612f1 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -2081,6 +2081,9 @@ Only if you have unlimited texting! + Enable WiFi Direct + Experimental, uses lots of battery + Confirm your SMS plan diff --git a/xwords4/android/app/src/main/res/xml/xwprefs.xml b/xwords4/android/app/src/main/res/xml/xwprefs.xml index 6dae388dc..7093806db 100644 --- a/xwords4/android/app/src/main/res/xml/xwprefs.xml +++ b/xwords4/android/app/src/main/res/xml/xwprefs.xml @@ -325,6 +325,11 @@ android:summary="@string/notify_other_summary" android:defaultValue="false" /> + Date: Sun, 22 Jan 2017 15:27:35 -0800 Subject: [PATCH 4/4] include debug keystore directly replace symlink silliness ant required with gradle commands to sign debug builds with the checked-in (local file) debug keystore. Make it possible for an environment variable to override in case somebody wants to use his own. --- xwords4/android/app/build.gradle | 10 ++++++++++ xwords4/android/{scripts => app}/debug.keystore | Bin 2 files changed, 10 insertions(+) rename xwords4/android/{scripts => app}/debug.keystore (100%) diff --git a/xwords4/android/app/build.gradle b/xwords4/android/app/build.gradle index b86f2ba29..563812e2d 100644 --- a/xwords4/android/app/build.gradle +++ b/xwords4/android/app/build.gradle @@ -95,6 +95,16 @@ android { storePassword "notReal" keyPassword "notReal" } + debug { + def path = System.getenv("DEBUG_KEYSTORE_PATH") + if (! path) { + path = "./debug.keystore" + } + storeFile file(path) + keyAlias "androiddebugkey" + storePassword "android" + keyPassword "android" + } } buildTypes { diff --git a/xwords4/android/scripts/debug.keystore b/xwords4/android/app/debug.keystore similarity index 100% rename from xwords4/android/scripts/debug.keystore rename to xwords4/android/app/debug.keystore